1 diff -NurpP --minimal linux-3.1.6/Documentation/vserver/debug.txt linux-3.1.6-vs2.3.2.5/Documentation/vserver/debug.txt
2 --- linux-3.1.6/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-3.1.6-vs2.3.2.5/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.6/arch/alpha/Kconfig linux-3.1.6-vs2.3.2.5/arch/alpha/Kconfig
160 --- linux-3.1.6/arch/alpha/Kconfig 2011-10-24 18:44:54.000000000 +0200
161 +++ linux-3.1.6-vs2.3.2.5/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.6/arch/alpha/kernel/entry.S linux-3.1.6-vs2.3.2.5/arch/alpha/kernel/entry.S
172 --- linux-3.1.6/arch/alpha/kernel/entry.S 2010-10-21 13:06:45.000000000 +0200
173 +++ linux-3.1.6-vs2.3.2.5/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.6/arch/alpha/kernel/ptrace.c linux-3.1.6-vs2.3.2.5/arch/alpha/kernel/ptrace.c
207 --- linux-3.1.6/arch/alpha/kernel/ptrace.c 2011-01-05 21:48:40.000000000 +0100
208 +++ linux-3.1.6-vs2.3.2.5/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.6/arch/alpha/kernel/systbls.S linux-3.1.6-vs2.3.2.5/arch/alpha/kernel/systbls.S
218 --- linux-3.1.6/arch/alpha/kernel/systbls.S 2011-10-24 18:44:54.000000000 +0200
219 +++ linux-3.1.6-vs2.3.2.5/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.6/arch/alpha/kernel/traps.c linux-3.1.6-vs2.3.2.5/arch/alpha/kernel/traps.c
230 --- linux-3.1.6/arch/alpha/kernel/traps.c 2010-10-21 13:06:46.000000000 +0200
231 +++ linux-3.1.6-vs2.3.2.5/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.6/arch/arm/Kconfig linux-3.1.6-vs2.3.2.5/arch/arm/Kconfig
243 --- linux-3.1.6/arch/arm/Kconfig 2011-12-23 16:04:05.000000000 +0100
244 +++ linux-3.1.6-vs2.3.2.5/arch/arm/Kconfig 2011-12-15 01:07:58.000000000 +0100
245 @@ -2123,6 +2123,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.6/arch/arm/kernel/calls.S linux-3.1.6-vs2.3.2.5/arch/arm/kernel/calls.S
255 --- linux-3.1.6/arch/arm/kernel/calls.S 2011-10-24 18:44:54.000000000 +0200
256 +++ linux-3.1.6-vs2.3.2.5/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.6/arch/arm/kernel/process.c linux-3.1.6-vs2.3.2.5/arch/arm/kernel/process.c
267 --- linux-3.1.6/arch/arm/kernel/process.c 2011-12-23 16:04:05.000000000 +0100
268 +++ linux-3.1.6-vs2.3.2.5/arch/arm/kernel/process.c 2011-12-15 01:07:58.000000000 +0100
269 @@ -320,7 +320,8 @@ void __show_regs(struct pt_regs *regs)
270 void show_regs(struct pt_regs * regs)
273 - printk("Pid: %d, comm: %20s\n", task_pid_nr(current), current->comm);
274 + printk("Pid: %d[#%u], comm: %20s\n",
275 + task_pid_nr(current), current->xid, current->comm);
279 diff -NurpP --minimal linux-3.1.6/arch/arm/kernel/traps.c linux-3.1.6-vs2.3.2.5/arch/arm/kernel/traps.c
280 --- linux-3.1.6/arch/arm/kernel/traps.c 2011-10-24 18:44:54.000000000 +0200
281 +++ linux-3.1.6-vs2.3.2.5/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.6/arch/cris/Kconfig linux-3.1.6-vs2.3.2.5/arch/cris/Kconfig
294 --- linux-3.1.6/arch/cris/Kconfig 2011-07-22 11:17:35.000000000 +0200
295 +++ linux-3.1.6-vs2.3.2.5/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.6/arch/frv/kernel/kernel_thread.S linux-3.1.6-vs2.3.2.5/arch/frv/kernel/kernel_thread.S
306 --- linux-3.1.6/arch/frv/kernel/kernel_thread.S 2008-12-25 00:26:37.000000000 +0100
307 +++ linux-3.1.6-vs2.3.2.5/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.6/arch/h8300/Kconfig linux-3.1.6-vs2.3.2.5/arch/h8300/Kconfig
318 --- linux-3.1.6/arch/h8300/Kconfig 2011-07-22 11:17:35.000000000 +0200
319 +++ linux-3.1.6-vs2.3.2.5/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.6/arch/ia64/Kconfig linux-3.1.6-vs2.3.2.5/arch/ia64/Kconfig
330 --- linux-3.1.6/arch/ia64/Kconfig 2011-10-24 18:44:58.000000000 +0200
331 +++ linux-3.1.6-vs2.3.2.5/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.6/arch/ia64/kernel/entry.S linux-3.1.6-vs2.3.2.5/arch/ia64/kernel/entry.S
342 --- linux-3.1.6/arch/ia64/kernel/entry.S 2011-10-24 18:44:58.000000000 +0200
343 +++ linux-3.1.6-vs2.3.2.5/arch/ia64/kernel/entry.S 2011-10-24 18:53:33.000000000 +0200
344 @@ -1714,7 +1714,7 @@ sys_call_table:
346 data8 sys_mq_getsetattr
348 - data8 sys_ni_syscall // reserved for vserver
350 data8 sys_waitid // 1270
352 data8 sys_request_key
353 diff -NurpP --minimal linux-3.1.6/arch/ia64/kernel/process.c linux-3.1.6-vs2.3.2.5/arch/ia64/kernel/process.c
354 --- linux-3.1.6/arch/ia64/kernel/process.c 2011-03-15 18:06:39.000000000 +0100
355 +++ linux-3.1.6-vs2.3.2.5/arch/ia64/kernel/process.c 2011-10-24 18:53:33.000000000 +0200
356 @@ -109,8 +109,8 @@ show_regs (struct pt_regs *regs)
357 unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
360 - printk("\nPid: %d, CPU %d, comm: %20s\n", task_pid_nr(current),
361 - smp_processor_id(), current->comm);
362 + printk("\nPid: %d[#%u], CPU %d, comm: %20s\n", task_pid_nr(current),
363 + current->xid, smp_processor_id(), current->comm);
364 printk("psr : %016lx ifs : %016lx ip : [<%016lx>] %s (%s)\n",
365 regs->cr_ipsr, regs->cr_ifs, ip, print_tainted(),
366 init_utsname()->release);
367 diff -NurpP --minimal linux-3.1.6/arch/ia64/kernel/ptrace.c linux-3.1.6-vs2.3.2.5/arch/ia64/kernel/ptrace.c
368 --- linux-3.1.6/arch/ia64/kernel/ptrace.c 2011-01-05 21:48:59.000000000 +0100
369 +++ linux-3.1.6-vs2.3.2.5/arch/ia64/kernel/ptrace.c 2011-10-24 18:53:33.000000000 +0200
371 #include <linux/regset.h>
372 #include <linux/elf.h>
373 #include <linux/tracehook.h>
374 +#include <linux/vs_base.h>
376 #include <asm/pgtable.h>
377 #include <asm/processor.h>
378 diff -NurpP --minimal linux-3.1.6/arch/ia64/kernel/traps.c linux-3.1.6-vs2.3.2.5/arch/ia64/kernel/traps.c
379 --- linux-3.1.6/arch/ia64/kernel/traps.c 2010-07-07 18:31:01.000000000 +0200
380 +++ linux-3.1.6-vs2.3.2.5/arch/ia64/kernel/traps.c 2011-10-24 18:53:33.000000000 +0200
381 @@ -59,8 +59,9 @@ die (const char *str, struct pt_regs *re
384 if (++die.lock_owner_depth < 3) {
385 - printk("%s[%d]: %s %ld [%d]\n",
386 - current->comm, task_pid_nr(current), str, err, ++die_counter);
387 + printk("%s[%d[#%u]]: %s %ld [%d]\n",
388 + current->comm, task_pid_nr(current), current->xid,
389 + str, err, ++die_counter);
390 if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV)
393 @@ -323,8 +324,9 @@ handle_fpu_swa (int fp_fault, struct pt_
394 if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
395 last.time = current_jiffies + 5 * HZ;
397 - "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
398 - current->comm, task_pid_nr(current), regs->cr_iip + ia64_psr(regs)->ri, isr);
399 + "%s(%d[#%u]): floating-point assist fault at ip %016lx, isr %016lx\n",
400 + current->comm, task_pid_nr(current), current->xid,
401 + regs->cr_iip + ia64_psr(regs)->ri, isr);
405 diff -NurpP --minimal linux-3.1.6/arch/m32r/kernel/traps.c linux-3.1.6-vs2.3.2.5/arch/m32r/kernel/traps.c
406 --- linux-3.1.6/arch/m32r/kernel/traps.c 2011-10-24 18:44:58.000000000 +0200
407 +++ linux-3.1.6-vs2.3.2.5/arch/m32r/kernel/traps.c 2011-10-24 18:53:33.000000000 +0200
408 @@ -196,8 +196,9 @@ static void show_registers(struct pt_reg
410 printk("SPI: %08lx\n", sp);
412 - printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
413 - current->comm, task_pid_nr(current), 0xffff & i, 4096+(unsigned long)current);
414 + printk("Process %s (pid: %d[#%u], process nr: %d, stackpage=%08lx)",
415 + current->comm, task_pid_nr(current), current->xid,
416 + 0xffff & i, 4096+(unsigned long)current);
419 * When in-kernel, we also print out the stack and code at the
420 diff -NurpP --minimal linux-3.1.6/arch/m68k/Kconfig linux-3.1.6-vs2.3.2.5/arch/m68k/Kconfig
421 --- linux-3.1.6/arch/m68k/Kconfig 2011-10-24 18:44:58.000000000 +0200
422 +++ linux-3.1.6-vs2.3.2.5/arch/m68k/Kconfig 2011-10-24 18:53:33.000000000 +0200
423 @@ -246,6 +246,8 @@ source "fs/Kconfig"
425 source "arch/m68k/Kconfig.debug"
427 +source "kernel/vserver/Kconfig"
429 source "security/Kconfig"
431 source "crypto/Kconfig"
432 diff -NurpP --minimal linux-3.1.6/arch/mips/Kconfig linux-3.1.6-vs2.3.2.5/arch/mips/Kconfig
433 --- linux-3.1.6/arch/mips/Kconfig 2011-10-24 18:44:59.000000000 +0200
434 +++ linux-3.1.6-vs2.3.2.5/arch/mips/Kconfig 2011-10-24 18:53:33.000000000 +0200
435 @@ -2495,6 +2495,8 @@ source "fs/Kconfig"
437 source "arch/mips/Kconfig.debug"
439 +source "kernel/vserver/Kconfig"
441 source "security/Kconfig"
443 source "crypto/Kconfig"
444 diff -NurpP --minimal linux-3.1.6/arch/mips/kernel/ptrace.c linux-3.1.6-vs2.3.2.5/arch/mips/kernel/ptrace.c
445 --- linux-3.1.6/arch/mips/kernel/ptrace.c 2011-07-22 11:17:36.000000000 +0200
446 +++ linux-3.1.6-vs2.3.2.5/arch/mips/kernel/ptrace.c 2011-10-24 18:53:33.000000000 +0200
448 #include <linux/security.h>
449 #include <linux/audit.h>
450 #include <linux/seccomp.h>
451 +#include <linux/vs_base.h>
453 #include <asm/byteorder.h>
455 @@ -263,6 +264,9 @@ long arch_ptrace(struct task_struct *chi
456 void __user *datavp = (void __user *) data;
457 unsigned long __user *datalp = (void __user *) data;
459 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
463 /* when I and D space are separate, these will need to be fixed. */
464 case PTRACE_PEEKTEXT: /* read word at location addr. */
465 diff -NurpP --minimal linux-3.1.6/arch/mips/kernel/scall32-o32.S linux-3.1.6-vs2.3.2.5/arch/mips/kernel/scall32-o32.S
466 --- linux-3.1.6/arch/mips/kernel/scall32-o32.S 2011-10-24 18:44:59.000000000 +0200
467 +++ linux-3.1.6-vs2.3.2.5/arch/mips/kernel/scall32-o32.S 2011-10-24 18:53:33.000000000 +0200
468 @@ -523,7 +523,7 @@ einval: li v0, -ENOSYS
469 sys sys_mq_timedreceive 5
470 sys sys_mq_notify 2 /* 4275 */
471 sys sys_mq_getsetattr 3
472 - sys sys_ni_syscall 0 /* sys_vserver */
475 sys sys_ni_syscall 0 /* available, was setaltroot */
476 sys sys_add_key 5 /* 4280 */
477 diff -NurpP --minimal linux-3.1.6/arch/mips/kernel/scall64-64.S linux-3.1.6-vs2.3.2.5/arch/mips/kernel/scall64-64.S
478 --- linux-3.1.6/arch/mips/kernel/scall64-64.S 2011-10-24 18:44:59.000000000 +0200
479 +++ linux-3.1.6-vs2.3.2.5/arch/mips/kernel/scall64-64.S 2011-10-24 18:53:33.000000000 +0200
480 @@ -362,7 +362,7 @@ sys_call_table:
481 PTR sys_mq_timedreceive
483 PTR sys_mq_getsetattr /* 5235 */
484 - PTR sys_ni_syscall /* sys_vserver */
487 PTR sys_ni_syscall /* available, was setaltroot */
489 diff -NurpP --minimal linux-3.1.6/arch/mips/kernel/scall64-n32.S linux-3.1.6-vs2.3.2.5/arch/mips/kernel/scall64-n32.S
490 --- linux-3.1.6/arch/mips/kernel/scall64-n32.S 2011-10-24 18:44:59.000000000 +0200
491 +++ linux-3.1.6-vs2.3.2.5/arch/mips/kernel/scall64-n32.S 2011-10-24 18:53:33.000000000 +0200
492 @@ -361,7 +361,7 @@ EXPORT(sysn32_call_table)
493 PTR compat_sys_mq_timedreceive
494 PTR compat_sys_mq_notify
495 PTR compat_sys_mq_getsetattr
496 - PTR sys_ni_syscall /* 6240, sys_vserver */
497 + PTR sys32_vserver /* 6240 */
498 PTR compat_sys_waitid
499 PTR sys_ni_syscall /* available, was setaltroot */
501 diff -NurpP --minimal linux-3.1.6/arch/mips/kernel/scall64-o32.S linux-3.1.6-vs2.3.2.5/arch/mips/kernel/scall64-o32.S
502 --- linux-3.1.6/arch/mips/kernel/scall64-o32.S 2011-10-24 18:44:59.000000000 +0200
503 +++ linux-3.1.6-vs2.3.2.5/arch/mips/kernel/scall64-o32.S 2011-10-24 18:53:33.000000000 +0200
504 @@ -480,7 +480,7 @@ sys_call_table:
505 PTR compat_sys_mq_timedreceive
506 PTR compat_sys_mq_notify /* 4275 */
507 PTR compat_sys_mq_getsetattr
508 - PTR sys_ni_syscall /* sys_vserver */
511 PTR sys_ni_syscall /* available, was setaltroot */
512 PTR sys_add_key /* 4280 */
513 diff -NurpP --minimal linux-3.1.6/arch/mips/kernel/traps.c linux-3.1.6-vs2.3.2.5/arch/mips/kernel/traps.c
514 --- linux-3.1.6/arch/mips/kernel/traps.c 2011-10-24 18:44:59.000000000 +0200
515 +++ linux-3.1.6-vs2.3.2.5/arch/mips/kernel/traps.c 2011-10-24 18:53:33.000000000 +0200
516 @@ -344,9 +344,10 @@ void show_registers(struct pt_regs *regs
520 - printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
521 - current->comm, current->pid, current_thread_info(), current,
522 - field, current_thread_info()->tp_value);
523 + printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p, tls=%0*lx)\n",
524 + current->comm, task_pid_nr(current), current->xid,
525 + current_thread_info(), current,
526 + field, current_thread_info()->tp_value);
527 if (cpu_has_userlocal) {
530 diff -NurpP --minimal linux-3.1.6/arch/parisc/Kconfig linux-3.1.6-vs2.3.2.5/arch/parisc/Kconfig
531 --- linux-3.1.6/arch/parisc/Kconfig 2011-10-24 18:44:59.000000000 +0200
532 +++ linux-3.1.6-vs2.3.2.5/arch/parisc/Kconfig 2011-10-24 18:53:33.000000000 +0200
533 @@ -280,6 +280,8 @@ source "fs/Kconfig"
535 source "arch/parisc/Kconfig.debug"
537 +source "kernel/vserver/Kconfig"
539 source "security/Kconfig"
541 source "crypto/Kconfig"
542 diff -NurpP --minimal linux-3.1.6/arch/parisc/kernel/syscall_table.S linux-3.1.6-vs2.3.2.5/arch/parisc/kernel/syscall_table.S
543 --- linux-3.1.6/arch/parisc/kernel/syscall_table.S 2011-10-24 18:45:00.000000000 +0200
544 +++ linux-3.1.6-vs2.3.2.5/arch/parisc/kernel/syscall_table.S 2011-10-24 18:53:33.000000000 +0200
546 ENTRY_COMP(mbind) /* 260 */
547 ENTRY_COMP(get_mempolicy)
548 ENTRY_COMP(set_mempolicy)
549 - ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */
550 + ENTRY_DIFF(vserver)
552 ENTRY_SAME(request_key) /* 265 */
554 diff -NurpP --minimal linux-3.1.6/arch/parisc/kernel/traps.c linux-3.1.6-vs2.3.2.5/arch/parisc/kernel/traps.c
555 --- linux-3.1.6/arch/parisc/kernel/traps.c 2011-10-24 18:45:00.000000000 +0200
556 +++ linux-3.1.6-vs2.3.2.5/arch/parisc/kernel/traps.c 2011-10-24 18:53:33.000000000 +0200
557 @@ -236,8 +236,9 @@ void die_if_kernel(char *str, struct pt_
561 - printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
562 - current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
563 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
564 + current->comm, task_pid_nr(current), current->xid,
565 + str, err, regs->iaoq[0]);
566 #ifdef PRINT_USER_FAULTS
567 /* XXX for debugging only */
569 @@ -270,8 +271,8 @@ void die_if_kernel(char *str, struct pt_
570 pdc_console_restart();
573 - printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
574 - current->comm, task_pid_nr(current), str, err);
575 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
576 + current->comm, task_pid_nr(current), current->xid, str, err);
578 /* Wot's wrong wif bein' racy? */
579 if (current->thread.flags & PARISC_KERNEL_DEATH) {
580 diff -NurpP --minimal linux-3.1.6/arch/parisc/mm/fault.c linux-3.1.6-vs2.3.2.5/arch/parisc/mm/fault.c
581 --- linux-3.1.6/arch/parisc/mm/fault.c 2010-08-02 16:52:06.000000000 +0200
582 +++ linux-3.1.6-vs2.3.2.5/arch/parisc/mm/fault.c 2011-10-24 18:53:33.000000000 +0200
583 @@ -237,8 +237,9 @@ bad_area:
585 #ifdef PRINT_USER_FAULTS
586 printk(KERN_DEBUG "\n");
587 - printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
588 - task_pid_nr(tsk), tsk->comm, code, address);
589 + printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
590 + "command='%s' type=%lu address=0x%08lx\n",
591 + task_pid_nr(tsk), tsk->xid, tsk->comm, code, address);
593 printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
594 vma->vm_start, vma->vm_end);
595 diff -NurpP --minimal linux-3.1.6/arch/powerpc/Kconfig linux-3.1.6-vs2.3.2.5/arch/powerpc/Kconfig
596 --- linux-3.1.6/arch/powerpc/Kconfig 2011-10-24 18:45:00.000000000 +0200
597 +++ linux-3.1.6-vs2.3.2.5/arch/powerpc/Kconfig 2011-10-24 18:53:33.000000000 +0200
598 @@ -981,6 +981,8 @@ source "lib/Kconfig"
600 source "arch/powerpc/Kconfig.debug"
602 +source "kernel/vserver/Kconfig"
604 source "security/Kconfig"
607 diff -NurpP --minimal linux-3.1.6/arch/powerpc/include/asm/unistd.h linux-3.1.6-vs2.3.2.5/arch/powerpc/include/asm/unistd.h
608 --- linux-3.1.6/arch/powerpc/include/asm/unistd.h 2011-07-22 11:17:40.000000000 +0200
609 +++ linux-3.1.6-vs2.3.2.5/arch/powerpc/include/asm/unistd.h 2011-10-24 18:53:33.000000000 +0200
612 #define __NR_rtas 255
613 #define __NR_sys_debug_setcontext 256
614 -/* Number 257 is reserved for vserver */
615 +#define __NR_vserver 257
616 #define __NR_migrate_pages 258
617 #define __NR_mbind 259
618 #define __NR_get_mempolicy 260
619 diff -NurpP --minimal linux-3.1.6/arch/powerpc/kernel/process.c linux-3.1.6-vs2.3.2.5/arch/powerpc/kernel/process.c
620 --- linux-3.1.6/arch/powerpc/kernel/process.c 2011-10-24 18:45:00.000000000 +0200
621 +++ linux-3.1.6-vs2.3.2.5/arch/powerpc/kernel/process.c 2011-10-24 18:53:33.000000000 +0200
622 @@ -662,8 +662,9 @@ void show_regs(struct pt_regs * regs)
624 printk("DAR: "REG", DSISR: %08lx\n", regs->dar, regs->dsisr);
626 - printk("TASK = %p[%d] '%s' THREAD: %p",
627 - current, task_pid_nr(current), current->comm, task_thread_info(current));
628 + printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
629 + current, task_pid_nr(current), current->xid,
630 + current->comm, task_thread_info(current));
633 printk(" CPU: %d", raw_smp_processor_id());
634 diff -NurpP --minimal linux-3.1.6/arch/powerpc/kernel/traps.c linux-3.1.6-vs2.3.2.5/arch/powerpc/kernel/traps.c
635 --- linux-3.1.6/arch/powerpc/kernel/traps.c 2011-10-24 18:45:00.000000000 +0200
636 +++ linux-3.1.6-vs2.3.2.5/arch/powerpc/kernel/traps.c 2011-10-24 18:53:33.000000000 +0200
637 @@ -1075,8 +1075,9 @@ void nonrecoverable_exception(struct pt_
639 void trace_syscall(struct pt_regs *regs)
641 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
642 - current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
643 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
644 + current, task_pid_nr(current), current->xid,
645 + regs->nip, regs->link, regs->gpr[0],
646 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
649 diff -NurpP --minimal linux-3.1.6/arch/s390/Kconfig linux-3.1.6-vs2.3.2.5/arch/s390/Kconfig
650 --- linux-3.1.6/arch/s390/Kconfig 2011-10-24 18:45:01.000000000 +0200
651 +++ linux-3.1.6-vs2.3.2.5/arch/s390/Kconfig 2011-10-24 18:53:33.000000000 +0200
652 @@ -629,6 +629,8 @@ source "fs/Kconfig"
654 source "arch/s390/Kconfig.debug"
656 +source "kernel/vserver/Kconfig"
658 source "security/Kconfig"
660 source "crypto/Kconfig"
661 diff -NurpP --minimal linux-3.1.6/arch/s390/include/asm/tlb.h linux-3.1.6-vs2.3.2.5/arch/s390/include/asm/tlb.h
662 --- linux-3.1.6/arch/s390/include/asm/tlb.h 2011-07-22 11:17:41.000000000 +0200
663 +++ linux-3.1.6-vs2.3.2.5/arch/s390/include/asm/tlb.h 2011-12-07 04:18:50.000000000 +0100
665 #include <linux/mm.h>
666 #include <linux/pagemap.h>
667 #include <linux/swap.h>
669 #include <asm/processor.h>
670 #include <asm/pgalloc.h>
671 #include <asm/tlbflush.h>
672 diff -NurpP --minimal linux-3.1.6/arch/s390/include/asm/unistd.h linux-3.1.6-vs2.3.2.5/arch/s390/include/asm/unistd.h
673 --- linux-3.1.6/arch/s390/include/asm/unistd.h 2011-07-22 11:17:41.000000000 +0200
674 +++ linux-3.1.6-vs2.3.2.5/arch/s390/include/asm/unistd.h 2011-10-24 18:53:33.000000000 +0200
676 #define __NR_clock_gettime (__NR_timer_create+6)
677 #define __NR_clock_getres (__NR_timer_create+7)
678 #define __NR_clock_nanosleep (__NR_timer_create+8)
679 -/* Number 263 is reserved for vserver */
680 +#define __NR_vserver 263
681 #define __NR_statfs64 265
682 #define __NR_fstatfs64 266
683 #define __NR_remap_file_pages 267
684 diff -NurpP --minimal linux-3.1.6/arch/s390/kernel/ptrace.c linux-3.1.6-vs2.3.2.5/arch/s390/kernel/ptrace.c
685 --- linux-3.1.6/arch/s390/kernel/ptrace.c 2011-12-23 16:04:05.000000000 +0100
686 +++ linux-3.1.6-vs2.3.2.5/arch/s390/kernel/ptrace.c 2011-12-15 01:07:58.000000000 +0100
688 #include <linux/regset.h>
689 #include <linux/tracehook.h>
690 #include <linux/seccomp.h>
691 +#include <linux/vs_base.h>
692 #include <trace/syscall.h>
693 #include <asm/compat.h>
694 #include <asm/segment.h>
695 diff -NurpP --minimal linux-3.1.6/arch/s390/kernel/syscalls.S linux-3.1.6-vs2.3.2.5/arch/s390/kernel/syscalls.S
696 --- linux-3.1.6/arch/s390/kernel/syscalls.S 2011-10-24 18:45:01.000000000 +0200
697 +++ linux-3.1.6-vs2.3.2.5/arch/s390/kernel/syscalls.S 2011-10-24 18:53:33.000000000 +0200
698 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
699 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
700 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
701 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
702 -NI_SYSCALL /* reserved for vserver */
703 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
704 SYSCALL(sys_s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
705 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
706 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
707 diff -NurpP --minimal linux-3.1.6/arch/sh/Kconfig linux-3.1.6-vs2.3.2.5/arch/sh/Kconfig
708 --- linux-3.1.6/arch/sh/Kconfig 2011-10-24 18:45:01.000000000 +0200
709 +++ linux-3.1.6-vs2.3.2.5/arch/sh/Kconfig 2011-10-24 18:53:33.000000000 +0200
710 @@ -894,6 +894,8 @@ source "fs/Kconfig"
712 source "arch/sh/Kconfig.debug"
714 +source "kernel/vserver/Kconfig"
716 source "security/Kconfig"
718 source "crypto/Kconfig"
719 diff -NurpP --minimal linux-3.1.6/arch/sh/kernel/irq.c linux-3.1.6-vs2.3.2.5/arch/sh/kernel/irq.c
720 --- linux-3.1.6/arch/sh/kernel/irq.c 2011-07-22 11:17:41.000000000 +0200
721 +++ linux-3.1.6-vs2.3.2.5/arch/sh/kernel/irq.c 2011-10-24 18:53:33.000000000 +0200
723 #include <linux/ftrace.h>
724 #include <linux/delay.h>
725 #include <linux/ratelimit.h>
726 +// #include <linux/vs_context.h>
727 #include <asm/processor.h>
728 #include <asm/machvec.h>
729 #include <asm/uaccess.h>
730 diff -NurpP --minimal linux-3.1.6/arch/sparc/Kconfig linux-3.1.6-vs2.3.2.5/arch/sparc/Kconfig
731 --- linux-3.1.6/arch/sparc/Kconfig 2011-10-24 18:45:02.000000000 +0200
732 +++ linux-3.1.6-vs2.3.2.5/arch/sparc/Kconfig 2011-10-24 18:53:33.000000000 +0200
733 @@ -600,6 +600,8 @@ source "fs/Kconfig"
735 source "arch/sparc/Kconfig.debug"
737 +source "kernel/vserver/Kconfig"
739 source "security/Kconfig"
741 source "crypto/Kconfig"
742 diff -NurpP --minimal linux-3.1.6/arch/sparc/include/asm/unistd.h linux-3.1.6-vs2.3.2.5/arch/sparc/include/asm/unistd.h
743 --- linux-3.1.6/arch/sparc/include/asm/unistd.h 2011-07-22 11:17:42.000000000 +0200
744 +++ linux-3.1.6-vs2.3.2.5/arch/sparc/include/asm/unistd.h 2011-10-24 18:53:33.000000000 +0200
746 #define __NR_timer_getoverrun 264
747 #define __NR_timer_delete 265
748 #define __NR_timer_create 266
749 -/* #define __NR_vserver 267 Reserved for VSERVER */
750 +#define __NR_vserver 267
751 #define __NR_io_setup 268
752 #define __NR_io_destroy 269
753 #define __NR_io_submit 270
754 diff -NurpP --minimal linux-3.1.6/arch/sparc/kernel/systbls_32.S linux-3.1.6-vs2.3.2.5/arch/sparc/kernel/systbls_32.S
755 --- linux-3.1.6/arch/sparc/kernel/systbls_32.S 2011-10-24 18:45:02.000000000 +0200
756 +++ linux-3.1.6-vs2.3.2.5/arch/sparc/kernel/systbls_32.S 2011-10-24 18:53:33.000000000 +0200
757 @@ -70,7 +70,7 @@ sys_call_table:
758 /*250*/ .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_ni_syscall
759 /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
760 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
761 -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
762 +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
763 /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
764 /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
765 /*280*/ .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
766 diff -NurpP --minimal linux-3.1.6/arch/sparc/kernel/systbls_64.S linux-3.1.6-vs2.3.2.5/arch/sparc/kernel/systbls_64.S
767 --- linux-3.1.6/arch/sparc/kernel/systbls_64.S 2011-10-24 18:45:02.000000000 +0200
768 +++ linux-3.1.6-vs2.3.2.5/arch/sparc/kernel/systbls_64.S 2011-10-24 18:53:33.000000000 +0200
769 @@ -71,7 +71,7 @@ sys_call_table32:
770 /*250*/ .word sys_mremap, compat_sys_sysctl, sys32_getsid, sys_fdatasync, sys_nis_syscall
771 .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
772 /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
773 - .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
774 + .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
775 /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
776 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
777 /*280*/ .word sys32_tee, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat
778 @@ -148,7 +148,7 @@ sys_call_table:
779 /*250*/ .word sys_64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nis_syscall
780 .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
781 /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
782 - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
783 + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
784 /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
785 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
786 /*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
787 diff -NurpP --minimal linux-3.1.6/arch/um/Kconfig.rest linux-3.1.6-vs2.3.2.5/arch/um/Kconfig.rest
788 --- linux-3.1.6/arch/um/Kconfig.rest 2009-06-11 17:12:19.000000000 +0200
789 +++ linux-3.1.6-vs2.3.2.5/arch/um/Kconfig.rest 2011-10-24 18:53:33.000000000 +0200
790 @@ -18,6 +18,8 @@ source "drivers/connector/Kconfig"
794 +source "kernel/vserver/Kconfig"
796 source "security/Kconfig"
798 source "crypto/Kconfig"
799 diff -NurpP --minimal linux-3.1.6/arch/um/include/shared/kern_constants.h linux-3.1.6-vs2.3.2.5/arch/um/include/shared/kern_constants.h
800 --- linux-3.1.6/arch/um/include/shared/kern_constants.h 1970-01-01 01:00:00.000000000 +0100
801 +++ linux-3.1.6-vs2.3.2.5/arch/um/include/shared/kern_constants.h 2011-10-24 18:53:33.000000000 +0200
803 +#include "../../../../include/generated/asm-offsets.h"
804 diff -NurpP --minimal linux-3.1.6/arch/um/include/shared/user_constants.h linux-3.1.6-vs2.3.2.5/arch/um/include/shared/user_constants.h
805 --- linux-3.1.6/arch/um/include/shared/user_constants.h 1970-01-01 01:00:00.000000000 +0100
806 +++ linux-3.1.6-vs2.3.2.5/arch/um/include/shared/user_constants.h 2011-10-24 18:53:33.000000000 +0200
811 + * This file was generated by arch/um/Makefile
815 +#define HOST_SC_CR2 176 /* offsetof(struct sigcontext, cr2) # */
816 +#define HOST_SC_ERR 152 /* offsetof(struct sigcontext, err) # */
817 +#define HOST_SC_TRAPNO 160 /* offsetof(struct sigcontext, trapno) # */
818 +#define HOST_FP_SIZE 64 /* sizeof(struct _fpstate) / sizeof(unsigned long) # */
819 +#define HOST_RBX 5 /* RBX # */
820 +#define HOST_RCX 11 /* RCX # */
821 +#define HOST_RDI 14 /* RDI # */
822 +#define HOST_RSI 13 /* RSI # */
823 +#define HOST_RDX 12 /* RDX # */
824 +#define HOST_RBP 4 /* RBP # */
825 +#define HOST_RAX 10 /* RAX # */
826 +#define HOST_R8 9 /* R8 # */
827 +#define HOST_R9 8 /* R9 # */
828 +#define HOST_R10 7 /* R10 # */
829 +#define HOST_R11 6 /* R11 # */
830 +#define HOST_R12 3 /* R12 # */
831 +#define HOST_R13 2 /* R13 # */
832 +#define HOST_R14 1 /* R14 # */
833 +#define HOST_R15 0 /* R15 # */
834 +#define HOST_ORIG_RAX 15 /* ORIG_RAX # */
835 +#define HOST_CS 17 /* CS # */
836 +#define HOST_SS 20 /* SS # */
837 +#define HOST_EFLAGS 18 /* EFLAGS # */
838 +#define HOST_IP 16 /* RIP # */
839 +#define HOST_SP 19 /* RSP # */
840 +#define UM_FRAME_SIZE 216 /* sizeof(struct user_regs_struct) # */
841 +#define UM_POLLIN 1 /* POLLIN # */
842 +#define UM_POLLPRI 2 /* POLLPRI # */
843 +#define UM_POLLOUT 4 /* POLLOUT # */
844 +#define UM_PROT_READ 1 /* PROT_READ # */
845 +#define UM_PROT_WRITE 2 /* PROT_WRITE # */
846 +#define UM_PROT_EXEC 4 /* PROT_EXEC # */
848 diff -NurpP --minimal linux-3.1.6/arch/x86/Kconfig linux-3.1.6-vs2.3.2.5/arch/x86/Kconfig
849 --- linux-3.1.6/arch/x86/Kconfig 2011-10-24 18:45:06.000000000 +0200
850 +++ linux-3.1.6-vs2.3.2.5/arch/x86/Kconfig 2011-10-24 18:53:33.000000000 +0200
851 @@ -2144,6 +2144,8 @@ source "fs/Kconfig"
853 source "arch/x86/Kconfig.debug"
855 +source "kernel/vserver/Kconfig"
857 source "security/Kconfig"
859 source "crypto/Kconfig"
860 diff -NurpP --minimal linux-3.1.6/arch/x86/ia32/ia32entry.S linux-3.1.6-vs2.3.2.5/arch/x86/ia32/ia32entry.S
861 --- linux-3.1.6/arch/x86/ia32/ia32entry.S 2011-10-24 18:45:06.000000000 +0200
862 +++ linux-3.1.6-vs2.3.2.5/arch/x86/ia32/ia32entry.S 2011-10-24 18:53:33.000000000 +0200
863 @@ -776,7 +776,7 @@ ia32_sys_call_table:
864 .quad sys_tgkill /* 270 */
865 .quad compat_sys_utimes
866 .quad sys32_fadvise64_64
867 - .quad quiet_ni_syscall /* sys_vserver */
868 + .quad sys32_vserver
870 .quad compat_sys_get_mempolicy /* 275 */
871 .quad sys_set_mempolicy
872 diff -NurpP --minimal linux-3.1.6/arch/x86/include/asm/unistd_64.h linux-3.1.6-vs2.3.2.5/arch/x86/include/asm/unistd_64.h
873 --- linux-3.1.6/arch/x86/include/asm/unistd_64.h 2011-10-24 18:45:07.000000000 +0200
874 +++ linux-3.1.6-vs2.3.2.5/arch/x86/include/asm/unistd_64.h 2011-10-24 18:53:33.000000000 +0200
875 @@ -535,7 +535,7 @@ __SYSCALL(__NR_tgkill, sys_tgkill)
876 #define __NR_utimes 235
877 __SYSCALL(__NR_utimes, sys_utimes)
878 #define __NR_vserver 236
879 -__SYSCALL(__NR_vserver, sys_ni_syscall)
880 +__SYSCALL(__NR_vserver, sys_vserver)
881 #define __NR_mbind 237
882 __SYSCALL(__NR_mbind, sys_mbind)
883 #define __NR_set_mempolicy 238
884 diff -NurpP --minimal linux-3.1.6/arch/x86/kernel/syscall_table_32.S linux-3.1.6-vs2.3.2.5/arch/x86/kernel/syscall_table_32.S
885 --- linux-3.1.6/arch/x86/kernel/syscall_table_32.S 2011-10-24 18:45:07.000000000 +0200
886 +++ linux-3.1.6-vs2.3.2.5/arch/x86/kernel/syscall_table_32.S 2011-10-24 18:53:33.000000000 +0200
887 @@ -272,7 +272,7 @@ ENTRY(sys_call_table)
888 .long sys_tgkill /* 270 */
890 .long sys_fadvise64_64
891 - .long sys_ni_syscall /* sys_vserver */
894 .long sys_get_mempolicy
895 .long sys_set_mempolicy
896 diff -NurpP --minimal linux-3.1.6/drivers/block/Kconfig linux-3.1.6-vs2.3.2.5/drivers/block/Kconfig
897 --- linux-3.1.6/drivers/block/Kconfig 2011-10-24 18:45:08.000000000 +0200
898 +++ linux-3.1.6-vs2.3.2.5/drivers/block/Kconfig 2011-10-24 18:53:33.000000000 +0200
899 @@ -288,6 +288,13 @@ config BLK_DEV_CRYPTOLOOP
901 source "drivers/block/drbd/Kconfig"
903 +config BLK_DEV_VROOT
904 + tristate "Virtual Root device support"
905 + depends on QUOTACTL
907 + Saying Y here will allow you to use quota/fs ioctls on a shared
908 + partition within a virtual server without compromising security.
911 tristate "Network block device support"
913 diff -NurpP --minimal linux-3.1.6/drivers/block/Makefile linux-3.1.6-vs2.3.2.5/drivers/block/Makefile
914 --- linux-3.1.6/drivers/block/Makefile 2011-07-22 11:17:44.000000000 +0200
915 +++ linux-3.1.6-vs2.3.2.5/drivers/block/Makefile 2011-10-24 18:53:33.000000000 +0200
916 @@ -34,6 +34,7 @@ obj-$(CONFIG_VIODASD) += viodasd.o
917 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
918 obj-$(CONFIG_BLK_DEV_UB) += ub.o
919 obj-$(CONFIG_BLK_DEV_HD) += hd.o
920 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
922 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
923 obj-$(CONFIG_XEN_BLKDEV_BACKEND) += xen-blkback/
924 diff -NurpP --minimal linux-3.1.6/drivers/block/loop.c linux-3.1.6-vs2.3.2.5/drivers/block/loop.c
925 --- linux-3.1.6/drivers/block/loop.c 2011-10-24 18:45:08.000000000 +0200
926 +++ linux-3.1.6-vs2.3.2.5/drivers/block/loop.c 2011-12-17 20:00:17.000000000 +0100
928 #include <linux/splice.h>
929 #include <linux/sysfs.h>
930 #include <linux/miscdevice.h>
931 +#include <linux/vs_context.h>
932 #include <asm/uaccess.h>
934 static DEFINE_IDR(loop_index_idr);
935 @@ -884,6 +885,7 @@ static int loop_set_fd(struct loop_devic
936 lo->lo_blocksize = lo_blocksize;
937 lo->lo_device = bdev;
938 lo->lo_flags = lo_flags;
939 + lo->lo_xid = vx_current_xid();
940 lo->lo_backing_file = file;
941 lo->transfer = transfer_none;
943 @@ -1014,6 +1016,7 @@ static int loop_clr_fd(struct loop_devic
944 lo->lo_encrypt_key_size = 0;
946 lo->lo_thread = NULL;
948 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
949 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
950 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
951 @@ -1052,7 +1055,7 @@ loop_set_status(struct loop_device *lo,
953 if (lo->lo_encrypt_key_size &&
954 lo->lo_key_owner != uid &&
955 - !capable(CAP_SYS_ADMIN))
956 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
958 if (lo->lo_state != Lo_bound)
960 @@ -1136,7 +1139,8 @@ loop_get_status(struct loop_device *lo,
961 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
962 info->lo_encrypt_type =
963 lo->lo_encryption ? lo->lo_encryption->number : 0;
964 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
965 + if (lo->lo_encrypt_key_size &&
966 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
967 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
968 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
969 lo->lo_encrypt_key_size);
970 @@ -1490,6 +1494,11 @@ static int lo_open(struct block_device *
974 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P)) {
979 mutex_lock(&lo->lo_ctl_mutex);
981 mutex_unlock(&lo->lo_ctl_mutex);
982 diff -NurpP --minimal linux-3.1.6/drivers/block/vroot.c linux-3.1.6-vs2.3.2.5/drivers/block/vroot.c
983 --- linux-3.1.6/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
984 +++ linux-3.1.6-vs2.3.2.5/drivers/block/vroot.c 2011-10-24 18:53:33.000000000 +0200
987 + * linux/drivers/block/vroot.c
989 + * written by Herbert Pötzl, 9/11/2002
990 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
992 + * based on the loop.c code by Theodore Ts'o.
994 + * Copyright (C) 2002-2007 by Herbert Pötzl.
995 + * Redistribution of this file is permitted under the
996 + * GNU General Public License.
1000 +#include <linux/module.h>
1001 +#include <linux/moduleparam.h>
1002 +#include <linux/file.h>
1003 +#include <linux/major.h>
1004 +#include <linux/blkdev.h>
1005 +#include <linux/slab.h>
1007 +#include <linux/vroot.h>
1008 +#include <linux/vs_context.h>
1011 +static int max_vroot = 8;
1013 +static struct vroot_device *vroot_dev;
1014 +static struct gendisk **disks;
1017 +static int vroot_set_dev(
1018 + struct vroot_device *vr,
1019 + struct block_device *bdev,
1022 + struct block_device *real_bdev;
1023 + struct file *file;
1024 + struct inode *inode;
1028 + if (vr->vr_state != Vr_unbound)
1037 + inode = file->f_dentry->d_inode;
1040 + if (S_ISBLK(inode->i_mode)) {
1041 + real_bdev = inode->i_bdev;
1042 + vr->vr_device = real_bdev;
1043 + __iget(real_bdev->bd_inode);
1047 + vxdprintk(VXD_CBIT(misc, 0),
1048 + "vroot[%d]_set_dev: dev=" VXF_DEV,
1049 + vr->vr_number, VXD_DEV(real_bdev));
1051 + vr->vr_state = Vr_bound;
1060 +static int vroot_clr_dev(
1061 + struct vroot_device *vr,
1062 + struct block_device *bdev)
1064 + struct block_device *real_bdev;
1066 + if (vr->vr_state != Vr_bound)
1068 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
1071 + real_bdev = vr->vr_device;
1073 + vxdprintk(VXD_CBIT(misc, 0),
1074 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
1075 + vr->vr_number, VXD_DEV(real_bdev));
1078 + vr->vr_state = Vr_unbound;
1079 + vr->vr_device = NULL;
1084 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
1085 + unsigned int cmd, unsigned long arg)
1087 + struct vroot_device *vr = bdev->bd_disk->private_data;
1090 + down(&vr->vr_ctl_mutex);
1092 + case VROOT_SET_DEV:
1093 + err = vroot_set_dev(vr, bdev, arg);
1095 + case VROOT_CLR_DEV:
1096 + err = vroot_clr_dev(vr, bdev);
1102 + up(&vr->vr_ctl_mutex);
1106 +static int vr_open(struct block_device *bdev, fmode_t mode)
1108 + struct vroot_device *vr = bdev->bd_disk->private_data;
1110 + down(&vr->vr_ctl_mutex);
1112 + up(&vr->vr_ctl_mutex);
1116 +static int vr_release(struct gendisk *disk, fmode_t mode)
1118 + struct vroot_device *vr = disk->private_data;
1120 + down(&vr->vr_ctl_mutex);
1122 + up(&vr->vr_ctl_mutex);
1126 +static struct block_device_operations vr_fops = {
1127 + .owner = THIS_MODULE,
1129 + .release = vr_release,
1130 + .ioctl = vr_ioctl,
1133 +static int vroot_make_request(struct request_queue *q, struct bio *bio)
1135 + printk("vroot_make_request %p, %p\n", q, bio);
1136 + bio_io_error(bio);
1140 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
1142 + struct inode *inode = bdev->bd_inode;
1143 + struct vroot_device *vr;
1144 + struct block_device *real_bdev;
1145 + int minor = iminor(inode);
1147 + vr = &vroot_dev[minor];
1148 + real_bdev = vr->vr_device;
1150 + vxdprintk(VXD_CBIT(misc, 0),
1151 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
1152 + vr->vr_number, VXD_DEV(real_bdev));
1154 + if (vr->vr_state != Vr_bound)
1155 + return ERR_PTR(-ENXIO);
1157 + __iget(real_bdev->bd_inode);
1164 + * And now the modules code and kernel interface.
1167 +module_param(max_vroot, int, 0);
1169 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
1170 +MODULE_LICENSE("GPL");
1171 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
1173 +MODULE_AUTHOR ("Herbert Pötzl");
1174 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
1177 +int __init vroot_init(void)
1181 + if (max_vroot < 1 || max_vroot > 256) {
1182 + max_vroot = MAX_VROOT_DEFAULT;
1183 + printk(KERN_WARNING "vroot: invalid max_vroot "
1184 + "(must be between 1 and 256), "
1185 + "using default (%d)\n", max_vroot);
1188 + if (register_blkdev(VROOT_MAJOR, "vroot"))
1192 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
1195 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
1197 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
1201 + for (i = 0; i < max_vroot; i++) {
1202 + disks[i] = alloc_disk(1);
1205 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
1206 + if (!disks[i]->queue)
1208 + blk_queue_make_request(disks[i]->queue, vroot_make_request);
1211 + for (i = 0; i < max_vroot; i++) {
1212 + struct vroot_device *vr = &vroot_dev[i];
1213 + struct gendisk *disk = disks[i];
1215 + memset(vr, 0, sizeof(*vr));
1216 + sema_init(&vr->vr_ctl_mutex, 1);
1217 + vr->vr_number = i;
1218 + disk->major = VROOT_MAJOR;
1219 + disk->first_minor = i;
1220 + disk->fops = &vr_fops;
1221 + sprintf(disk->disk_name, "vroot%d", i);
1222 + disk->private_data = vr;
1225 + err = register_vroot_grb(&__vroot_get_real_bdev);
1229 + for (i = 0; i < max_vroot; i++)
1230 + add_disk(disks[i]);
1231 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
1236 + put_disk(disks[i]);
1241 + unregister_blkdev(VROOT_MAJOR, "vroot");
1242 + printk(KERN_ERR "vroot: ran out of memory\n");
1246 +void vroot_exit(void)
1250 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
1251 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
1253 + for (i = 0; i < max_vroot; i++) {
1254 + del_gendisk(disks[i]);
1255 + put_disk(disks[i]);
1257 + unregister_blkdev(VROOT_MAJOR, "vroot");
1263 +module_init(vroot_init);
1264 +module_exit(vroot_exit);
1268 +static int __init max_vroot_setup(char *str)
1270 + max_vroot = simple_strtol(str, NULL, 0);
1274 +__setup("max_vroot=", max_vroot_setup);
1278 diff -NurpP --minimal linux-3.1.6/drivers/infiniband/core/addr.c linux-3.1.6-vs2.3.2.5/drivers/infiniband/core/addr.c
1279 --- linux-3.1.6/drivers/infiniband/core/addr.c 2011-12-23 16:04:05.000000000 +0100
1280 +++ linux-3.1.6-vs2.3.2.5/drivers/infiniband/core/addr.c 2011-12-15 01:07:58.000000000 +0100
1281 @@ -254,7 +254,7 @@ static int addr6_resolve(struct sockaddr
1283 if (ipv6_addr_any(&fl6.saddr)) {
1284 ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
1285 - &fl6.daddr, 0, &fl6.saddr);
1286 + &fl6.daddr, 0, &fl6.saddr, NULL);
1290 diff -NurpP --minimal linux-3.1.6/drivers/md/dm-ioctl.c linux-3.1.6-vs2.3.2.5/drivers/md/dm-ioctl.c
1291 --- linux-3.1.6/drivers/md/dm-ioctl.c 2011-10-24 18:45:10.000000000 +0200
1292 +++ linux-3.1.6-vs2.3.2.5/drivers/md/dm-ioctl.c 2011-10-24 18:53:33.000000000 +0200
1294 #include <linux/dm-ioctl.h>
1295 #include <linux/hdreg.h>
1296 #include <linux/compat.h>
1297 +#include <linux/vs_context.h>
1299 #include <asm/uaccess.h>
1301 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
1302 unsigned int h = hash_str(str);
1304 list_for_each_entry (hc, _name_buckets + h, name_list)
1305 - if (!strcmp(hc->name, str)) {
1306 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1307 + !strcmp(hc->name, str)) {
1311 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
1312 unsigned int h = hash_str(str);
1314 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
1315 - if (!strcmp(hc->uuid, str)) {
1316 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1317 + !strcmp(hc->uuid, str)) {
1321 @@ -131,13 +134,15 @@ static struct hash_cell *__get_uuid_cell
1322 static struct hash_cell *__get_dev_cell(uint64_t dev)
1324 struct mapped_device *md;
1325 - struct hash_cell *hc;
1326 + struct hash_cell *hc = NULL;
1328 md = dm_get_md(huge_decode_dev(dev));
1332 - hc = dm_get_mdptr(md);
1333 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
1334 + hc = dm_get_mdptr(md);
1339 @@ -445,6 +450,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
1341 static int remove_all(struct dm_ioctl *param, size_t param_size)
1343 + if (!vx_check(0, VS_ADMIN))
1346 dm_hash_remove_all(1);
1347 param->data_size = 0;
1349 @@ -492,6 +500,8 @@ static int list_devices(struct dm_ioctl
1351 for (i = 0; i < NUM_BUCKETS; i++) {
1352 list_for_each_entry (hc, _name_buckets + i, name_list) {
1353 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1355 needed += sizeof(struct dm_name_list);
1356 needed += strlen(hc->name) + 1;
1357 needed += ALIGN_MASK;
1358 @@ -515,6 +525,8 @@ static int list_devices(struct dm_ioctl
1360 for (i = 0; i < NUM_BUCKETS; i++) {
1361 list_for_each_entry (hc, _name_buckets + i, name_list) {
1362 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1365 old_nl->next = (uint32_t) ((void *) nl -
1367 @@ -1604,8 +1616,8 @@ static int ctl_ioctl(uint command, struc
1369 size_t input_param_size;
1371 - /* only root can play with this */
1372 - if (!capable(CAP_SYS_ADMIN))
1373 + /* only root and certain contexts can play with this */
1374 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
1377 if (_IOC_TYPE(command) != DM_IOCTL)
1378 diff -NurpP --minimal linux-3.1.6/drivers/md/dm.c linux-3.1.6-vs2.3.2.5/drivers/md/dm.c
1379 --- linux-3.1.6/drivers/md/dm.c 2011-10-24 18:45:10.000000000 +0200
1380 +++ linux-3.1.6-vs2.3.2.5/drivers/md/dm.c 2011-10-24 18:53:33.000000000 +0200
1382 #include <linux/idr.h>
1383 #include <linux/hdreg.h>
1384 #include <linux/delay.h>
1385 +#include <linux/vs_base.h>
1387 #include <trace/events/block.h>
1389 @@ -122,6 +123,7 @@ struct mapped_device {
1392 atomic_t open_count;
1395 unsigned long flags;
1397 @@ -335,6 +337,7 @@ int dm_deleting_md(struct mapped_device
1398 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
1400 struct mapped_device *md;
1403 spin_lock(&_minor_lock);
1405 @@ -343,18 +346,19 @@ static int dm_blk_open(struct block_devi
1408 if (test_bit(DMF_FREEING, &md->flags) ||
1409 - dm_deleting_md(md)) {
1411 + dm_deleting_md(md))
1415 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
1420 atomic_inc(&md->open_count);
1424 spin_unlock(&_minor_lock);
1426 - return md ? 0 : -ENXIO;
1430 static int dm_blk_close(struct gendisk *disk, fmode_t mode)
1431 @@ -575,6 +579,14 @@ int dm_set_geometry(struct mapped_device
1436 + * Get the xid associated with a dm device
1438 +xid_t dm_get_xid(struct mapped_device *md)
1443 /*-----------------------------------------------------------------
1445 * A more elegant soln is in the works that uses the queue
1446 @@ -1848,6 +1860,7 @@ static struct mapped_device *alloc_dev(i
1447 INIT_LIST_HEAD(&md->uevent_list);
1448 spin_lock_init(&md->uevent_lock);
1450 + md->xid = vx_current_xid();
1451 md->queue = blk_alloc_queue(GFP_KERNEL);
1454 diff -NurpP --minimal linux-3.1.6/drivers/md/dm.h linux-3.1.6-vs2.3.2.5/drivers/md/dm.h
1455 --- linux-3.1.6/drivers/md/dm.h 2011-10-24 18:45:10.000000000 +0200
1456 +++ linux-3.1.6-vs2.3.2.5/drivers/md/dm.h 2011-10-24 18:53:33.000000000 +0200
1457 @@ -41,6 +41,8 @@ struct dm_dev_internal {
1459 struct dm_md_mempools;
1461 +xid_t dm_get_xid(struct mapped_device *md);
1463 /*-----------------------------------------------------------------
1464 * Internal table functions.
1465 *---------------------------------------------------------------*/
1466 diff -NurpP --minimal linux-3.1.6/drivers/net/tun.c linux-3.1.6-vs2.3.2.5/drivers/net/tun.c
1467 --- linux-3.1.6/drivers/net/tun.c 2011-10-24 18:45:17.000000000 +0200
1468 +++ linux-3.1.6-vs2.3.2.5/drivers/net/tun.c 2011-10-24 18:53:33.000000000 +0200
1470 #include <linux/nsproxy.h>
1471 #include <linux/virtio_net.h>
1472 #include <linux/rcupdate.h>
1473 +#include <linux/vs_network.h>
1474 #include <net/net_namespace.h>
1475 #include <net/netns/generic.h>
1476 #include <net/rtnetlink.h>
1477 @@ -121,6 +122,7 @@ struct tun_struct {
1483 struct net_device *dev;
1485 @@ -909,6 +911,7 @@ static void tun_setup(struct net_device
1489 + tun->nid = current->nid;
1491 dev->ethtool_ops = &tun_ethtool_ops;
1492 dev->destructor = tun_free_netdev;
1493 @@ -1059,7 +1062,7 @@ static int tun_set_iff(struct net *net,
1495 if (((tun->owner != -1 && cred->euid != tun->owner) ||
1496 (tun->group != -1 && !in_egroup_p(tun->group))) &&
1497 - !capable(CAP_NET_ADMIN))
1498 + !cap_raised(current_cap(), CAP_NET_ADMIN))
1500 err = security_tun_dev_attach(tun->socket.sk);
1502 @@ -1073,7 +1076,7 @@ static int tun_set_iff(struct net *net,
1504 unsigned long flags = 0;
1506 - if (!capable(CAP_NET_ADMIN))
1507 + if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
1509 err = security_tun_dev_create();
1511 @@ -1141,6 +1144,9 @@ static int tun_set_iff(struct net *net,
1513 sk->sk_destruct = tun_sock_destruct;
1515 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
1518 err = tun_attach(tun, file);
1521 @@ -1322,6 +1328,16 @@ static long __tun_chr_ioctl(struct file
1522 tun_debug(KERN_INFO, tun, "group set to %d\n", tun->group);
1526 + if (!capable(CAP_CONTEXT))
1529 + /* Set nid owner of the device */
1530 + tun->nid = (nid_t) arg;
1532 + tun_debug(KERN_INFO, tun, "nid owner set to %u\n", tun->nid);
1536 /* Only allow setting the type when the interface is down */
1537 if (tun->dev->flags & IFF_UP) {
1538 diff -NurpP --minimal linux-3.1.6/drivers/tty/sysrq.c linux-3.1.6-vs2.3.2.5/drivers/tty/sysrq.c
1539 --- linux-3.1.6/drivers/tty/sysrq.c 2011-05-22 16:17:44.000000000 +0200
1540 +++ linux-3.1.6-vs2.3.2.5/drivers/tty/sysrq.c 2011-10-24 18:53:33.000000000 +0200
1542 #include <linux/oom.h>
1543 #include <linux/slab.h>
1544 #include <linux/input.h>
1545 +#include <linux/vserver/debug.h>
1547 #include <asm/ptrace.h>
1548 #include <asm/irq_regs.h>
1549 @@ -395,6 +396,21 @@ static struct sysrq_key_op sysrq_unrt_op
1550 .enable_mask = SYSRQ_ENABLE_RTNICE,
1554 +#ifdef CONFIG_VSERVER_DEBUG
1555 +static void sysrq_handle_vxinfo(int key)
1557 + dump_vx_info_inactive((key == 'x') ? 0 : 1);
1560 +static struct sysrq_key_op sysrq_showvxinfo_op = {
1561 + .handler = sysrq_handle_vxinfo,
1562 + .help_msg = "conteXt",
1563 + .action_msg = "Show Context Info",
1564 + .enable_mask = SYSRQ_ENABLE_DUMP,
1568 /* Key Operations table and lock */
1569 static DEFINE_SPINLOCK(sysrq_key_table_lock);
1571 @@ -449,7 +465,11 @@ static struct sysrq_key_op *sysrq_key_ta
1573 &sysrq_showstate_blocked_op, /* w */
1574 /* x: May be registered on ppc/powerpc for xmon */
1575 +#ifdef CONFIG_VSERVER_DEBUG
1576 + &sysrq_showvxinfo_op, /* x */
1580 /* y: May be registered on sparc64 for global register dump */
1582 &sysrq_ftrace_dump_op, /* z */
1583 @@ -464,6 +484,8 @@ static int sysrq_key_table_key2index(int
1585 else if ((key >= 'a') && (key <= 'z'))
1586 retval = key + 10 - 'a';
1587 + else if ((key >= 'A') && (key <= 'Z'))
1588 + retval = key + 10 - 'A';
1592 diff -NurpP --minimal linux-3.1.6/drivers/tty/tty_io.c linux-3.1.6-vs2.3.2.5/drivers/tty/tty_io.c
1593 --- linux-3.1.6/drivers/tty/tty_io.c 2011-12-23 16:04:06.000000000 +0100
1594 +++ linux-3.1.6-vs2.3.2.5/drivers/tty/tty_io.c 2011-11-15 17:08:44.000000000 +0100
1597 #include <linux/kmod.h>
1598 #include <linux/nsproxy.h>
1599 +#include <linux/vs_pid.h>
1601 #undef TTY_DEBUG_HANGUP
1603 @@ -2080,7 +2081,8 @@ static int tiocsti(struct tty_struct *tt
1605 struct tty_ldisc *ld;
1607 - if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
1608 + if (((current->signal->tty != tty) &&
1609 + !vx_capable(CAP_SYS_ADMIN, VXC_TIOCSTI)))
1611 if (get_user(ch, p))
1613 @@ -2368,6 +2370,7 @@ static int tiocspgrp(struct tty_struct *
1615 if (get_user(pgrp_nr, p))
1617 + pgrp_nr = vx_rmap_pid(pgrp_nr);
1621 diff -NurpP --minimal linux-3.1.6/fs/attr.c linux-3.1.6-vs2.3.2.5/fs/attr.c
1622 --- linux-3.1.6/fs/attr.c 2011-10-24 18:45:26.000000000 +0200
1623 +++ linux-3.1.6-vs2.3.2.5/fs/attr.c 2011-10-24 18:53:33.000000000 +0200
1625 #include <linux/fsnotify.h>
1626 #include <linux/fcntl.h>
1627 #include <linux/security.h>
1628 +#include <linux/proc_fs.h>
1629 +#include <linux/devpts_fs.h>
1630 +#include <linux/vs_tag.h>
1633 * inode_change_ok - check if attribute changes to an inode are allowed
1634 @@ -73,6 +76,10 @@ int inode_change_ok(const struct inode *
1638 + /* check for inode tag permission */
1639 + if (dx_permission(inode, MAY_WRITE))
1644 EXPORT_SYMBOL(inode_change_ok);
1645 @@ -143,6 +150,8 @@ void setattr_copy(struct inode *inode, c
1646 inode->i_uid = attr->ia_uid;
1647 if (ia_valid & ATTR_GID)
1648 inode->i_gid = attr->ia_gid;
1649 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
1650 + inode->i_tag = attr->ia_tag;
1651 if (ia_valid & ATTR_ATIME)
1652 inode->i_atime = timespec_trunc(attr->ia_atime,
1653 inode->i_sb->s_time_gran);
1654 @@ -170,7 +179,8 @@ int notify_change(struct dentry * dentry
1655 struct timespec now;
1656 unsigned int ia_valid = attr->ia_valid;
1658 - if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
1659 + if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
1660 + ATTR_TAG | ATTR_TIMES_SET)) {
1661 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1664 diff -NurpP --minimal linux-3.1.6/fs/block_dev.c linux-3.1.6-vs2.3.2.5/fs/block_dev.c
1665 --- linux-3.1.6/fs/block_dev.c 2011-12-23 16:04:06.000000000 +0100
1666 +++ linux-3.1.6-vs2.3.2.5/fs/block_dev.c 2011-11-15 17:08:44.000000000 +0100
1668 #include <linux/namei.h>
1669 #include <linux/log2.h>
1670 #include <linux/kmemleak.h>
1671 +#include <linux/vs_device.h>
1672 #include <asm/uaccess.h>
1673 #include "internal.h"
1675 @@ -563,6 +564,7 @@ struct block_device *bdget(dev_t dev)
1676 bdev->bd_invalidated = 0;
1677 inode->i_mode = S_IFBLK;
1678 inode->i_rdev = dev;
1679 + inode->i_mdev = dev;
1680 inode->i_bdev = bdev;
1681 inode->i_data.a_ops = &def_blk_aops;
1682 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
1683 @@ -609,6 +611,11 @@ EXPORT_SYMBOL(bdput);
1684 static struct block_device *bd_acquire(struct inode *inode)
1686 struct block_device *bdev;
1689 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
1691 + inode->i_mdev = mdev;
1693 spin_lock(&bdev_lock);
1694 bdev = inode->i_bdev;
1695 @@ -619,7 +626,7 @@ static struct block_device *bd_acquire(s
1697 spin_unlock(&bdev_lock);
1699 - bdev = bdget(inode->i_rdev);
1700 + bdev = bdget(mdev);
1702 spin_lock(&bdev_lock);
1703 if (!inode->i_bdev) {
1704 diff -NurpP --minimal linux-3.1.6/fs/btrfs/ctree.h linux-3.1.6-vs2.3.2.5/fs/btrfs/ctree.h
1705 --- linux-3.1.6/fs/btrfs/ctree.h 2011-10-24 18:45:26.000000000 +0200
1706 +++ linux-3.1.6-vs2.3.2.5/fs/btrfs/ctree.h 2011-10-24 18:53:33.000000000 +0200
1707 @@ -600,11 +600,14 @@ struct btrfs_inode_item {
1708 /* modification sequence number for NFS */
1713 * a little future expansion, for more than this we can
1714 * just grow the inode item and version it
1716 - __le64 reserved[4];
1717 + __le16 reserved16;
1718 + __le32 reserved32;
1719 + __le64 reserved[3];
1720 struct btrfs_timespec atime;
1721 struct btrfs_timespec ctime;
1722 struct btrfs_timespec mtime;
1723 @@ -1364,6 +1367,8 @@ struct btrfs_ioctl_defrag_range_args {
1724 #define BTRFS_MOUNT_AUTO_DEFRAG (1 << 16)
1725 #define BTRFS_MOUNT_INODE_MAP_CACHE (1 << 17)
1727 +#define BTRFS_MOUNT_TAGGED (1 << 24)
1729 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
1730 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
1731 #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \
1732 @@ -1571,6 +1576,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
1733 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
1734 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
1735 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
1736 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
1737 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
1738 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
1739 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
1740 @@ -1624,6 +1630,10 @@ BTRFS_SETGET_FUNCS(extent_flags, struct
1742 BTRFS_SETGET_FUNCS(extent_refs_v0, struct btrfs_extent_item_v0, refs, 32);
1744 +#define BTRFS_INODE_IXUNLINK (1 << 24)
1745 +#define BTRFS_INODE_BARRIER (1 << 25)
1746 +#define BTRFS_INODE_COW (1 << 26)
1749 BTRFS_SETGET_FUNCS(tree_block_level, struct btrfs_tree_block_info, level, 8);
1751 @@ -2603,6 +2613,7 @@ extern const struct dentry_operations bt
1752 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1753 void btrfs_update_iflags(struct inode *inode);
1754 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
1755 +int btrfs_sync_flags(struct inode *inode, int, int);
1756 int btrfs_defrag_file(struct inode *inode, struct file *file,
1757 struct btrfs_ioctl_defrag_range_args *range,
1758 u64 newer_than, unsigned long max_pages);
1759 diff -NurpP --minimal linux-3.1.6/fs/btrfs/disk-io.c linux-3.1.6-vs2.3.2.5/fs/btrfs/disk-io.c
1760 --- linux-3.1.6/fs/btrfs/disk-io.c 2011-10-24 18:45:26.000000000 +0200
1761 +++ linux-3.1.6-vs2.3.2.5/fs/btrfs/disk-io.c 2011-10-24 18:53:33.000000000 +0200
1762 @@ -1794,6 +1794,9 @@ struct btrfs_root *open_ctree(struct sup
1766 + if (btrfs_test_opt(tree_root, TAGGED))
1767 + sb->s_flags |= MS_TAGGED;
1769 features = btrfs_super_incompat_flags(disk_super) &
1770 ~BTRFS_FEATURE_INCOMPAT_SUPP;
1772 diff -NurpP --minimal linux-3.1.6/fs/btrfs/inode.c linux-3.1.6-vs2.3.2.5/fs/btrfs/inode.c
1773 --- linux-3.1.6/fs/btrfs/inode.c 2011-10-24 18:45:26.000000000 +0200
1774 +++ linux-3.1.6-vs2.3.2.5/fs/btrfs/inode.c 2011-10-24 18:53:33.000000000 +0200
1776 #include <linux/falloc.h>
1777 #include <linux/slab.h>
1778 #include <linux/ratelimit.h>
1779 +#include <linux/vs_tag.h>
1782 #include "disk-io.h"
1783 @@ -2508,6 +2509,8 @@ static void btrfs_read_locked_inode(stru
1784 struct btrfs_key location;
1790 bool filled = false;
1792 @@ -2535,8 +2538,13 @@ static void btrfs_read_locked_inode(stru
1793 struct btrfs_inode_item);
1794 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
1795 inode->i_nlink = btrfs_inode_nlink(leaf, inode_item);
1796 - inode->i_uid = btrfs_inode_uid(leaf, inode_item);
1797 - inode->i_gid = btrfs_inode_gid(leaf, inode_item);
1799 + uid = btrfs_inode_uid(leaf, inode_item);
1800 + gid = btrfs_inode_gid(leaf, inode_item);
1801 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
1802 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
1803 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
1804 + btrfs_inode_tag(leaf, inode_item));
1805 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
1807 tspec = btrfs_inode_atime(inode_item);
1808 @@ -2614,8 +2622,14 @@ static void fill_inode_item(struct btrfs
1809 struct btrfs_inode_item *item,
1810 struct inode *inode)
1812 - btrfs_set_inode_uid(leaf, item, inode->i_uid);
1813 - btrfs_set_inode_gid(leaf, item, inode->i_gid);
1814 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
1815 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
1817 + btrfs_set_inode_uid(leaf, item, uid);
1818 + btrfs_set_inode_gid(leaf, item, gid);
1819 +#ifdef CONFIG_TAGGING_INTERN
1820 + btrfs_set_inode_tag(leaf, item, inode->i_tag);
1822 btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
1823 btrfs_set_inode_mode(leaf, item, inode->i_mode);
1824 btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
1825 @@ -7393,11 +7407,13 @@ static const struct inode_operations btr
1826 .listxattr = btrfs_listxattr,
1827 .removexattr = btrfs_removexattr,
1828 .permission = btrfs_permission,
1829 + .sync_flags = btrfs_sync_flags,
1830 .get_acl = btrfs_get_acl,
1832 static const struct inode_operations btrfs_dir_ro_inode_operations = {
1833 .lookup = btrfs_lookup,
1834 .permission = btrfs_permission,
1835 + .sync_flags = btrfs_sync_flags,
1836 .get_acl = btrfs_get_acl,
1839 diff -NurpP --minimal linux-3.1.6/fs/btrfs/ioctl.c linux-3.1.6-vs2.3.2.5/fs/btrfs/ioctl.c
1840 --- linux-3.1.6/fs/btrfs/ioctl.c 2011-10-24 18:45:26.000000000 +0200
1841 +++ linux-3.1.6-vs2.3.2.5/fs/btrfs/ioctl.c 2011-10-24 18:53:33.000000000 +0200
1842 @@ -70,10 +70,13 @@ static unsigned int btrfs_flags_to_ioctl
1844 unsigned int iflags = 0;
1846 - if (flags & BTRFS_INODE_SYNC)
1847 - iflags |= FS_SYNC_FL;
1848 if (flags & BTRFS_INODE_IMMUTABLE)
1849 iflags |= FS_IMMUTABLE_FL;
1850 + if (flags & BTRFS_INODE_IXUNLINK)
1851 + iflags |= FS_IXUNLINK_FL;
1853 + if (flags & BTRFS_INODE_SYNC)
1854 + iflags |= FS_SYNC_FL;
1855 if (flags & BTRFS_INODE_APPEND)
1856 iflags |= FS_APPEND_FL;
1857 if (flags & BTRFS_INODE_NODUMP)
1858 @@ -90,28 +93,78 @@ static unsigned int btrfs_flags_to_ioctl
1859 else if (flags & BTRFS_INODE_NOCOMPRESS)
1860 iflags |= FS_NOCOMP_FL;
1862 + if (flags & BTRFS_INODE_BARRIER)
1863 + iflags |= FS_BARRIER_FL;
1864 + if (flags & BTRFS_INODE_COW)
1865 + iflags |= FS_COW_FL;
1870 - * Update inode->i_flags based on the btrfs internal flags.
1871 + * Update inode->i_(v)flags based on the btrfs internal flags.
1873 void btrfs_update_iflags(struct inode *inode)
1875 struct btrfs_inode *ip = BTRFS_I(inode);
1877 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
1878 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
1879 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
1881 - if (ip->flags & BTRFS_INODE_SYNC)
1882 - inode->i_flags |= S_SYNC;
1883 if (ip->flags & BTRFS_INODE_IMMUTABLE)
1884 inode->i_flags |= S_IMMUTABLE;
1885 + if (ip->flags & BTRFS_INODE_IXUNLINK)
1886 + inode->i_flags |= S_IXUNLINK;
1888 + if (ip->flags & BTRFS_INODE_SYNC)
1889 + inode->i_flags |= S_SYNC;
1890 if (ip->flags & BTRFS_INODE_APPEND)
1891 inode->i_flags |= S_APPEND;
1892 if (ip->flags & BTRFS_INODE_NOATIME)
1893 inode->i_flags |= S_NOATIME;
1894 if (ip->flags & BTRFS_INODE_DIRSYNC)
1895 inode->i_flags |= S_DIRSYNC;
1897 + inode->i_vflags &= ~(V_BARRIER | V_COW);
1899 + if (ip->flags & BTRFS_INODE_BARRIER)
1900 + inode->i_vflags |= V_BARRIER;
1901 + if (ip->flags & BTRFS_INODE_COW)
1902 + inode->i_vflags |= V_COW;
1906 + * Update btrfs internal flags from inode->i_(v)flags.
1908 +void btrfs_update_flags(struct inode *inode)
1910 + struct btrfs_inode *ip = BTRFS_I(inode);
1912 + unsigned int flags = inode->i_flags;
1913 + unsigned int vflags = inode->i_vflags;
1915 + ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
1916 + BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
1917 + BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
1918 + BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
1920 + if (flags & S_IMMUTABLE)
1921 + ip->flags |= BTRFS_INODE_IMMUTABLE;
1922 + if (flags & S_IXUNLINK)
1923 + ip->flags |= BTRFS_INODE_IXUNLINK;
1925 + if (flags & S_SYNC)
1926 + ip->flags |= BTRFS_INODE_SYNC;
1927 + if (flags & S_APPEND)
1928 + ip->flags |= BTRFS_INODE_APPEND;
1929 + if (flags & S_NOATIME)
1930 + ip->flags |= BTRFS_INODE_NOATIME;
1931 + if (flags & S_DIRSYNC)
1932 + ip->flags |= BTRFS_INODE_DIRSYNC;
1934 + if (vflags & V_BARRIER)
1935 + ip->flags |= BTRFS_INODE_BARRIER;
1936 + if (vflags & V_COW)
1937 + ip->flags |= BTRFS_INODE_COW;
1941 @@ -129,7 +182,7 @@ void btrfs_inherit_iflags(struct inode *
1942 flags = BTRFS_I(dir)->flags;
1944 if (S_ISREG(inode->i_mode))
1945 - flags &= ~BTRFS_INODE_DIRSYNC;
1946 + flags &= ~(BTRFS_INODE_DIRSYNC | BTRFS_INODE_BARRIER);
1947 else if (!S_ISDIR(inode->i_mode))
1948 flags &= (BTRFS_INODE_NODUMP | BTRFS_INODE_NOATIME);
1950 @@ -137,6 +190,30 @@ void btrfs_inherit_iflags(struct inode *
1951 btrfs_update_iflags(inode);
1954 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
1956 + struct btrfs_inode *ip = BTRFS_I(inode);
1957 + struct btrfs_root *root = ip->root;
1958 + struct btrfs_trans_handle *trans;
1961 + trans = btrfs_join_transaction(root);
1964 + inode->i_flags = flags;
1965 + inode->i_vflags = vflags;
1966 + btrfs_update_flags(inode);
1968 + ret = btrfs_update_inode(trans, root, inode);
1971 + btrfs_update_iflags(inode);
1972 + inode->i_ctime = CURRENT_TIME;
1973 + btrfs_end_transaction(trans, root);
1978 static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
1980 struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
1981 @@ -188,7 +265,8 @@ static int btrfs_ioctl_setflags(struct f
1983 flags = btrfs_mask_flags(inode->i_mode, flags);
1984 oldflags = btrfs_flags_to_ioctl(ip->flags);
1985 - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
1986 + if ((flags ^ oldflags) & (FS_APPEND_FL |
1987 + FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
1988 if (!capable(CAP_LINUX_IMMUTABLE)) {
1991 @@ -199,14 +277,19 @@ static int btrfs_ioctl_setflags(struct f
1995 - if (flags & FS_SYNC_FL)
1996 - ip->flags |= BTRFS_INODE_SYNC;
1998 - ip->flags &= ~BTRFS_INODE_SYNC;
1999 if (flags & FS_IMMUTABLE_FL)
2000 ip->flags |= BTRFS_INODE_IMMUTABLE;
2002 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
2003 + if (flags & FS_IXUNLINK_FL)
2004 + ip->flags |= BTRFS_INODE_IXUNLINK;
2006 + ip->flags &= ~BTRFS_INODE_IXUNLINK;
2008 + if (flags & FS_SYNC_FL)
2009 + ip->flags |= BTRFS_INODE_SYNC;
2011 + ip->flags &= ~BTRFS_INODE_SYNC;
2012 if (flags & FS_APPEND_FL)
2013 ip->flags |= BTRFS_INODE_APPEND;
2015 diff -NurpP --minimal linux-3.1.6/fs/btrfs/super.c linux-3.1.6-vs2.3.2.5/fs/btrfs/super.c
2016 --- linux-3.1.6/fs/btrfs/super.c 2011-07-22 11:18:05.000000000 +0200
2017 +++ linux-3.1.6-vs2.3.2.5/fs/btrfs/super.c 2011-10-24 18:53:33.000000000 +0200
2018 @@ -162,7 +162,7 @@ enum {
2019 Opt_notreelog, Opt_ratio, Opt_flushoncommit, Opt_discard,
2020 Opt_space_cache, Opt_clear_cache, Opt_user_subvol_rm_allowed,
2021 Opt_enospc_debug, Opt_subvolrootid, Opt_defrag,
2022 - Opt_inode_cache, Opt_err,
2023 + Opt_inode_cache, Opt_tag, Opt_notag, Opt_tagid, Opt_err,
2026 static match_table_t tokens = {
2027 @@ -195,6 +195,9 @@ static match_table_t tokens = {
2028 {Opt_subvolrootid, "subvolrootid=%d"},
2029 {Opt_defrag, "autodefrag"},
2030 {Opt_inode_cache, "inode_cache"},
2032 + {Opt_notag, "notag"},
2033 + {Opt_tagid, "tagid=%u"},
2037 @@ -381,6 +384,22 @@ int btrfs_parse_options(struct btrfs_roo
2038 printk(KERN_INFO "btrfs: enabling auto defrag");
2039 btrfs_set_opt(info->mount_opt, AUTO_DEFRAG);
2041 +#ifndef CONFIG_TAGGING_NONE
2043 + printk(KERN_INFO "btrfs: use tagging\n");
2044 + btrfs_set_opt(info->mount_opt, TAGGED);
2047 + printk(KERN_INFO "btrfs: disabled tagging\n");
2048 + btrfs_clear_opt(info->mount_opt, TAGGED);
2051 +#ifdef CONFIG_PROPAGATE
2054 + btrfs_set_opt(info->mount_opt, TAGGED);
2058 printk(KERN_INFO "btrfs: unrecognized mount option "
2060 @@ -907,6 +926,12 @@ static int btrfs_remount(struct super_bl
2064 + if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
2065 + printk("btrfs: %s: tagging not permitted on remount.\n",
2070 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
2073 diff -NurpP --minimal linux-3.1.6/fs/char_dev.c linux-3.1.6-vs2.3.2.5/fs/char_dev.c
2074 --- linux-3.1.6/fs/char_dev.c 2011-03-15 18:07:31.000000000 +0100
2075 +++ linux-3.1.6-vs2.3.2.5/fs/char_dev.c 2011-10-24 18:53:33.000000000 +0200
2077 #include <linux/mutex.h>
2078 #include <linux/backing-dev.h>
2079 #include <linux/tty.h>
2080 +#include <linux/vs_context.h>
2081 +#include <linux/vs_device.h>
2083 #include "internal.h"
2085 @@ -371,14 +373,21 @@ static int chrdev_open(struct inode *ino
2087 struct cdev *new = NULL;
2091 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2093 + inode->i_mdev = mdev;
2095 spin_lock(&cdev_lock);
2098 struct kobject *kobj;
2101 spin_unlock(&cdev_lock);
2102 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2104 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2107 new = container_of(kobj, struct cdev, kobj);
2108 diff -NurpP --minimal linux-3.1.6/fs/dcache.c linux-3.1.6-vs2.3.2.5/fs/dcache.c
2109 --- linux-3.1.6/fs/dcache.c 2011-12-23 16:04:06.000000000 +0100
2110 +++ linux-3.1.6-vs2.3.2.5/fs/dcache.c 2011-12-23 16:11:57.000000000 +0100
2112 #include <linux/bit_spinlock.h>
2113 #include <linux/rculist_bl.h>
2114 #include <linux/prefetch.h>
2115 +#include <linux/vs_limit.h>
2116 #include "internal.h"
2119 @@ -513,6 +514,8 @@ int d_invalidate(struct dentry * dentry)
2120 spin_lock(&dentry->d_lock);
2123 + vx_dentry_dec(dentry);
2126 * Somebody else still using it?
2128 @@ -540,6 +543,7 @@ EXPORT_SYMBOL(d_invalidate);
2129 static inline void __dget_dlock(struct dentry *dentry)
2132 + vx_dentry_inc(dentry);
2135 static inline void __dget(struct dentry *dentry)
2136 @@ -1175,6 +1179,9 @@ struct dentry *__d_alloc(struct super_bl
2137 struct dentry *dentry;
2140 + if (!vx_dentry_avail(1))
2143 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
2146 @@ -1197,6 +1204,7 @@ struct dentry *__d_alloc(struct super_bl
2148 dentry->d_count = 1;
2149 dentry->d_flags = 0;
2150 + vx_dentry_inc(dentry);
2151 spin_lock_init(&dentry->d_lock);
2152 seqcount_init(&dentry->d_seq);
2153 dentry->d_inode = NULL;
2154 @@ -1853,6 +1861,7 @@ struct dentry *__d_lookup(struct dentry
2158 + vx_dentry_inc(dentry);
2160 spin_unlock(&dentry->d_lock);
2162 diff -NurpP --minimal linux-3.1.6/fs/devpts/inode.c linux-3.1.6-vs2.3.2.5/fs/devpts/inode.c
2163 --- linux-3.1.6/fs/devpts/inode.c 2011-05-22 16:17:50.000000000 +0200
2164 +++ linux-3.1.6-vs2.3.2.5/fs/devpts/inode.c 2011-10-24 18:53:33.000000000 +0200
2166 #include <linux/parser.h>
2167 #include <linux/fsnotify.h>
2168 #include <linux/seq_file.h>
2169 +#include <linux/vs_base.h>
2171 #define DEVPTS_DEFAULT_MODE 0600
2174 #define DEVPTS_DEFAULT_PTMX_MODE 0000
2175 #define PTMX_MINOR 2
2177 +static int devpts_permission(struct inode *inode, int mask)
2179 + int ret = -EACCES;
2181 + /* devpts is xid tagged */
2182 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
2183 + ret = generic_permission(inode, mask);
2187 +static struct inode_operations devpts_file_inode_operations = {
2188 + .permission = devpts_permission,
2191 extern int pty_limit; /* Config limit on Unix98 ptys */
2192 static DEFINE_MUTEX(allocated_ptys_lock);
2194 @@ -263,6 +278,34 @@ static int devpts_show_options(struct se
2198 +static int devpts_filter(struct dentry *de)
2202 + /* devpts is xid tagged */
2203 + if (de && de->d_inode)
2204 + xid = (xid_t)de->d_inode->i_tag;
2205 +#ifdef CONFIG_VSERVER_WARN_DEVPTS
2207 + vxwprintk_task(1, "devpts " VS_Q("%.*s") " without inode.",
2208 + de->d_name.len, de->d_name.name);
2210 + return vx_check(xid, VS_WATCH_P | VS_IDENT);
2213 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2215 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2218 +static struct file_operations devpts_dir_operations = {
2219 + .open = dcache_dir_open,
2220 + .release = dcache_dir_close,
2221 + .llseek = dcache_dir_lseek,
2222 + .read = generic_read_dir,
2223 + .readdir = devpts_readdir,
2226 static const struct super_operations devpts_sops = {
2227 .statfs = simple_statfs,
2228 .remount_fs = devpts_remount,
2229 @@ -302,12 +345,15 @@ devpts_fill_super(struct super_block *s,
2230 inode = new_inode(s);
2235 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2236 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2237 inode->i_op = &simple_dir_inode_operations;
2238 - inode->i_fop = &simple_dir_operations;
2239 + inode->i_fop = &devpts_dir_operations;
2241 + /* devpts is xid tagged */
2242 + inode->i_tag = (tag_t)vx_current_xid();
2244 s->s_root = d_alloc_root(inode);
2246 @@ -494,6 +540,9 @@ int devpts_pty_new(struct inode *ptmx_in
2247 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
2248 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2249 init_special_inode(inode, S_IFCHR|opts->mode, device);
2250 + /* devpts is xid tagged */
2251 + inode->i_tag = (tag_t)vx_current_xid();
2252 + inode->i_op = &devpts_file_inode_operations;
2253 inode->i_private = tty;
2254 tty->driver_data = inode;
2256 diff -NurpP --minimal linux-3.1.6/fs/ext2/balloc.c linux-3.1.6-vs2.3.2.5/fs/ext2/balloc.c
2257 --- linux-3.1.6/fs/ext2/balloc.c 2011-05-22 16:17:51.000000000 +0200
2258 +++ linux-3.1.6-vs2.3.2.5/fs/ext2/balloc.c 2011-10-24 18:53:33.000000000 +0200
2259 @@ -701,7 +701,6 @@ ext2_try_to_allocate(struct super_block
2261 end = EXT2_BLOCKS_PER_GROUP(sb);
2264 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2267 diff -NurpP --minimal linux-3.1.6/fs/ext2/ext2.h linux-3.1.6-vs2.3.2.5/fs/ext2/ext2.h
2268 --- linux-3.1.6/fs/ext2/ext2.h 2011-10-24 18:45:27.000000000 +0200
2269 +++ linux-3.1.6-vs2.3.2.5/fs/ext2/ext2.h 2011-10-24 18:53:33.000000000 +0200
2270 @@ -126,6 +126,7 @@ extern void ext2_set_inode_flags(struct
2271 extern void ext2_get_inode_flags(struct ext2_inode_info *);
2272 extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2273 u64 start, u64 len);
2274 +extern int ext2_sync_flags(struct inode *, int, int);
2277 extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
2278 diff -NurpP --minimal linux-3.1.6/fs/ext2/file.c linux-3.1.6-vs2.3.2.5/fs/ext2/file.c
2279 --- linux-3.1.6/fs/ext2/file.c 2011-10-24 18:45:27.000000000 +0200
2280 +++ linux-3.1.6-vs2.3.2.5/fs/ext2/file.c 2011-10-24 18:53:33.000000000 +0200
2281 @@ -104,4 +104,5 @@ const struct inode_operations ext2_file_
2282 .setattr = ext2_setattr,
2283 .get_acl = ext2_get_acl,
2284 .fiemap = ext2_fiemap,
2285 + .sync_flags = ext2_sync_flags,
2287 diff -NurpP --minimal linux-3.1.6/fs/ext2/ialloc.c linux-3.1.6-vs2.3.2.5/fs/ext2/ialloc.c
2288 --- linux-3.1.6/fs/ext2/ialloc.c 2011-05-22 16:17:51.000000000 +0200
2289 +++ linux-3.1.6-vs2.3.2.5/fs/ext2/ialloc.c 2011-10-24 18:53:33.000000000 +0200
2291 #include <linux/backing-dev.h>
2292 #include <linux/buffer_head.h>
2293 #include <linux/random.h>
2294 +#include <linux/vs_tag.h>
2298 @@ -549,6 +550,7 @@ got:
2299 inode->i_mode = mode;
2300 inode->i_uid = current_fsuid();
2301 inode->i_gid = dir->i_gid;
2302 + inode->i_tag = dx_current_fstag(sb);
2304 inode_init_owner(inode, dir, mode);
2306 diff -NurpP --minimal linux-3.1.6/fs/ext2/inode.c linux-3.1.6-vs2.3.2.5/fs/ext2/inode.c
2307 --- linux-3.1.6/fs/ext2/inode.c 2011-10-24 18:45:27.000000000 +0200
2308 +++ linux-3.1.6-vs2.3.2.5/fs/ext2/inode.c 2011-10-24 18:53:33.000000000 +0200
2310 #include <linux/mpage.h>
2311 #include <linux/fiemap.h>
2312 #include <linux/namei.h>
2313 +#include <linux/vs_tag.h>
2317 @@ -1167,7 +1168,7 @@ static void ext2_truncate_blocks(struct
2319 if (ext2_inode_is_fast_symlink(inode))
2321 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2322 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2324 __ext2_truncate_blocks(inode, offset);
2326 @@ -1258,36 +1259,61 @@ void ext2_set_inode_flags(struct inode *
2328 unsigned int flags = EXT2_I(inode)->i_flags;
2330 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2331 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2332 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2335 + if (flags & EXT2_IMMUTABLE_FL)
2336 + inode->i_flags |= S_IMMUTABLE;
2337 + if (flags & EXT2_IXUNLINK_FL)
2338 + inode->i_flags |= S_IXUNLINK;
2340 if (flags & EXT2_SYNC_FL)
2341 inode->i_flags |= S_SYNC;
2342 if (flags & EXT2_APPEND_FL)
2343 inode->i_flags |= S_APPEND;
2344 - if (flags & EXT2_IMMUTABLE_FL)
2345 - inode->i_flags |= S_IMMUTABLE;
2346 if (flags & EXT2_NOATIME_FL)
2347 inode->i_flags |= S_NOATIME;
2348 if (flags & EXT2_DIRSYNC_FL)
2349 inode->i_flags |= S_DIRSYNC;
2351 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2353 + if (flags & EXT2_BARRIER_FL)
2354 + inode->i_vflags |= V_BARRIER;
2355 + if (flags & EXT2_COW_FL)
2356 + inode->i_vflags |= V_COW;
2359 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
2360 void ext2_get_inode_flags(struct ext2_inode_info *ei)
2362 unsigned int flags = ei->vfs_inode.i_flags;
2363 + unsigned int vflags = ei->vfs_inode.i_vflags;
2365 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
2366 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
2367 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
2368 + EXT2_BARRIER_FL | EXT2_COW_FL);
2370 + if (flags & S_IMMUTABLE)
2371 + ei->i_flags |= EXT2_IMMUTABLE_FL;
2372 + if (flags & S_IXUNLINK)
2373 + ei->i_flags |= EXT2_IXUNLINK_FL;
2375 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
2376 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
2378 ei->i_flags |= EXT2_SYNC_FL;
2379 if (flags & S_APPEND)
2380 ei->i_flags |= EXT2_APPEND_FL;
2381 - if (flags & S_IMMUTABLE)
2382 - ei->i_flags |= EXT2_IMMUTABLE_FL;
2383 if (flags & S_NOATIME)
2384 ei->i_flags |= EXT2_NOATIME_FL;
2385 if (flags & S_DIRSYNC)
2386 ei->i_flags |= EXT2_DIRSYNC_FL;
2388 + if (vflags & V_BARRIER)
2389 + ei->i_flags |= EXT2_BARRIER_FL;
2390 + if (vflags & V_COW)
2391 + ei->i_flags |= EXT2_COW_FL;
2394 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
2395 @@ -1297,6 +1323,8 @@ struct inode *ext2_iget (struct super_bl
2396 struct ext2_inode *raw_inode;
2397 struct inode *inode;
2403 inode = iget_locked(sb, ino);
2404 @@ -1315,12 +1343,17 @@ struct inode *ext2_iget (struct super_bl
2407 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2408 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2409 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2410 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2411 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2412 if (!(test_opt (inode->i_sb, NO_UID32))) {
2413 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2414 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2415 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2416 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2418 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2419 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2420 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2421 + le16_to_cpu(raw_inode->i_raw_tag));
2423 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
2424 inode->i_size = le32_to_cpu(raw_inode->i_size);
2425 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2426 @@ -1418,8 +1451,8 @@ static int __ext2_write_inode(struct ino
2427 struct ext2_inode_info *ei = EXT2_I(inode);
2428 struct super_block *sb = inode->i_sb;
2429 ino_t ino = inode->i_ino;
2430 - uid_t uid = inode->i_uid;
2431 - gid_t gid = inode->i_gid;
2432 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2433 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2434 struct buffer_head * bh;
2435 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2437 @@ -1455,6 +1488,9 @@ static int __ext2_write_inode(struct ino
2438 raw_inode->i_uid_high = 0;
2439 raw_inode->i_gid_high = 0;
2441 +#ifdef CONFIG_TAGGING_INTERN
2442 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2444 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2445 raw_inode->i_size = cpu_to_le32(inode->i_size);
2446 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2447 @@ -1535,7 +1571,8 @@ int ext2_setattr(struct dentry *dentry,
2448 if (is_quota_modification(inode, iattr))
2449 dquot_initialize(inode);
2450 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
2451 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
2452 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
2453 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
2454 error = dquot_transfer(inode, iattr);
2457 diff -NurpP --minimal linux-3.1.6/fs/ext2/ioctl.c linux-3.1.6-vs2.3.2.5/fs/ext2/ioctl.c
2458 --- linux-3.1.6/fs/ext2/ioctl.c 2011-05-22 16:17:51.000000000 +0200
2459 +++ linux-3.1.6-vs2.3.2.5/fs/ext2/ioctl.c 2011-10-24 18:53:33.000000000 +0200
2461 #include <asm/uaccess.h>
2464 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
2466 + inode->i_flags = flags;
2467 + inode->i_vflags = vflags;
2468 + ext2_get_inode_flags(EXT2_I(inode));
2469 + inode->i_ctime = CURRENT_TIME_SEC;
2470 + mark_inode_dirty(inode);
2474 long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2476 struct inode *inode = filp->f_dentry->d_inode;
2477 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
2479 flags = ext2_mask_flags(inode->i_mode, flags);
2481 + if (IS_BARRIER(inode)) {
2482 + vxwprintk_task(1, "messing with the barrier.");
2486 mutex_lock(&inode->i_mutex);
2487 /* Is it quota file? Do not allow user to mess with it */
2488 if (IS_NOQUOTA(inode)) {
2489 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
2491 * This test looks nicer. Thanks to Pauline Middelink
2493 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
2494 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
2495 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
2496 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
2497 if (!capable(CAP_LINUX_IMMUTABLE)) {
2498 mutex_unlock(&inode->i_mutex);
2500 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
2504 - flags = flags & EXT2_FL_USER_MODIFIABLE;
2505 + flags &= EXT2_FL_USER_MODIFIABLE;
2506 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
2507 ei->i_flags = flags;
2508 mutex_unlock(&inode->i_mutex);
2509 diff -NurpP --minimal linux-3.1.6/fs/ext2/namei.c linux-3.1.6-vs2.3.2.5/fs/ext2/namei.c
2510 --- linux-3.1.6/fs/ext2/namei.c 2011-10-24 18:45:27.000000000 +0200
2511 +++ linux-3.1.6-vs2.3.2.5/fs/ext2/namei.c 2011-10-24 18:53:33.000000000 +0200
2514 #include <linux/pagemap.h>
2515 #include <linux/quotaops.h>
2516 +#include <linux/vs_tag.h>
2520 @@ -73,6 +74,7 @@ static struct dentry *ext2_lookup(struct
2521 (unsigned long) ino);
2522 return ERR_PTR(-EIO);
2524 + dx_propagate_tag(nd, inode);
2526 return d_splice_alias(inode, dentry);
2528 @@ -408,6 +410,7 @@ const struct inode_operations ext2_dir_i
2529 .removexattr = generic_removexattr,
2531 .setattr = ext2_setattr,
2532 + .sync_flags = ext2_sync_flags,
2533 .get_acl = ext2_get_acl,
2536 diff -NurpP --minimal linux-3.1.6/fs/ext2/super.c linux-3.1.6-vs2.3.2.5/fs/ext2/super.c
2537 --- linux-3.1.6/fs/ext2/super.c 2011-07-22 11:18:05.000000000 +0200
2538 +++ linux-3.1.6-vs2.3.2.5/fs/ext2/super.c 2011-10-24 18:53:33.000000000 +0200
2539 @@ -394,7 +394,8 @@ enum {
2540 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
2541 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
2542 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
2543 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
2544 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
2545 + Opt_tag, Opt_notag, Opt_tagid
2548 static const match_table_t tokens = {
2549 @@ -422,6 +423,9 @@ static const match_table_t tokens = {
2551 {Opt_noacl, "noacl"},
2554 + {Opt_notag, "notag"},
2555 + {Opt_tagid, "tagid=%u"},
2556 {Opt_grpquota, "grpquota"},
2557 {Opt_ignore, "noquota"},
2558 {Opt_quota, "quota"},
2559 @@ -492,6 +496,20 @@ static int parse_options(char *options,
2561 set_opt (sbi->s_mount_opt, NO_UID32);
2563 +#ifndef CONFIG_TAGGING_NONE
2565 + set_opt (sbi->s_mount_opt, TAGGED);
2568 + clear_opt (sbi->s_mount_opt, TAGGED);
2571 +#ifdef CONFIG_PROPAGATE
2574 + set_opt (sbi->s_mount_opt, TAGGED);
2578 clear_opt (sbi->s_mount_opt, CHECK);
2580 @@ -850,6 +868,8 @@ static int ext2_fill_super(struct super_
2581 if (!parse_options((char *) data, sb))
2584 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
2585 + sb->s_flags |= MS_TAGGED;
2586 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2587 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
2589 @@ -1224,6 +1244,14 @@ static int ext2_remount (struct super_bl
2593 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
2594 + !(sb->s_flags & MS_TAGGED)) {
2595 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
2598 + goto restore_opts;
2601 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2602 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
2604 diff -NurpP --minimal linux-3.1.6/fs/ext3/file.c linux-3.1.6-vs2.3.2.5/fs/ext3/file.c
2605 --- linux-3.1.6/fs/ext3/file.c 2011-10-24 18:45:27.000000000 +0200
2606 +++ linux-3.1.6-vs2.3.2.5/fs/ext3/file.c 2011-10-24 18:53:33.000000000 +0200
2607 @@ -80,5 +80,6 @@ const struct inode_operations ext3_file_
2609 .get_acl = ext3_get_acl,
2610 .fiemap = ext3_fiemap,
2611 + .sync_flags = ext3_sync_flags,
2614 diff -NurpP --minimal linux-3.1.6/fs/ext3/ialloc.c linux-3.1.6-vs2.3.2.5/fs/ext3/ialloc.c
2615 --- linux-3.1.6/fs/ext3/ialloc.c 2011-10-24 18:45:27.000000000 +0200
2616 +++ linux-3.1.6-vs2.3.2.5/fs/ext3/ialloc.c 2011-10-24 18:53:33.000000000 +0200
2618 #include <linux/buffer_head.h>
2619 #include <linux/random.h>
2620 #include <linux/bitops.h>
2621 +#include <linux/vs_tag.h>
2622 #include <trace/events/ext3.h>
2624 #include <asm/byteorder.h>
2625 @@ -535,6 +536,7 @@ got:
2626 inode->i_mode = mode;
2627 inode->i_uid = current_fsuid();
2628 inode->i_gid = dir->i_gid;
2629 + inode->i_tag = dx_current_fstag(sb);
2631 inode_init_owner(inode, dir, mode);
2633 diff -NurpP --minimal linux-3.1.6/fs/ext3/inode.c linux-3.1.6-vs2.3.2.5/fs/ext3/inode.c
2634 --- linux-3.1.6/fs/ext3/inode.c 2011-10-24 18:45:27.000000000 +0200
2635 +++ linux-3.1.6-vs2.3.2.5/fs/ext3/inode.c 2011-10-24 18:53:33.000000000 +0200
2637 #include <linux/bio.h>
2638 #include <linux/fiemap.h>
2639 #include <linux/namei.h>
2640 +#include <linux/vs_tag.h>
2641 #include <trace/events/ext3.h>
2644 @@ -2834,36 +2835,60 @@ void ext3_set_inode_flags(struct inode *
2646 unsigned int flags = EXT3_I(inode)->i_flags;
2648 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2649 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2650 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2652 + if (flags & EXT3_IMMUTABLE_FL)
2653 + inode->i_flags |= S_IMMUTABLE;
2654 + if (flags & EXT3_IXUNLINK_FL)
2655 + inode->i_flags |= S_IXUNLINK;
2657 if (flags & EXT3_SYNC_FL)
2658 inode->i_flags |= S_SYNC;
2659 if (flags & EXT3_APPEND_FL)
2660 inode->i_flags |= S_APPEND;
2661 - if (flags & EXT3_IMMUTABLE_FL)
2662 - inode->i_flags |= S_IMMUTABLE;
2663 if (flags & EXT3_NOATIME_FL)
2664 inode->i_flags |= S_NOATIME;
2665 if (flags & EXT3_DIRSYNC_FL)
2666 inode->i_flags |= S_DIRSYNC;
2668 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2670 + if (flags & EXT3_BARRIER_FL)
2671 + inode->i_vflags |= V_BARRIER;
2672 + if (flags & EXT3_COW_FL)
2673 + inode->i_vflags |= V_COW;
2676 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
2677 void ext3_get_inode_flags(struct ext3_inode_info *ei)
2679 unsigned int flags = ei->vfs_inode.i_flags;
2680 + unsigned int vflags = ei->vfs_inode.i_vflags;
2682 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
2683 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
2684 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
2685 + EXT3_BARRIER_FL | EXT3_COW_FL);
2687 + if (flags & S_IMMUTABLE)
2688 + ei->i_flags |= EXT3_IMMUTABLE_FL;
2689 + if (flags & S_IXUNLINK)
2690 + ei->i_flags |= EXT3_IXUNLINK_FL;
2692 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
2693 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
2695 ei->i_flags |= EXT3_SYNC_FL;
2696 if (flags & S_APPEND)
2697 ei->i_flags |= EXT3_APPEND_FL;
2698 - if (flags & S_IMMUTABLE)
2699 - ei->i_flags |= EXT3_IMMUTABLE_FL;
2700 if (flags & S_NOATIME)
2701 ei->i_flags |= EXT3_NOATIME_FL;
2702 if (flags & S_DIRSYNC)
2703 ei->i_flags |= EXT3_DIRSYNC_FL;
2705 + if (vflags & V_BARRIER)
2706 + ei->i_flags |= EXT3_BARRIER_FL;
2707 + if (vflags & V_COW)
2708 + ei->i_flags |= EXT3_COW_FL;
2711 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
2712 @@ -2877,6 +2902,8 @@ struct inode *ext3_iget(struct super_blo
2713 transaction_t *transaction;
2719 inode = iget_locked(sb, ino);
2721 @@ -2893,12 +2920,17 @@ struct inode *ext3_iget(struct super_blo
2723 raw_inode = ext3_raw_inode(&iloc);
2724 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2725 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2726 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2727 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2728 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2729 if(!(test_opt (inode->i_sb, NO_UID32))) {
2730 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2731 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2732 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2733 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2735 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2736 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2737 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2738 + le16_to_cpu(raw_inode->i_raw_tag));
2740 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
2741 inode->i_size = le32_to_cpu(raw_inode->i_size);
2742 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2743 @@ -3053,6 +3085,8 @@ static int ext3_do_update_inode(handle_t
2744 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
2745 struct ext3_inode_info *ei = EXT3_I(inode);
2746 struct buffer_head *bh = iloc->bh;
2747 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2748 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2749 int err = 0, rc, block;
2752 @@ -3067,29 +3101,32 @@ again:
2753 ext3_get_inode_flags(ei);
2754 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
2755 if(!(test_opt(inode->i_sb, NO_UID32))) {
2756 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
2757 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
2758 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
2759 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
2761 * Fix up interoperability with old kernels. Otherwise, old inodes get
2762 * re-used with the upper 16 bits of the uid/gid intact
2765 raw_inode->i_uid_high =
2766 - cpu_to_le16(high_16_bits(inode->i_uid));
2767 + cpu_to_le16(high_16_bits(uid));
2768 raw_inode->i_gid_high =
2769 - cpu_to_le16(high_16_bits(inode->i_gid));
2770 + cpu_to_le16(high_16_bits(gid));
2772 raw_inode->i_uid_high = 0;
2773 raw_inode->i_gid_high = 0;
2776 raw_inode->i_uid_low =
2777 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
2778 + cpu_to_le16(fs_high2lowuid(uid));
2779 raw_inode->i_gid_low =
2780 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
2781 + cpu_to_le16(fs_high2lowgid(gid));
2782 raw_inode->i_uid_high = 0;
2783 raw_inode->i_gid_high = 0;
2785 +#ifdef CONFIG_TAGGING_INTERN
2786 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2788 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2789 raw_inode->i_size = cpu_to_le32(ei->i_disksize);
2790 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2791 @@ -3249,7 +3286,8 @@ int ext3_setattr(struct dentry *dentry,
2792 if (is_quota_modification(inode, attr))
2793 dquot_initialize(inode);
2794 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
2795 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
2796 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
2797 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
2800 /* (user+group)*(old+new) structure, inode write (sb,
2801 @@ -3271,6 +3309,8 @@ int ext3_setattr(struct dentry *dentry,
2802 inode->i_uid = attr->ia_uid;
2803 if (attr->ia_valid & ATTR_GID)
2804 inode->i_gid = attr->ia_gid;
2805 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2806 + inode->i_tag = attr->ia_tag;
2807 error = ext3_mark_inode_dirty(handle, inode);
2808 ext3_journal_stop(handle);
2810 diff -NurpP --minimal linux-3.1.6/fs/ext3/ioctl.c linux-3.1.6-vs2.3.2.5/fs/ext3/ioctl.c
2811 --- linux-3.1.6/fs/ext3/ioctl.c 2011-10-24 18:45:27.000000000 +0200
2812 +++ linux-3.1.6-vs2.3.2.5/fs/ext3/ioctl.c 2011-10-24 18:53:33.000000000 +0200
2816 #include <linux/fs.h>
2817 +#include <linux/mount.h>
2818 #include <linux/jbd.h>
2819 #include <linux/capability.h>
2820 #include <linux/ext3_fs.h>
2822 #include <linux/compat.h>
2823 #include <asm/uaccess.h>
2826 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
2828 + handle_t *handle = NULL;
2829 + struct ext3_iloc iloc;
2832 + handle = ext3_journal_start(inode, 1);
2833 + if (IS_ERR(handle))
2834 + return PTR_ERR(handle);
2836 + if (IS_SYNC(inode))
2837 + handle->h_sync = 1;
2838 + err = ext3_reserve_inode_write(handle, inode, &iloc);
2842 + inode->i_flags = flags;
2843 + inode->i_vflags = vflags;
2844 + ext3_get_inode_flags(EXT3_I(inode));
2845 + inode->i_ctime = CURRENT_TIME_SEC;
2847 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
2849 + ext3_journal_stop(handle);
2853 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2855 struct inode *inode = filp->f_dentry->d_inode;
2856 @@ -50,6 +79,11 @@ long ext3_ioctl(struct file *filp, unsig
2858 flags = ext3_mask_flags(inode->i_mode, flags);
2860 + if (IS_BARRIER(inode)) {
2861 + vxwprintk_task(1, "messing with the barrier.");
2865 mutex_lock(&inode->i_mutex);
2867 /* Is it quota file? Do not allow user to mess with it */
2868 @@ -68,7 +102,9 @@ long ext3_ioctl(struct file *filp, unsig
2870 * This test looks nicer. Thanks to Pauline Middelink
2872 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
2873 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
2874 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
2875 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
2876 if (!capable(CAP_LINUX_IMMUTABLE))
2879 @@ -93,7 +129,7 @@ long ext3_ioctl(struct file *filp, unsig
2883 - flags = flags & EXT3_FL_USER_MODIFIABLE;
2884 + flags &= EXT3_FL_USER_MODIFIABLE;
2885 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
2886 ei->i_flags = flags;
2888 diff -NurpP --minimal linux-3.1.6/fs/ext3/namei.c linux-3.1.6-vs2.3.2.5/fs/ext3/namei.c
2889 --- linux-3.1.6/fs/ext3/namei.c 2011-10-24 18:45:27.000000000 +0200
2890 +++ linux-3.1.6-vs2.3.2.5/fs/ext3/namei.c 2011-10-24 18:53:33.000000000 +0200
2892 #include <linux/quotaops.h>
2893 #include <linux/buffer_head.h>
2894 #include <linux/bio.h>
2895 +#include <linux/vs_tag.h>
2896 #include <trace/events/ext3.h>
2899 @@ -925,6 +926,7 @@ restart:
2900 ll_rw_block(READ | REQ_META | REQ_PRIO,
2903 + dx_propagate_tag(nd, inode);
2905 if ((bh = bh_use[ra_ptr++]) == NULL)
2907 @@ -2535,6 +2537,7 @@ const struct inode_operations ext3_dir_i
2908 .listxattr = ext3_listxattr,
2909 .removexattr = generic_removexattr,
2911 + .sync_flags = ext3_sync_flags,
2912 .get_acl = ext3_get_acl,
2915 diff -NurpP --minimal linux-3.1.6/fs/ext3/super.c linux-3.1.6-vs2.3.2.5/fs/ext3/super.c
2916 --- linux-3.1.6/fs/ext3/super.c 2011-10-24 18:45:27.000000000 +0200
2917 +++ linux-3.1.6-vs2.3.2.5/fs/ext3/super.c 2011-10-24 18:53:33.000000000 +0200
2918 @@ -833,7 +833,8 @@ enum {
2919 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
2920 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
2921 Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
2922 - Opt_resize, Opt_usrquota, Opt_grpquota
2923 + Opt_resize, Opt_usrquota, Opt_grpquota,
2924 + Opt_tag, Opt_notag, Opt_tagid
2927 static const match_table_t tokens = {
2928 @@ -890,6 +891,9 @@ static const match_table_t tokens = {
2929 {Opt_barrier, "barrier"},
2930 {Opt_nobarrier, "nobarrier"},
2931 {Opt_resize, "resize"},
2933 + {Opt_notag, "notag"},
2934 + {Opt_tagid, "tagid=%u"},
2938 @@ -1042,6 +1046,20 @@ static int parse_options (char *options,
2940 set_opt (sbi->s_mount_opt, NO_UID32);
2942 +#ifndef CONFIG_TAGGING_NONE
2944 + set_opt (sbi->s_mount_opt, TAGGED);
2947 + clear_opt (sbi->s_mount_opt, TAGGED);
2950 +#ifdef CONFIG_PROPAGATE
2953 + set_opt (sbi->s_mount_opt, TAGGED);
2957 clear_opt (sbi->s_mount_opt, CHECK);
2959 @@ -1738,6 +1756,9 @@ static int ext3_fill_super (struct super
2963 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
2964 + sb->s_flags |= MS_TAGGED;
2966 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2967 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
2969 @@ -2619,6 +2640,14 @@ static int ext3_remount (struct super_bl
2970 if (test_opt(sb, ABORT))
2971 ext3_abort(sb, __func__, "Abort forced by user");
2973 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
2974 + !(sb->s_flags & MS_TAGGED)) {
2975 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
2978 + goto restore_opts;
2981 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2982 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
2984 diff -NurpP --minimal linux-3.1.6/fs/ext4/ext4.h linux-3.1.6-vs2.3.2.5/fs/ext4/ext4.h
2985 --- linux-3.1.6/fs/ext4/ext4.h 2011-12-23 16:04:07.000000000 +0100
2986 +++ linux-3.1.6-vs2.3.2.5/fs/ext4/ext4.h 2011-11-15 17:08:44.000000000 +0100
2987 @@ -351,8 +351,12 @@ struct flex_groups {
2988 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
2989 #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
2990 #define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
2991 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
2992 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
2994 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
2995 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
2997 #define EXT4_FL_USER_VISIBLE 0x004BDFFF /* User visible flags */
2998 #define EXT4_FL_USER_MODIFIABLE 0x004B80FF /* User modifiable flags */
3000 @@ -609,7 +613,8 @@ struct ext4_inode {
3001 __le16 l_i_file_acl_high;
3002 __le16 l_i_uid_high; /* these 2 fields */
3003 __le16 l_i_gid_high; /* were reserved2[0] */
3004 - __u32 l_i_reserved2;
3005 + __le16 l_i_tag; /* Context Tag */
3006 + __u16 l_i_reserved2;
3009 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
3010 @@ -727,6 +732,7 @@ do { \
3011 #define i_gid_low i_gid
3012 #define i_uid_high osd2.linux2.l_i_uid_high
3013 #define i_gid_high osd2.linux2.l_i_gid_high
3014 +#define i_raw_tag osd2.linux2.l_i_tag
3015 #define i_reserved2 osd2.linux2.l_i_reserved2
3017 #elif defined(__GNU__)
3018 @@ -903,6 +909,7 @@ struct ext4_inode_info {
3019 #define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
3020 #define EXT4_MOUNT_NO_AUTO_DA_ALLOC 0x10000 /* No auto delalloc mapping */
3021 #define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */
3022 +#define EXT4_MOUNT_TAGGED 0x40000 /* Enable Context Tags */
3023 #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
3024 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
3025 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
3026 @@ -2217,6 +2224,7 @@ extern int ext4_map_blocks(handle_t *han
3027 struct ext4_map_blocks *map, int flags);
3028 extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
3029 __u64 start, __u64 len);
3030 +extern int ext4_sync_flags(struct inode *, int, int);
3032 extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
3033 __u64 start_orig, __u64 start_donor,
3034 diff -NurpP --minimal linux-3.1.6/fs/ext4/file.c linux-3.1.6-vs2.3.2.5/fs/ext4/file.c
3035 --- linux-3.1.6/fs/ext4/file.c 2011-10-24 18:45:27.000000000 +0200
3036 +++ linux-3.1.6-vs2.3.2.5/fs/ext4/file.c 2011-10-24 18:53:33.000000000 +0200
3037 @@ -303,5 +303,6 @@ const struct inode_operations ext4_file_
3039 .get_acl = ext4_get_acl,
3040 .fiemap = ext4_fiemap,
3041 + .sync_flags = ext4_sync_flags,
3044 diff -NurpP --minimal linux-3.1.6/fs/ext4/ialloc.c linux-3.1.6-vs2.3.2.5/fs/ext4/ialloc.c
3045 --- linux-3.1.6/fs/ext4/ialloc.c 2011-10-24 18:45:27.000000000 +0200
3046 +++ linux-3.1.6-vs2.3.2.5/fs/ext4/ialloc.c 2011-10-24 18:53:33.000000000 +0200
3048 #include <linux/random.h>
3049 #include <linux/bitops.h>
3050 #include <linux/blkdev.h>
3051 +#include <linux/vs_tag.h>
3052 #include <asm/byteorder.h>
3055 @@ -992,6 +993,7 @@ got:
3056 inode->i_mode = mode;
3057 inode->i_uid = current_fsuid();
3058 inode->i_gid = dir->i_gid;
3059 + inode->i_tag = dx_current_fstag(sb);
3061 inode_init_owner(inode, dir, mode);
3063 diff -NurpP --minimal linux-3.1.6/fs/ext4/inode.c linux-3.1.6-vs2.3.2.5/fs/ext4/inode.c
3064 --- linux-3.1.6/fs/ext4/inode.c 2011-12-23 16:04:07.000000000 +0100
3065 +++ linux-3.1.6-vs2.3.2.5/fs/ext4/inode.c 2011-12-23 16:11:57.000000000 +0100
3067 #include <linux/printk.h>
3068 #include <linux/slab.h>
3069 #include <linux/ratelimit.h>
3070 +#include <linux/vs_tag.h>
3072 #include "ext4_jbd2.h"
3074 @@ -3326,41 +3327,64 @@ void ext4_set_inode_flags(struct inode *
3076 unsigned int flags = EXT4_I(inode)->i_flags;
3078 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3079 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3080 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3082 + if (flags & EXT4_IMMUTABLE_FL)
3083 + inode->i_flags |= S_IMMUTABLE;
3084 + if (flags & EXT4_IXUNLINK_FL)
3085 + inode->i_flags |= S_IXUNLINK;
3087 if (flags & EXT4_SYNC_FL)
3088 inode->i_flags |= S_SYNC;
3089 if (flags & EXT4_APPEND_FL)
3090 inode->i_flags |= S_APPEND;
3091 - if (flags & EXT4_IMMUTABLE_FL)
3092 - inode->i_flags |= S_IMMUTABLE;
3093 if (flags & EXT4_NOATIME_FL)
3094 inode->i_flags |= S_NOATIME;
3095 if (flags & EXT4_DIRSYNC_FL)
3096 inode->i_flags |= S_DIRSYNC;
3098 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3100 + if (flags & EXT4_BARRIER_FL)
3101 + inode->i_vflags |= V_BARRIER;
3102 + if (flags & EXT4_COW_FL)
3103 + inode->i_vflags |= V_COW;
3106 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3107 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3109 - unsigned int vfs_fl;
3110 + unsigned int vfs_fl, vfs_vf;
3111 unsigned long old_fl, new_fl;
3114 vfs_fl = ei->vfs_inode.i_flags;
3115 + vfs_vf = ei->vfs_inode.i_vflags;
3116 old_fl = ei->i_flags;
3117 new_fl = old_fl & ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3118 EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|
3120 + EXT4_DIRSYNC_FL|EXT4_BARRIER_FL|
3123 + if (vfs_fl & S_IMMUTABLE)
3124 + new_fl |= EXT4_IMMUTABLE_FL;
3125 + if (vfs_fl & S_IXUNLINK)
3126 + new_fl |= EXT4_IXUNLINK_FL;
3128 if (vfs_fl & S_SYNC)
3129 new_fl |= EXT4_SYNC_FL;
3130 if (vfs_fl & S_APPEND)
3131 new_fl |= EXT4_APPEND_FL;
3132 - if (vfs_fl & S_IMMUTABLE)
3133 - new_fl |= EXT4_IMMUTABLE_FL;
3134 if (vfs_fl & S_NOATIME)
3135 new_fl |= EXT4_NOATIME_FL;
3136 if (vfs_fl & S_DIRSYNC)
3137 new_fl |= EXT4_DIRSYNC_FL;
3139 + if (vfs_vf & V_BARRIER)
3140 + new_fl |= EXT4_BARRIER_FL;
3141 + if (vfs_vf & V_COW)
3142 + new_fl |= EXT4_COW_FL;
3143 } while (cmpxchg(&ei->i_flags, old_fl, new_fl) != old_fl);
3146 @@ -3396,6 +3420,8 @@ struct inode *ext4_iget(struct super_blo
3147 journal_t *journal = EXT4_SB(sb)->s_journal;
3153 inode = iget_locked(sb, ino);
3155 @@ -3411,12 +3437,16 @@ struct inode *ext4_iget(struct super_blo
3157 raw_inode = ext4_raw_inode(&iloc);
3158 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3159 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3160 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3161 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3162 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3163 if (!(test_opt(inode->i_sb, NO_UID32))) {
3164 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3165 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3166 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3167 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3169 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3170 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3171 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3172 + le16_to_cpu(raw_inode->i_raw_tag));
3173 inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
3175 ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */
3176 @@ -3635,6 +3665,8 @@ static int ext4_do_update_inode(handle_t
3177 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
3178 struct ext4_inode_info *ei = EXT4_I(inode);
3179 struct buffer_head *bh = iloc->bh;
3180 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3181 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3182 int err = 0, rc, block;
3184 /* For fields not not tracking in the in-memory inode,
3185 @@ -3645,29 +3677,32 @@ static int ext4_do_update_inode(handle_t
3186 ext4_get_inode_flags(ei);
3187 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3188 if (!(test_opt(inode->i_sb, NO_UID32))) {
3189 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3190 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3191 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3192 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3194 * Fix up interoperability with old kernels. Otherwise, old inodes get
3195 * re-used with the upper 16 bits of the uid/gid intact
3198 raw_inode->i_uid_high =
3199 - cpu_to_le16(high_16_bits(inode->i_uid));
3200 + cpu_to_le16(high_16_bits(uid));
3201 raw_inode->i_gid_high =
3202 - cpu_to_le16(high_16_bits(inode->i_gid));
3203 + cpu_to_le16(high_16_bits(gid));
3205 raw_inode->i_uid_high = 0;
3206 raw_inode->i_gid_high = 0;
3209 raw_inode->i_uid_low =
3210 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3211 + cpu_to_le16(fs_high2lowuid(uid));
3212 raw_inode->i_gid_low =
3213 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3214 + cpu_to_le16(fs_high2lowgid(gid));
3215 raw_inode->i_uid_high = 0;
3216 raw_inode->i_gid_high = 0;
3218 +#ifdef CONFIG_TAGGING_INTERN
3219 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3221 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3223 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3224 @@ -3853,7 +3888,8 @@ int ext4_setattr(struct dentry *dentry,
3225 if (is_quota_modification(inode, attr))
3226 dquot_initialize(inode);
3227 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3228 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3229 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3230 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3233 /* (user+group)*(old+new) structure, inode write (sb,
3234 @@ -3875,6 +3911,8 @@ int ext4_setattr(struct dentry *dentry,
3235 inode->i_uid = attr->ia_uid;
3236 if (attr->ia_valid & ATTR_GID)
3237 inode->i_gid = attr->ia_gid;
3238 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3239 + inode->i_tag = attr->ia_tag;
3240 error = ext4_mark_inode_dirty(handle, inode);
3241 ext4_journal_stop(handle);
3243 diff -NurpP --minimal linux-3.1.6/fs/ext4/ioctl.c linux-3.1.6-vs2.3.2.5/fs/ext4/ioctl.c
3244 --- linux-3.1.6/fs/ext4/ioctl.c 2011-10-24 18:45:27.000000000 +0200
3245 +++ linux-3.1.6-vs2.3.2.5/fs/ext4/ioctl.c 2011-10-24 18:53:33.000000000 +0200
3247 #include <linux/compat.h>
3248 #include <linux/mount.h>
3249 #include <linux/file.h>
3250 +#include <linux/vs_tag.h>
3251 #include <asm/uaccess.h>
3252 #include "ext4_jbd2.h"
3256 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
3258 + handle_t *handle = NULL;
3259 + struct ext4_iloc iloc;
3262 + handle = ext4_journal_start(inode, 1);
3263 + if (IS_ERR(handle))
3264 + return PTR_ERR(handle);
3266 + if (IS_SYNC(inode))
3267 + ext4_handle_sync(handle);
3268 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3272 + inode->i_flags = flags;
3273 + inode->i_vflags = vflags;
3274 + ext4_get_inode_flags(EXT4_I(inode));
3275 + inode->i_ctime = ext4_current_time(inode);
3277 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3279 + ext4_journal_stop(handle);
3283 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3285 struct inode *inode = filp->f_dentry->d_inode;
3286 @@ -50,6 +79,11 @@ long ext4_ioctl(struct file *filp, unsig
3288 flags = ext4_mask_flags(inode->i_mode, flags);
3290 + if (IS_BARRIER(inode)) {
3291 + vxwprintk_task(1, "messing with the barrier.");
3296 mutex_lock(&inode->i_mutex);
3297 /* Is it quota file? Do not allow user to mess with it */
3298 @@ -67,7 +101,9 @@ long ext4_ioctl(struct file *filp, unsig
3300 * This test looks nicer. Thanks to Pauline Middelink
3302 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3303 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3304 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3305 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3306 if (!capable(CAP_LINUX_IMMUTABLE))
3309 diff -NurpP --minimal linux-3.1.6/fs/ext4/namei.c linux-3.1.6-vs2.3.2.5/fs/ext4/namei.c
3310 --- linux-3.1.6/fs/ext4/namei.c 2011-12-23 16:04:07.000000000 +0100
3311 +++ linux-3.1.6-vs2.3.2.5/fs/ext4/namei.c 2011-11-15 17:08:44.000000000 +0100
3313 #include <linux/quotaops.h>
3314 #include <linux/buffer_head.h>
3315 #include <linux/bio.h>
3316 +#include <linux/vs_tag.h>
3318 #include "ext4_jbd2.h"
3320 @@ -925,6 +926,7 @@ restart:
3321 ll_rw_block(READ | REQ_META | REQ_PRIO,
3324 + dx_propagate_tag(nd, inode);
3326 if ((bh = bh_use[ra_ptr++]) == NULL)
3328 @@ -2588,6 +2590,7 @@ const struct inode_operations ext4_dir_i
3330 .get_acl = ext4_get_acl,
3331 .fiemap = ext4_fiemap,
3332 + .sync_flags = ext4_sync_flags,
3335 const struct inode_operations ext4_special_inode_operations = {
3336 diff -NurpP --minimal linux-3.1.6/fs/ext4/super.c linux-3.1.6-vs2.3.2.5/fs/ext4/super.c
3337 --- linux-3.1.6/fs/ext4/super.c 2011-12-23 16:04:07.000000000 +0100
3338 +++ linux-3.1.6-vs2.3.2.5/fs/ext4/super.c 2011-12-23 16:13:10.000000000 +0100
3339 @@ -1319,6 +1319,7 @@ enum {
3340 Opt_inode_readahead_blks, Opt_journal_ioprio,
3341 Opt_dioread_nolock, Opt_dioread_lock,
3342 Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable,
3343 + Opt_tag, Opt_notag, Opt_tagid
3346 static const match_table_t tokens = {
3347 @@ -1394,6 +1395,9 @@ static const match_table_t tokens = {
3348 {Opt_init_itable, "init_itable=%u"},
3349 {Opt_init_itable, "init_itable"},
3350 {Opt_noinit_itable, "noinit_itable"},
3352 + {Opt_notag, "notag"},
3353 + {Opt_tagid, "tagid=%u"},
3357 @@ -1562,6 +1566,20 @@ static int parse_options(char *options,
3359 set_opt(sb, NO_UID32);
3361 +#ifndef CONFIG_TAGGING_NONE
3363 + set_opt(sb, TAGGED);
3366 + clear_opt(sb, TAGGED);
3369 +#ifdef CONFIG_PROPAGATE
3372 + set_opt(sb, TAGGED);
3378 @@ -3223,6 +3241,9 @@ static int ext4_fill_super(struct super_
3379 &journal_ioprio, NULL, 0))
3382 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3383 + sb->s_flags |= MS_TAGGED;
3385 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3386 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3388 @@ -4350,6 +4371,14 @@ static int ext4_remount(struct super_blo
3389 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
3390 ext4_abort(sb, "Abort forced by user");
3392 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3393 + !(sb->s_flags & MS_TAGGED)) {
3394 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3397 + goto restore_opts;
3400 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3401 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3403 diff -NurpP --minimal linux-3.1.6/fs/fcntl.c linux-3.1.6-vs2.3.2.5/fs/fcntl.c
3404 --- linux-3.1.6/fs/fcntl.c 2011-05-22 16:17:52.000000000 +0200
3405 +++ linux-3.1.6-vs2.3.2.5/fs/fcntl.c 2011-10-24 18:53:33.000000000 +0200
3407 #include <linux/signal.h>
3408 #include <linux/rcupdate.h>
3409 #include <linux/pid_namespace.h>
3410 +#include <linux/vs_limit.h>
3412 #include <asm/poll.h>
3413 #include <asm/siginfo.h>
3414 @@ -103,6 +104,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
3417 filp_close(tofree, files);
3419 + vx_openfd_inc(newfd); /* fd was unused */
3423 @@ -447,6 +450,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
3424 filp = fget_raw(fd);
3427 + if (!vx_files_avail(1))
3430 if (unlikely(filp->f_mode & FMODE_PATH)) {
3431 if (!check_fcntl_cmd(cmd)) {
3432 diff -NurpP --minimal linux-3.1.6/fs/file.c linux-3.1.6-vs2.3.2.5/fs/file.c
3433 --- linux-3.1.6/fs/file.c 2011-05-22 16:17:52.000000000 +0200
3434 +++ linux-3.1.6-vs2.3.2.5/fs/file.c 2011-10-24 18:53:33.000000000 +0200
3436 #include <linux/spinlock.h>
3437 #include <linux/rcupdate.h>
3438 #include <linux/workqueue.h>
3439 +#include <linux/vs_limit.h>
3441 struct fdtable_defer {
3443 @@ -359,6 +360,8 @@ struct files_struct *dup_fd(struct files
3444 struct file *f = *old_fds++;
3447 + /* TODO: sum it first for check and performance */
3448 + vx_openfd_inc(open_files - i);
3451 * The fd may be claimed in the fd bitmap but not yet
3452 @@ -466,6 +469,7 @@ repeat:
3454 FD_CLR(fd, fdt->close_on_exec);
3456 + vx_openfd_inc(fd);
3459 if (rcu_dereference_raw(fdt->fd[fd]) != NULL) {
3460 diff -NurpP --minimal linux-3.1.6/fs/file_table.c linux-3.1.6-vs2.3.2.5/fs/file_table.c
3461 --- linux-3.1.6/fs/file_table.c 2011-10-24 18:45:27.000000000 +0200
3462 +++ linux-3.1.6-vs2.3.2.5/fs/file_table.c 2011-10-24 18:53:33.000000000 +0200
3464 #include <linux/percpu_counter.h>
3465 #include <linux/percpu.h>
3466 #include <linux/ima.h>
3467 +#include <linux/vs_limit.h>
3468 +#include <linux/vs_context.h>
3470 #include <linux/atomic.h>
3472 @@ -135,6 +137,8 @@ struct file *get_empty_filp(void)
3473 spin_lock_init(&f->f_lock);
3474 eventpoll_init_file(f);
3475 /* f->f_version: 0 */
3476 + f->f_xid = vx_current_xid();
3481 @@ -253,6 +257,8 @@ static void __fput(struct file *file)
3483 fops_put(file->f_op);
3484 put_pid(file->f_owner.pid);
3485 + vx_files_dec(file);
3487 file_sb_list_del(file);
3488 if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
3489 i_readcount_dec(inode);
3490 @@ -383,6 +389,8 @@ void put_filp(struct file *file)
3492 if (atomic_long_dec_and_test(&file->f_count)) {
3493 security_file_free(file);
3494 + vx_files_dec(file);
3496 file_sb_list_del(file);
3499 diff -NurpP --minimal linux-3.1.6/fs/fs_struct.c linux-3.1.6-vs2.3.2.5/fs/fs_struct.c
3500 --- linux-3.1.6/fs/fs_struct.c 2011-03-15 18:07:31.000000000 +0100
3501 +++ linux-3.1.6-vs2.3.2.5/fs/fs_struct.c 2011-10-24 18:53:33.000000000 +0200
3503 #include <linux/path.h>
3504 #include <linux/slab.h>
3505 #include <linux/fs_struct.h>
3506 +#include <linux/vserver/global.h>
3507 #include "internal.h"
3509 static inline void path_get_longterm(struct path *path)
3510 @@ -96,6 +97,7 @@ void free_fs_struct(struct fs_struct *fs
3512 path_put_longterm(&fs->root);
3513 path_put_longterm(&fs->pwd);
3514 + atomic_dec(&vs_global_fs);
3515 kmem_cache_free(fs_cachep, fs);
3518 @@ -135,6 +137,7 @@ struct fs_struct *copy_fs_struct(struct
3520 path_get_longterm(&fs->pwd);
3521 spin_unlock(&old->lock);
3522 + atomic_inc(&vs_global_fs);
3526 diff -NurpP --minimal linux-3.1.6/fs/gfs2/file.c linux-3.1.6-vs2.3.2.5/fs/gfs2/file.c
3527 --- linux-3.1.6/fs/gfs2/file.c 2011-10-24 18:45:27.000000000 +0200
3528 +++ linux-3.1.6-vs2.3.2.5/fs/gfs2/file.c 2011-10-24 18:53:33.000000000 +0200
3529 @@ -134,6 +134,9 @@ static const u32 fsflags_to_gfs2[32] = {
3530 [7] = GFS2_DIF_NOATIME,
3531 [12] = GFS2_DIF_EXHASH,
3532 [14] = GFS2_DIF_INHERIT_JDATA,
3533 + [27] = GFS2_DIF_IXUNLINK,
3534 + [26] = GFS2_DIF_BARRIER,
3535 + [29] = GFS2_DIF_COW,
3538 static const u32 gfs2_to_fsflags[32] = {
3539 @@ -143,6 +146,9 @@ static const u32 gfs2_to_fsflags[32] = {
3540 [gfs2fl_NoAtime] = FS_NOATIME_FL,
3541 [gfs2fl_ExHash] = FS_INDEX_FL,
3542 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
3543 + [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
3544 + [gfs2fl_Barrier] = FS_BARRIER_FL,
3545 + [gfs2fl_Cow] = FS_COW_FL,
3548 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
3549 @@ -173,12 +179,18 @@ void gfs2_set_inode_flags(struct inode *
3551 struct gfs2_inode *ip = GFS2_I(inode);
3552 unsigned int flags = inode->i_flags;
3553 + unsigned int vflags = inode->i_vflags;
3555 + flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3556 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC | S_NOSEC);
3558 - flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|S_NOSEC);
3559 if ((ip->i_eattr == 0) && !is_sxid(inode->i_mode))
3560 inode->i_flags |= S_NOSEC;
3561 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
3562 flags |= S_IMMUTABLE;
3563 + if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
3564 + flags |= S_IXUNLINK;
3566 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
3568 if (ip->i_diskflags & GFS2_DIF_NOATIME)
3569 @@ -186,6 +198,43 @@ void gfs2_set_inode_flags(struct inode *
3570 if (ip->i_diskflags & GFS2_DIF_SYNC)
3572 inode->i_flags = flags;
3574 + vflags &= ~(V_BARRIER | V_COW);
3576 + if (ip->i_diskflags & GFS2_DIF_BARRIER)
3577 + vflags |= V_BARRIER;
3578 + if (ip->i_diskflags & GFS2_DIF_COW)
3580 + inode->i_vflags = vflags;
3583 +void gfs2_get_inode_flags(struct inode *inode)
3585 + struct gfs2_inode *ip = GFS2_I(inode);
3586 + unsigned int flags = inode->i_flags;
3587 + unsigned int vflags = inode->i_vflags;
3589 + ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
3590 + GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
3591 + GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
3592 + GFS2_DIF_BARRIER | GFS2_DIF_COW);
3594 + if (flags & S_IMMUTABLE)
3595 + ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
3596 + if (flags & S_IXUNLINK)
3597 + ip->i_diskflags |= GFS2_DIF_IXUNLINK;
3599 + if (flags & S_APPEND)
3600 + ip->i_diskflags |= GFS2_DIF_APPENDONLY;
3601 + if (flags & S_NOATIME)
3602 + ip->i_diskflags |= GFS2_DIF_NOATIME;
3603 + if (flags & S_SYNC)
3604 + ip->i_diskflags |= GFS2_DIF_SYNC;
3606 + if (vflags & V_BARRIER)
3607 + ip->i_diskflags |= GFS2_DIF_BARRIER;
3608 + if (vflags & V_COW)
3609 + ip->i_diskflags |= GFS2_DIF_COW;
3612 /* Flags that can be set by user space */
3613 @@ -297,6 +346,37 @@ static int gfs2_set_flags(struct file *f
3614 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
3617 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
3619 + struct gfs2_inode *ip = GFS2_I(inode);
3620 + struct gfs2_sbd *sdp = GFS2_SB(inode);
3621 + struct buffer_head *bh;
3622 + struct gfs2_holder gh;
3625 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
3628 + error = gfs2_trans_begin(sdp, RES_DINODE, 0);
3631 + error = gfs2_meta_inode_buffer(ip, &bh);
3633 + goto out_trans_end;
3634 + gfs2_trans_add_bh(ip->i_gl, bh, 1);
3635 + inode->i_flags = flags;
3636 + inode->i_vflags = vflags;
3637 + gfs2_get_inode_flags(inode);
3638 + gfs2_dinode_out(ip, bh->b_data);
3640 + gfs2_set_aops(inode);
3642 + gfs2_trans_end(sdp);
3644 + gfs2_glock_dq_uninit(&gh);
3648 static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3651 diff -NurpP --minimal linux-3.1.6/fs/gfs2/inode.h linux-3.1.6-vs2.3.2.5/fs/gfs2/inode.h
3652 --- linux-3.1.6/fs/gfs2/inode.h 2011-10-24 18:45:27.000000000 +0200
3653 +++ linux-3.1.6-vs2.3.2.5/fs/gfs2/inode.h 2011-10-24 18:53:33.000000000 +0200
3654 @@ -120,6 +120,7 @@ extern const struct file_operations gfs2
3655 extern const struct file_operations gfs2_dir_fops_nolock;
3657 extern void gfs2_set_inode_flags(struct inode *inode);
3658 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
3660 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
3661 extern const struct file_operations gfs2_file_fops;
3662 diff -NurpP --minimal linux-3.1.6/fs/inode.c linux-3.1.6-vs2.3.2.5/fs/inode.c
3663 --- linux-3.1.6/fs/inode.c 2011-10-24 18:45:27.000000000 +0200
3664 +++ linux-3.1.6-vs2.3.2.5/fs/inode.c 2011-10-24 18:53:33.000000000 +0200
3666 #include <linux/ima.h>
3667 #include <linux/cred.h>
3668 #include <linux/buffer_head.h> /* for inode_has_buffers */
3669 +#include <linux/vs_tag.h>
3670 #include "internal.h"
3673 @@ -137,6 +138,9 @@ int inode_init_always(struct super_block
3674 struct address_space *const mapping = &inode->i_data;
3678 + /* essential because of inode slab reuse */
3680 inode->i_blkbits = sb->s_blocksize_bits;
3682 atomic_set(&inode->i_count, 1);
3683 @@ -158,6 +162,7 @@ int inode_init_always(struct super_block
3684 inode->i_bdev = NULL;
3685 inode->i_cdev = NULL;
3687 + inode->i_mdev = 0;
3688 inode->dirtied_when = 0;
3690 if (security_inode_alloc(inode))
3691 @@ -399,6 +404,8 @@ void __insert_inode_hash(struct inode *i
3693 EXPORT_SYMBOL(__insert_inode_hash);
3695 +EXPORT_SYMBOL_GPL(__iget);
3698 * __remove_inode_hash - remove an inode from the hash
3699 * @inode: inode to unhash
3700 @@ -1626,9 +1633,11 @@ void init_special_inode(struct inode *in
3701 if (S_ISCHR(mode)) {
3702 inode->i_fop = &def_chr_fops;
3703 inode->i_rdev = rdev;
3704 + inode->i_mdev = rdev;
3705 } else if (S_ISBLK(mode)) {
3706 inode->i_fop = &def_blk_fops;
3707 inode->i_rdev = rdev;
3708 + inode->i_mdev = rdev;
3709 } else if (S_ISFIFO(mode))
3710 inode->i_fop = &def_fifo_fops;
3711 else if (S_ISSOCK(mode))
3712 @@ -1657,6 +1666,7 @@ void inode_init_owner(struct inode *inod
3714 inode->i_gid = current_fsgid();
3715 inode->i_mode = mode;
3716 + inode->i_tag = dx_current_fstag(inode->i_sb);
3718 EXPORT_SYMBOL(inode_init_owner);
3720 diff -NurpP --minimal linux-3.1.6/fs/ioctl.c linux-3.1.6-vs2.3.2.5/fs/ioctl.c
3721 --- linux-3.1.6/fs/ioctl.c 2011-05-22 16:17:52.000000000 +0200
3722 +++ linux-3.1.6-vs2.3.2.5/fs/ioctl.c 2011-10-24 18:53:33.000000000 +0200
3724 #include <linux/writeback.h>
3725 #include <linux/buffer_head.h>
3726 #include <linux/falloc.h>
3727 +#include <linux/proc_fs.h>
3728 +#include <linux/vserver/inode.h>
3729 +#include <linux/vs_tag.h>
3731 #include <asm/ioctls.h>
3733 diff -NurpP --minimal linux-3.1.6/fs/ioprio.c linux-3.1.6-vs2.3.2.5/fs/ioprio.c
3734 --- linux-3.1.6/fs/ioprio.c 2011-01-05 21:50:24.000000000 +0100
3735 +++ linux-3.1.6-vs2.3.2.5/fs/ioprio.c 2011-10-24 18:53:33.000000000 +0200
3737 #include <linux/syscalls.h>
3738 #include <linux/security.h>
3739 #include <linux/pid_namespace.h>
3740 +#include <linux/vs_base.h>
3742 int set_task_ioprio(struct task_struct *task, int ioprio)
3744 @@ -119,6 +120,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
3746 pgrp = find_vpid(who);
3747 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3748 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3750 ret = set_task_ioprio(p, ioprio);
3753 @@ -208,6 +211,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
3755 pgrp = find_vpid(who);
3756 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3757 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3759 tmpio = get_task_ioprio(p);
3762 diff -NurpP --minimal linux-3.1.6/fs/jfs/file.c linux-3.1.6-vs2.3.2.5/fs/jfs/file.c
3763 --- linux-3.1.6/fs/jfs/file.c 2011-10-24 18:45:27.000000000 +0200
3764 +++ linux-3.1.6-vs2.3.2.5/fs/jfs/file.c 2011-10-24 18:53:33.000000000 +0200
3765 @@ -109,7 +109,8 @@ int jfs_setattr(struct dentry *dentry, s
3766 if (is_quota_modification(inode, iattr))
3767 dquot_initialize(inode);
3768 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
3769 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
3770 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
3771 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
3772 rc = dquot_transfer(inode, iattr);
3775 @@ -142,6 +143,7 @@ const struct inode_operations jfs_file_i
3776 #ifdef CONFIG_JFS_POSIX_ACL
3777 .get_acl = jfs_get_acl,
3779 + .sync_flags = jfs_sync_flags,
3782 const struct file_operations jfs_file_operations = {
3783 diff -NurpP --minimal linux-3.1.6/fs/jfs/ioctl.c linux-3.1.6-vs2.3.2.5/fs/jfs/ioctl.c
3784 --- linux-3.1.6/fs/jfs/ioctl.c 2011-05-22 16:17:52.000000000 +0200
3785 +++ linux-3.1.6-vs2.3.2.5/fs/jfs/ioctl.c 2011-10-24 18:53:33.000000000 +0200
3787 #include <linux/mount.h>
3788 #include <linux/time.h>
3789 #include <linux/sched.h>
3790 +#include <linux/mount.h>
3791 #include <asm/current.h>
3792 #include <asm/uaccess.h>
3794 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
3798 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
3800 + inode->i_flags = flags;
3801 + inode->i_vflags = vflags;
3802 + jfs_get_inode_flags(JFS_IP(inode));
3803 + inode->i_ctime = CURRENT_TIME_SEC;
3804 + mark_inode_dirty(inode);
3808 long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3810 struct inode *inode = filp->f_dentry->d_inode;
3811 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
3812 if (!S_ISDIR(inode->i_mode))
3813 flags &= ~JFS_DIRSYNC_FL;
3815 + if (IS_BARRIER(inode)) {
3816 + vxwprintk_task(1, "messing with the barrier.");
3820 /* Is it quota file? Do not allow user to mess with it */
3821 if (IS_NOQUOTA(inode)) {
3823 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
3824 * the relevant capability.
3826 if ((oldflags & JFS_IMMUTABLE_FL) ||
3827 - ((flags ^ oldflags) &
3828 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
3829 + ((flags ^ oldflags) & (JFS_APPEND_FL |
3830 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
3831 if (!capable(CAP_LINUX_IMMUTABLE)) {
3832 mutex_unlock(&inode->i_mutex);
3834 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
3838 - flags = flags & JFS_FL_USER_MODIFIABLE;
3839 + flags &= JFS_FL_USER_MODIFIABLE;
3840 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
3841 jfs_inode->mode2 = flags;
3843 diff -NurpP --minimal linux-3.1.6/fs/jfs/jfs_dinode.h linux-3.1.6-vs2.3.2.5/fs/jfs/jfs_dinode.h
3844 --- linux-3.1.6/fs/jfs/jfs_dinode.h 2008-12-25 00:26:37.000000000 +0100
3845 +++ linux-3.1.6-vs2.3.2.5/fs/jfs/jfs_dinode.h 2011-10-24 18:53:33.000000000 +0200
3846 @@ -161,9 +161,13 @@ struct dinode {
3848 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
3849 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
3850 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3852 -#define JFS_FL_USER_VISIBLE 0x03F80000
3853 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
3854 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3855 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
3857 +#define JFS_FL_USER_VISIBLE 0x07F80000
3858 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
3859 #define JFS_FL_INHERIT 0x03C80000
3861 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
3862 diff -NurpP --minimal linux-3.1.6/fs/jfs/jfs_filsys.h linux-3.1.6-vs2.3.2.5/fs/jfs/jfs_filsys.h
3863 --- linux-3.1.6/fs/jfs/jfs_filsys.h 2008-12-25 00:26:37.000000000 +0100
3864 +++ linux-3.1.6-vs2.3.2.5/fs/jfs/jfs_filsys.h 2011-10-24 18:53:33.000000000 +0200
3866 #define JFS_NAME_MAX 255
3867 #define JFS_PATH_MAX BPSIZE
3869 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
3872 * file system state (superblock state)
3873 diff -NurpP --minimal linux-3.1.6/fs/jfs/jfs_imap.c linux-3.1.6-vs2.3.2.5/fs/jfs/jfs_imap.c
3874 --- linux-3.1.6/fs/jfs/jfs_imap.c 2011-07-22 11:18:05.000000000 +0200
3875 +++ linux-3.1.6-vs2.3.2.5/fs/jfs/jfs_imap.c 2011-10-24 18:53:33.000000000 +0200
3877 #include <linux/pagemap.h>
3878 #include <linux/quotaops.h>
3879 #include <linux/slab.h>
3880 +#include <linux/vs_tag.h>
3882 #include "jfs_incore.h"
3883 #include "jfs_inode.h"
3884 @@ -3058,6 +3059,8 @@ static int copy_from_dinode(struct dinod
3886 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
3887 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
3891 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
3892 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
3893 @@ -3078,14 +3081,18 @@ static int copy_from_dinode(struct dinod
3895 ip->i_nlink = le32_to_cpu(dip->di_nlink);
3897 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
3898 + uid = le32_to_cpu(dip->di_uid);
3899 + gid = le32_to_cpu(dip->di_gid);
3900 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
3902 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
3904 ip->i_uid = jfs_ip->saved_uid;
3906 ip->i_uid = sbi->uid;
3909 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
3910 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
3912 ip->i_gid = jfs_ip->saved_gid;
3914 @@ -3150,14 +3157,12 @@ static void copy_to_dinode(struct dinode
3915 dip->di_size = cpu_to_le64(ip->i_size);
3916 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
3917 dip->di_nlink = cpu_to_le32(ip->i_nlink);
3918 - if (sbi->uid == -1)
3919 - dip->di_uid = cpu_to_le32(ip->i_uid);
3921 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
3922 - if (sbi->gid == -1)
3923 - dip->di_gid = cpu_to_le32(ip->i_gid);
3925 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
3927 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
3928 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
3929 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
3930 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
3932 jfs_get_inode_flags(jfs_ip);
3934 * mode2 is only needed for storing the higher order bits.
3935 diff -NurpP --minimal linux-3.1.6/fs/jfs/jfs_inode.c linux-3.1.6-vs2.3.2.5/fs/jfs/jfs_inode.c
3936 --- linux-3.1.6/fs/jfs/jfs_inode.c 2010-08-02 16:52:49.000000000 +0200
3937 +++ linux-3.1.6-vs2.3.2.5/fs/jfs/jfs_inode.c 2011-10-24 18:53:33.000000000 +0200
3940 #include <linux/fs.h>
3941 #include <linux/quotaops.h>
3942 +#include <linux/vs_tag.h>
3943 #include "jfs_incore.h"
3944 #include "jfs_inode.h"
3945 #include "jfs_filsys.h"
3946 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
3948 unsigned int flags = JFS_IP(inode)->mode2;
3950 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
3951 - S_NOATIME | S_DIRSYNC | S_SYNC);
3952 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3953 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3955 if (flags & JFS_IMMUTABLE_FL)
3956 inode->i_flags |= S_IMMUTABLE;
3957 + if (flags & JFS_IXUNLINK_FL)
3958 + inode->i_flags |= S_IXUNLINK;
3960 + if (flags & JFS_SYNC_FL)
3961 + inode->i_flags |= S_SYNC;
3962 if (flags & JFS_APPEND_FL)
3963 inode->i_flags |= S_APPEND;
3964 if (flags & JFS_NOATIME_FL)
3965 inode->i_flags |= S_NOATIME;
3966 if (flags & JFS_DIRSYNC_FL)
3967 inode->i_flags |= S_DIRSYNC;
3968 - if (flags & JFS_SYNC_FL)
3969 - inode->i_flags |= S_SYNC;
3971 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3973 + if (flags & JFS_BARRIER_FL)
3974 + inode->i_vflags |= V_BARRIER;
3975 + if (flags & JFS_COW_FL)
3976 + inode->i_vflags |= V_COW;
3979 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
3981 unsigned int flags = jfs_ip->vfs_inode.i_flags;
3982 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
3984 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
3985 + JFS_APPEND_FL | JFS_NOATIME_FL |
3986 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
3987 + JFS_BARRIER_FL | JFS_COW_FL);
3989 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
3990 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
3991 if (flags & S_IMMUTABLE)
3992 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
3993 + if (flags & S_IXUNLINK)
3994 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
3996 if (flags & S_APPEND)
3997 jfs_ip->mode2 |= JFS_APPEND_FL;
3998 if (flags & S_NOATIME)
3999 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
4000 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
4002 jfs_ip->mode2 |= JFS_SYNC_FL;
4004 + if (vflags & V_BARRIER)
4005 + jfs_ip->mode2 |= JFS_BARRIER_FL;
4006 + if (vflags & V_COW)
4007 + jfs_ip->mode2 |= JFS_COW_FL;
4011 diff -NurpP --minimal linux-3.1.6/fs/jfs/jfs_inode.h linux-3.1.6-vs2.3.2.5/fs/jfs/jfs_inode.h
4012 --- linux-3.1.6/fs/jfs/jfs_inode.h 2011-10-24 18:45:27.000000000 +0200
4013 +++ linux-3.1.6-vs2.3.2.5/fs/jfs/jfs_inode.h 2011-10-24 18:53:33.000000000 +0200
4014 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
4015 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
4016 int fh_len, int fh_type);
4017 extern void jfs_set_inode_flags(struct inode *);
4018 +extern int jfs_sync_flags(struct inode *, int, int);
4019 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
4020 extern int jfs_setattr(struct dentry *, struct iattr *);
4022 diff -NurpP --minimal linux-3.1.6/fs/jfs/namei.c linux-3.1.6-vs2.3.2.5/fs/jfs/namei.c
4023 --- linux-3.1.6/fs/jfs/namei.c 2011-10-24 18:45:27.000000000 +0200
4024 +++ linux-3.1.6-vs2.3.2.5/fs/jfs/namei.c 2011-10-24 18:53:33.000000000 +0200
4026 #include <linux/ctype.h>
4027 #include <linux/quotaops.h>
4028 #include <linux/exportfs.h>
4029 +#include <linux/vs_tag.h>
4030 #include "jfs_incore.h"
4031 #include "jfs_superblock.h"
4032 #include "jfs_inode.h"
4033 @@ -1474,6 +1475,7 @@ static struct dentry *jfs_lookup(struct
4034 jfs_err("jfs_lookup: iget failed on inum %d", (uint)inum);
4037 + dx_propagate_tag(nd, ip);
4038 return d_splice_alias(ip, dentry);
4041 @@ -1538,6 +1540,7 @@ const struct inode_operations jfs_dir_in
4042 #ifdef CONFIG_JFS_POSIX_ACL
4043 .get_acl = jfs_get_acl,
4045 + .sync_flags = jfs_sync_flags,
4048 const struct file_operations jfs_dir_operations = {
4049 diff -NurpP --minimal linux-3.1.6/fs/jfs/super.c linux-3.1.6-vs2.3.2.5/fs/jfs/super.c
4050 --- linux-3.1.6/fs/jfs/super.c 2011-05-22 16:17:53.000000000 +0200
4051 +++ linux-3.1.6-vs2.3.2.5/fs/jfs/super.c 2011-10-24 18:53:33.000000000 +0200
4052 @@ -198,7 +198,8 @@ static void jfs_put_super(struct super_b
4054 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
4055 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
4056 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
4057 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
4058 + Opt_tag, Opt_notag, Opt_tagid
4061 static const match_table_t tokens = {
4062 @@ -208,6 +209,10 @@ static const match_table_t tokens = {
4063 {Opt_resize, "resize=%u"},
4064 {Opt_resize_nosize, "resize"},
4065 {Opt_errors, "errors=%s"},
4067 + {Opt_notag, "notag"},
4068 + {Opt_tagid, "tagid=%u"},
4069 + {Opt_tag, "tagxid"},
4070 {Opt_ignore, "noquota"},
4071 {Opt_ignore, "quota"},
4072 {Opt_usrquota, "usrquota"},
4073 @@ -342,6 +347,20 @@ static int parse_options(char *options,
4077 +#ifndef CONFIG_TAGGING_NONE
4079 + *flag |= JFS_TAGGED;
4082 + *flag &= JFS_TAGGED;
4085 +#ifdef CONFIG_PROPAGATE
4088 + *flag |= JFS_TAGGED;
4092 printk("jfs: Unrecognized mount option \"%s\" "
4093 " or missing value\n", p);
4094 @@ -373,6 +392,12 @@ static int jfs_remount(struct super_bloc
4098 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4099 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4105 if (sb->s_flags & MS_RDONLY) {
4107 @@ -455,6 +480,9 @@ static int jfs_fill_super(struct super_b
4108 #ifdef CONFIG_JFS_POSIX_ACL
4109 sb->s_flags |= MS_POSIXACL;
4111 + /* map mount option tagxid */
4112 + if (sbi->flag & JFS_TAGGED)
4113 + sb->s_flags |= MS_TAGGED;
4116 printk(KERN_ERR "resize option for remount only\n");
4117 diff -NurpP --minimal linux-3.1.6/fs/libfs.c linux-3.1.6-vs2.3.2.5/fs/libfs.c
4118 --- linux-3.1.6/fs/libfs.c 2011-10-24 18:45:27.000000000 +0200
4119 +++ linux-3.1.6-vs2.3.2.5/fs/libfs.c 2011-10-24 18:53:33.000000000 +0200
4120 @@ -135,7 +135,8 @@ static inline unsigned char dt_type(stru
4121 * both impossible due to the lock on directory.
4124 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4125 +static inline int do_dcache_readdir_filter(struct file *filp,
4126 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4128 struct dentry *dentry = filp->f_path.dentry;
4129 struct dentry *cursor = filp->private_data;
4130 @@ -166,6 +167,8 @@ int dcache_readdir(struct file * filp, v
4131 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
4132 struct dentry *next;
4133 next = list_entry(p, struct dentry, d_u.d_child);
4134 + if (filter && !filter(next))
4136 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
4137 if (!simple_positive(next)) {
4138 spin_unlock(&next->d_lock);
4139 @@ -192,6 +195,17 @@ int dcache_readdir(struct file * filp, v
4143 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4145 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4148 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4149 + int (*filter)(struct dentry *))
4151 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4154 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4157 @@ -975,6 +989,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4158 EXPORT_SYMBOL(dcache_dir_lseek);
4159 EXPORT_SYMBOL(dcache_dir_open);
4160 EXPORT_SYMBOL(dcache_readdir);
4161 +EXPORT_SYMBOL(dcache_readdir_filter);
4162 EXPORT_SYMBOL(generic_read_dir);
4163 EXPORT_SYMBOL(mount_pseudo);
4164 EXPORT_SYMBOL(simple_write_begin);
4165 diff -NurpP --minimal linux-3.1.6/fs/locks.c linux-3.1.6-vs2.3.2.5/fs/locks.c
4166 --- linux-3.1.6/fs/locks.c 2011-10-24 18:45:27.000000000 +0200
4167 +++ linux-3.1.6-vs2.3.2.5/fs/locks.c 2011-10-24 18:53:33.000000000 +0200
4169 #include <linux/time.h>
4170 #include <linux/rcupdate.h>
4171 #include <linux/pid_namespace.h>
4172 +#include <linux/vs_base.h>
4173 +#include <linux/vs_limit.h>
4175 #include <asm/uaccess.h>
4177 @@ -170,11 +172,17 @@ static void locks_init_lock_heads(struct
4178 /* Allocate an empty lock structure. */
4179 struct file_lock *locks_alloc_lock(void)
4181 - struct file_lock *fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL);
4182 + struct file_lock *fl;
4185 - locks_init_lock_heads(fl);
4186 + if (!vx_locks_avail(1))
4189 + fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL);
4192 + locks_init_lock_heads(fl);
4197 EXPORT_SYMBOL_GPL(locks_alloc_lock);
4198 @@ -202,6 +210,7 @@ void locks_free_lock(struct file_lock *f
4199 BUG_ON(!list_empty(&fl->fl_block));
4200 BUG_ON(!list_empty(&fl->fl_link));
4203 locks_release_private(fl);
4204 kmem_cache_free(filelock_cache, fl);
4206 @@ -211,6 +220,7 @@ void locks_init_lock(struct file_lock *f
4208 memset(fl, 0, sizeof(struct file_lock));
4209 locks_init_lock_heads(fl);
4213 EXPORT_SYMBOL(locks_init_lock);
4214 @@ -251,6 +261,7 @@ void locks_copy_lock(struct file_lock *n
4215 new->fl_file = fl->fl_file;
4216 new->fl_ops = fl->fl_ops;
4217 new->fl_lmops = fl->fl_lmops;
4218 + new->fl_xid = fl->fl_xid;
4220 locks_copy_private(new, fl);
4222 @@ -289,6 +300,11 @@ static int flock_make_lock(struct file *
4223 fl->fl_flags = FL_FLOCK;
4225 fl->fl_end = OFFSET_MAX;
4227 + vxd_assert(filp->f_xid == vx_current_xid(),
4228 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4229 + fl->fl_xid = filp->f_xid;
4234 @@ -438,6 +454,7 @@ static int lease_init(struct file *filp,
4236 fl->fl_owner = current->files;
4237 fl->fl_pid = current->tgid;
4238 + fl->fl_xid = vx_current_xid();
4241 fl->fl_flags = FL_LEASE;
4242 @@ -457,6 +474,11 @@ static struct file_lock *lease_alloc(str
4244 return ERR_PTR(error);
4246 + fl->fl_xid = vx_current_xid();
4248 + vxd_assert(filp->f_xid == fl->fl_xid,
4249 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4251 error = lease_init(filp, type, fl);
4253 locks_free_lock(fl);
4254 @@ -758,6 +780,7 @@ static int flock_lock_file(struct file *
4258 + new_fl->fl_xid = -1;
4260 for_each_lock(inode, before) {
4261 struct file_lock *fl = *before;
4262 @@ -778,6 +801,7 @@ find_conflict:
4264 locks_copy_lock(new_fl, request);
4265 locks_insert_lock(before, new_fl);
4266 + vx_locks_inc(new_fl);
4270 @@ -788,7 +812,8 @@ out:
4274 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4275 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4276 + struct file_lock *conflock, xid_t xid)
4278 struct file_lock *fl;
4279 struct file_lock *new_fl = NULL;
4280 @@ -798,6 +823,8 @@ static int __posix_lock_file(struct inod
4281 struct file_lock **before;
4282 int error, added = 0;
4284 + vxd_assert(xid == vx_current_xid(),
4285 + "xid(%d) == current(%d)", xid, vx_current_xid());
4287 * We may need two file_lock structures for this operation,
4288 * so we get them in advance to avoid races.
4289 @@ -808,7 +835,11 @@ static int __posix_lock_file(struct inod
4290 (request->fl_type != F_UNLCK ||
4291 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4292 new_fl = locks_alloc_lock();
4293 + new_fl->fl_xid = xid;
4294 + vx_locks_inc(new_fl);
4295 new_fl2 = locks_alloc_lock();
4296 + new_fl2->fl_xid = xid;
4297 + vx_locks_inc(new_fl2);
4301 @@ -1007,7 +1038,8 @@ static int __posix_lock_file(struct inod
4302 int posix_lock_file(struct file *filp, struct file_lock *fl,
4303 struct file_lock *conflock)
4305 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
4306 + return __posix_lock_file(filp->f_path.dentry->d_inode,
4307 + fl, conflock, filp->f_xid);
4309 EXPORT_SYMBOL(posix_lock_file);
4311 @@ -1097,7 +1129,7 @@ int locks_mandatory_area(int read_write,
4312 fl.fl_end = offset + count - 1;
4315 - error = __posix_lock_file(inode, &fl, NULL);
4316 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
4317 if (error != FILE_LOCK_DEFERRED)
4319 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
4320 @@ -1410,6 +1442,7 @@ int generic_setlease(struct file *filp,
4323 locks_insert_lock(before, lease);
4324 + vx_locks_inc(lease);
4328 @@ -1794,6 +1827,11 @@ int fcntl_setlk(unsigned int fd, struct
4329 if (file_lock == NULL)
4332 + vxd_assert(filp->f_xid == vx_current_xid(),
4333 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4334 + file_lock->fl_xid = filp->f_xid;
4335 + vx_locks_inc(file_lock);
4338 * This might block, so we do it before checking the inode.
4340 @@ -1912,6 +1950,11 @@ int fcntl_setlk64(unsigned int fd, struc
4341 if (file_lock == NULL)
4344 + vxd_assert(filp->f_xid == vx_current_xid(),
4345 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4346 + file_lock->fl_xid = filp->f_xid;
4347 + vx_locks_inc(file_lock);
4350 * This might block, so we do it before checking the inode.
4352 @@ -2177,8 +2220,11 @@ static int locks_show(struct seq_file *f
4354 lock_get_status(f, fl, *((loff_t *)f->private), "");
4356 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
4357 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
4358 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
4360 lock_get_status(f, bfl, *((loff_t *)f->private), " ->");
4365 diff -NurpP --minimal linux-3.1.6/fs/namei.c linux-3.1.6-vs2.3.2.5/fs/namei.c
4366 --- linux-3.1.6/fs/namei.c 2011-12-23 16:04:07.000000000 +0100
4367 +++ linux-3.1.6-vs2.3.2.5/fs/namei.c 2011-11-16 14:28:54.000000000 +0100
4369 #include <linux/device_cgroup.h>
4370 #include <linux/fs_struct.h>
4371 #include <linux/posix_acl.h>
4372 +#include <linux/proc_fs.h>
4373 +#include <linux/vserver/inode.h>
4374 +#include <linux/vs_base.h>
4375 +#include <linux/vs_tag.h>
4376 +#include <linux/vs_cowbl.h>
4377 +#include <linux/vs_device.h>
4378 +#include <linux/vs_context.h>
4379 +#include <linux/pid_namespace.h>
4380 #include <asm/uaccess.h>
4382 #include "internal.h"
4383 @@ -222,6 +230,89 @@ static int check_acl(struct inode *inode
4387 +static inline int dx_barrier(const struct inode *inode)
4389 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
4390 + vxwprintk_task(1, "did hit the barrier.");
4396 +static int __dx_permission(const struct inode *inode, int mask)
4398 + if (dx_barrier(inode))
4401 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
4402 + /* devpts is xid tagged */
4403 + if (S_ISDIR(inode->i_mode) ||
4404 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
4407 + /* just pretend we didn't find anything */
4410 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
4411 + struct proc_dir_entry *de = PDE(inode);
4413 + if (de && !vx_hide_check(0, de->vx_flags))
4416 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
4418 + struct task_struct *tsk;
4420 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
4421 + vx_flags(VXF_STATE_SETUP, 0))
4424 + pid = PROC_I(inode)->pid;
4429 + tsk = pid_task(pid, PIDTYPE_PID);
4430 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
4431 + tsk, (tsk ? vx_task_xid(tsk) : 0));
4433 + vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P)) {
4434 + rcu_read_unlock();
4437 + rcu_read_unlock();
4440 + /* FIXME: Should we block some entries here? */
4445 + if (dx_notagcheck(inode->i_sb) ||
4446 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
4455 +int dx_permission(const struct inode *inode, int mask)
4457 + int ret = __dx_permission(inode, mask);
4458 + if (unlikely(ret)) {
4459 +#ifndef CONFIG_VSERVER_WARN_DEVPTS
4460 + if (inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC)
4463 + "denied [0x%x] access to inode %s:%p[#%d,%lu]",
4464 + mask, inode->i_sb->s_id, inode, inode->i_tag,
4471 * This does basic POSIX ACL permission checking
4473 @@ -357,10 +448,14 @@ int inode_permission(struct inode *inode
4475 * Nobody gets write access to an immutable file.
4477 - if (IS_IMMUTABLE(inode))
4478 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
4482 + retval = dx_permission(inode, mask);
4486 retval = do_inode_permission(inode, mask);
4489 @@ -1037,7 +1132,8 @@ static void follow_dotdot(struct nameida
4491 if (nd->path.dentry == nd->root.dentry &&
4492 nd->path.mnt == nd->root.mnt) {
4494 + /* for sane '/' avoid follow_mount() */
4497 if (nd->path.dentry != nd->path.mnt->mnt_root) {
4498 /* rare case of legitimate dget_parent()... */
4499 @@ -1146,6 +1242,9 @@ static int do_lookup(struct nameidata *n
4501 if (unlikely(d_need_lookup(dentry)))
4504 + /* FIXME: check dx permission */
4507 path->dentry = dentry;
4508 if (unlikely(!__follow_mount_rcu(nd, path, inode)))
4509 @@ -1207,6 +1306,8 @@ retry:
4513 + /* FIXME: check dx permission */
4516 path->dentry = dentry;
4517 err = follow_managed(path, nd->flags);
4518 @@ -1901,7 +2002,7 @@ static int may_delete(struct inode *dir,
4521 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
4522 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4523 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4526 if (!S_ISDIR(victim->d_inode->i_mode))
4527 @@ -1981,19 +2082,25 @@ int vfs_create(struct inode *dir, struct
4529 int error = may_create(dir, dentry);
4533 + vxdprintk(VXD_CBIT(misc, 3), "may_create failed with %d", error);
4537 if (!dir->i_op->create)
4538 return -EACCES; /* shouldn't it be ENOSYS? */
4541 error = security_inode_create(dir, dentry, mode);
4544 + vxdprintk(VXD_CBIT(misc, 3), "security_inode_create failed with %d", error);
4547 error = dir->i_op->create(dir, dentry, mode, nd);
4549 fsnotify_create(dir, dentry);
4551 + vxdprintk(VXD_CBIT(misc, 3), "i_op->create failed with %d", error);
4555 @@ -2028,6 +2135,15 @@ static int may_open(struct path *path, i
4559 +#ifdef CONFIG_VSERVER_COWBL
4560 + if (IS_COW(inode) &&
4561 + ((flag & O_ACCMODE) != O_RDONLY)) {
4562 + if (IS_COW_LINK(inode))
4564 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
4565 + mark_inode_dirty(inode);
4568 error = inode_permission(inode, acc_mode);
4571 @@ -2255,6 +2371,16 @@ ok:
4574 error = may_open(&nd->path, acc_mode, open_flag);
4575 +#ifdef CONFIG_VSERVER_COWBL
4576 + if (error == -EMLINK) {
4577 + struct dentry *dentry;
4578 + dentry = cow_break_link(pathname);
4579 + if (IS_ERR(dentry))
4580 + error = PTR_ERR(dentry);
4587 filp = nameidata_to_filp(nd);
4588 @@ -2297,6 +2423,7 @@ static struct file *path_openat(int dfd,
4593 filp = get_empty_filp();
4595 return ERR_PTR(-ENFILE);
4596 @@ -2334,6 +2461,17 @@ static struct file *path_openat(int dfd,
4597 filp = do_last(nd, &path, op, pathname);
4598 put_link(nd, &link, cookie);
4601 +#ifdef CONFIG_VSERVER_COWBL
4602 + if (filp == ERR_PTR(-EMLINK)) {
4603 + if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
4604 + path_put(&nd->root);
4607 + release_open_intent(nd);
4612 if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
4613 path_put(&nd->root);
4614 @@ -2423,6 +2561,11 @@ struct dentry *kern_path_create(int dfd,
4618 + vxdprintk(VXD_CBIT(misc, 3), "kern_path_create path.dentry = %p (%.*s), dentry = %p (%.*s), d_inode = %p",
4619 + path->dentry, path->dentry->d_name.len,
4620 + path->dentry->d_name.name, dentry,
4621 + dentry->d_name.len, dentry->d_name.name,
4622 + path->dentry->d_inode);
4626 @@ -2904,7 +3047,7 @@ int vfs_link(struct dentry *old_dentry,
4628 * A link to an append-only or immutable file cannot be created.
4630 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4631 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4633 if (!dir->i_op->link)
4635 @@ -3285,6 +3428,227 @@ int vfs_follow_link(struct nameidata *nd
4636 return __vfs_follow_link(nd, link);
4640 +#ifdef CONFIG_VSERVER_COWBL
4643 +long do_cow_splice(struct file *in, struct file *out, size_t len)
4647 + return do_splice_direct(in, &ppos, out, len, 0);
4650 +struct dentry *cow_break_link(const char *pathname)
4652 + int ret, mode, pathlen, redo = 0;
4653 + struct nameidata old_nd, dir_nd;
4654 + struct path old_path, dir_path;
4655 + struct dentry *dir, *old_dentry, *new_dentry = NULL;
4656 + struct file *old_file;
4657 + struct file *new_file;
4658 + char *to, *path, pad='\251';
4661 + vxdprintk(VXD_CBIT(misc, 1),
4662 + "cow_break_link(" VS_Q("%s") ")", pathname);
4663 + path = kmalloc(PATH_MAX, GFP_KERNEL);
4668 + /* old_nd will have refs to dentry and mnt */
4669 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
4670 + vxdprintk(VXD_CBIT(misc, 2),
4671 + "do_path_lookup(old): %d [r=%d]",
4672 + ret, mnt_get_count(old_nd.path.mnt));
4674 + goto out_free_path;
4676 + old_path = old_nd.path;
4677 + old_dentry = old_path.dentry;
4678 + mode = old_dentry->d_inode->i_mode;
4680 + to = d_path(&old_path, path, PATH_MAX-2);
4681 + pathlen = strlen(to);
4682 + vxdprintk(VXD_CBIT(misc, 2),
4683 + "old path " VS_Q("%s") " [%p:" VS_Q("%.*s") ":%d]", to,
4685 + old_dentry->d_name.len, old_dentry->d_name.name,
4686 + old_dentry->d_name.len);
4688 + to[pathlen + 1] = 0;
4690 + new_dentry = NULL;
4691 + to[pathlen] = pad--;
4693 + if (pad <= '\240')
4696 + vxdprintk(VXD_CBIT(misc, 1), "temp copy " VS_Q("%s"), to);
4697 + /* dir_nd will have refs to dentry and mnt */
4698 + ret = do_path_lookup(AT_FDCWD, to,
4699 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
4700 + vxdprintk(VXD_CBIT(misc, 2), "do_path_lookup(new): %d", ret);
4704 + /* this puppy downs the dir inode mutex if successful */
4705 + new_dentry = kern_path_create(AT_FDCWD, to, &dir_path, 0);
4706 + if (!new_dentry || IS_ERR(new_dentry)) {
4707 + path_put(&dir_nd.path);
4708 + vxdprintk(VXD_CBIT(misc, 2),
4709 + "kern_path_create(new) failed with %ld",
4710 + PTR_ERR(new_dentry));
4713 + path_put(&dir_path);
4714 + vxdprintk(VXD_CBIT(misc, 2),
4715 + "kern_path_create(new): %p [" VS_Q("%.*s") ":%d]",
4717 + new_dentry->d_name.len, new_dentry->d_name.name,
4718 + new_dentry->d_name.len);
4720 + dir = dir_nd.path.dentry;
4722 + ret = vfs_create(dir->d_inode, new_dentry, mode, &dir_nd);
4723 + vxdprintk(VXD_CBIT(misc, 2),
4724 + "vfs_create(new): %d", ret);
4725 + if (ret == -EEXIST) {
4726 + mutex_unlock(&dir->d_inode->i_mutex);
4727 + path_put(&dir_nd.path);
4732 + goto out_unlock_new;
4734 + /* drop out early, ret passes ENOENT */
4736 + if ((redo = d_unhashed(old_dentry)))
4737 + goto out_unlock_new;
4739 + path_get(&old_path);
4740 + /* this one cleans up the dentry/mnt in case of failure */
4741 + old_file = dentry_open(old_dentry, old_path.mnt,
4742 + O_RDONLY, current_cred());
4743 + vxdprintk(VXD_CBIT(misc, 2),
4744 + "dentry_open(old): %p", old_file);
4745 + if (IS_ERR(old_file)) {
4746 + ret = PTR_ERR(old_file);
4747 + goto out_unlock_new;
4751 + mntget(old_path.mnt);
4752 + /* this one cleans up the dentry/mnt in case of failure */
4753 + new_file = dentry_open(new_dentry, old_path.mnt,
4754 + O_WRONLY, current_cred());
4755 + vxdprintk(VXD_CBIT(misc, 2),
4756 + "dentry_open(new): %p", new_file);
4757 + if (IS_ERR(new_file)) {
4758 + ret = PTR_ERR(new_file);
4759 + goto out_fput_old;
4762 + size = i_size_read(old_file->f_dentry->d_inode);
4763 + ret = do_cow_splice(old_file, new_file, size);
4764 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
4766 + goto out_fput_both;
4767 + } else if (ret < size) {
4769 + goto out_fput_both;
4771 + struct inode *old_inode = old_dentry->d_inode;
4772 + struct inode *new_inode = new_dentry->d_inode;
4773 + struct iattr attr = {
4774 + .ia_uid = old_inode->i_uid,
4775 + .ia_gid = old_inode->i_gid,
4776 + .ia_valid = ATTR_UID | ATTR_GID
4779 + setattr_copy(new_inode, &attr);
4780 + mark_inode_dirty(new_inode);
4783 + mutex_lock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
4785 + /* drop out late */
4787 + if ((redo = d_unhashed(old_dentry)))
4790 + vxdprintk(VXD_CBIT(misc, 2),
4791 + "vfs_rename: [" VS_Q("%*s") ":%d] -> [" VS_Q("%*s") ":%d]",
4792 + new_dentry->d_name.len, new_dentry->d_name.name,
4793 + new_dentry->d_name.len,
4794 + old_dentry->d_name.len, old_dentry->d_name.name,
4795 + old_dentry->d_name.len);
4796 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_dentry,
4797 + old_dentry->d_parent->d_inode, old_dentry);
4798 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
4801 + mutex_unlock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
4804 + vxdprintk(VXD_CBIT(misc, 3),
4805 + "fput(new_file=%p[#%ld])", new_file,
4806 + atomic_long_read(&new_file->f_count));
4810 + vxdprintk(VXD_CBIT(misc, 3),
4811 + "fput(old_file=%p[#%ld])", old_file,
4812 + atomic_long_read(&old_file->f_count));
4816 + mutex_unlock(&dir->d_inode->i_mutex);
4820 + /* error path cleanup */
4821 + vfs_unlink(dir->d_inode, new_dentry);
4825 + goto out_rel_both;
4826 + /* lookup dentry once again */
4827 + /* old_nd.path is freed as old_path in out_rel_old */
4828 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
4830 + goto out_rel_both;
4833 + new_dentry = old_nd.path.dentry;
4834 + vxdprintk(VXD_CBIT(misc, 2),
4835 + "do_path_lookup(redo): %p [" VS_Q("%.*s") ":%d]",
4837 + new_dentry->d_name.len, new_dentry->d_name.name,
4838 + new_dentry->d_name.len);
4842 + path_put(&dir_nd.path);
4844 + path_put(&old_path);
4850 + new_dentry = ERR_PTR(ret);
4852 + vxdprintk(VXD_CBIT(misc, 3),
4853 + "cow_break_link returning with %p [r=%d]",
4854 + new_dentry, mnt_get_count(old_nd.path.mnt));
4855 + return new_dentry;
4860 /* get the link contents into pagecache */
4861 static char *page_getlink(struct dentry * dentry, struct page **ppage)
4863 diff -NurpP --minimal linux-3.1.6/fs/namespace.c linux-3.1.6-vs2.3.2.5/fs/namespace.c
4864 --- linux-3.1.6/fs/namespace.c 2011-12-23 16:04:07.000000000 +0100
4865 +++ linux-3.1.6-vs2.3.2.5/fs/namespace.c 2011-12-23 16:11:57.000000000 +0100
4867 #include <linux/idr.h>
4868 #include <linux/fs_struct.h>
4869 #include <linux/fsnotify.h>
4870 +#include <linux/vs_base.h>
4871 +#include <linux/vs_context.h>
4872 +#include <linux/vs_tag.h>
4873 +#include <linux/vserver/space.h>
4874 +#include <linux/vserver/global.h>
4875 #include <asm/uaccess.h>
4876 #include <asm/unistd.h>
4878 @@ -679,6 +684,10 @@ vfs_kern_mount(struct file_system_type *
4880 return ERR_PTR(-ENODEV);
4882 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
4883 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
4884 + return ERR_PTR(-EPERM);
4886 mnt = alloc_vfsmnt(name);
4888 return ERR_PTR(-ENOMEM);
4889 @@ -724,6 +733,7 @@ static struct vfsmount *clone_mnt(struct
4890 mnt->mnt_root = dget(root);
4891 mnt->mnt_mountpoint = mnt->mnt_root;
4892 mnt->mnt_parent = mnt;
4893 + mnt->mnt_tag = old->mnt_tag;
4895 if (flag & CL_SLAVE) {
4896 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
4897 @@ -852,6 +862,31 @@ static inline void mangle(struct seq_fil
4898 seq_escape(m, s, " \t\n\\");
4901 +static int mnt_is_reachable(struct vfsmount *mnt)
4904 + struct dentry *point;
4907 + if (mnt == mnt->mnt_ns->root)
4910 + br_read_lock(vfsmount_lock);
4911 + root = current->fs->root;
4912 + point = root.dentry;
4914 + while ((mnt != mnt->mnt_parent) && (mnt != root.mnt)) {
4915 + point = mnt->mnt_mountpoint;
4916 + mnt = mnt->mnt_parent;
4919 + ret = (mnt == root.mnt) && is_subdir(point, root.dentry);
4921 + br_read_unlock(vfsmount_lock);
4927 * Simple .show_options callback for filesystems which don't want to
4928 * implement more complex mount option showing.
4929 @@ -954,6 +989,8 @@ static int show_sb_opts(struct seq_file
4930 { MS_SYNCHRONOUS, ",sync" },
4931 { MS_DIRSYNC, ",dirsync" },
4932 { MS_MANDLOCK, ",mand" },
4933 + { MS_TAGGED, ",tag" },
4934 + { MS_NOTAGCHECK, ",notagcheck" },
4937 const struct proc_fs_info *fs_infop;
4938 @@ -1000,16 +1037,26 @@ static int show_vfsmnt(struct seq_file *
4940 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
4942 - if (mnt->mnt_sb->s_op->show_devname) {
4943 - err = mnt->mnt_sb->s_op->show_devname(m, mnt);
4946 + if (vx_flags(VXF_HIDE_MOUNT, 0))
4948 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
4951 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
4952 + mnt == current->fs->root.mnt) {
4953 + seq_puts(m, "/dev/root / ");
4955 - mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
4956 + if (mnt->mnt_sb->s_op->show_devname) {
4957 + err = mnt->mnt_sb->s_op->show_devname(m, mnt);
4961 + mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
4964 + seq_path(m, &mnt_path, " \t\n\\");
4968 - seq_path(m, &mnt_path, " \t\n\\");
4970 show_type(m, mnt->mnt_sb);
4971 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
4972 err = show_sb_opts(m, mnt->mnt_sb);
4973 @@ -1039,6 +1086,11 @@ static int show_mountinfo(struct seq_fil
4974 struct path root = p->root;
4977 + if (vx_flags(VXF_HIDE_MOUNT, 0))
4979 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
4982 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
4983 MAJOR(sb->s_dev), MINOR(sb->s_dev));
4984 if (sb->s_op->show_path)
4985 @@ -1104,22 +1156,32 @@ static int show_vfsstat(struct seq_file
4986 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
4990 - if (mnt->mnt_sb->s_op->show_devname) {
4991 - seq_puts(m, "device ");
4992 - err = mnt->mnt_sb->s_op->show_devname(m, mnt);
4993 + if (vx_flags(VXF_HIDE_MOUNT, 0))
4995 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
4998 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
4999 + mnt == current->fs->root.mnt) {
5000 + seq_puts(m, "device /dev/root mounted on / ");
5002 - if (mnt->mnt_devname) {
5004 + if (mnt->mnt_sb->s_op->show_devname) {
5005 seq_puts(m, "device ");
5006 - mangle(m, mnt->mnt_devname);
5008 - seq_puts(m, "no device");
5010 + err = mnt->mnt_sb->s_op->show_devname(m, mnt);
5012 + if (mnt->mnt_devname) {
5013 + seq_puts(m, "device ");
5014 + mangle(m, mnt->mnt_devname);
5016 + seq_puts(m, "no device");
5020 - seq_puts(m, " mounted on ");
5021 - seq_path(m, &mnt_path, " \t\n\\");
5024 + seq_puts(m, " mounted on ");
5025 + seq_path(m, &mnt_path, " \t\n\\");
5029 /* file system type */
5030 seq_puts(m, "with fstype ");
5031 @@ -1378,7 +1440,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
5035 - if (!capable(CAP_SYS_ADMIN))
5036 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5039 retval = do_umount(path.mnt, flags);
5040 @@ -1404,7 +1466,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
5042 static int mount_is_safe(struct path *path)
5044 - if (capable(CAP_SYS_ADMIN))
5045 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5049 @@ -1714,7 +1776,7 @@ static int do_change_type(struct path *p
5053 - if (!capable(CAP_SYS_ADMIN))
5054 + if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
5057 if (path->dentry != path->mnt->mnt_root)
5058 @@ -1730,6 +1792,7 @@ static int do_change_type(struct path *p
5062 + // mnt->mnt_flags = mnt_flags;
5064 br_write_lock(vfsmount_lock);
5065 for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL))
5066 @@ -1745,12 +1808,14 @@ static int do_change_type(struct path *p
5067 * do loopback mount.
5069 static int do_loopback(struct path *path, char *old_name,
5071 + tag_t tag, unsigned long flags, int mnt_flags)
5073 LIST_HEAD(umount_list);
5074 struct path old_path;
5075 struct vfsmount *mnt = NULL;
5076 int err = mount_is_safe(path);
5077 + int recurse = flags & MS_REC;
5081 if (!old_name || !*old_name)
5082 @@ -1816,12 +1881,12 @@ static int change_mount_flags(struct vfs
5083 * on it - tough luck.
5085 static int do_remount(struct path *path, int flags, int mnt_flags,
5087 + void *data, xid_t xid)
5090 struct super_block *sb = path->mnt->mnt_sb;
5092 - if (!capable(CAP_SYS_ADMIN))
5093 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
5096 if (!check_mnt(path->mnt))
5097 @@ -1869,7 +1934,7 @@ static int do_move_mount(struct path *pa
5098 struct path old_path, parent_path;
5101 - if (!capable(CAP_SYS_ADMIN))
5102 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5104 if (!old_name || !*old_name)
5106 @@ -2020,7 +2085,7 @@ static int do_new_mount(struct path *pat
5109 /* we need capabilities... */
5110 - if (!capable(CAP_SYS_ADMIN))
5111 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5114 mnt = do_kern_mount(type, flags, name, data);
5115 @@ -2289,6 +2354,7 @@ long do_mount(char *dev_name, char *dir_
5122 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
5123 @@ -2316,6 +2382,12 @@ long do_mount(char *dev_name, char *dir_
5124 if (!(flags & MS_NOATIME))
5125 mnt_flags |= MNT_RELATIME;
5127 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
5128 + /* FIXME: bind and re-mounts get the tag flag? */
5129 + if (flags & (MS_BIND|MS_REMOUNT))
5130 + flags |= MS_TAGID;
5133 /* Separate the per-mountpoint flags */
5134 if (flags & MS_NOSUID)
5135 mnt_flags |= MNT_NOSUID;
5136 @@ -2332,15 +2404,17 @@ long do_mount(char *dev_name, char *dir_
5137 if (flags & MS_RDONLY)
5138 mnt_flags |= MNT_READONLY;
5140 + if (!capable(CAP_SYS_ADMIN))
5141 + mnt_flags |= MNT_NODEV;
5142 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN |
5143 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
5146 if (flags & MS_REMOUNT)
5147 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
5150 else if (flags & MS_BIND)
5151 - retval = do_loopback(&path, dev_name, flags & MS_REC);
5152 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
5153 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
5154 retval = do_change_type(&path, flags);
5155 else if (flags & MS_MOVE)
5156 @@ -2440,6 +2514,7 @@ static struct mnt_namespace *dup_mnt_ns(
5157 q = next_mnt(q, new_ns->root);
5159 up_write(&namespace_sem);
5160 + atomic_inc(&vs_global_mnt_ns);
5164 @@ -2579,9 +2654,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
5168 - if (IS_MNT_SHARED(old.mnt) ||
5169 + if ((IS_MNT_SHARED(old.mnt) ||
5170 IS_MNT_SHARED(new.mnt->mnt_parent) ||
5171 - IS_MNT_SHARED(root.mnt->mnt_parent))
5172 + IS_MNT_SHARED(root.mnt->mnt_parent)) &&
5173 + !vx_flags(VXF_STATE_SETUP, 0))
5175 if (!check_mnt(root.mnt) || !check_mnt(new.mnt))
5177 @@ -2713,6 +2789,7 @@ void put_mnt_ns(struct mnt_namespace *ns
5178 br_write_unlock(vfsmount_lock);
5179 up_write(&namespace_sem);
5180 release_mounts(&umount_list);
5181 + atomic_dec(&vs_global_mnt_ns);
5184 EXPORT_SYMBOL(put_mnt_ns);
5185 diff -NurpP --minimal linux-3.1.6/fs/nfs/client.c linux-3.1.6-vs2.3.2.5/fs/nfs/client.c
5186 --- linux-3.1.6/fs/nfs/client.c 2011-10-24 18:45:27.000000000 +0200
5187 +++ linux-3.1.6-vs2.3.2.5/fs/nfs/client.c 2011-10-24 18:53:33.000000000 +0200
5188 @@ -778,6 +778,9 @@ static int nfs_init_server_rpcclient(str
5189 if (server->flags & NFS_MOUNT_SOFT)
5190 server->client->cl_softrtry = 1;
5192 + server->client->cl_tag = 0;
5193 + if (server->flags & NFS_MOUNT_TAGGED)
5194 + server->client->cl_tag = 1;
5198 @@ -952,6 +955,10 @@ static void nfs_server_set_fsinfo(struct
5199 server->acdirmin = server->acdirmax = 0;
5202 + /* FIXME: needs fsinfo
5203 + if (server->flags & NFS_MOUNT_TAGGED)
5204 + sb->s_flags |= MS_TAGGED; */
5206 server->maxfilesize = fsinfo->maxfilesize;
5208 server->time_delta = fsinfo->time_delta;
5209 diff -NurpP --minimal linux-3.1.6/fs/nfs/dir.c linux-3.1.6-vs2.3.2.5/fs/nfs/dir.c
5210 --- linux-3.1.6/fs/nfs/dir.c 2011-12-23 16:04:07.000000000 +0100
5211 +++ linux-3.1.6-vs2.3.2.5/fs/nfs/dir.c 2011-11-29 12:53:17.000000000 +0100
5213 #include <linux/sched.h>
5214 #include <linux/kmemleak.h>
5215 #include <linux/xattr.h>
5216 +#include <linux/vs_tag.h>
5218 #include "delegation.h"
5220 @@ -1311,6 +1312,7 @@ static struct dentry *nfs_lookup(struct
5222 goto out_unblock_sillyrename;
5224 + dx_propagate_tag(nd, inode);
5226 res = d_materialise_unique(dentry, inode);
5228 diff -NurpP --minimal linux-3.1.6/fs/nfs/inode.c linux-3.1.6-vs2.3.2.5/fs/nfs/inode.c
5229 --- linux-3.1.6/fs/nfs/inode.c 2011-12-23 16:04:07.000000000 +0100
5230 +++ linux-3.1.6-vs2.3.2.5/fs/nfs/inode.c 2011-11-29 12:53:17.000000000 +0100
5232 #include <linux/nfs_xdr.h>
5233 #include <linux/slab.h>
5234 #include <linux/compat.h>
5235 +#include <linux/vs_tag.h>
5237 #include <asm/system.h>
5238 #include <asm/uaccess.h>
5239 @@ -273,6 +274,8 @@ nfs_fhget(struct super_block *sb, struct
5240 if (inode->i_state & I_NEW) {
5241 struct nfs_inode *nfsi = NFS_I(inode);
5242 unsigned long now = jiffies;
5246 /* We set i_ino for the few things that still rely on it,
5247 * such as stat(2) */
5248 @@ -321,8 +324,8 @@ nfs_fhget(struct super_block *sb, struct
5249 nfsi->change_attr = 0;
5252 - inode->i_uid = -2;
5253 - inode->i_gid = -2;
5256 inode->i_blocks = 0;
5257 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
5259 @@ -359,13 +362,13 @@ nfs_fhget(struct super_block *sb, struct
5260 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
5261 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5262 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
5263 - inode->i_uid = fattr->uid;
5265 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
5266 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5267 | NFS_INO_INVALID_ACCESS
5268 | NFS_INO_INVALID_ACL;
5269 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
5270 - inode->i_gid = fattr->gid;
5272 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
5273 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5274 | NFS_INO_INVALID_ACCESS
5275 @@ -378,6 +381,11 @@ nfs_fhget(struct super_block *sb, struct
5277 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
5279 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5280 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5281 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
5282 + /* maybe fattr->xid someday */
5284 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
5285 nfsi->attrtimeo_timestamp = now;
5286 nfsi->access_cache = RB_ROOT;
5287 @@ -494,6 +502,8 @@ void nfs_setattr_update_inode(struct ino
5288 inode->i_uid = attr->ia_uid;
5289 if ((attr->ia_valid & ATTR_GID) != 0)
5290 inode->i_gid = attr->ia_gid;
5291 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5292 + inode->i_tag = attr->ia_tag;
5293 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5294 spin_unlock(&inode->i_lock);
5296 @@ -943,6 +953,9 @@ static int nfs_check_inode_attributes(st
5297 struct nfs_inode *nfsi = NFS_I(inode);
5298 loff_t cur_size, new_isize;
5299 unsigned long invalid = 0;
5305 /* Has the inode gone and changed behind our back? */
5306 @@ -966,13 +979,18 @@ static int nfs_check_inode_attributes(st
5307 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5310 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5311 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5312 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5314 /* Have any file permissions changed? */
5315 if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
5316 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5317 - if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
5318 + if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
5319 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5320 - if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
5321 + if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
5322 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5323 + /* maybe check for tag too? */
5325 /* Has the link count changed? */
5326 if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
5327 @@ -1207,6 +1225,9 @@ static int nfs_update_inode(struct inode
5328 unsigned long invalid = 0;
5329 unsigned long now = jiffies;
5330 unsigned long save_cache_validity;
5335 dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n",
5336 __func__, inode->i_sb->s_id, inode->i_ino,
5337 @@ -1314,6 +1335,9 @@ static int nfs_update_inode(struct inode
5338 | NFS_INO_REVAL_PAGECACHE
5339 | NFS_INO_REVAL_FORCED);
5341 + uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
5342 + gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
5343 + tag = inode->i_tag;
5345 if (fattr->valid & NFS_ATTR_FATTR_ATIME)
5346 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5347 @@ -1335,9 +1359,9 @@ static int nfs_update_inode(struct inode
5348 | NFS_INO_REVAL_FORCED);
5350 if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
5351 - if (inode->i_uid != fattr->uid) {
5352 + if (uid != fattr->uid) {
5353 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5354 - inode->i_uid = fattr->uid;
5357 } else if (server->caps & NFS_CAP_OWNER)
5358 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5359 @@ -1346,9 +1370,9 @@ static int nfs_update_inode(struct inode
5360 | NFS_INO_REVAL_FORCED);
5362 if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
5363 - if (inode->i_gid != fattr->gid) {
5364 + if (gid != fattr->gid) {
5365 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5366 - inode->i_gid = fattr->gid;
5369 } else if (server->caps & NFS_CAP_OWNER_GROUP)
5370 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5371 @@ -1356,6 +1380,10 @@ static int nfs_update_inode(struct inode
5372 | NFS_INO_INVALID_ACL
5373 | NFS_INO_REVAL_FORCED);
5375 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5376 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5377 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, tag);
5379 if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
5380 if (inode->i_nlink != fattr->nlink) {
5381 invalid |= NFS_INO_INVALID_ATTR;
5382 diff -NurpP --minimal linux-3.1.6/fs/nfs/nfs3xdr.c linux-3.1.6-vs2.3.2.5/fs/nfs/nfs3xdr.c
5383 --- linux-3.1.6/fs/nfs/nfs3xdr.c 2011-03-15 18:07:32.000000000 +0100
5384 +++ linux-3.1.6-vs2.3.2.5/fs/nfs/nfs3xdr.c 2011-10-24 18:53:33.000000000 +0200
5386 #include <linux/nfs3.h>
5387 #include <linux/nfs_fs.h>
5388 #include <linux/nfsacl.h>
5389 +#include <linux/vs_tag.h>
5390 #include "internal.h"
5392 #define NFSDBG_FACILITY NFSDBG_XDR
5393 @@ -562,7 +563,8 @@ static __be32 *xdr_decode_nfstime3(__be3
5397 -static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr)
5398 +static void encode_sattr3(struct xdr_stream *xdr,
5399 + const struct iattr *attr, int tag)
5403 @@ -594,15 +596,19 @@ static void encode_sattr3(struct xdr_str
5407 - if (attr->ia_valid & ATTR_UID) {
5408 + if (attr->ia_valid & ATTR_UID ||
5409 + (tag && (attr->ia_valid & ATTR_TAG))) {
5411 - *p++ = cpu_to_be32(attr->ia_uid);
5412 + *p++ = cpu_to_be32(TAGINO_UID(tag,
5413 + attr->ia_uid, attr->ia_tag));
5417 - if (attr->ia_valid & ATTR_GID) {
5418 + if (attr->ia_valid & ATTR_GID ||
5419 + (tag && (attr->ia_valid & ATTR_TAG))) {
5421 - *p++ = cpu_to_be32(attr->ia_gid);
5422 + *p++ = cpu_to_be32(TAGINO_GID(tag,
5423 + attr->ia_gid, attr->ia_tag));
5427 @@ -878,7 +884,7 @@ static void nfs3_xdr_enc_setattr3args(st
5428 const struct nfs3_sattrargs *args)
5430 encode_nfs_fh3(xdr, args->fh);
5431 - encode_sattr3(xdr, args->sattr);
5432 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5433 encode_sattrguard3(xdr, args);
5436 @@ -1028,13 +1034,13 @@ static void nfs3_xdr_enc_write3args(stru
5439 static void encode_createhow3(struct xdr_stream *xdr,
5440 - const struct nfs3_createargs *args)
5441 + const struct nfs3_createargs *args, int tag)
5443 encode_uint32(xdr, args->createmode);
5444 switch (args->createmode) {
5445 case NFS3_CREATE_UNCHECKED:
5446 case NFS3_CREATE_GUARDED:
5447 - encode_sattr3(xdr, args->sattr);
5448 + encode_sattr3(xdr, args->sattr, tag);
5450 case NFS3_CREATE_EXCLUSIVE:
5451 encode_createverf3(xdr, args->verifier);
5452 @@ -1049,7 +1055,7 @@ static void nfs3_xdr_enc_create3args(str
5453 const struct nfs3_createargs *args)
5455 encode_diropargs3(xdr, args->fh, args->name, args->len);
5456 - encode_createhow3(xdr, args);
5457 + encode_createhow3(xdr, args, req->rq_task->tk_client->cl_tag);
5461 @@ -1065,7 +1071,7 @@ static void nfs3_xdr_enc_mkdir3args(stru
5462 const struct nfs3_mkdirargs *args)
5464 encode_diropargs3(xdr, args->fh, args->name, args->len);
5465 - encode_sattr3(xdr, args->sattr);
5466 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5470 @@ -1082,9 +1088,9 @@ static void nfs3_xdr_enc_mkdir3args(stru
5473 static void encode_symlinkdata3(struct xdr_stream *xdr,
5474 - const struct nfs3_symlinkargs *args)
5475 + const struct nfs3_symlinkargs *args, int tag)
5477 - encode_sattr3(xdr, args->sattr);
5478 + encode_sattr3(xdr, args->sattr, tag);
5479 encode_nfspath3(xdr, args->pages, args->pathlen);
5482 @@ -1093,7 +1099,7 @@ static void nfs3_xdr_enc_symlink3args(st
5483 const struct nfs3_symlinkargs *args)
5485 encode_diropargs3(xdr, args->fromfh, args->fromname, args->fromlen);
5486 - encode_symlinkdata3(xdr, args);
5487 + encode_symlinkdata3(xdr, args, req->rq_task->tk_client->cl_tag);
5491 @@ -1121,24 +1127,24 @@ static void nfs3_xdr_enc_symlink3args(st
5494 static void encode_devicedata3(struct xdr_stream *xdr,
5495 - const struct nfs3_mknodargs *args)
5496 + const struct nfs3_mknodargs *args, int tag)
5498 - encode_sattr3(xdr, args->sattr);
5499 + encode_sattr3(xdr, args->sattr, tag);
5500 encode_specdata3(xdr, args->rdev);
5503 static void encode_mknoddata3(struct xdr_stream *xdr,
5504 - const struct nfs3_mknodargs *args)
5505 + const struct nfs3_mknodargs *args, int tag)
5507 encode_ftype3(xdr, args->type);
5508 switch (args->type) {
5511 - encode_devicedata3(xdr, args);
5512 + encode_devicedata3(xdr, args, tag);
5516 - encode_sattr3(xdr, args->sattr);
5517 + encode_sattr3(xdr, args->sattr, tag);
5521 @@ -1153,7 +1159,7 @@ static void nfs3_xdr_enc_mknod3args(stru
5522 const struct nfs3_mknodargs *args)
5524 encode_diropargs3(xdr, args->fh, args->name, args->len);
5525 - encode_mknoddata3(xdr, args);
5526 + encode_mknoddata3(xdr, args, req->rq_task->tk_client->cl_tag);
5530 diff -NurpP --minimal linux-3.1.6/fs/nfs/super.c linux-3.1.6-vs2.3.2.5/fs/nfs/super.c
5531 --- linux-3.1.6/fs/nfs/super.c 2011-10-24 18:45:27.000000000 +0200
5532 +++ linux-3.1.6-vs2.3.2.5/fs/nfs/super.c 2011-10-24 18:53:33.000000000 +0200
5534 #include <linux/nfs_xdr.h>
5535 #include <linux/magic.h>
5536 #include <linux/parser.h>
5537 +#include <linux/vs_tag.h>
5539 #include <asm/system.h>
5540 #include <asm/uaccess.h>
5541 @@ -87,6 +88,7 @@ enum {
5542 Opt_sharecache, Opt_nosharecache,
5543 Opt_resvport, Opt_noresvport,
5544 Opt_fscache, Opt_nofscache,
5545 + Opt_tag, Opt_notag,
5547 /* Mount options that take integer arguments */
5549 @@ -100,6 +102,7 @@ enum {
5555 /* Mount options that take string arguments */
5556 Opt_sec, Opt_proto, Opt_mountproto, Opt_mounthost,
5557 @@ -180,6 +183,10 @@ static const match_table_t nfs_mount_opt
5558 { Opt_fscache_uniq, "fsc=%s" },
5559 { Opt_local_lock, "local_lock=%s" },
5561 + { Opt_tag, "tag" },
5562 + { Opt_notag, "notag" },
5563 + { Opt_tagid, "tagid=%u" },
5568 @@ -650,6 +657,7 @@ static void nfs_show_mount_options(struc
5569 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
5570 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
5571 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
5572 + { NFS_MOUNT_TAGGED, ",tag", "" },
5575 const struct proc_nfs_info *nfs_infop;
5576 @@ -1198,6 +1206,14 @@ static int nfs_parse_mount_options(char
5577 kfree(mnt->fscache_uniq);
5578 mnt->fscache_uniq = NULL;
5580 +#ifndef CONFIG_TAGGING_NONE
5582 + mnt->flags |= NFS_MOUNT_TAGGED;
5585 + mnt->flags &= ~NFS_MOUNT_TAGGED;
5590 * options that take numeric values
5591 @@ -1304,6 +1320,12 @@ static int nfs_parse_mount_options(char
5592 goto out_invalid_value;
5593 mnt->minorversion = option;
5595 +#ifdef CONFIG_PROPAGATE
5598 + nfs_data.flags |= NFS_MOUNT_TAGGED;
5603 * options that take text values
5604 diff -NurpP --minimal linux-3.1.6/fs/nfsd/auth.c linux-3.1.6-vs2.3.2.5/fs/nfsd/auth.c
5605 --- linux-3.1.6/fs/nfsd/auth.c 2010-02-25 11:52:05.000000000 +0100
5606 +++ linux-3.1.6-vs2.3.2.5/fs/nfsd/auth.c 2011-10-24 18:53:33.000000000 +0200
5608 /* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */
5610 #include <linux/sched.h>
5611 +#include <linux/vs_tag.h>
5615 @@ -36,6 +37,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
5617 new->fsuid = rqstp->rq_cred.cr_uid;
5618 new->fsgid = rqstp->rq_cred.cr_gid;
5619 + /* FIXME: this desperately needs a tag :)
5620 + new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
5623 rqgi = rqstp->rq_cred.cr_group_info;
5625 diff -NurpP --minimal linux-3.1.6/fs/nfsd/nfs3xdr.c linux-3.1.6-vs2.3.2.5/fs/nfsd/nfs3xdr.c
5626 --- linux-3.1.6/fs/nfsd/nfs3xdr.c 2011-07-22 11:18:05.000000000 +0200
5627 +++ linux-3.1.6-vs2.3.2.5/fs/nfsd/nfs3xdr.c 2011-10-24 18:53:33.000000000 +0200
5631 #include <linux/namei.h>
5632 +#include <linux/vs_tag.h>
5636 @@ -95,6 +96,8 @@ static __be32 *
5637 decode_sattr3(__be32 *p, struct iattr *iap)
5645 @@ -104,12 +107,15 @@ decode_sattr3(__be32 *p, struct iattr *i
5648 iap->ia_valid |= ATTR_UID;
5649 - iap->ia_uid = ntohl(*p++);
5650 + uid = ntohl(*p++);
5653 iap->ia_valid |= ATTR_GID;
5654 - iap->ia_gid = ntohl(*p++);
5655 + gid = ntohl(*p++);
5657 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
5658 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
5659 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
5663 @@ -165,8 +171,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
5664 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
5665 *p++ = htonl((u32) stat->mode);
5666 *p++ = htonl((u32) stat->nlink);
5667 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
5668 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
5669 + *p++ = htonl((u32) nfsd_ruid(rqstp,
5670 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5671 + stat->uid, stat->tag)));
5672 + *p++ = htonl((u32) nfsd_rgid(rqstp,
5673 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5674 + stat->gid, stat->tag)));
5675 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
5676 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
5678 diff -NurpP --minimal linux-3.1.6/fs/nfsd/nfs4xdr.c linux-3.1.6-vs2.3.2.5/fs/nfsd/nfs4xdr.c
5679 --- linux-3.1.6/fs/nfsd/nfs4xdr.c 2011-12-23 16:04:07.000000000 +0100
5680 +++ linux-3.1.6-vs2.3.2.5/fs/nfsd/nfs4xdr.c 2011-11-15 17:08:44.000000000 +0100
5682 #include <linux/utsname.h>
5683 #include <linux/pagemap.h>
5684 #include <linux/sunrpc/svcauth_gss.h>
5685 +#include <linux/vs_tag.h>
5689 @@ -2177,14 +2178,18 @@ out_acl:
5690 WRITE32(stat.nlink);
5692 if (bmval1 & FATTR4_WORD1_OWNER) {
5693 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
5694 + status = nfsd4_encode_user(rqstp,
5695 + TAGINO_UID(DX_TAG(dentry->d_inode),
5696 + stat.uid, stat.tag), &p, &buflen);
5697 if (status == nfserr_resource)
5702 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
5703 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
5704 + status = nfsd4_encode_group(rqstp,
5705 + TAGINO_GID(DX_TAG(dentry->d_inode),
5706 + stat.gid, stat.tag), &p, &buflen);
5707 if (status == nfserr_resource)
5710 diff -NurpP --minimal linux-3.1.6/fs/nfsd/nfsxdr.c linux-3.1.6-vs2.3.2.5/fs/nfsd/nfsxdr.c
5711 --- linux-3.1.6/fs/nfsd/nfsxdr.c 2011-05-22 16:17:53.000000000 +0200
5712 +++ linux-3.1.6-vs2.3.2.5/fs/nfsd/nfsxdr.c 2011-10-24 18:53:33.000000000 +0200
5717 +#include <linux/vs_tag.h>
5719 #define NFSDDBG_FACILITY NFSDDBG_XDR
5721 @@ -88,6 +89,8 @@ static __be32 *
5722 decode_sattr(__be32 *p, struct iattr *iap)
5730 @@ -101,12 +104,15 @@ decode_sattr(__be32 *p, struct iattr *ia
5732 if ((tmp = ntohl(*p++)) != (u32)-1) {
5733 iap->ia_valid |= ATTR_UID;
5734 - iap->ia_uid = tmp;
5737 if ((tmp = ntohl(*p++)) != (u32)-1) {
5738 iap->ia_valid |= ATTR_GID;
5739 - iap->ia_gid = tmp;
5742 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
5743 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
5744 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
5745 if ((tmp = ntohl(*p++)) != (u32)-1) {
5746 iap->ia_valid |= ATTR_SIZE;
5748 @@ -151,8 +157,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
5749 *p++ = htonl(nfs_ftypes[type >> 12]);
5750 *p++ = htonl((u32) stat->mode);
5751 *p++ = htonl((u32) stat->nlink);
5752 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
5753 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
5754 + *p++ = htonl((u32) nfsd_ruid(rqstp,
5755 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
5756 + *p++ = htonl((u32) nfsd_rgid(rqstp,
5757 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
5759 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
5760 *p++ = htonl(NFS_MAXPATHLEN);
5761 diff -NurpP --minimal linux-3.1.6/fs/ocfs2/dlmglue.c linux-3.1.6-vs2.3.2.5/fs/ocfs2/dlmglue.c
5762 --- linux-3.1.6/fs/ocfs2/dlmglue.c 2011-05-22 16:17:53.000000000 +0200
5763 +++ linux-3.1.6-vs2.3.2.5/fs/ocfs2/dlmglue.c 2011-10-24 18:53:33.000000000 +0200
5764 @@ -2041,6 +2041,7 @@ static void __ocfs2_stuff_meta_lvb(struc
5765 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
5766 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
5767 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
5768 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
5769 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
5770 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
5771 lvb->lvb_iatime_packed =
5772 @@ -2091,6 +2092,7 @@ static void ocfs2_refresh_inode_from_lvb
5774 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
5775 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
5776 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
5777 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
5778 inode->i_nlink = be16_to_cpu(lvb->lvb_inlink);
5779 ocfs2_unpack_timespec(&inode->i_atime,
5780 diff -NurpP --minimal linux-3.1.6/fs/ocfs2/dlmglue.h linux-3.1.6-vs2.3.2.5/fs/ocfs2/dlmglue.h
5781 --- linux-3.1.6/fs/ocfs2/dlmglue.h 2010-10-21 13:07:50.000000000 +0200
5782 +++ linux-3.1.6-vs2.3.2.5/fs/ocfs2/dlmglue.h 2011-10-24 18:53:33.000000000 +0200
5783 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
5786 __be32 lvb_igeneration;
5787 - __be32 lvb_reserved2;
5789 + __be16 lvb_reserved2;
5792 #define OCFS2_QINFO_LVB_VERSION 1
5793 diff -NurpP --minimal linux-3.1.6/fs/ocfs2/file.c linux-3.1.6-vs2.3.2.5/fs/ocfs2/file.c
5794 --- linux-3.1.6/fs/ocfs2/file.c 2011-10-24 18:45:27.000000000 +0200
5795 +++ linux-3.1.6-vs2.3.2.5/fs/ocfs2/file.c 2011-10-24 18:53:33.000000000 +0200
5796 @@ -1123,7 +1123,7 @@ int ocfs2_setattr(struct dentry *dentry,
5797 attr->ia_valid &= ~ATTR_SIZE;
5799 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
5800 - | ATTR_GID | ATTR_UID | ATTR_MODE)
5801 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
5802 if (!(attr->ia_valid & OCFS2_VALID_ATTRS))
5805 diff -NurpP --minimal linux-3.1.6/fs/ocfs2/inode.c linux-3.1.6-vs2.3.2.5/fs/ocfs2/inode.c
5806 --- linux-3.1.6/fs/ocfs2/inode.c 2011-05-22 16:17:53.000000000 +0200
5807 +++ linux-3.1.6-vs2.3.2.5/fs/ocfs2/inode.c 2011-10-24 18:53:33.000000000 +0200
5809 #include <linux/highmem.h>
5810 #include <linux/pagemap.h>
5811 #include <linux/quotaops.h>
5812 +#include <linux/vs_tag.h>
5814 #include <asm/byteorder.h>
5816 @@ -78,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode
5818 unsigned int flags = OCFS2_I(inode)->ip_attr;
5820 - inode->i_flags &= ~(S_IMMUTABLE |
5821 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5822 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5824 if (flags & OCFS2_IMMUTABLE_FL)
5825 inode->i_flags |= S_IMMUTABLE;
5826 + if (flags & OCFS2_IXUNLINK_FL)
5827 + inode->i_flags |= S_IXUNLINK;
5829 if (flags & OCFS2_SYNC_FL)
5830 inode->i_flags |= S_SYNC;
5831 @@ -92,25 +95,44 @@ void ocfs2_set_inode_flags(struct inode
5832 inode->i_flags |= S_NOATIME;
5833 if (flags & OCFS2_DIRSYNC_FL)
5834 inode->i_flags |= S_DIRSYNC;
5836 + inode->i_vflags &= ~(V_BARRIER | V_COW);
5838 + if (flags & OCFS2_BARRIER_FL)
5839 + inode->i_vflags |= V_BARRIER;
5840 + if (flags & OCFS2_COW_FL)
5841 + inode->i_vflags |= V_COW;
5844 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
5845 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
5847 unsigned int flags = oi->vfs_inode.i_flags;
5848 + unsigned int vflags = oi->vfs_inode.i_vflags;
5850 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
5851 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
5852 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
5853 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
5855 + if (flags & S_IMMUTABLE)
5856 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
5857 + if (flags & S_IXUNLINK)
5858 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
5860 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
5861 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
5863 oi->ip_attr |= OCFS2_SYNC_FL;
5864 if (flags & S_APPEND)
5865 oi->ip_attr |= OCFS2_APPEND_FL;
5866 - if (flags & S_IMMUTABLE)
5867 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
5868 if (flags & S_NOATIME)
5869 oi->ip_attr |= OCFS2_NOATIME_FL;
5870 if (flags & S_DIRSYNC)
5871 oi->ip_attr |= OCFS2_DIRSYNC_FL;
5873 + if (vflags & V_BARRIER)
5874 + oi->ip_attr |= OCFS2_BARRIER_FL;
5875 + if (vflags & V_COW)
5876 + oi->ip_attr |= OCFS2_COW_FL;
5879 struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
5880 @@ -241,6 +263,8 @@ void ocfs2_populate_inode(struct inode *
5881 struct super_block *sb;
5882 struct ocfs2_super *osb;
5889 @@ -269,8 +293,12 @@ void ocfs2_populate_inode(struct inode *
5890 inode->i_generation = le32_to_cpu(fe->i_generation);
5891 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
5892 inode->i_mode = le16_to_cpu(fe->i_mode);
5893 - inode->i_uid = le32_to_cpu(fe->i_uid);
5894 - inode->i_gid = le32_to_cpu(fe->i_gid);
5895 + uid = le32_to_cpu(fe->i_uid);
5896 + gid = le32_to_cpu(fe->i_gid);
5897 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5898 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5899 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
5900 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
5902 /* Fast symlinks will have i_size but no allocated clusters. */
5903 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
5904 diff -NurpP --minimal linux-3.1.6/fs/ocfs2/inode.h linux-3.1.6-vs2.3.2.5/fs/ocfs2/inode.h
5905 --- linux-3.1.6/fs/ocfs2/inode.h 2011-01-05 21:50:26.000000000 +0100
5906 +++ linux-3.1.6-vs2.3.2.5/fs/ocfs2/inode.h 2011-10-24 18:53:33.000000000 +0200
5907 @@ -151,6 +151,7 @@ struct buffer_head *ocfs2_bread(struct i
5909 void ocfs2_set_inode_flags(struct inode *inode);
5910 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
5911 +int ocfs2_sync_flags(struct inode *inode, int, int);
5913 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
5915 diff -NurpP --minimal linux-3.1.6/fs/ocfs2/ioctl.c linux-3.1.6-vs2.3.2.5/fs/ocfs2/ioctl.c
5916 --- linux-3.1.6/fs/ocfs2/ioctl.c 2011-07-22 11:18:06.000000000 +0200
5917 +++ linux-3.1.6-vs2.3.2.5/fs/ocfs2/ioctl.c 2011-10-24 18:53:33.000000000 +0200
5918 @@ -78,7 +78,41 @@ static int ocfs2_get_inode_attr(struct i
5922 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
5923 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
5925 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
5926 + struct buffer_head *bh = NULL;
5927 + handle_t *handle = NULL;
5930 + status = ocfs2_inode_lock(inode, &bh, 1);
5932 + mlog_errno(status);
5935 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
5936 + if (IS_ERR(handle)) {
5937 + status = PTR_ERR(handle);
5938 + mlog_errno(status);
5942 + inode->i_flags = flags;
5943 + inode->i_vflags = vflags;
5944 + ocfs2_get_inode_flags(OCFS2_I(inode));
5946 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
5948 + mlog_errno(status);
5950 + ocfs2_commit_trans(osb, handle);
5952 + ocfs2_inode_unlock(inode, 1);
5957 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
5960 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
5961 @@ -103,6 +137,11 @@ static int ocfs2_set_inode_attr(struct i
5962 if (!S_ISDIR(inode->i_mode))
5963 flags &= ~OCFS2_DIRSYNC_FL;
5965 + if (IS_BARRIER(inode)) {
5966 + vxwprintk_task(1, "messing with the barrier.");
5970 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
5971 if (IS_ERR(handle)) {
5972 status = PTR_ERR(handle);
5973 @@ -880,6 +919,7 @@ bail:
5978 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5980 struct inode *inode = filp->f_path.dentry->d_inode;
5981 diff -NurpP --minimal linux-3.1.6/fs/ocfs2/namei.c linux-3.1.6-vs2.3.2.5/fs/ocfs2/namei.c
5982 --- linux-3.1.6/fs/ocfs2/namei.c 2011-10-24 18:45:27.000000000 +0200
5983 +++ linux-3.1.6-vs2.3.2.5/fs/ocfs2/namei.c 2011-10-24 18:53:33.000000000 +0200
5985 #include <linux/slab.h>
5986 #include <linux/highmem.h>
5987 #include <linux/quotaops.h>
5988 +#include <linux/vs_tag.h>
5990 #include <cluster/masklog.h>
5992 @@ -477,6 +478,7 @@ static int __ocfs2_mknod_locked(struct i
5993 struct ocfs2_dinode *fe = NULL;
5994 struct ocfs2_extent_list *fel;
6000 @@ -514,8 +516,11 @@ static int __ocfs2_mknod_locked(struct i
6001 fe->i_suballoc_loc = cpu_to_le64(suballoc_loc);
6002 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
6003 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
6004 - fe->i_uid = cpu_to_le32(inode->i_uid);
6005 - fe->i_gid = cpu_to_le32(inode->i_gid);
6007 + tag = dx_current_fstag(osb->sb);
6008 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
6009 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
6010 + inode->i_tag = tag;
6011 fe->i_mode = cpu_to_le16(inode->i_mode);
6012 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
6013 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
6014 diff -NurpP --minimal linux-3.1.6/fs/ocfs2/ocfs2.h linux-3.1.6-vs2.3.2.5/fs/ocfs2/ocfs2.h
6015 --- linux-3.1.6/fs/ocfs2/ocfs2.h 2011-05-22 16:17:53.000000000 +0200
6016 +++ linux-3.1.6-vs2.3.2.5/fs/ocfs2/ocfs2.h 2011-10-24 18:53:33.000000000 +0200
6017 @@ -272,6 +272,7 @@ enum ocfs2_mount_options
6019 OCFS2_MOUNT_HB_NONE = 1 << 13, /* No heartbeat */
6020 OCFS2_MOUNT_HB_GLOBAL = 1 << 14, /* Global heartbeat */
6021 + OCFS2_MOUNT_TAGGED = 1 << 15, /* use tagging */
6024 #define OCFS2_OSB_SOFT_RO 0x0001
6025 diff -NurpP --minimal linux-3.1.6/fs/ocfs2/ocfs2_fs.h linux-3.1.6-vs2.3.2.5/fs/ocfs2/ocfs2_fs.h
6026 --- linux-3.1.6/fs/ocfs2/ocfs2_fs.h 2011-05-22 16:17:53.000000000 +0200
6027 +++ linux-3.1.6-vs2.3.2.5/fs/ocfs2/ocfs2_fs.h 2011-10-24 18:53:33.000000000 +0200
6028 @@ -266,6 +266,11 @@
6029 #define OCFS2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
6030 #define OCFS2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
6032 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
6034 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
6035 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
6037 #define OCFS2_FL_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
6038 #define OCFS2_FL_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
6040 diff -NurpP --minimal linux-3.1.6/fs/ocfs2/super.c linux-3.1.6-vs2.3.2.5/fs/ocfs2/super.c
6041 --- linux-3.1.6/fs/ocfs2/super.c 2011-07-22 11:18:06.000000000 +0200
6042 +++ linux-3.1.6-vs2.3.2.5/fs/ocfs2/super.c 2011-10-24 18:53:33.000000000 +0200
6043 @@ -184,6 +184,7 @@ enum {
6047 + Opt_tag, Opt_notag, Opt_tagid,
6051 @@ -215,6 +216,9 @@ static const match_table_t tokens = {
6052 {Opt_coherency_full, "coherency=full"},
6053 {Opt_resv_level, "resv_level=%u"},
6054 {Opt_dir_resv_level, "dir_resv_level=%u"},
6056 + {Opt_notag, "notag"},
6057 + {Opt_tagid, "tagid=%u"},
6061 @@ -662,6 +666,13 @@ static int ocfs2_remount(struct super_bl
6065 + if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
6066 + (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
6068 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
6072 /* We're going to/from readonly mode. */
6073 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
6074 /* Disable quota accounting before remounting RO */
6075 @@ -1177,6 +1188,9 @@ static int ocfs2_fill_super(struct super
6077 ocfs2_complete_mount_recovery(osb);
6079 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
6080 + sb->s_flags |= MS_TAGGED;
6082 if (ocfs2_mount_local(osb))
6083 snprintf(nodestr, sizeof(nodestr), "local");
6085 @@ -1506,6 +1520,20 @@ static int ocfs2_parse_options(struct su
6086 option < OCFS2_MAX_RESV_LEVEL)
6087 mopt->dir_resv_level = option;
6089 +#ifndef CONFIG_TAGGING_NONE
6091 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6094 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
6097 +#ifdef CONFIG_PROPAGATE
6100 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6105 "Unrecognized mount option \"%s\" "
6106 diff -NurpP --minimal linux-3.1.6/fs/open.c linux-3.1.6-vs2.3.2.5/fs/open.c
6107 --- linux-3.1.6/fs/open.c 2011-10-24 18:45:27.000000000 +0200
6108 +++ linux-3.1.6-vs2.3.2.5/fs/open.c 2011-10-30 02:06:37.000000000 +0100
6110 #include <linux/fs_struct.h>
6111 #include <linux/ima.h>
6112 #include <linux/dnotify.h>
6113 +#include <linux/vs_base.h>
6114 +#include <linux/vs_limit.h>
6115 +#include <linux/vs_tag.h>
6116 +#include <linux/vs_cowbl.h>
6117 +#include <linux/vserver/dlimit.h>
6119 #include "internal.h"
6121 @@ -74,6 +79,12 @@ static long do_sys_truncate(const char _
6122 error = user_path(pathname, &path);
6126 +#ifdef CONFIG_VSERVER_COWBL
6127 + error = cow_check_and_break(&path);
6129 + goto dput_and_out;
6131 inode = path.dentry->d_inode;
6133 /* For directories it's -EISDIR, for other non-regulars - -EINVAL */
6134 @@ -489,6 +500,10 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
6136 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
6138 +#ifdef CONFIG_VSERVER_COWBL
6139 + error = cow_check_and_break(&path);
6142 error = chmod_common(&path, mode);
6145 @@ -509,11 +524,11 @@ static int chown_common(struct path *pat
6146 newattrs.ia_valid = ATTR_CTIME;
6147 if (user != (uid_t) -1) {
6148 newattrs.ia_valid |= ATTR_UID;
6149 - newattrs.ia_uid = user;
6150 + newattrs.ia_uid = dx_map_uid(user);
6152 if (group != (gid_t) -1) {
6153 newattrs.ia_valid |= ATTR_GID;
6154 - newattrs.ia_gid = group;
6155 + newattrs.ia_gid = dx_map_gid(group);
6157 if (!S_ISDIR(inode->i_mode))
6158 newattrs.ia_valid |=
6159 @@ -538,6 +553,10 @@ SYSCALL_DEFINE3(chown, const char __user
6160 error = mnt_want_write(path.mnt);
6163 +#ifdef CONFIG_VSERVER_COWBL
6164 + error = cow_check_and_break(&path);
6167 error = chown_common(&path, user, group);
6168 mnt_drop_write(path.mnt);
6170 @@ -565,6 +584,10 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
6171 error = mnt_want_write(path.mnt);
6174 +#ifdef CONFIG_VSERVER_COWBL
6175 + error = cow_check_and_break(&path);
6178 error = chown_common(&path, user, group);
6179 mnt_drop_write(path.mnt);
6181 @@ -584,6 +607,10 @@ SYSCALL_DEFINE3(lchown, const char __use
6182 error = mnt_want_write(path.mnt);
6185 +#ifdef CONFIG_VSERVER_COWBL
6186 + error = cow_check_and_break(&path);
6189 error = chown_common(&path, user, group);
6190 mnt_drop_write(path.mnt);
6192 @@ -835,6 +862,7 @@ static void __put_unused_fd(struct files
6193 __FD_CLR(fd, fdt->open_fds);
6194 if (fd < files->next_fd)
6195 files->next_fd = fd;
6196 + vx_openfd_dec(fd);
6199 void put_unused_fd(unsigned int fd)
6200 diff -NurpP --minimal linux-3.1.6/fs/proc/array.c linux-3.1.6-vs2.3.2.5/fs/proc/array.c
6201 --- linux-3.1.6/fs/proc/array.c 2011-10-24 18:45:27.000000000 +0200
6202 +++ linux-3.1.6-vs2.3.2.5/fs/proc/array.c 2011-10-24 18:53:33.000000000 +0200
6204 #include <linux/pid_namespace.h>
6205 #include <linux/ptrace.h>
6206 #include <linux/tracehook.h>
6207 +#include <linux/vs_context.h>
6208 +#include <linux/vs_network.h>
6210 #include <asm/pgtable.h>
6211 #include <asm/processor.h>
6212 @@ -170,6 +172,9 @@ static inline void task_state(struct seq
6214 ppid = pid_alive(p) ?
6215 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
6216 + if (unlikely(vx_current_initpid(p->pid)))
6221 struct task_struct *tracer = ptrace_parent(p);
6222 @@ -287,7 +292,7 @@ static inline void task_sig(struct seq_f
6225 static void render_cap_t(struct seq_file *m, const char *header,
6227 + struct vx_info *vxi, kernel_cap_t *a)
6231 @@ -312,10 +317,11 @@ static inline void task_cap(struct seq_f
6232 cap_bset = cred->cap_bset;
6235 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
6236 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
6237 - render_cap_t(m, "CapEff:\t", &cap_effective);
6238 - render_cap_t(m, "CapBnd:\t", &cap_bset);
6239 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
6240 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
6241 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
6242 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
6243 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
6246 static inline void task_context_switch_counts(struct seq_file *m,
6247 @@ -337,6 +343,42 @@ static void task_cpus_allowed(struct seq
6251 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6252 + struct pid *pid, struct task_struct *task)
6254 + seq_printf(m, "Proxy:\t%p(%c)\n"
6262 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6263 + atomic_read(&task->nsproxy->count),
6264 + task->nsproxy->uts_ns,
6265 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6266 + task->nsproxy->ipc_ns,
6267 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6268 + task->nsproxy->mnt_ns,
6269 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6270 + task->nsproxy->pid_ns,
6271 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6272 + task->nsproxy->net_ns,
6273 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6277 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6279 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6282 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6283 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6287 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6288 struct pid *pid, struct task_struct *task)
6290 @@ -353,6 +395,7 @@ int proc_pid_status(struct seq_file *m,
6292 task_cpus_allowed(m, task);
6293 cpuset_task_status_allowed(m, task);
6294 + task_vs_id(m, task);
6295 task_context_switch_counts(m, task);
6298 @@ -462,6 +505,17 @@ static int do_task_stat(struct seq_file
6299 /* convert nsec -> ticks */
6300 start_time = nsec_to_clock_t(start_time);
6302 + /* fixup start time for virt uptime */
6303 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6304 + unsigned long long bias =
6305 + current->vx_info->cvirt.bias_clock;
6307 + if (start_time > bias)
6308 + start_time -= bias;
6313 seq_printf(m, "%d (%s) %c %d %d %d %d %d %u %lu \
6314 %lu %lu %lu %lu %lu %ld %ld %ld %ld %d 0 %llu %lu %ld %lu %lu %lu %lu %lu \
6315 %lu %lu %lu %lu %lu %lu %lu %lu %d %d %u %u %llu %lu %ld\n",
6316 diff -NurpP --minimal linux-3.1.6/fs/proc/base.c linux-3.1.6-vs2.3.2.5/fs/proc/base.c
6317 --- linux-3.1.6/fs/proc/base.c 2011-10-24 18:45:27.000000000 +0200
6318 +++ linux-3.1.6-vs2.3.2.5/fs/proc/base.c 2011-10-24 18:53:33.000000000 +0200
6320 #include <linux/pid_namespace.h>
6321 #include <linux/fs_struct.h>
6322 #include <linux/slab.h>
6323 +#include <linux/vs_context.h>
6324 +#include <linux/vs_network.h>
6325 #ifdef CONFIG_HARDWALL
6326 #include <asm/hardwall.h>
6328 @@ -1102,11 +1104,16 @@ static ssize_t oom_adjust_write(struct f
6332 - if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
6333 + if (oom_adjust < task->signal->oom_adj &&
6334 + !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
6339 + /* prevent guest processes from circumventing the oom killer */
6340 + if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
6341 + oom_adjust = OOM_ADJUST_MIN;
6343 if (oom_adjust != task->signal->oom_adj) {
6344 if (oom_adjust == OOM_DISABLE)
6345 atomic_inc(&task->mm->oom_disable_count);
6346 @@ -1274,7 +1281,7 @@ static ssize_t proc_loginuid_write(struc
6350 - if (!capable(CAP_AUDIT_CONTROL))
6351 + if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
6355 @@ -1721,6 +1728,8 @@ struct inode *proc_pid_make_inode(struct
6356 inode->i_gid = cred->egid;
6359 + /* procfs is xid tagged */
6360 + inode->i_tag = (tag_t)vx_task_xid(task);
6361 security_task_to_inode(task, inode);
6364 @@ -1757,6 +1766,8 @@ int pid_getattr(struct vfsmount *mnt, st
6368 +static unsigned name_to_int(struct dentry *dentry);
6371 * Exceptional case: normally we are not allowed to unhash a busy
6372 * directory. In this case, however, we can do it - no aliasing problems
6373 @@ -1785,6 +1796,12 @@ int pid_revalidate(struct dentry *dentry
6374 task = get_proc_task(inode);
6377 + unsigned pid = name_to_int(dentry);
6379 + if (pid != ~0U && pid != vx_map_pid(task->pid)) {
6380 + put_task_struct(task);
6383 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
6384 task_dumpable(task)) {
6386 @@ -1801,6 +1818,7 @@ int pid_revalidate(struct dentry *dentry
6387 put_task_struct(task);
6394 @@ -2290,6 +2308,13 @@ static struct dentry *proc_pident_lookup
6398 + /* TODO: maybe we can come up with a generic approach? */
6399 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
6400 + (dentry->d_name.len == 5) &&
6401 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
6402 + !memcmp(dentry->d_name.name, "ninfo", 5)))
6406 * Yes, it does not scale. And it should not. Don't add
6407 * new entries into /proc/<tgid>/ without very good reasons.
6408 @@ -2675,7 +2700,7 @@ out_iput:
6409 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
6411 struct dentry *error;
6412 - struct task_struct *task = get_proc_task(dir);
6413 + struct task_struct *task = get_proc_task_real(dir);
6414 const struct pid_entry *p, *last;
6416 error = ERR_PTR(-ENOENT);
6417 @@ -2782,6 +2807,9 @@ static int proc_pid_personality(struct s
6418 static const struct file_operations proc_task_operations;
6419 static const struct inode_operations proc_task_inode_operations;
6421 +extern int proc_pid_vx_info(struct task_struct *, char *);
6422 +extern int proc_pid_nx_info(struct task_struct *, char *);
6424 static const struct pid_entry tgid_base_stuff[] = {
6425 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
6426 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
6427 @@ -2845,6 +2873,8 @@ static const struct pid_entry tgid_base_
6428 #ifdef CONFIG_CGROUPS
6429 REG("cgroup", S_IRUGO, proc_cgroup_operations),
6431 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
6432 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
6433 INF("oom_score", S_IRUGO, proc_oom_score),
6434 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
6435 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
6436 @@ -2864,6 +2894,7 @@ static const struct pid_entry tgid_base_
6437 #ifdef CONFIG_HARDWALL
6438 INF("hardwall", S_IRUGO, proc_pid_hardwall),
6440 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
6443 static int proc_tgid_base_readdir(struct file * filp,
6444 @@ -3056,7 +3087,7 @@ retry:
6446 pid = find_ge_pid(iter.tgid, ns);
6448 - iter.tgid = pid_nr_ns(pid, ns);
6449 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
6450 iter.task = pid_task(pid, PIDTYPE_PID);
6451 /* What we to know is if the pid we have find is the
6452 * pid of a thread_group_leader. Testing for task
6453 @@ -3086,7 +3117,7 @@ static int proc_pid_fill_cache(struct fi
6454 struct tgid_iter iter)
6456 char name[PROC_NUMBUF];
6457 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
6458 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
6459 return proc_fill_cache(filp, dirent, filldir, name, len,
6460 proc_pid_instantiate, iter.task, NULL);
6462 @@ -3103,7 +3134,7 @@ int proc_pid_readdir(struct file * filp,
6464 nr = filp->f_pos - FIRST_PROCESS_ENTRY;
6466 - reaper = get_proc_task(filp->f_path.dentry->d_inode);
6467 + reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
6471 @@ -3120,6 +3151,8 @@ int proc_pid_readdir(struct file * filp,
6473 iter.tgid += 1, iter = next_tgid(ns, iter)) {
6474 filp->f_pos = iter.tgid + TGID_OFFSET;
6475 + if (!vx_proc_task_visible(iter.task))
6477 if (proc_pid_fill_cache(filp, dirent, filldir, iter) < 0) {
6478 put_task_struct(iter.task);
6480 @@ -3273,6 +3306,8 @@ static struct dentry *proc_task_lookup(s
6481 tid = name_to_int(dentry);
6484 + if (vx_current_initpid(tid))
6487 ns = dentry->d_sb->s_fs_info;
6489 diff -NurpP --minimal linux-3.1.6/fs/proc/generic.c linux-3.1.6-vs2.3.2.5/fs/proc/generic.c
6490 --- linux-3.1.6/fs/proc/generic.c 2011-10-24 18:45:27.000000000 +0200
6491 +++ linux-3.1.6-vs2.3.2.5/fs/proc/generic.c 2011-10-24 18:53:33.000000000 +0200
6493 #include <linux/bitops.h>
6494 #include <linux/spinlock.h>
6495 #include <linux/completion.h>
6496 +#include <linux/vserver/inode.h>
6497 #include <asm/uaccess.h>
6499 #include "internal.h"
6500 @@ -424,11 +425,15 @@ struct dentry *proc_lookup_de(struct pro
6501 for (de = de->subdir; de ; de = de->next) {
6502 if (de->namelen != dentry->d_name.len)
6504 + if (!vx_hide_check(0, de->vx_flags))
6506 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
6508 spin_unlock(&proc_subdir_lock);
6510 inode = proc_get_inode(dir->i_sb, de);
6511 + /* generic proc entries belong to the host */
6516 @@ -506,6 +511,8 @@ int proc_readdir_de(struct proc_dir_entr
6518 /* filldir passes info to user space */
6520 + if (!vx_hide_check(0, de->vx_flags))
6522 spin_unlock(&proc_subdir_lock);
6523 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
6524 de->low_ino, de->mode >> 12) < 0) {
6525 @@ -513,6 +520,7 @@ int proc_readdir_de(struct proc_dir_entr
6528 spin_lock(&proc_subdir_lock);
6533 @@ -626,6 +634,7 @@ static struct proc_dir_entry *__proc_cre
6535 atomic_set(&ent->count, 1);
6537 + ent->vx_flags = IATTR_PROC_DEFAULT;
6538 spin_lock_init(&ent->pde_unload_lock);
6539 ent->pde_unload_completion = NULL;
6540 INIT_LIST_HEAD(&ent->pde_openers);
6541 @@ -649,7 +658,8 @@ struct proc_dir_entry *proc_symlink(cons
6547 + ent->vx_flags = IATTR_PROC_SYMLINK;
6551 diff -NurpP --minimal linux-3.1.6/fs/proc/inode.c linux-3.1.6-vs2.3.2.5/fs/proc/inode.c
6552 --- linux-3.1.6/fs/proc/inode.c 2011-10-24 18:45:27.000000000 +0200
6553 +++ linux-3.1.6-vs2.3.2.5/fs/proc/inode.c 2011-10-24 18:53:33.000000000 +0200
6554 @@ -442,6 +442,8 @@ struct inode *proc_get_inode(struct supe
6555 inode->i_uid = de->uid;
6556 inode->i_gid = de->gid;
6559 + PROC_I(inode)->vx_flags = de->vx_flags;
6561 inode->i_size = de->size;
6563 diff -NurpP --minimal linux-3.1.6/fs/proc/internal.h linux-3.1.6-vs2.3.2.5/fs/proc/internal.h
6564 --- linux-3.1.6/fs/proc/internal.h 2011-07-22 11:18:06.000000000 +0200
6565 +++ linux-3.1.6-vs2.3.2.5/fs/proc/internal.h 2011-10-24 18:53:33.000000000 +0200
6569 #include <linux/proc_fs.h>
6570 +#include <linux/vs_pid.h>
6572 extern struct proc_dir_entry proc_root;
6573 #ifdef CONFIG_PROC_SYSCTL
6574 @@ -51,6 +52,9 @@ extern int proc_pid_status(struct seq_fi
6575 struct pid *pid, struct task_struct *task);
6576 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
6577 struct pid *pid, struct task_struct *task);
6578 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6579 + struct pid *pid, struct task_struct *task);
6581 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
6583 extern const struct file_operations proc_maps_operations;
6584 @@ -76,11 +80,16 @@ static inline struct pid *proc_pid(struc
6585 return PROC_I(inode)->pid;
6588 -static inline struct task_struct *get_proc_task(struct inode *inode)
6589 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
6591 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
6594 +static inline struct task_struct *get_proc_task(struct inode *inode)
6596 + return vx_get_proc_task(inode, proc_pid(inode));
6599 static inline int proc_fd(struct inode *inode)
6601 return PROC_I(inode)->fd;
6602 diff -NurpP --minimal linux-3.1.6/fs/proc/loadavg.c linux-3.1.6-vs2.3.2.5/fs/proc/loadavg.c
6603 --- linux-3.1.6/fs/proc/loadavg.c 2009-09-10 15:26:23.000000000 +0200
6604 +++ linux-3.1.6-vs2.3.2.5/fs/proc/loadavg.c 2011-10-24 18:53:33.000000000 +0200
6607 static int loadavg_proc_show(struct seq_file *m, void *v)
6609 + unsigned long running;
6610 + unsigned int threads;
6611 unsigned long avnrun[3];
6613 get_avenrun(avnrun, FIXED_1/200, 0);
6615 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
6616 + struct vx_info *vxi = current_vx_info();
6618 + running = atomic_read(&vxi->cvirt.nr_running);
6619 + threads = atomic_read(&vxi->cvirt.nr_threads);
6621 + running = nr_running();
6622 + threads = nr_threads;
6625 seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
6626 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
6627 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
6628 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
6629 - nr_running(), nr_threads,
6631 task_active_pid_ns(current)->last_pid);
6634 diff -NurpP --minimal linux-3.1.6/fs/proc/meminfo.c linux-3.1.6-vs2.3.2.5/fs/proc/meminfo.c
6635 --- linux-3.1.6/fs/proc/meminfo.c 2011-12-23 16:04:07.000000000 +0100
6636 +++ linux-3.1.6-vs2.3.2.5/fs/proc/meminfo.c 2011-12-23 16:11:57.000000000 +0100
6637 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
6638 allowed = ((totalram_pages - hugetlb_total_pages())
6639 * sysctl_overcommit_ratio / 100) + total_swap_pages;
6641 - cached = global_page_state(NR_FILE_PAGES) -
6642 + cached = vx_flags(VXF_VIRT_MEM, 0) ?
6643 + vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
6644 total_swapcache_pages - i.bufferram;
6647 diff -NurpP --minimal linux-3.1.6/fs/proc/root.c linux-3.1.6-vs2.3.2.5/fs/proc/root.c
6648 --- linux-3.1.6/fs/proc/root.c 2011-10-24 18:45:27.000000000 +0200
6649 +++ linux-3.1.6-vs2.3.2.5/fs/proc/root.c 2011-10-24 18:53:33.000000000 +0200
6651 #include <linux/bitops.h>
6652 #include <linux/mount.h>
6653 #include <linux/pid_namespace.h>
6654 +#include <linux/vserver/inode.h>
6656 #include "internal.h"
6658 +struct proc_dir_entry *proc_virtual;
6660 +extern void proc_vx_init(void);
6662 static int proc_test_super(struct super_block *sb, void *data)
6664 return sb->s_fs_info == data;
6665 @@ -125,6 +130,7 @@ void __init proc_root_init(void)
6667 proc_mkdir("bus", NULL);
6672 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
6673 @@ -192,6 +198,7 @@ struct proc_dir_entry proc_root = {
6674 .proc_iops = &proc_root_inode_operations,
6675 .proc_fops = &proc_root_operations,
6676 .parent = &proc_root,
6677 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
6681 diff -NurpP --minimal linux-3.1.6/fs/proc/uptime.c linux-3.1.6-vs2.3.2.5/fs/proc/uptime.c
6682 --- linux-3.1.6/fs/proc/uptime.c 2009-12-03 20:02:53.000000000 +0100
6683 +++ linux-3.1.6-vs2.3.2.5/fs/proc/uptime.c 2011-10-24 18:53:33.000000000 +0200
6685 #include <linux/sched.h>
6686 #include <linux/seq_file.h>
6687 #include <linux/time.h>
6688 -#include <linux/kernel_stat.h>
6689 +#include <linux/vserver/cvirt.h>
6690 #include <asm/cputime.h>
6692 static int uptime_proc_show(struct seq_file *m, void *v)
6694 struct timespec uptime;
6695 struct timespec idle;
6697 - cputime_t idletime = cputime_zero;
6699 - for_each_possible_cpu(i)
6700 - idletime = cputime64_add(idletime, kstat_cpu(i).cpustat.idle);
6701 + cputime_t idletime = cputime_add(init_task.utime, init_task.stime);
6703 do_posix_clock_monotonic_gettime(&uptime);
6704 monotonic_to_bootbased(&uptime);
6705 cputime_to_timespec(idletime, &idle);
6707 + if (vx_flags(VXF_VIRT_UPTIME, 0))
6708 + vx_vsi_uptime(&uptime, &idle);
6710 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
6711 (unsigned long) uptime.tv_sec,
6712 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
6713 diff -NurpP --minimal linux-3.1.6/fs/quota/dquot.c linux-3.1.6-vs2.3.2.5/fs/quota/dquot.c
6714 --- linux-3.1.6/fs/quota/dquot.c 2011-07-22 11:18:06.000000000 +0200
6715 +++ linux-3.1.6-vs2.3.2.5/fs/quota/dquot.c 2011-10-24 18:53:33.000000000 +0200
6716 @@ -1548,6 +1548,9 @@ int __dquot_alloc_space(struct inode *in
6717 int reserve = flags & DQUOT_SPACE_RESERVE;
6718 int nofail = flags & DQUOT_SPACE_NOFAIL;
6720 + if ((ret = dl_alloc_space(inode, number)))
6724 * First test before acquiring mutex - solves deadlocks when we
6725 * re-enter the quota code and are already holding the mutex
6726 @@ -1602,6 +1605,9 @@ int dquot_alloc_inode(const struct inode
6728 char warntype[MAXQUOTAS];
6730 + if ((ret = dl_alloc_inode(inode)))
6733 /* First test before acquiring mutex - solves deadlocks when we
6734 * re-enter the quota code and are already holding the mutex */
6735 if (!dquot_active(inode))
6736 @@ -1672,6 +1678,8 @@ void __dquot_free_space(struct inode *in
6737 char warntype[MAXQUOTAS];
6738 int reserve = flags & DQUOT_SPACE_RESERVE;
6740 + dl_free_space(inode, number);
6742 /* First test before acquiring mutex - solves deadlocks when we
6743 * re-enter the quota code and are already holding the mutex */
6744 if (!dquot_active(inode)) {
6745 @@ -1710,6 +1718,8 @@ void dquot_free_inode(const struct inode
6747 char warntype[MAXQUOTAS];
6749 + dl_free_inode(inode);
6751 /* First test before acquiring mutex - solves deadlocks when we
6752 * re-enter the quota code and are already holding the mutex */
6753 if (!dquot_active(inode))
6754 diff -NurpP --minimal linux-3.1.6/fs/quota/quota.c linux-3.1.6-vs2.3.2.5/fs/quota/quota.c
6755 --- linux-3.1.6/fs/quota/quota.c 2011-10-24 18:45:27.000000000 +0200
6756 +++ linux-3.1.6-vs2.3.2.5/fs/quota/quota.c 2011-10-24 18:53:33.000000000 +0200
6758 #include <linux/fs.h>
6759 #include <linux/namei.h>
6760 #include <linux/slab.h>
6761 +#include <linux/vs_context.h>
6762 #include <asm/current.h>
6763 #include <asm/uaccess.h>
6764 #include <linux/kernel.h>
6765 @@ -38,7 +39,7 @@ static int check_quotactl_permission(str
6769 - if (!capable(CAP_SYS_ADMIN))
6770 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
6774 @@ -293,6 +294,46 @@ static int do_quotactl(struct super_bloc
6778 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
6780 +#include <linux/vroot.h>
6781 +#include <linux/major.h>
6782 +#include <linux/module.h>
6783 +#include <linux/kallsyms.h>
6784 +#include <linux/vserver/debug.h>
6786 +static vroot_grb_func *vroot_get_real_bdev = NULL;
6788 +static DEFINE_SPINLOCK(vroot_grb_lock);
6790 +int register_vroot_grb(vroot_grb_func *func) {
6793 + spin_lock(&vroot_grb_lock);
6794 + if (!vroot_get_real_bdev) {
6795 + vroot_get_real_bdev = func;
6798 + spin_unlock(&vroot_grb_lock);
6801 +EXPORT_SYMBOL(register_vroot_grb);
6803 +int unregister_vroot_grb(vroot_grb_func *func) {
6804 + int ret = -EINVAL;
6806 + spin_lock(&vroot_grb_lock);
6807 + if (vroot_get_real_bdev) {
6808 + vroot_get_real_bdev = NULL;
6811 + spin_unlock(&vroot_grb_lock);
6814 +EXPORT_SYMBOL(unregister_vroot_grb);
6819 * look up a superblock on which quota ops will be performed
6820 * - use the name of a block device to find the superblock thereon
6821 @@ -310,6 +351,22 @@ static struct super_block *quotactl_bloc
6824 return ERR_CAST(bdev);
6825 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
6826 + if (bdev && bdev->bd_inode &&
6827 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
6828 + struct block_device *bdnew = (void *)-EINVAL;
6830 + if (vroot_get_real_bdev)
6831 + bdnew = vroot_get_real_bdev(bdev);
6833 + vxdprintk(VXD_CBIT(misc, 0),
6834 + "vroot_get_real_bdev not set");
6836 + if (IS_ERR(bdnew))
6837 + return ERR_PTR(PTR_ERR(bdnew));
6841 sb = get_super(bdev);
6844 diff -NurpP --minimal linux-3.1.6/fs/reiserfs/file.c linux-3.1.6-vs2.3.2.5/fs/reiserfs/file.c
6845 --- linux-3.1.6/fs/reiserfs/file.c 2011-10-24 18:45:27.000000000 +0200
6846 +++ linux-3.1.6-vs2.3.2.5/fs/reiserfs/file.c 2011-10-24 18:53:33.000000000 +0200
6847 @@ -319,5 +319,6 @@ const struct inode_operations reiserfs_f
6848 .listxattr = reiserfs_listxattr,
6849 .removexattr = reiserfs_removexattr,
6850 .permission = reiserfs_permission,
6851 + .sync_flags = reiserfs_sync_flags,
6852 .get_acl = reiserfs_get_acl,
6854 diff -NurpP --minimal linux-3.1.6/fs/reiserfs/inode.c linux-3.1.6-vs2.3.2.5/fs/reiserfs/inode.c
6855 --- linux-3.1.6/fs/reiserfs/inode.c 2011-10-24 18:45:27.000000000 +0200
6856 +++ linux-3.1.6-vs2.3.2.5/fs/reiserfs/inode.c 2011-10-24 18:53:33.000000000 +0200
6858 #include <linux/writeback.h>
6859 #include <linux/quotaops.h>
6860 #include <linux/swap.h>
6861 +#include <linux/vs_tag.h>
6863 int reiserfs_commit_write(struct file *f, struct page *page,
6864 unsigned from, unsigned to);
6865 @@ -1131,6 +1132,8 @@ static void init_inode(struct inode *ino
6866 struct buffer_head *bh;
6867 struct item_head *ih;
6871 //int version = ITEM_VERSION_1;
6873 bh = PATH_PLAST_BUFFER(path);
6874 @@ -1151,12 +1154,13 @@ static void init_inode(struct inode *ino
6875 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
6876 unsigned long blocks;
6878 + uid = sd_v1_uid(sd);
6879 + gid = sd_v1_gid(sd);
6881 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
6882 set_inode_sd_version(inode, STAT_DATA_V1);
6883 inode->i_mode = sd_v1_mode(sd);
6884 inode->i_nlink = sd_v1_nlink(sd);
6885 - inode->i_uid = sd_v1_uid(sd);
6886 - inode->i_gid = sd_v1_gid(sd);
6887 inode->i_size = sd_v1_size(sd);
6888 inode->i_atime.tv_sec = sd_v1_atime(sd);
6889 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
6890 @@ -1198,11 +1202,12 @@ static void init_inode(struct inode *ino
6891 // (directories and symlinks)
6892 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
6894 + uid = sd_v2_uid(sd);
6895 + gid = sd_v2_gid(sd);
6897 inode->i_mode = sd_v2_mode(sd);
6898 inode->i_nlink = sd_v2_nlink(sd);
6899 - inode->i_uid = sd_v2_uid(sd);
6900 inode->i_size = sd_v2_size(sd);
6901 - inode->i_gid = sd_v2_gid(sd);
6902 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
6903 inode->i_atime.tv_sec = sd_v2_atime(sd);
6904 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
6905 @@ -1232,6 +1237,10 @@ static void init_inode(struct inode *ino
6906 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
6909 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6910 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6911 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
6914 if (S_ISREG(inode->i_mode)) {
6915 inode->i_op = &reiserfs_file_inode_operations;
6916 @@ -1254,13 +1263,15 @@ static void init_inode(struct inode *ino
6917 static void inode2sd(void *sd, struct inode *inode, loff_t size)
6919 struct stat_data *sd_v2 = (struct stat_data *)sd;
6920 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
6921 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
6924 + set_sd_v2_uid(sd_v2, uid);
6925 + set_sd_v2_gid(sd_v2, gid);
6926 set_sd_v2_mode(sd_v2, inode->i_mode);
6927 set_sd_v2_nlink(sd_v2, inode->i_nlink);
6928 - set_sd_v2_uid(sd_v2, inode->i_uid);
6929 set_sd_v2_size(sd_v2, size);
6930 - set_sd_v2_gid(sd_v2, inode->i_gid);
6931 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
6932 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
6933 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
6934 @@ -2868,14 +2879,19 @@ int reiserfs_commit_write(struct file *f
6935 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
6937 if (reiserfs_attrs(inode->i_sb)) {
6938 - if (sd_attrs & REISERFS_SYNC_FL)
6939 - inode->i_flags |= S_SYNC;
6941 - inode->i_flags &= ~S_SYNC;
6942 if (sd_attrs & REISERFS_IMMUTABLE_FL)
6943 inode->i_flags |= S_IMMUTABLE;
6945 inode->i_flags &= ~S_IMMUTABLE;
6946 + if (sd_attrs & REISERFS_IXUNLINK_FL)
6947 + inode->i_flags |= S_IXUNLINK;
6949 + inode->i_flags &= ~S_IXUNLINK;
6951 + if (sd_attrs & REISERFS_SYNC_FL)
6952 + inode->i_flags |= S_SYNC;
6954 + inode->i_flags &= ~S_SYNC;
6955 if (sd_attrs & REISERFS_APPEND_FL)
6956 inode->i_flags |= S_APPEND;
6958 @@ -2888,6 +2904,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
6959 REISERFS_I(inode)->i_flags |= i_nopack_mask;
6961 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
6963 + if (sd_attrs & REISERFS_BARRIER_FL)
6964 + inode->i_vflags |= V_BARRIER;
6966 + inode->i_vflags &= ~V_BARRIER;
6967 + if (sd_attrs & REISERFS_COW_FL)
6968 + inode->i_vflags |= V_COW;
6970 + inode->i_vflags &= ~V_COW;
6974 @@ -2898,6 +2923,11 @@ void i_attrs_to_sd_attrs(struct inode *i
6975 *sd_attrs |= REISERFS_IMMUTABLE_FL;
6977 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
6978 + if (inode->i_flags & S_IXUNLINK)
6979 + *sd_attrs |= REISERFS_IXUNLINK_FL;
6981 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
6983 if (inode->i_flags & S_SYNC)
6984 *sd_attrs |= REISERFS_SYNC_FL;
6986 @@ -2910,6 +2940,15 @@ void i_attrs_to_sd_attrs(struct inode *i
6987 *sd_attrs |= REISERFS_NOTAIL_FL;
6989 *sd_attrs &= ~REISERFS_NOTAIL_FL;
6991 + if (inode->i_vflags & V_BARRIER)
6992 + *sd_attrs |= REISERFS_BARRIER_FL;
6994 + *sd_attrs &= ~REISERFS_BARRIER_FL;
6995 + if (inode->i_vflags & V_COW)
6996 + *sd_attrs |= REISERFS_COW_FL;
6998 + *sd_attrs &= ~REISERFS_COW_FL;
7002 @@ -3155,7 +3194,8 @@ int reiserfs_setattr(struct dentry *dent
7005 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
7006 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
7007 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
7008 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
7009 struct reiserfs_transaction_handle th;
7012 @@ -3184,6 +3224,9 @@ int reiserfs_setattr(struct dentry *dent
7013 inode->i_uid = attr->ia_uid;
7014 if (attr->ia_valid & ATTR_GID)
7015 inode->i_gid = attr->ia_gid;
7016 + if ((attr->ia_valid & ATTR_TAG) &&
7018 + inode->i_tag = attr->ia_tag;
7019 mark_inode_dirty(inode);
7020 error = journal_end(&th, inode->i_sb, jbegin_count);
7022 diff -NurpP --minimal linux-3.1.6/fs/reiserfs/ioctl.c linux-3.1.6-vs2.3.2.5/fs/reiserfs/ioctl.c
7023 --- linux-3.1.6/fs/reiserfs/ioctl.c 2011-05-22 16:17:53.000000000 +0200
7024 +++ linux-3.1.6-vs2.3.2.5/fs/reiserfs/ioctl.c 2011-10-24 18:53:33.000000000 +0200
7026 #include <linux/pagemap.h>
7027 #include <linux/compat.h>
7030 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
7032 + __u16 sd_attrs = 0;
7034 + inode->i_flags = flags;
7035 + inode->i_vflags = vflags;
7037 + i_attrs_to_sd_attrs(inode, &sd_attrs);
7038 + REISERFS_I(inode)->i_attrs = sd_attrs;
7039 + inode->i_ctime = CURRENT_TIME_SEC;
7040 + mark_inode_dirty(inode);
7045 * reiserfs_ioctl - handler for ioctl for inode
7046 * supported commands:
7048 long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
7050 struct inode *inode = filp->f_path.dentry->d_inode;
7051 - unsigned int flags;
7052 + unsigned int flags, oldflags;
7055 reiserfs_write_lock(inode->i_sb);
7056 @@ -47,6 +62,7 @@ long reiserfs_ioctl(struct file *filp, u
7058 flags = REISERFS_I(inode)->i_attrs;
7059 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
7060 + flags &= REISERFS_FL_USER_VISIBLE;
7061 err = put_user(flags, (int __user *)arg);
7063 case REISERFS_IOC_SETFLAGS:{
7064 @@ -67,6 +83,10 @@ long reiserfs_ioctl(struct file *filp, u
7068 + if (IS_BARRIER(inode)) {
7069 + vxwprintk_task(1, "messing with the barrier.");
7073 * Is it quota file? Do not allow user to mess with it
7075 @@ -91,6 +111,10 @@ long reiserfs_ioctl(struct file *filp, u
7080 + oldflags = REISERFS_I(inode)->i_attrs;
7081 + flags &= REISERFS_FL_USER_MODIFIABLE;
7082 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
7083 sd_attrs_to_i_attrs(flags, inode);
7084 REISERFS_I(inode)->i_attrs = flags;
7085 inode->i_ctime = CURRENT_TIME_SEC;
7086 diff -NurpP --minimal linux-3.1.6/fs/reiserfs/namei.c linux-3.1.6-vs2.3.2.5/fs/reiserfs/namei.c
7087 --- linux-3.1.6/fs/reiserfs/namei.c 2011-10-24 18:45:27.000000000 +0200
7088 +++ linux-3.1.6-vs2.3.2.5/fs/reiserfs/namei.c 2011-10-24 18:53:33.000000000 +0200
7090 #include <linux/reiserfs_acl.h>
7091 #include <linux/reiserfs_xattr.h>
7092 #include <linux/quotaops.h>
7093 +#include <linux/vs_tag.h>
7095 #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; }
7096 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
7097 @@ -362,6 +363,7 @@ static struct dentry *reiserfs_lookup(st
7098 if (retval == IO_ERROR) {
7099 return ERR_PTR(-EIO);
7101 + dx_propagate_tag(nd, inode);
7103 return d_splice_alias(inode, dentry);
7105 diff -NurpP --minimal linux-3.1.6/fs/reiserfs/super.c linux-3.1.6-vs2.3.2.5/fs/reiserfs/super.c
7106 --- linux-3.1.6/fs/reiserfs/super.c 2011-10-24 18:45:27.000000000 +0200
7107 +++ linux-3.1.6-vs2.3.2.5/fs/reiserfs/super.c 2011-10-24 18:53:33.000000000 +0200
7108 @@ -899,6 +899,14 @@ static int reiserfs_parse_options(struct
7109 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
7110 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
7112 +#ifndef CONFIG_TAGGING_NONE
7113 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
7114 + {"tag",.setmask = 1 << REISERFS_TAGGED},
7115 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
7117 +#ifdef CONFIG_PROPAGATE
7118 + {"tag",.arg_required = 'T',.values = NULL},
7120 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
7121 {"acl",.setmask = 1 << REISERFS_POSIXACL},
7122 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
7123 @@ -1208,6 +1216,14 @@ static int reiserfs_remount(struct super
7124 handle_quota_files(s, qf_names, &qfmt);
7127 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
7128 + !(s->s_flags & MS_TAGGED)) {
7129 + reiserfs_warning(s, "super-vs01",
7130 + "reiserfs: tagging not permitted on remount.");
7137 /* Add options that are safe here */
7138 @@ -1691,6 +1707,10 @@ static int reiserfs_fill_super(struct su
7142 + /* map mount option tagxid */
7143 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
7144 + s->s_flags |= MS_TAGGED;
7146 rs = SB_DISK_SUPER_BLOCK(s);
7147 /* Let's do basic sanity check to verify that underlying device is not
7148 smaller than the filesystem. If the check fails then abort and scream,
7149 diff -NurpP --minimal linux-3.1.6/fs/reiserfs/xattr.c linux-3.1.6-vs2.3.2.5/fs/reiserfs/xattr.c
7150 --- linux-3.1.6/fs/reiserfs/xattr.c 2011-10-24 18:45:27.000000000 +0200
7151 +++ linux-3.1.6-vs2.3.2.5/fs/reiserfs/xattr.c 2011-10-24 18:53:33.000000000 +0200
7153 #include <linux/errno.h>
7154 #include <linux/gfp.h>
7155 #include <linux/fs.h>
7156 +#include <linux/mount.h>
7157 #include <linux/file.h>
7158 #include <linux/pagemap.h>
7159 #include <linux/xattr.h>
7160 diff -NurpP --minimal linux-3.1.6/fs/stat.c linux-3.1.6-vs2.3.2.5/fs/stat.c
7161 --- linux-3.1.6/fs/stat.c 2011-12-23 16:04:07.000000000 +0100
7162 +++ linux-3.1.6-vs2.3.2.5/fs/stat.c 2011-11-15 17:08:44.000000000 +0100
7163 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
7164 stat->nlink = inode->i_nlink;
7165 stat->uid = inode->i_uid;
7166 stat->gid = inode->i_gid;
7167 + stat->tag = inode->i_tag;
7168 stat->rdev = inode->i_rdev;
7169 stat->size = i_size_read(inode);
7170 stat->atime = inode->i_atime;
7171 diff -NurpP --minimal linux-3.1.6/fs/statfs.c linux-3.1.6-vs2.3.2.5/fs/statfs.c
7172 --- linux-3.1.6/fs/statfs.c 2011-12-23 16:04:07.000000000 +0100
7173 +++ linux-3.1.6-vs2.3.2.5/fs/statfs.c 2011-11-15 17:08:44.000000000 +0100
7175 #include <linux/statfs.h>
7176 #include <linux/security.h>
7177 #include <linux/uaccess.h>
7178 +#include <linux/vs_base.h>
7179 +#include <linux/vs_dlimit.h>
7181 static int flags_by_mnt(int mnt_flags)
7183 @@ -59,6 +61,8 @@ int statfs_by_dentry(struct dentry *dent
7184 retval = dentry->d_sb->s_op->statfs(dentry, buf);
7185 if (retval == 0 && buf->f_frsize == 0)
7186 buf->f_frsize = buf->f_bsize;
7187 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
7188 + vx_vsi_statfs(dentry->d_sb, buf);
7192 diff -NurpP --minimal linux-3.1.6/fs/super.c linux-3.1.6-vs2.3.2.5/fs/super.c
7193 --- linux-3.1.6/fs/super.c 2011-12-23 16:04:07.000000000 +0100
7194 +++ linux-3.1.6-vs2.3.2.5/fs/super.c 2011-11-29 12:53:17.000000000 +0100
7196 #include <linux/backing-dev.h>
7197 #include <linux/rculist_bl.h>
7198 #include <linux/cleancache.h>
7199 +#include <linux/devpts_fs.h>
7200 +#include <linux/proc_fs.h>
7201 +#include <linux/vs_context.h>
7202 #include "internal.h"
7205 @@ -1095,6 +1098,13 @@ mount_fs(struct file_system_type *type,
7206 WARN_ON(sb->s_bdi == &default_backing_dev_info);
7207 sb->s_flags |= MS_BORN;
7210 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) &&
7212 + (sb->s_magic != PROC_SUPER_MAGIC) &&
7213 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
7216 error = security_sb_kern_mount(sb, flags, secdata);
7219 diff -NurpP --minimal linux-3.1.6/fs/sysfs/mount.c linux-3.1.6-vs2.3.2.5/fs/sysfs/mount.c
7220 --- linux-3.1.6/fs/sysfs/mount.c 2011-07-22 11:18:06.000000000 +0200
7221 +++ linux-3.1.6-vs2.3.2.5/fs/sysfs/mount.c 2011-10-24 18:53:33.000000000 +0200
7222 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
7224 sb->s_blocksize = PAGE_CACHE_SIZE;
7225 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
7226 - sb->s_magic = SYSFS_MAGIC;
7227 + sb->s_magic = SYSFS_SUPER_MAGIC;
7228 sb->s_op = &sysfs_ops;
7229 sb->s_time_gran = 1;
7231 diff -NurpP --minimal linux-3.1.6/fs/utimes.c linux-3.1.6-vs2.3.2.5/fs/utimes.c
7232 --- linux-3.1.6/fs/utimes.c 2011-05-22 16:17:54.000000000 +0200
7233 +++ linux-3.1.6-vs2.3.2.5/fs/utimes.c 2011-10-24 18:53:33.000000000 +0200
7235 #include <linux/stat.h>
7236 #include <linux/utime.h>
7237 #include <linux/syscalls.h>
7238 +#include <linux/mount.h>
7239 +#include <linux/vs_cowbl.h>
7240 #include <asm/uaccess.h>
7241 #include <asm/unistd.h>
7243 @@ -52,12 +54,18 @@ static int utimes_common(struct path *pa
7246 struct iattr newattrs;
7247 - struct inode *inode = path->dentry->d_inode;
7248 + struct inode *inode;
7250 error = mnt_want_write(path->mnt);
7254 + error = cow_check_and_break(path);
7256 + goto mnt_drop_write_and_out;
7258 + inode = path->dentry->d_inode;
7260 if (times && times[0].tv_nsec == UTIME_NOW &&
7261 times[1].tv_nsec == UTIME_NOW)
7263 diff -NurpP --minimal linux-3.1.6/fs/xattr.c linux-3.1.6-vs2.3.2.5/fs/xattr.c
7264 --- linux-3.1.6/fs/xattr.c 2011-07-22 11:18:09.000000000 +0200
7265 +++ linux-3.1.6-vs2.3.2.5/fs/xattr.c 2011-10-24 18:53:33.000000000 +0200
7267 #include <linux/module.h>
7268 #include <linux/fsnotify.h>
7269 #include <linux/audit.h>
7270 +#include <linux/mount.h>
7271 #include <asm/uaccess.h>
7274 @@ -49,7 +50,7 @@ xattr_permission(struct inode *inode, co
7275 * The trusted.* namespace can only be accessed by privileged users.
7277 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) {
7278 - if (!capable(CAP_SYS_ADMIN))
7279 + if (!vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED))
7280 return (mask & MAY_WRITE) ? -EPERM : -ENODATA;
7283 diff -NurpP --minimal linux-3.1.6/fs/xfs/xfs_dinode.h linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_dinode.h
7284 --- linux-3.1.6/fs/xfs/xfs_dinode.h 2011-10-24 18:45:31.000000000 +0200
7285 +++ linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_dinode.h 2011-10-24 18:53:33.000000000 +0200
7286 @@ -51,7 +51,9 @@ typedef struct xfs_dinode {
7287 __be32 di_nlink; /* number of links to file */
7288 __be16 di_projid_lo; /* lower part of owner's project id */
7289 __be16 di_projid_hi; /* higher part owner's project id */
7290 - __u8 di_pad[6]; /* unused, zeroed space */
7291 + __u8 di_pad[2]; /* unused, zeroed space */
7292 + __be16 di_tag; /* context tagging */
7293 + __be16 di_vflags; /* vserver specific flags */
7294 __be16 di_flushiter; /* incremented on flush */
7295 xfs_timestamp_t di_atime; /* time last accessed */
7296 xfs_timestamp_t di_mtime; /* time last modified */
7297 @@ -184,6 +186,8 @@ static inline void xfs_dinode_put_rdev(s
7298 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
7299 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
7300 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
7301 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
7303 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
7304 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
7305 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
7306 @@ -199,6 +203,7 @@ static inline void xfs_dinode_put_rdev(s
7307 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
7308 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
7309 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
7310 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
7312 #ifdef CONFIG_XFS_RT
7313 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
7314 @@ -211,6 +216,10 @@ static inline void xfs_dinode_put_rdev(s
7315 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
7316 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
7317 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
7318 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
7319 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
7320 + XFS_DIFLAG_IXUNLINK)
7322 +#define XFS_DIVFLAG_BARRIER 0x01
7323 +#define XFS_DIVFLAG_COW 0x02
7325 #endif /* __XFS_DINODE_H__ */
7326 diff -NurpP --minimal linux-3.1.6/fs/xfs/xfs_fs.h linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_fs.h
7327 --- linux-3.1.6/fs/xfs/xfs_fs.h 2011-10-24 18:45:31.000000000 +0200
7328 +++ linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_fs.h 2011-10-24 18:53:33.000000000 +0200
7329 @@ -67,6 +67,9 @@ struct fsxattr {
7330 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
7331 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
7332 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
7333 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
7334 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
7335 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
7336 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
7339 @@ -302,7 +305,8 @@ typedef struct xfs_bstat {
7340 #define bs_projid bs_projid_lo /* (previously just bs_projid) */
7341 __u16 bs_forkoff; /* inode fork offset in bytes */
7342 __u16 bs_projid_hi; /* higher part of project id */
7343 - unsigned char bs_pad[10]; /* pad space, unused */
7344 + unsigned char bs_pad[8]; /* pad space, unused */
7345 + __u16 bs_tag; /* context tagging */
7346 __u32 bs_dmevmask; /* DMIG event mask */
7347 __u16 bs_dmstate; /* DMIG state info */
7348 __u16 bs_aextents; /* attribute number of extents */
7349 diff -NurpP --minimal linux-3.1.6/fs/xfs/xfs_ialloc.c linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_ialloc.c
7350 --- linux-3.1.6/fs/xfs/xfs_ialloc.c 2011-10-24 18:45:31.000000000 +0200
7351 +++ linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_ialloc.c 2011-10-24 18:53:33.000000000 +0200
7353 #include "xfs_error.h"
7354 #include "xfs_bmap.h"
7358 * Allocation group level functions.
7360 diff -NurpP --minimal linux-3.1.6/fs/xfs/xfs_inode.c linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_inode.c
7361 --- linux-3.1.6/fs/xfs/xfs_inode.c 2011-10-24 18:45:31.000000000 +0200
7362 +++ linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_inode.c 2011-10-24 18:53:33.000000000 +0200
7363 @@ -242,6 +242,7 @@ xfs_inotobp(
7367 +#include <linux/vs_tag.h>
7370 * This routine is called to map an inode to the buffer containing
7371 @@ -640,15 +641,25 @@ xfs_iformat_btree(
7373 xfs_dinode_from_disk(
7375 - xfs_dinode_t *from)
7376 + xfs_dinode_t *from,
7379 + uint32_t uid, gid, tag;
7381 to->di_magic = be16_to_cpu(from->di_magic);
7382 to->di_mode = be16_to_cpu(from->di_mode);
7383 to->di_version = from ->di_version;
7384 to->di_format = from->di_format;
7385 to->di_onlink = be16_to_cpu(from->di_onlink);
7386 - to->di_uid = be32_to_cpu(from->di_uid);
7387 - to->di_gid = be32_to_cpu(from->di_gid);
7389 + uid = be32_to_cpu(from->di_uid);
7390 + gid = be32_to_cpu(from->di_gid);
7391 + tag = be16_to_cpu(from->di_tag);
7393 + to->di_uid = INOTAG_UID(tagged, uid, gid);
7394 + to->di_gid = INOTAG_GID(tagged, uid, gid);
7395 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
7397 to->di_nlink = be32_to_cpu(from->di_nlink);
7398 to->di_projid_lo = be16_to_cpu(from->di_projid_lo);
7399 to->di_projid_hi = be16_to_cpu(from->di_projid_hi);
7400 @@ -670,21 +681,26 @@ xfs_dinode_from_disk(
7401 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
7402 to->di_dmstate = be16_to_cpu(from->di_dmstate);
7403 to->di_flags = be16_to_cpu(from->di_flags);
7404 + to->di_vflags = be16_to_cpu(from->di_vflags);
7405 to->di_gen = be32_to_cpu(from->di_gen);
7411 - xfs_icdinode_t *from)
7412 + xfs_icdinode_t *from,
7415 to->di_magic = cpu_to_be16(from->di_magic);
7416 to->di_mode = cpu_to_be16(from->di_mode);
7417 to->di_version = from ->di_version;
7418 to->di_format = from->di_format;
7419 to->di_onlink = cpu_to_be16(from->di_onlink);
7420 - to->di_uid = cpu_to_be32(from->di_uid);
7421 - to->di_gid = cpu_to_be32(from->di_gid);
7423 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
7424 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
7425 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
7427 to->di_nlink = cpu_to_be32(from->di_nlink);
7428 to->di_projid_lo = cpu_to_be16(from->di_projid_lo);
7429 to->di_projid_hi = cpu_to_be16(from->di_projid_hi);
7430 @@ -706,12 +722,14 @@ xfs_dinode_to_disk(
7431 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
7432 to->di_dmstate = cpu_to_be16(from->di_dmstate);
7433 to->di_flags = cpu_to_be16(from->di_flags);
7434 + to->di_vflags = cpu_to_be16(from->di_vflags);
7435 to->di_gen = cpu_to_be32(from->di_gen);
7440 - __uint16_t di_flags)
7441 + __uint16_t di_flags,
7442 + __uint16_t di_vflags)
7446 @@ -722,6 +740,8 @@ _xfs_dic2xflags(
7447 flags |= XFS_XFLAG_PREALLOC;
7448 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7449 flags |= XFS_XFLAG_IMMUTABLE;
7450 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7451 + flags |= XFS_XFLAG_IXUNLINK;
7452 if (di_flags & XFS_DIFLAG_APPEND)
7453 flags |= XFS_XFLAG_APPEND;
7454 if (di_flags & XFS_DIFLAG_SYNC)
7455 @@ -746,6 +766,10 @@ _xfs_dic2xflags(
7456 flags |= XFS_XFLAG_FILESTREAM;
7459 + if (di_vflags & XFS_DIVFLAG_BARRIER)
7460 + flags |= FS_BARRIER_FL;
7461 + if (di_vflags & XFS_DIVFLAG_COW)
7462 + flags |= FS_COW_FL;
7466 @@ -755,7 +779,7 @@ xfs_ip2xflags(
7468 xfs_icdinode_t *dic = &ip->i_d;
7470 - return _xfs_dic2xflags(dic->di_flags) |
7471 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
7472 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
7475 @@ -763,7 +787,8 @@ uint
7479 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
7480 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
7481 + be16_to_cpu(dip->di_vflags)) |
7482 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
7485 @@ -796,7 +821,6 @@ xfs_iread(
7488 dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
7491 * If we got something that isn't an inode it means someone
7492 * (nfs or dmi) has a stale handle.
7493 @@ -819,7 +843,8 @@ xfs_iread(
7494 * Otherwise, just get the truly permanent information.
7497 - xfs_dinode_from_disk(&ip->i_d, dip);
7498 + xfs_dinode_from_disk(&ip->i_d, dip,
7499 + mp->m_flags & XFS_MOUNT_TAGGED);
7500 error = xfs_iformat(ip, dip);
7503 @@ -1014,6 +1039,7 @@ xfs_ialloc(
7504 ASSERT(ip->i_d.di_nlink == nlink);
7505 ip->i_d.di_uid = current_fsuid();
7506 ip->i_d.di_gid = current_fsgid();
7507 + ip->i_d.di_tag = current_fstag(&ip->i_vnode);
7508 xfs_set_projid(ip, prid);
7509 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
7511 @@ -1074,6 +1100,7 @@ xfs_ialloc(
7512 ip->i_d.di_dmevmask = 0;
7513 ip->i_d.di_dmstate = 0;
7514 ip->i_d.di_flags = 0;
7515 + ip->i_d.di_vflags = 0;
7516 flags = XFS_ILOG_CORE;
7517 switch (mode & S_IFMT) {
7519 @@ -1845,6 +1872,7 @@ xfs_ifree(
7521 ip->i_d.di_mode = 0; /* mark incore inode as free */
7522 ip->i_d.di_flags = 0;
7523 + ip->i_d.di_vflags = 0;
7524 ip->i_d.di_dmevmask = 0;
7525 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
7526 ip->i_df.if_ext_max =
7527 @@ -2724,7 +2752,8 @@ xfs_iflush_int(
7528 * because if the inode is dirty at all the core must
7531 - xfs_dinode_to_disk(dip, &ip->i_d);
7532 + xfs_dinode_to_disk(dip, &ip->i_d,
7533 + mp->m_flags & XFS_MOUNT_TAGGED);
7535 /* Wrap, we never let the log put out DI_MAX_FLUSH */
7536 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
7537 diff -NurpP --minimal linux-3.1.6/fs/xfs/xfs_inode.h linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_inode.h
7538 --- linux-3.1.6/fs/xfs/xfs_inode.h 2011-10-24 18:45:31.000000000 +0200
7539 +++ linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_inode.h 2011-10-24 18:53:33.000000000 +0200
7540 @@ -135,7 +135,9 @@ typedef struct xfs_icdinode {
7541 __uint32_t di_nlink; /* number of links to file */
7542 __uint16_t di_projid_lo; /* lower part of owner's project id */
7543 __uint16_t di_projid_hi; /* higher part of owner's project id */
7544 - __uint8_t di_pad[6]; /* unused, zeroed space */
7545 + __uint8_t di_pad[2]; /* unused, zeroed space */
7546 + __uint16_t di_tag; /* context tagging */
7547 + __uint16_t di_vflags; /* vserver specific flags */
7548 __uint16_t di_flushiter; /* incremented on flush */
7549 xfs_ictimestamp_t di_atime; /* time last accessed */
7550 xfs_ictimestamp_t di_mtime; /* time last modified */
7551 @@ -536,7 +538,7 @@ int xfs_itobp(struct xfs_mount *, struc
7552 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
7553 struct xfs_inode *, uint);
7554 void xfs_dinode_to_disk(struct xfs_dinode *,
7555 - struct xfs_icdinode *);
7556 + struct xfs_icdinode *, int);
7557 void xfs_idestroy_fork(struct xfs_inode *, int);
7558 void xfs_idata_realloc(struct xfs_inode *, int, int);
7559 void xfs_iroot_realloc(struct xfs_inode *, int, int);
7560 diff -NurpP --minimal linux-3.1.6/fs/xfs/xfs_ioctl.c linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_ioctl.c
7561 --- linux-3.1.6/fs/xfs/xfs_ioctl.c 2011-10-24 18:45:31.000000000 +0200
7562 +++ linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_ioctl.c 2011-10-24 18:53:33.000000000 +0200
7564 #include "xfs_bmap_btree.h"
7565 #include "xfs_dinode.h"
7566 #include "xfs_inode.h"
7567 -#include "xfs_ioctl.h"
7568 +// #include "xfs_ioctl.h"
7569 #include "xfs_rtalloc.h"
7570 #include "xfs_itable.h"
7571 #include "xfs_error.h"
7572 @@ -748,6 +748,10 @@ xfs_merge_ioc_xflags(
7573 xflags |= XFS_XFLAG_IMMUTABLE;
7575 xflags &= ~XFS_XFLAG_IMMUTABLE;
7576 + if (flags & FS_IXUNLINK_FL)
7577 + xflags |= XFS_XFLAG_IXUNLINK;
7579 + xflags &= ~XFS_XFLAG_IXUNLINK;
7580 if (flags & FS_APPEND_FL)
7581 xflags |= XFS_XFLAG_APPEND;
7583 @@ -776,6 +780,8 @@ xfs_di2lxflags(
7585 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7586 flags |= FS_IMMUTABLE_FL;
7587 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7588 + flags |= FS_IXUNLINK_FL;
7589 if (di_flags & XFS_DIFLAG_APPEND)
7590 flags |= FS_APPEND_FL;
7591 if (di_flags & XFS_DIFLAG_SYNC)
7592 @@ -836,6 +842,8 @@ xfs_set_diflags(
7593 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
7594 if (xflags & XFS_XFLAG_IMMUTABLE)
7595 di_flags |= XFS_DIFLAG_IMMUTABLE;
7596 + if (xflags & XFS_XFLAG_IXUNLINK)
7597 + di_flags |= XFS_DIFLAG_IXUNLINK;
7598 if (xflags & XFS_XFLAG_APPEND)
7599 di_flags |= XFS_DIFLAG_APPEND;
7600 if (xflags & XFS_XFLAG_SYNC)
7601 @@ -878,6 +886,10 @@ xfs_diflags_to_linux(
7602 inode->i_flags |= S_IMMUTABLE;
7604 inode->i_flags &= ~S_IMMUTABLE;
7605 + if (xflags & XFS_XFLAG_IXUNLINK)
7606 + inode->i_flags |= S_IXUNLINK;
7608 + inode->i_flags &= ~S_IXUNLINK;
7609 if (xflags & XFS_XFLAG_APPEND)
7610 inode->i_flags |= S_APPEND;
7612 @@ -1370,10 +1382,18 @@ xfs_file_ioctl(
7613 case XFS_IOC_FSGETXATTRA:
7614 return xfs_ioc_fsgetxattr(ip, 1, arg);
7615 case XFS_IOC_FSSETXATTR:
7616 + if (IS_BARRIER(inode)) {
7617 + vxwprintk_task(1, "messing with the barrier.");
7618 + return -XFS_ERROR(EACCES);
7620 return xfs_ioc_fssetxattr(ip, filp, arg);
7621 case XFS_IOC_GETXFLAGS:
7622 return xfs_ioc_getxflags(ip, arg);
7623 case XFS_IOC_SETXFLAGS:
7624 + if (IS_BARRIER(inode)) {
7625 + vxwprintk_task(1, "messing with the barrier.");
7626 + return -XFS_ERROR(EACCES);
7628 return xfs_ioc_setxflags(ip, filp, arg);
7630 case XFS_IOC_FSSETDM: {
7631 diff -NurpP --minimal linux-3.1.6/fs/xfs/xfs_ioctl.h linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_ioctl.h
7632 --- linux-3.1.6/fs/xfs/xfs_ioctl.h 2011-10-24 18:45:31.000000000 +0200
7633 +++ linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_ioctl.h 2011-10-24 18:53:33.000000000 +0200
7634 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
7635 void __user *uhandle,
7640 + struct inode *inode,
7647 diff -NurpP --minimal linux-3.1.6/fs/xfs/xfs_iops.c linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_iops.c
7648 --- linux-3.1.6/fs/xfs/xfs_iops.c 2011-12-23 16:04:07.000000000 +0100
7649 +++ linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_iops.c 2011-12-15 01:07:58.000000000 +0100
7651 #include "xfs_bmap_btree.h"
7652 #include "xfs_dinode.h"
7653 #include "xfs_inode.h"
7654 +#include "xfs_ioctl.h"
7655 #include "xfs_bmap.h"
7656 #include "xfs_rtalloc.h"
7657 #include "xfs_error.h"
7659 #include <linux/security.h>
7660 #include <linux/fiemap.h>
7661 #include <linux/slab.h>
7662 +#include <linux/vs_tag.h>
7665 * Bring the timestamps in the XFS inode uptodate.
7666 @@ -473,6 +475,7 @@ xfs_vn_getattr(
7667 stat->nlink = ip->i_d.di_nlink;
7668 stat->uid = ip->i_d.di_uid;
7669 stat->gid = ip->i_d.di_gid;
7670 + stat->tag = ip->i_d.di_tag;
7671 stat->ino = ip->i_ino;
7672 stat->atime = inode->i_atime;
7673 stat->mtime = inode->i_mtime;
7674 @@ -1038,6 +1041,7 @@ static const struct inode_operations xfs
7675 .removexattr = generic_removexattr,
7676 .listxattr = xfs_vn_listxattr,
7677 .fiemap = xfs_vn_fiemap,
7678 + .sync_flags = xfs_sync_flags,
7681 static const struct inode_operations xfs_dir_inode_operations = {
7682 @@ -1063,6 +1067,7 @@ static const struct inode_operations xfs
7683 .getxattr = generic_getxattr,
7684 .removexattr = generic_removexattr,
7685 .listxattr = xfs_vn_listxattr,
7686 + .sync_flags = xfs_sync_flags,
7689 static const struct inode_operations xfs_dir_ci_inode_operations = {
7690 @@ -1112,6 +1117,10 @@ xfs_diflags_to_iflags(
7691 inode->i_flags |= S_IMMUTABLE;
7693 inode->i_flags &= ~S_IMMUTABLE;
7694 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
7695 + inode->i_flags |= S_IXUNLINK;
7697 + inode->i_flags &= ~S_IXUNLINK;
7698 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
7699 inode->i_flags |= S_APPEND;
7701 @@ -1124,6 +1133,15 @@ xfs_diflags_to_iflags(
7702 inode->i_flags |= S_NOATIME;
7704 inode->i_flags &= ~S_NOATIME;
7706 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
7707 + inode->i_vflags |= V_BARRIER;
7709 + inode->i_vflags &= ~V_BARRIER;
7710 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
7711 + inode->i_vflags |= V_COW;
7713 + inode->i_vflags &= ~V_COW;
7717 @@ -1155,6 +1173,7 @@ xfs_setup_inode(
7718 inode->i_nlink = ip->i_d.di_nlink;
7719 inode->i_uid = ip->i_d.di_uid;
7720 inode->i_gid = ip->i_d.di_gid;
7721 + inode->i_tag = ip->i_d.di_tag;
7723 switch (inode->i_mode & S_IFMT) {
7725 diff -NurpP --minimal linux-3.1.6/fs/xfs/xfs_itable.c linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_itable.c
7726 --- linux-3.1.6/fs/xfs/xfs_itable.c 2011-05-22 16:17:54.000000000 +0200
7727 +++ linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_itable.c 2011-10-24 18:53:33.000000000 +0200
7728 @@ -98,6 +98,7 @@ xfs_bulkstat_one_int(
7729 buf->bs_mode = dic->di_mode;
7730 buf->bs_uid = dic->di_uid;
7731 buf->bs_gid = dic->di_gid;
7732 + buf->bs_tag = dic->di_tag;
7733 buf->bs_size = dic->di_size;
7736 diff -NurpP --minimal linux-3.1.6/fs/xfs/xfs_linux.h linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_linux.h
7737 --- linux-3.1.6/fs/xfs/xfs_linux.h 2011-10-24 18:45:31.000000000 +0200
7738 +++ linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_linux.h 2011-10-24 18:53:33.000000000 +0200
7741 #define current_cpu() (raw_smp_processor_id())
7742 #define current_pid() (current->pid)
7743 +#define current_fstag(vp) (dx_current_fstag((vp)->i_sb))
7744 #define current_test_flags(f) (current->flags & (f))
7745 #define current_set_flags_nested(sp, f) \
7746 (*(sp) = current->flags, current->flags |= (f))
7747 diff -NurpP --minimal linux-3.1.6/fs/xfs/xfs_log_recover.c linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_log_recover.c
7748 --- linux-3.1.6/fs/xfs/xfs_log_recover.c 2011-10-24 18:45:31.000000000 +0200
7749 +++ linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_log_recover.c 2011-10-24 18:53:33.000000000 +0200
7750 @@ -2347,7 +2347,8 @@ xlog_recover_inode_pass2(
7753 /* The core is in in-core format */
7754 - xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr);
7755 + xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr,
7756 + mp->m_flags & XFS_MOUNT_TAGGED);
7758 /* the rest is in on-disk format */
7759 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
7760 diff -NurpP --minimal linux-3.1.6/fs/xfs/xfs_mount.h linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_mount.h
7761 --- linux-3.1.6/fs/xfs/xfs_mount.h 2011-10-24 18:45:31.000000000 +0200
7762 +++ linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_mount.h 2011-10-24 18:53:33.000000000 +0200
7763 @@ -249,6 +249,7 @@ typedef struct xfs_mount {
7765 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
7767 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
7770 * Default minimum read and write sizes.
7771 diff -NurpP --minimal linux-3.1.6/fs/xfs/xfs_super.c linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_super.c
7772 --- linux-3.1.6/fs/xfs/xfs_super.c 2011-10-24 18:45:31.000000000 +0200
7773 +++ linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_super.c 2011-10-24 18:53:33.000000000 +0200
7774 @@ -113,6 +113,9 @@ mempool_t *xfs_ioend_pool;
7775 #define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed logging disabled */
7776 #define MNTOPT_DISCARD "discard" /* Discard unused blocks */
7777 #define MNTOPT_NODISCARD "nodiscard" /* Do not discard unused blocks */
7778 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
7779 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
7780 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
7783 * Table driven mount option parser.
7784 @@ -121,10 +124,14 @@ mempool_t *xfs_ioend_pool;
7785 * in the future, too.
7788 + Opt_tag, Opt_notag,
7789 Opt_barrier, Opt_nobarrier, Opt_err
7792 static const match_table_t tokens = {
7793 + {Opt_tag, "tagxid"},
7795 + {Opt_notag, "notag"},
7796 {Opt_barrier, "barrier"},
7797 {Opt_nobarrier, "nobarrier"},
7799 @@ -374,6 +381,19 @@ xfs_parseargs(
7800 } else if (!strcmp(this_char, "irixsgid")) {
7802 "irixsgid is now a sysctl(2) variable, option is deprecated.");
7803 +#ifndef CONFIG_TAGGING_NONE
7804 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7805 + mp->m_flags |= XFS_MOUNT_TAGGED;
7806 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
7807 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
7808 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
7809 + mp->m_flags |= XFS_MOUNT_TAGGED;
7811 +#ifdef CONFIG_PROPAGATE
7812 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7814 + mp->m_flags |= XFS_MOUNT_TAGGED;
7817 xfs_warn(mp, "unknown mount option [%s].", this_char);
7819 @@ -1162,6 +1182,16 @@ xfs_fs_remount(
7821 mp->m_flags &= ~XFS_MOUNT_BARRIER;
7824 + if (!(sb->s_flags & MS_TAGGED)) {
7826 + "XFS: %s: tagging not permitted on remount.\n",
7835 * Logically we would return an error here to prevent
7836 @@ -1377,6 +1407,9 @@ xfs_fs_fill_super(
7840 + if (mp->m_flags & XFS_MOUNT_TAGGED)
7841 + sb->s_flags |= MS_TAGGED;
7844 * we must configure the block size in the superblock before we run the
7845 * full mount process as the mount process can lookup and cache inodes.
7846 diff -NurpP --minimal linux-3.1.6/fs/xfs/xfs_vnodeops.c linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_vnodeops.c
7847 --- linux-3.1.6/fs/xfs/xfs_vnodeops.c 2011-12-23 16:04:07.000000000 +0100
7848 +++ linux-3.1.6-vs2.3.2.5/fs/xfs/xfs_vnodeops.c 2011-12-15 01:07:58.000000000 +0100
7849 @@ -107,6 +107,78 @@ xfs_readlink_bmap(
7855 +xfs_get_inode_flags(
7858 + struct inode *inode = VFS_I(ip);
7859 + unsigned int flags = inode->i_flags;
7860 + unsigned int vflags = inode->i_vflags;
7862 + if (flags & S_IMMUTABLE)
7863 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
7865 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
7866 + if (flags & S_IXUNLINK)
7867 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
7869 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
7871 + if (vflags & V_BARRIER)
7872 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
7874 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
7875 + if (vflags & V_COW)
7876 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
7878 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
7883 + struct inode *inode,
7887 + struct xfs_inode *ip = XFS_I(inode);
7888 + struct xfs_mount *mp = ip->i_mount;
7889 + struct xfs_trans *tp;
7890 + unsigned int lock_flags = 0;
7893 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
7894 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
7898 + xfs_ilock(ip, XFS_ILOCK_EXCL);
7900 + xfs_trans_ijoin(tp, ip);
7902 + inode->i_flags = flags;
7903 + inode->i_vflags = vflags;
7904 + xfs_get_inode_flags(ip);
7906 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
7907 + xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
7909 + XFS_STATS_INC(xs_ig_attrchg);
7911 + if (mp->m_flags & XFS_MOUNT_WSYNC)
7912 + xfs_trans_set_sync(tp);
7913 + code = xfs_trans_commit(tp, 0);
7914 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
7918 + xfs_trans_cancel(tp, 0);
7920 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
7928 diff -NurpP --minimal linux-3.1.6/include/linux/Kbuild linux-3.1.6-vs2.3.2.5/include/linux/Kbuild
7929 --- linux-3.1.6/include/linux/Kbuild 2011-10-24 18:45:31.000000000 +0200
7930 +++ linux-3.1.6-vs2.3.2.5/include/linux/Kbuild 2011-10-24 18:53:33.000000000 +0200
7931 @@ -17,6 +17,7 @@ header-y += netfilter_bridge/
7932 header-y += netfilter_ipv4/
7933 header-y += netfilter_ipv6/
7935 +header-y += vserver/
7938 objhdr-y += version.h
7939 diff -NurpP --minimal linux-3.1.6/include/linux/capability.h linux-3.1.6-vs2.3.2.5/include/linux/capability.h
7940 --- linux-3.1.6/include/linux/capability.h 2011-07-22 11:18:10.000000000 +0200
7941 +++ linux-3.1.6-vs2.3.2.5/include/linux/capability.h 2011-10-24 18:53:33.000000000 +0200
7942 @@ -279,6 +279,7 @@ struct cpu_vfs_cap_data {
7943 arbitrary SCSI commands */
7944 /* Allow setting encryption key on loopback filesystem */
7945 /* Allow setting zone reclaim policy */
7946 +/* Allow the selection of a security context */
7948 #define CAP_SYS_ADMIN 21
7950 @@ -362,7 +363,12 @@ struct cpu_vfs_cap_data {
7952 #define CAP_LAST_CAP CAP_WAKE_ALARM
7954 -#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
7955 +/* Allow context manipulations */
7956 +/* Allow changing context info on files */
7958 +#define CAP_CONTEXT 63
7960 +#define cap_valid(x) ((x) >= 0 && ((x) <= CAP_LAST_CAP || (x) == CAP_CONTEXT))
7963 * Bit location of each capability (used by user-space library and kernel)
7964 diff -NurpP --minimal linux-3.1.6/include/linux/cred.h linux-3.1.6-vs2.3.2.5/include/linux/cred.h
7965 --- linux-3.1.6/include/linux/cred.h 2011-10-24 18:45:31.000000000 +0200
7966 +++ linux-3.1.6-vs2.3.2.5/include/linux/cred.h 2011-10-24 18:53:33.000000000 +0200
7967 @@ -156,6 +156,7 @@ extern void exit_creds(struct task_struc
7968 extern int copy_creds(struct task_struct *, unsigned long);
7969 extern const struct cred *get_task_cred(struct task_struct *);
7970 extern struct cred *cred_alloc_blank(void);
7971 +extern struct cred *__prepare_creds(const struct cred *);
7972 extern struct cred *prepare_creds(void);
7973 extern struct cred *prepare_exec_creds(void);
7974 extern int commit_creds(struct cred *);
7975 @@ -209,6 +210,31 @@ static inline void validate_process_cred
7979 +static inline void set_cred_subscribers(struct cred *cred, int n)
7981 +#ifdef CONFIG_DEBUG_CREDENTIALS
7982 + atomic_set(&cred->subscribers, n);
7986 +static inline int read_cred_subscribers(const struct cred *cred)
7988 +#ifdef CONFIG_DEBUG_CREDENTIALS
7989 + return atomic_read(&cred->subscribers);
7995 +static inline void alter_cred_subscribers(const struct cred *_cred, int n)
7997 +#ifdef CONFIG_DEBUG_CREDENTIALS
7998 + struct cred *cred = (struct cred *) _cred;
8000 + atomic_add(n, &cred->subscribers);
8005 * get_new_cred - Get a reference on a new set of credentials
8006 * @cred: The new credentials to reference
8007 diff -NurpP --minimal linux-3.1.6/include/linux/devpts_fs.h linux-3.1.6-vs2.3.2.5/include/linux/devpts_fs.h
8008 --- linux-3.1.6/include/linux/devpts_fs.h 2008-12-25 00:26:37.000000000 +0100
8009 +++ linux-3.1.6-vs2.3.2.5/include/linux/devpts_fs.h 2011-10-24 18:53:33.000000000 +0200
8010 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
8015 #endif /* _LINUX_DEVPTS_FS_H */
8016 diff -NurpP --minimal linux-3.1.6/include/linux/ext2_fs.h linux-3.1.6-vs2.3.2.5/include/linux/ext2_fs.h
8017 --- linux-3.1.6/include/linux/ext2_fs.h 2011-12-23 16:04:07.000000000 +0100
8018 +++ linux-3.1.6-vs2.3.2.5/include/linux/ext2_fs.h 2011-11-15 17:08:44.000000000 +0100
8019 @@ -190,8 +190,12 @@ struct ext2_group_desc
8020 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
8021 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
8022 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
8023 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
8024 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
8026 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
8027 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
8029 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
8030 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
8032 @@ -275,7 +279,8 @@ struct ext2_inode {
8034 __le16 l_i_uid_high; /* these 2 fields */
8035 __le16 l_i_gid_high; /* were reserved2[0] */
8036 - __u32 l_i_reserved2;
8037 + __le16 l_i_tag; /* Context Tag */
8038 + __u16 l_i_reserved2;
8041 __u8 h_i_frag; /* Fragment number */
8042 @@ -304,6 +309,7 @@ struct ext2_inode {
8043 #define i_gid_low i_gid
8044 #define i_uid_high osd2.linux2.l_i_uid_high
8045 #define i_gid_high osd2.linux2.l_i_gid_high
8046 +#define i_raw_tag osd2.linux2.l_i_tag
8047 #define i_reserved2 osd2.linux2.l_i_reserved2
8050 @@ -348,6 +354,7 @@ struct ext2_inode {
8051 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
8052 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
8053 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
8054 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8057 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
8058 diff -NurpP --minimal linux-3.1.6/include/linux/ext3_fs.h linux-3.1.6-vs2.3.2.5/include/linux/ext3_fs.h
8059 --- linux-3.1.6/include/linux/ext3_fs.h 2011-12-23 16:04:07.000000000 +0100
8060 +++ linux-3.1.6-vs2.3.2.5/include/linux/ext3_fs.h 2011-11-15 17:08:44.000000000 +0100
8061 @@ -173,10 +173,14 @@ struct ext3_group_desc
8062 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
8063 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
8064 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
8065 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8066 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
8068 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8069 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8070 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8071 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
8073 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8074 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8076 /* Flags that should be inherited by new inodes from their parent. */
8077 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
8078 @@ -312,7 +316,8 @@ struct ext3_inode {
8080 __le16 l_i_uid_high; /* these 2 fields */
8081 __le16 l_i_gid_high; /* were reserved2[0] */
8082 - __u32 l_i_reserved2;
8083 + __le16 l_i_tag; /* Context Tag */
8084 + __u16 l_i_reserved2;
8087 __u8 h_i_frag; /* Fragment number */
8088 @@ -343,6 +348,7 @@ struct ext3_inode {
8089 #define i_gid_low i_gid
8090 #define i_uid_high osd2.linux2.l_i_uid_high
8091 #define i_gid_high osd2.linux2.l_i_gid_high
8092 +#define i_raw_tag osd2.linux2.l_i_tag
8093 #define i_reserved2 osd2.linux2.l_i_reserved2
8095 #elif defined(__GNU__)
8096 @@ -405,6 +411,7 @@ struct ext3_inode {
8097 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
8098 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
8099 * error in ordered mode */
8100 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
8102 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
8103 #ifndef _LINUX_EXT2_FS_H
8104 @@ -918,6 +925,7 @@ extern void ext3_get_inode_flags(struct
8105 extern void ext3_set_aops(struct inode *inode);
8106 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
8107 u64 start, u64 len);
8108 +extern int ext3_sync_flags(struct inode *, int, int);
8111 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
8112 diff -NurpP --minimal linux-3.1.6/include/linux/fs.h linux-3.1.6-vs2.3.2.5/include/linux/fs.h
8113 --- linux-3.1.6/include/linux/fs.h 2011-12-23 16:04:07.000000000 +0100
8114 +++ linux-3.1.6-vs2.3.2.5/include/linux/fs.h 2011-12-23 16:11:57.000000000 +0100
8115 @@ -209,6 +209,9 @@ struct inodes_stat_t {
8116 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
8117 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
8118 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
8119 +#define MS_TAGGED (1<<25) /* use generic inode tagging */
8120 +#define MS_TAGID (1<<26) /* use specific tag for this mount */
8121 +#define MS_NOTAGCHECK (1<<27) /* don't check tags */
8122 #define MS_NOSEC (1<<28)
8123 #define MS_BORN (1<<29)
8124 #define MS_ACTIVE (1<<30)
8125 @@ -240,6 +243,14 @@ struct inodes_stat_t {
8126 #define S_IMA 1024 /* Inode has an associated IMA struct */
8127 #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */
8128 #define S_NOSEC 4096 /* no suid or xattr security attributes */
8129 +#define S_IXUNLINK 8192 /* Immutable Invert on unlink */
8131 +/* Linux-VServer related Inode flags */
8135 +#define V_BARRIER 4 /* Barrier for chroot() */
8136 +#define V_COW 8 /* Copy on Write */
8139 * Note that nosuid etc flags are inode-specific: setting some file-system
8140 @@ -262,12 +273,15 @@ struct inodes_stat_t {
8141 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
8142 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
8143 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
8144 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8145 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8146 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8147 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8148 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
8150 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
8151 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
8152 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
8153 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
8154 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
8155 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
8157 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
8158 @@ -278,6 +292,16 @@ struct inodes_stat_t {
8159 #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT)
8160 #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC)
8162 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
8164 +#ifdef CONFIG_VSERVER_COWBL
8165 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
8166 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
8168 +# define IS_COW(inode) (0)
8169 +# define IS_COW_LINK(inode) (0)
8172 /* the read-only stuff doesn't really belong here, but any other place is
8173 probably as bad and I don't want to create yet another include file. */
8175 @@ -363,11 +387,14 @@ struct inodes_stat_t {
8176 #define FS_EXTENT_FL 0x00080000 /* Extents */
8177 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
8178 #define FS_NOCOW_FL 0x00800000 /* Do not cow file */
8179 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8180 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
8182 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8183 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8184 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8185 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
8187 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8188 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8190 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
8191 #define SYNC_FILE_RANGE_WRITE 2
8192 @@ -448,6 +475,7 @@ typedef void (dio_iodone_t)(struct kiocb
8193 #define ATTR_KILL_PRIV (1 << 14)
8194 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
8195 #define ATTR_TIMES_SET (1 << 16)
8196 +#define ATTR_TAG (1 << 17)
8199 * This is the Inode Attributes structure, used for notify_change(). It
8200 @@ -463,6 +491,7 @@ struct iattr {
8206 struct timespec ia_atime;
8207 struct timespec ia_mtime;
8208 @@ -476,6 +505,9 @@ struct iattr {
8209 struct file *ia_file;
8212 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
8213 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
8216 * Includes for diskquotas.
8218 @@ -750,7 +782,9 @@ struct inode {
8219 unsigned short i_opflags;
8222 - unsigned int i_flags;
8224 + unsigned short i_flags;
8225 + unsigned short i_vflags;
8227 #ifdef CONFIG_FS_POSIX_ACL
8228 struct posix_acl *i_acl;
8229 @@ -769,6 +803,7 @@ struct inode {
8230 unsigned long i_ino;
8231 unsigned int i_nlink;
8235 struct timespec i_atime;
8236 struct timespec i_mtime;
8237 @@ -906,12 +941,12 @@ static inline void i_size_write(struct i
8239 static inline unsigned iminor(const struct inode *inode)
8241 - return MINOR(inode->i_rdev);
8242 + return MINOR(inode->i_mdev);
8245 static inline unsigned imajor(const struct inode *inode)
8247 - return MAJOR(inode->i_rdev);
8248 + return MAJOR(inode->i_mdev);
8251 extern struct block_device *I_BDEV(struct inode *inode);
8252 @@ -973,6 +1008,7 @@ struct file {
8254 struct fown_struct f_owner;
8255 const struct cred *f_cred;
8257 struct file_ra_state f_ra;
8260 @@ -1117,6 +1153,7 @@ struct file_lock {
8261 struct file *fl_file;
8266 struct fasync_struct * fl_fasync; /* for lease break notifications */
8267 unsigned long fl_break_time; /* for nonblocking lease breaks */
8268 @@ -1615,6 +1652,7 @@ struct inode_operations {
8269 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
8270 ssize_t (*listxattr) (struct dentry *, char *, size_t);
8271 int (*removexattr) (struct dentry *, const char *);
8272 + int (*sync_flags) (struct inode *, int, int);
8273 void (*truncate_range)(struct inode *, loff_t, loff_t);
8274 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
8276 @@ -1633,6 +1671,7 @@ extern ssize_t vfs_readv(struct file *,
8277 unsigned long, loff_t *);
8278 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
8279 unsigned long, loff_t *);
8280 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
8282 struct super_operations {
8283 struct inode *(*alloc_inode)(struct super_block *sb);
8284 @@ -2506,6 +2545,7 @@ extern int dcache_dir_open(struct inode
8285 extern int dcache_dir_close(struct inode *, struct file *);
8286 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
8287 extern int dcache_readdir(struct file *, void *, filldir_t);
8288 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
8289 extern int simple_setattr(struct dentry *, struct iattr *);
8290 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
8291 extern int simple_statfs(struct dentry *, struct kstatfs *);
8292 diff -NurpP --minimal linux-3.1.6/include/linux/gfs2_ondisk.h linux-3.1.6-vs2.3.2.5/include/linux/gfs2_ondisk.h
8293 --- linux-3.1.6/include/linux/gfs2_ondisk.h 2010-07-07 18:31:55.000000000 +0200
8294 +++ linux-3.1.6-vs2.3.2.5/include/linux/gfs2_ondisk.h 2011-10-24 18:53:33.000000000 +0200
8295 @@ -211,6 +211,9 @@ enum {
8299 + gfs2fl_IXUnlink = 16,
8300 + gfs2fl_Barrier = 17,
8302 gfs2fl_TruncInProg = 29,
8303 gfs2fl_InheritDirectio = 30,
8304 gfs2fl_InheritJdata = 31,
8305 @@ -227,6 +230,9 @@ enum {
8306 #define GFS2_DIF_NOATIME 0x00000080
8307 #define GFS2_DIF_SYNC 0x00000100
8308 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
8309 +#define GFS2_DIF_IXUNLINK 0x00010000
8310 +#define GFS2_DIF_BARRIER 0x00020000
8311 +#define GFS2_DIF_COW 0x00040000
8312 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
8313 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000
8314 #define GFS2_DIF_INHERIT_JDATA 0x80000000
8315 diff -NurpP --minimal linux-3.1.6/include/linux/if_tun.h linux-3.1.6-vs2.3.2.5/include/linux/if_tun.h
8316 --- linux-3.1.6/include/linux/if_tun.h 2010-08-02 16:52:54.000000000 +0200
8317 +++ linux-3.1.6-vs2.3.2.5/include/linux/if_tun.h 2011-10-24 18:53:33.000000000 +0200
8319 #define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog)
8320 #define TUNGETVNETHDRSZ _IOR('T', 215, int)
8321 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
8322 +#define TUNSETNID _IOW('T', 217, int)
8324 /* TUNSETIFF ifr flags */
8325 #define IFF_TUN 0x0001
8326 diff -NurpP --minimal linux-3.1.6/include/linux/init_task.h linux-3.1.6-vs2.3.2.5/include/linux/init_task.h
8327 --- linux-3.1.6/include/linux/init_task.h 2011-10-24 18:45:32.000000000 +0200
8328 +++ linux-3.1.6-vs2.3.2.5/include/linux/init_task.h 2011-10-24 18:53:33.000000000 +0200
8329 @@ -192,6 +192,10 @@ extern struct cred init_cred;
8331 INIT_TRACE_RECURSION \
8332 INIT_TASK_RCU_PREEMPT(tsk) \
8334 + .vx_info = NULL, \
8336 + .nx_info = NULL, \
8340 diff -NurpP --minimal linux-3.1.6/include/linux/ipc.h linux-3.1.6-vs2.3.2.5/include/linux/ipc.h
8341 --- linux-3.1.6/include/linux/ipc.h 2009-12-03 20:02:55.000000000 +0100
8342 +++ linux-3.1.6-vs2.3.2.5/include/linux/ipc.h 2011-10-24 18:53:33.000000000 +0200
8343 @@ -91,6 +91,7 @@ struct kern_ipc_perm
8351 diff -NurpP --minimal linux-3.1.6/include/linux/ipc_namespace.h linux-3.1.6-vs2.3.2.5/include/linux/ipc_namespace.h
8352 --- linux-3.1.6/include/linux/ipc_namespace.h 2011-10-24 18:45:32.000000000 +0200
8353 +++ linux-3.1.6-vs2.3.2.5/include/linux/ipc_namespace.h 2011-10-24 18:53:33.000000000 +0200
8354 @@ -101,7 +101,8 @@ static inline int mq_init_ns(struct ipc_
8356 #if defined(CONFIG_IPC_NS)
8357 extern struct ipc_namespace *copy_ipcs(unsigned long flags,
8358 - struct task_struct *tsk);
8359 + struct ipc_namespace *old_ns,
8360 + struct user_namespace *user_ns);
8361 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
8364 @@ -112,12 +113,13 @@ static inline struct ipc_namespace *get_
8365 extern void put_ipc_ns(struct ipc_namespace *ns);
8367 static inline struct ipc_namespace *copy_ipcs(unsigned long flags,
8368 - struct task_struct *tsk)
8369 + struct ipc_namespace *old_ns,
8370 + struct user_namespace *user_ns)
8372 if (flags & CLONE_NEWIPC)
8373 return ERR_PTR(-EINVAL);
8375 - return tsk->nsproxy->ipc_ns;
8379 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
8380 diff -NurpP --minimal linux-3.1.6/include/linux/loop.h linux-3.1.6-vs2.3.2.5/include/linux/loop.h
8381 --- linux-3.1.6/include/linux/loop.h 2011-10-24 18:45:32.000000000 +0200
8382 +++ linux-3.1.6-vs2.3.2.5/include/linux/loop.h 2011-10-24 18:53:33.000000000 +0200
8383 @@ -45,6 +45,7 @@ struct loop_device {
8384 struct loop_func_table *lo_encryption;
8386 uid_t lo_key_owner; /* Who set the key */
8388 int (*ioctl)(struct loop_device *, int cmd,
8391 diff -NurpP --minimal linux-3.1.6/include/linux/magic.h linux-3.1.6-vs2.3.2.5/include/linux/magic.h
8392 --- linux-3.1.6/include/linux/magic.h 2011-05-22 16:17:55.000000000 +0200
8393 +++ linux-3.1.6-vs2.3.2.5/include/linux/magic.h 2011-10-24 18:53:33.000000000 +0200
8396 #define ADFS_SUPER_MAGIC 0xadf5
8397 #define AFFS_SUPER_MAGIC 0xadff
8398 -#define AFS_SUPER_MAGIC 0x5346414F
8399 +#define AFS_SUPER_MAGIC 0x5346414F
8400 #define AUTOFS_SUPER_MAGIC 0x0187
8401 #define CODA_SUPER_MAGIC 0x73757245
8402 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
8404 #define NFS_SUPER_MAGIC 0x6969
8405 #define OPENPROM_SUPER_MAGIC 0x9fa1
8406 #define PROC_SUPER_MAGIC 0x9fa0
8407 +#define DEVPTS_SUPER_MAGIC 0x1cd1
8408 #define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
8410 #define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
8411 diff -NurpP --minimal linux-3.1.6/include/linux/major.h linux-3.1.6-vs2.3.2.5/include/linux/major.h
8412 --- linux-3.1.6/include/linux/major.h 2009-09-10 15:26:25.000000000 +0200
8413 +++ linux-3.1.6-vs2.3.2.5/include/linux/major.h 2011-10-24 18:53:33.000000000 +0200
8415 #define HD_MAJOR IDE0_MAJOR
8416 #define PTY_SLAVE_MAJOR 3
8418 +#define VROOT_MAJOR 4
8419 #define TTYAUX_MAJOR 5
8422 diff -NurpP --minimal linux-3.1.6/include/linux/memcontrol.h linux-3.1.6-vs2.3.2.5/include/linux/memcontrol.h
8423 --- linux-3.1.6/include/linux/memcontrol.h 2011-10-24 18:45:32.000000000 +0200
8424 +++ linux-3.1.6-vs2.3.2.5/include/linux/memcontrol.h 2011-10-24 18:53:33.000000000 +0200
8425 @@ -84,6 +84,13 @@ extern struct mem_cgroup *try_get_mem_cg
8426 extern struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p);
8427 extern struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm);
8429 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
8430 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
8432 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
8433 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
8434 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
8437 int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
8439 diff -NurpP --minimal linux-3.1.6/include/linux/mm_types.h linux-3.1.6-vs2.3.2.5/include/linux/mm_types.h
8440 --- linux-3.1.6/include/linux/mm_types.h 2011-12-23 16:04:07.000000000 +0100
8441 +++ linux-3.1.6-vs2.3.2.5/include/linux/mm_types.h 2011-11-15 17:08:44.000000000 +0100
8442 @@ -314,6 +314,7 @@ struct mm_struct {
8444 /* Architecture-specific MM context */
8445 mm_context_t context;
8446 + struct vx_info *mm_vx_info;
8448 /* Swap token stuff */
8450 diff -NurpP --minimal linux-3.1.6/include/linux/mmzone.h linux-3.1.6-vs2.3.2.5/include/linux/mmzone.h
8451 --- linux-3.1.6/include/linux/mmzone.h 2011-10-24 18:45:32.000000000 +0200
8452 +++ linux-3.1.6-vs2.3.2.5/include/linux/mmzone.h 2011-10-24 18:53:33.000000000 +0200
8453 @@ -660,6 +660,13 @@ typedef struct pglist_data {
8454 __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
8457 +#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
8459 +#define node_end_pfn(nid) ({\
8460 + pg_data_t *__pgdat = NODE_DATA(nid);\
8461 + __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
8464 #include <linux/memory_hotplug.h>
8466 extern struct mutex zonelists_mutex;
8467 diff -NurpP --minimal linux-3.1.6/include/linux/mount.h linux-3.1.6-vs2.3.2.5/include/linux/mount.h
8468 --- linux-3.1.6/include/linux/mount.h 2011-10-24 18:45:32.000000000 +0200
8469 +++ linux-3.1.6-vs2.3.2.5/include/linux/mount.h 2011-10-24 18:53:33.000000000 +0200
8470 @@ -52,6 +52,9 @@ struct mnt_pcp {
8474 +#define MNT_TAGID 0x10000
8475 +#define MNT_NOTAG 0x20000
8478 struct list_head mnt_hash;
8479 struct vfsmount *mnt_parent; /* fs we are mounted on */
8480 @@ -86,6 +89,7 @@ struct vfsmount {
8481 int mnt_expiry_mark; /* true if marked for expiry */
8484 + tag_t mnt_tag; /* tagging used for vfsmount */
8487 struct file; /* forward dec */
8488 diff -NurpP --minimal linux-3.1.6/include/linux/net.h linux-3.1.6-vs2.3.2.5/include/linux/net.h
8489 --- linux-3.1.6/include/linux/net.h 2011-07-22 11:18:11.000000000 +0200
8490 +++ linux-3.1.6-vs2.3.2.5/include/linux/net.h 2011-10-24 18:53:33.000000000 +0200
8491 @@ -72,6 +72,7 @@ struct net;
8492 #define SOCK_NOSPACE 2
8493 #define SOCK_PASSCRED 3
8494 #define SOCK_PASSSEC 4
8495 +#define SOCK_USER_SOCKET 5
8497 #ifndef ARCH_HAS_SOCKET_TYPES
8499 diff -NurpP --minimal linux-3.1.6/include/linux/netdevice.h linux-3.1.6-vs2.3.2.5/include/linux/netdevice.h
8500 --- linux-3.1.6/include/linux/netdevice.h 2011-10-24 18:45:32.000000000 +0200
8501 +++ linux-3.1.6-vs2.3.2.5/include/linux/netdevice.h 2011-10-24 18:53:33.000000000 +0200
8502 @@ -1641,6 +1641,7 @@ extern void netdev_resync_ops(struct ne
8504 extern struct net_device *dev_get_by_index(struct net *net, int ifindex);
8505 extern struct net_device *__dev_get_by_index(struct net *net, int ifindex);
8506 +extern struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex);
8507 extern struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex);
8508 extern int dev_restart(struct net_device *dev);
8509 #ifdef CONFIG_NETPOLL_TRAP
8510 diff -NurpP --minimal linux-3.1.6/include/linux/nfs_mount.h linux-3.1.6-vs2.3.2.5/include/linux/nfs_mount.h
8511 --- linux-3.1.6/include/linux/nfs_mount.h 2011-01-05 21:50:31.000000000 +0100
8512 +++ linux-3.1.6-vs2.3.2.5/include/linux/nfs_mount.h 2011-10-24 18:53:33.000000000 +0200
8513 @@ -63,7 +63,8 @@ struct nfs_mount_data {
8514 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
8515 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
8516 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
8517 -#define NFS_MOUNT_FLAGMASK 0xFFFF
8518 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
8519 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
8521 /* The following are for internal use only */
8522 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
8523 diff -NurpP --minimal linux-3.1.6/include/linux/nsproxy.h linux-3.1.6-vs2.3.2.5/include/linux/nsproxy.h
8524 --- linux-3.1.6/include/linux/nsproxy.h 2011-10-24 18:45:32.000000000 +0200
8525 +++ linux-3.1.6-vs2.3.2.5/include/linux/nsproxy.h 2011-10-24 18:53:33.000000000 +0200
8528 #include <linux/spinlock.h>
8529 #include <linux/sched.h>
8530 +#include <linux/vserver/debug.h>
8532 struct mnt_namespace;
8533 struct uts_namespace;
8534 @@ -63,6 +64,7 @@ static inline struct nsproxy *task_nspro
8537 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
8538 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
8539 void exit_task_namespaces(struct task_struct *tsk);
8540 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
8541 void free_nsproxy(struct nsproxy *ns);
8542 @@ -70,16 +72,26 @@ int unshare_nsproxy_namespaces(unsigned
8543 struct fs_struct *);
8544 int __init nsproxy_cache_init(void);
8546 -static inline void put_nsproxy(struct nsproxy *ns)
8547 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
8549 +static inline void __get_nsproxy(struct nsproxy *ns,
8550 + const char *_file, int _line)
8552 - if (atomic_dec_and_test(&ns->count)) {
8555 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
8556 + ns, atomic_read(&ns->count), _file, _line);
8557 + atomic_inc(&ns->count);
8560 -static inline void get_nsproxy(struct nsproxy *ns)
8561 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
8563 +static inline void __put_nsproxy(struct nsproxy *ns,
8564 + const char *_file, int _line)
8566 - atomic_inc(&ns->count);
8567 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
8568 + ns, atomic_read(&ns->count), _file, _line);
8569 + if (atomic_dec_and_test(&ns->count)) {
8575 diff -NurpP --minimal linux-3.1.6/include/linux/pid.h linux-3.1.6-vs2.3.2.5/include/linux/pid.h
8576 --- linux-3.1.6/include/linux/pid.h 2011-07-22 11:18:11.000000000 +0200
8577 +++ linux-3.1.6-vs2.3.2.5/include/linux/pid.h 2011-10-24 18:53:33.000000000 +0200
8578 @@ -8,7 +8,8 @@ enum pid_type
8588 @@ -171,6 +172,7 @@ static inline pid_t pid_nr(struct pid *p
8591 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
8592 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
8593 pid_t pid_vnr(struct pid *pid);
8595 #define do_each_pid_task(pid, type, task) \
8596 diff -NurpP --minimal linux-3.1.6/include/linux/proc_fs.h linux-3.1.6-vs2.3.2.5/include/linux/proc_fs.h
8597 --- linux-3.1.6/include/linux/proc_fs.h 2011-10-24 18:45:32.000000000 +0200
8598 +++ linux-3.1.6-vs2.3.2.5/include/linux/proc_fs.h 2011-10-24 18:53:33.000000000 +0200
8599 @@ -54,6 +54,7 @@ struct proc_dir_entry {
8605 const struct inode_operations *proc_iops;
8607 @@ -252,12 +253,18 @@ extern const struct proc_ns_operations n
8608 extern const struct proc_ns_operations utsns_operations;
8609 extern const struct proc_ns_operations ipcns_operations;
8615 int (*proc_get_link)(struct inode *, struct path *);
8616 int (*proc_read)(struct task_struct *task, char *page);
8617 int (*proc_show)(struct seq_file *m,
8618 struct pid_namespace *ns, struct pid *pid,
8619 struct task_struct *task);
8620 + int (*proc_vs_read)(char *page);
8621 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
8622 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
8625 struct ctl_table_header;
8626 @@ -265,6 +272,7 @@ struct ctl_table;
8633 struct proc_dir_entry *pde;
8634 diff -NurpP --minimal linux-3.1.6/include/linux/quotaops.h linux-3.1.6-vs2.3.2.5/include/linux/quotaops.h
8635 --- linux-3.1.6/include/linux/quotaops.h 2011-05-22 16:17:57.000000000 +0200
8636 +++ linux-3.1.6-vs2.3.2.5/include/linux/quotaops.h 2011-10-24 18:53:33.000000000 +0200
8638 #define _LINUX_QUOTAOPS_
8640 #include <linux/fs.h>
8641 +#include <linux/vs_dlimit.h>
8643 #define DQUOT_SPACE_WARN 0x1
8644 #define DQUOT_SPACE_RESERVE 0x2
8645 @@ -204,11 +205,12 @@ static inline void dquot_drop(struct ino
8647 static inline int dquot_alloc_inode(const struct inode *inode)
8650 + return dl_alloc_inode(inode);
8653 static inline void dquot_free_inode(const struct inode *inode)
8655 + dl_free_inode(inode);
8658 static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
8659 @@ -219,6 +221,10 @@ static inline int dquot_transfer(struct
8660 static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
8665 + if ((ret = dl_alloc_space(inode, number)))
8667 if (!(flags & DQUOT_SPACE_RESERVE))
8668 inode_add_bytes(inode, number);
8670 @@ -229,6 +235,7 @@ static inline void __dquot_free_space(st
8672 if (!(flags & DQUOT_SPACE_RESERVE))
8673 inode_sub_bytes(inode, number);
8674 + dl_free_space(inode, number);
8677 static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
8678 diff -NurpP --minimal linux-3.1.6/include/linux/reboot.h linux-3.1.6-vs2.3.2.5/include/linux/reboot.h
8679 --- linux-3.1.6/include/linux/reboot.h 2011-10-24 18:45:32.000000000 +0200
8680 +++ linux-3.1.6-vs2.3.2.5/include/linux/reboot.h 2011-10-24 18:53:33.000000000 +0200
8682 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
8683 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
8684 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
8685 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
8689 diff -NurpP --minimal linux-3.1.6/include/linux/reiserfs_fs.h linux-3.1.6-vs2.3.2.5/include/linux/reiserfs_fs.h
8690 --- linux-3.1.6/include/linux/reiserfs_fs.h 2011-10-24 18:45:32.000000000 +0200
8691 +++ linux-3.1.6-vs2.3.2.5/include/linux/reiserfs_fs.h 2011-10-24 18:53:33.000000000 +0200
8692 @@ -976,6 +976,11 @@ struct stat_data_v1 {
8693 #define REISERFS_COMPR_FL FS_COMPR_FL
8694 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
8696 +/* unfortunately reiserfs sdattr is only 16 bit */
8697 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
8698 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
8699 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
8701 /* persistent flags that file inherits from the parent directory */
8702 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
8703 REISERFS_SYNC_FL | \
8704 @@ -985,6 +990,9 @@ struct stat_data_v1 {
8705 REISERFS_COMPR_FL | \
8706 REISERFS_NOTAIL_FL )
8708 +#define REISERFS_FL_USER_VISIBLE 0x80FF
8709 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
8711 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
8714 @@ -2073,6 +2081,7 @@ static inline void reiserfs_update_sd(st
8715 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
8716 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
8717 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
8718 +int reiserfs_sync_flags(struct inode *inode, int, int);
8720 int __reiserfs_write_begin(struct page *page, unsigned from, unsigned len);
8722 diff -NurpP --minimal linux-3.1.6/include/linux/reiserfs_fs_sb.h linux-3.1.6-vs2.3.2.5/include/linux/reiserfs_fs_sb.h
8723 --- linux-3.1.6/include/linux/reiserfs_fs_sb.h 2010-02-25 11:52:07.000000000 +0100
8724 +++ linux-3.1.6-vs2.3.2.5/include/linux/reiserfs_fs_sb.h 2011-10-24 18:53:33.000000000 +0200
8725 @@ -476,6 +476,7 @@ enum reiserfs_mount_options {
8726 REISERFS_EXPOSE_PRIVROOT,
8727 REISERFS_BARRIER_NONE,
8728 REISERFS_BARRIER_FLUSH,
8731 /* Actions on error */
8732 REISERFS_ERROR_PANIC,
8733 diff -NurpP --minimal linux-3.1.6/include/linux/sched.h linux-3.1.6-vs2.3.2.5/include/linux/sched.h
8734 --- linux-3.1.6/include/linux/sched.h 2011-10-24 18:45:32.000000000 +0200
8735 +++ linux-3.1.6-vs2.3.2.5/include/linux/sched.h 2011-10-24 18:53:33.000000000 +0200
8736 @@ -1406,6 +1406,14 @@ struct task_struct {
8740 +/* vserver context data */
8741 + struct vx_info *vx_info;
8742 + struct nx_info *nx_info;
8748 /* Thread group tracking */
8751 @@ -1648,6 +1656,11 @@ struct pid_namespace;
8752 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
8753 struct pid_namespace *ns);
8755 +#include <linux/vserver/base.h>
8756 +#include <linux/vserver/context.h>
8757 +#include <linux/vserver/debug.h>
8758 +#include <linux/vserver/pid.h>
8760 static inline pid_t task_pid_nr(struct task_struct *tsk)
8763 @@ -1661,7 +1674,8 @@ static inline pid_t task_pid_nr_ns(struc
8765 static inline pid_t task_pid_vnr(struct task_struct *tsk)
8767 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
8768 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
8769 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
8773 @@ -1674,7 +1688,7 @@ pid_t task_tgid_nr_ns(struct task_struct
8775 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
8777 - return pid_vnr(task_tgid(tsk));
8778 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
8782 diff -NurpP --minimal linux-3.1.6/include/linux/shmem_fs.h linux-3.1.6-vs2.3.2.5/include/linux/shmem_fs.h
8783 --- linux-3.1.6/include/linux/shmem_fs.h 2011-10-24 18:45:32.000000000 +0200
8784 +++ linux-3.1.6-vs2.3.2.5/include/linux/shmem_fs.h 2011-10-24 18:53:33.000000000 +0200
8787 /* inode in-kernel data */
8789 +#define TMPFS_SUPER_MAGIC 0x01021994
8792 struct shmem_inode_info {
8794 unsigned long flags;
8795 diff -NurpP --minimal linux-3.1.6/include/linux/stat.h linux-3.1.6-vs2.3.2.5/include/linux/stat.h
8796 --- linux-3.1.6/include/linux/stat.h 2008-12-25 00:26:37.000000000 +0100
8797 +++ linux-3.1.6-vs2.3.2.5/include/linux/stat.h 2011-10-24 18:53:33.000000000 +0200
8798 @@ -66,6 +66,7 @@ struct kstat {
8805 struct timespec atime;
8806 diff -NurpP --minimal linux-3.1.6/include/linux/sunrpc/auth.h linux-3.1.6-vs2.3.2.5/include/linux/sunrpc/auth.h
8807 --- linux-3.1.6/include/linux/sunrpc/auth.h 2011-10-24 18:45:32.000000000 +0200
8808 +++ linux-3.1.6-vs2.3.2.5/include/linux/sunrpc/auth.h 2011-10-24 18:53:33.000000000 +0200
8814 struct group_info *group_info;
8815 unsigned char machine_cred : 1;
8817 diff -NurpP --minimal linux-3.1.6/include/linux/sunrpc/clnt.h linux-3.1.6-vs2.3.2.5/include/linux/sunrpc/clnt.h
8818 --- linux-3.1.6/include/linux/sunrpc/clnt.h 2011-05-22 16:17:58.000000000 +0200
8819 +++ linux-3.1.6-vs2.3.2.5/include/linux/sunrpc/clnt.h 2011-10-24 18:53:33.000000000 +0200
8820 @@ -49,7 +49,8 @@ struct rpc_clnt {
8821 unsigned int cl_softrtry : 1,/* soft timeouts */
8822 cl_discrtry : 1,/* disconnect before retry */
8823 cl_autobind : 1,/* use getport() */
8824 - cl_chatty : 1;/* be verbose */
8825 + cl_chatty : 1,/* be verbose */
8826 + cl_tag : 1;/* context tagging */
8828 struct rpc_rtt * cl_rtt; /* RTO estimator data */
8829 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
8830 diff -NurpP --minimal linux-3.1.6/include/linux/syscalls.h linux-3.1.6-vs2.3.2.5/include/linux/syscalls.h
8831 --- linux-3.1.6/include/linux/syscalls.h 2011-10-24 18:45:32.000000000 +0200
8832 +++ linux-3.1.6-vs2.3.2.5/include/linux/syscalls.h 2011-10-24 18:53:33.000000000 +0200
8833 @@ -483,6 +483,8 @@ asmlinkage long sys_symlink(const char _
8834 asmlinkage long sys_unlink(const char __user *pathname);
8835 asmlinkage long sys_rename(const char __user *oldname,
8836 const char __user *newname);
8837 +asmlinkage long sys_copyfile(const char __user *from, const char __user *to,
8839 asmlinkage long sys_chmod(const char __user *filename, mode_t mode);
8840 asmlinkage long sys_fchmod(unsigned int fd, mode_t mode);
8842 diff -NurpP --minimal linux-3.1.6/include/linux/sysctl.h linux-3.1.6-vs2.3.2.5/include/linux/sysctl.h
8843 --- linux-3.1.6/include/linux/sysctl.h 2011-03-15 18:07:40.000000000 +0100
8844 +++ linux-3.1.6-vs2.3.2.5/include/linux/sysctl.h 2011-10-24 18:53:33.000000000 +0200
8845 @@ -60,6 +60,7 @@ enum
8846 CTL_ABI=9, /* Binary emulation */
8847 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
8848 CTL_ARLAN=254, /* arlan wireless driver */
8849 + CTL_VSERVER=4242, /* Linux-VServer debug */
8850 CTL_S390DBF=5677, /* s390 debug */
8851 CTL_SUNRPC=7249, /* sunrpc debug */
8852 CTL_PM=9899, /* frv power management */
8853 @@ -94,6 +95,7 @@ enum
8855 KERN_PANIC=15, /* int: panic timeout */
8856 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
8857 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
8859 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
8860 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
8861 diff -NurpP --minimal linux-3.1.6/include/linux/sysfs.h linux-3.1.6-vs2.3.2.5/include/linux/sysfs.h
8862 --- linux-3.1.6/include/linux/sysfs.h 2011-10-24 18:45:32.000000000 +0200
8863 +++ linux-3.1.6-vs2.3.2.5/include/linux/sysfs.h 2011-10-24 18:53:33.000000000 +0200
8865 #include <linux/kobject_ns.h>
8866 #include <linux/atomic.h>
8868 +#define SYSFS_SUPER_MAGIC 0x62656572
8873 diff -NurpP --minimal linux-3.1.6/include/linux/time.h linux-3.1.6-vs2.3.2.5/include/linux/time.h
8874 --- linux-3.1.6/include/linux/time.h 2011-07-22 11:18:11.000000000 +0200
8875 +++ linux-3.1.6-vs2.3.2.5/include/linux/time.h 2011-10-24 18:53:33.000000000 +0200
8876 @@ -256,6 +256,9 @@ static __always_inline void timespec_add
8877 a->tv_sec += __iter_div_u64_rem(a->tv_nsec + ns, NSEC_PER_SEC, &ns);
8881 +#include <linux/vs_time.h>
8883 #endif /* __KERNEL__ */
8885 #define NFDBITS __NFDBITS
8886 diff -NurpP --minimal linux-3.1.6/include/linux/types.h linux-3.1.6-vs2.3.2.5/include/linux/types.h
8887 --- linux-3.1.6/include/linux/types.h 2011-05-22 16:17:58.000000000 +0200
8888 +++ linux-3.1.6-vs2.3.2.5/include/linux/types.h 2011-10-24 18:53:33.000000000 +0200
8889 @@ -40,6 +40,9 @@ typedef __kernel_uid32_t uid_t;
8890 typedef __kernel_gid32_t gid_t;
8891 typedef __kernel_uid16_t uid16_t;
8892 typedef __kernel_gid16_t gid16_t;
8893 +typedef unsigned int xid_t;
8894 +typedef unsigned int nid_t;
8895 +typedef unsigned int tag_t;
8897 typedef unsigned long uintptr_t;
8899 diff -NurpP --minimal linux-3.1.6/include/linux/utsname.h linux-3.1.6-vs2.3.2.5/include/linux/utsname.h
8900 --- linux-3.1.6/include/linux/utsname.h 2011-05-22 16:17:58.000000000 +0200
8901 +++ linux-3.1.6-vs2.3.2.5/include/linux/utsname.h 2011-10-24 18:53:33.000000000 +0200
8902 @@ -54,7 +54,8 @@ static inline void get_uts_ns(struct uts
8905 extern struct uts_namespace *copy_utsname(unsigned long flags,
8906 - struct task_struct *tsk);
8907 + struct uts_namespace *old_ns,
8908 + struct user_namespace *user_ns);
8909 extern void free_uts_ns(struct kref *kref);
8911 static inline void put_uts_ns(struct uts_namespace *ns)
8912 @@ -71,12 +72,13 @@ static inline void put_uts_ns(struct uts
8915 static inline struct uts_namespace *copy_utsname(unsigned long flags,
8916 - struct task_struct *tsk)
8917 + struct uts_namespace *old_ns,
8918 + struct user_namespace *user_ns)
8920 if (flags & CLONE_NEWUTS)
8921 return ERR_PTR(-EINVAL);
8923 - return tsk->nsproxy->uts_ns;
8928 diff -NurpP --minimal linux-3.1.6/include/linux/vroot.h linux-3.1.6-vs2.3.2.5/include/linux/vroot.h
8929 --- linux-3.1.6/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
8930 +++ linux-3.1.6-vs2.3.2.5/include/linux/vroot.h 2011-10-24 18:53:33.000000000 +0200
8934 + * include/linux/vroot.h
8936 + * written by Herbert Pötzl, 9/11/2002
8937 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
8939 + * Copyright (C) 2002-2007 by Herbert Pötzl.
8940 + * Redistribution of this file is permitted under the
8941 + * GNU General Public License.
8944 +#ifndef _LINUX_VROOT_H
8945 +#define _LINUX_VROOT_H
8950 +/* Possible states of device */
8956 +struct vroot_device {
8960 + struct semaphore vr_ctl_mutex;
8961 + struct block_device *vr_device;
8966 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
8968 +extern int register_vroot_grb(vroot_grb_func *);
8969 +extern int unregister_vroot_grb(vroot_grb_func *);
8971 +#endif /* __KERNEL__ */
8973 +#define MAX_VROOT_DEFAULT 8
8976 + * IOCTL commands --- we will commandeer 0x56 ('V')
8979 +#define VROOT_SET_DEV 0x5600
8980 +#define VROOT_CLR_DEV 0x5601
8982 +#endif /* _LINUX_VROOT_H */
8983 diff -NurpP --minimal linux-3.1.6/include/linux/vs_base.h linux-3.1.6-vs2.3.2.5/include/linux/vs_base.h
8984 --- linux-3.1.6/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
8985 +++ linux-3.1.6-vs2.3.2.5/include/linux/vs_base.h 2011-10-24 18:53:33.000000000 +0200
8990 +#include "vserver/base.h"
8991 +#include "vserver/check.h"
8992 +#include "vserver/debug.h"
8995 +#warning duplicate inclusion
8997 diff -NurpP --minimal linux-3.1.6/include/linux/vs_context.h linux-3.1.6-vs2.3.2.5/include/linux/vs_context.h
8998 --- linux-3.1.6/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
8999 +++ linux-3.1.6-vs2.3.2.5/include/linux/vs_context.h 2011-10-24 18:53:33.000000000 +0200
9001 +#ifndef _VS_CONTEXT_H
9002 +#define _VS_CONTEXT_H
9004 +#include "vserver/base.h"
9005 +#include "vserver/check.h"
9006 +#include "vserver/context.h"
9007 +#include "vserver/history.h"
9008 +#include "vserver/debug.h"
9010 +#include <linux/sched.h>
9013 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
9015 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
9016 + const char *_file, int _line, void *_here)
9021 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
9022 + vxi, vxi ? vxi->vx_id : 0,
9023 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9025 + __vxh_get_vx_info(vxi, _here);
9027 + atomic_inc(&vxi->vx_usecnt);
9032 +extern void free_vx_info(struct vx_info *);
9034 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
9036 +static inline void __put_vx_info(struct vx_info *vxi,
9037 + const char *_file, int _line, void *_here)
9042 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
9043 + vxi, vxi ? vxi->vx_id : 0,
9044 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9046 + __vxh_put_vx_info(vxi, _here);
9048 + if (atomic_dec_and_test(&vxi->vx_usecnt))
9049 + free_vx_info(vxi);
9053 +#define init_vx_info(p, i) \
9054 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9056 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9057 + const char *_file, int _line, void *_here)
9060 + vxlprintk(VXD_CBIT(xid, 3),
9061 + "init_vx_info(%p[#%d.%d])",
9062 + vxi, vxi ? vxi->vx_id : 0,
9063 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9065 + __vxh_init_vx_info(vxi, vxp, _here);
9067 + atomic_inc(&vxi->vx_usecnt);
9073 +#define set_vx_info(p, i) \
9074 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9076 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9077 + const char *_file, int _line, void *_here)
9079 + struct vx_info *vxo;
9084 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
9085 + vxi, vxi ? vxi->vx_id : 0,
9086 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9088 + __vxh_set_vx_info(vxi, vxp, _here);
9090 + atomic_inc(&vxi->vx_usecnt);
9091 + vxo = xchg(vxp, vxi);
9096 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
9098 +static inline void __clr_vx_info(struct vx_info **vxp,
9099 + const char *_file, int _line, void *_here)
9101 + struct vx_info *vxo;
9103 + vxo = xchg(vxp, NULL);
9107 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
9108 + vxo, vxo ? vxo->vx_id : 0,
9109 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
9111 + __vxh_clr_vx_info(vxo, vxp, _here);
9113 + if (atomic_dec_and_test(&vxo->vx_usecnt))
9114 + free_vx_info(vxo);
9118 +#define claim_vx_info(v, p) \
9119 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9121 +static inline void __claim_vx_info(struct vx_info *vxi,
9122 + struct task_struct *task,
9123 + const char *_file, int _line, void *_here)
9125 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
9126 + vxi, vxi ? vxi->vx_id : 0,
9127 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9128 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9129 + task, _file, _line);
9130 + __vxh_claim_vx_info(vxi, task, _here);
9132 + atomic_inc(&vxi->vx_tasks);
9136 +extern void unhash_vx_info(struct vx_info *);
9138 +#define release_vx_info(v, p) \
9139 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9141 +static inline void __release_vx_info(struct vx_info *vxi,
9142 + struct task_struct *task,
9143 + const char *_file, int _line, void *_here)
9145 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
9146 + vxi, vxi ? vxi->vx_id : 0,
9147 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9148 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9149 + task, _file, _line);
9150 + __vxh_release_vx_info(vxi, task, _here);
9154 + if (atomic_dec_and_test(&vxi->vx_tasks))
9155 + unhash_vx_info(vxi);
9159 +#define task_get_vx_info(p) \
9160 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
9162 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
9163 + const char *_file, int _line, void *_here)
9165 + struct vx_info *vxi;
9168 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
9170 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
9176 +static inline void __wakeup_vx_info(struct vx_info *vxi)
9178 + if (waitqueue_active(&vxi->vx_wait))
9179 + wake_up_interruptible(&vxi->vx_wait);
9183 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
9185 +static inline void __enter_vx_info(struct vx_info *vxi,
9186 + struct vx_info_save *vxis, const char *_file, int _line)
9188 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
9189 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
9190 + current->xid, current->vx_info, _file, _line);
9191 + vxis->vxi = xchg(¤t->vx_info, vxi);
9192 + vxis->xid = current->xid;
9193 + current->xid = vxi ? vxi->vx_id : 0;
9196 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
9198 +static inline void __leave_vx_info(struct vx_info_save *vxis,
9199 + const char *_file, int _line)
9201 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
9202 + vxis, vxis->xid, vxis->vxi, current,
9203 + current->xid, current->vx_info, _file, _line);
9204 + (void)xchg(¤t->vx_info, vxis->vxi);
9205 + current->xid = vxis->xid;
9209 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
9211 + vxis->vxi = xchg(¤t->vx_info, NULL);
9212 + vxis->xid = xchg(¤t->xid, (xid_t)0);
9215 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
9217 + (void)xchg(¤t->xid, vxis->xid);
9218 + (void)xchg(¤t->vx_info, vxis->vxi);
9221 +#define task_is_init(p) \
9222 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
9224 +static inline int __task_is_init(struct task_struct *p,
9225 + const char *_file, int _line, void *_here)
9227 + int is_init = is_global_init(p);
9231 + is_init = p->vx_info->vx_initpid == p->pid;
9236 +extern void exit_vx_info(struct task_struct *, int);
9237 +extern void exit_vx_info_early(struct task_struct *, int);
9241 +#warning duplicate inclusion
9243 diff -NurpP --minimal linux-3.1.6/include/linux/vs_cowbl.h linux-3.1.6-vs2.3.2.5/include/linux/vs_cowbl.h
9244 --- linux-3.1.6/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
9245 +++ linux-3.1.6-vs2.3.2.5/include/linux/vs_cowbl.h 2011-10-24 18:53:33.000000000 +0200
9247 +#ifndef _VS_COWBL_H
9248 +#define _VS_COWBL_H
9250 +#include <linux/fs.h>
9251 +#include <linux/dcache.h>
9252 +#include <linux/namei.h>
9253 +#include <linux/slab.h>
9255 +extern struct dentry *cow_break_link(const char *pathname);
9257 +static inline int cow_check_and_break(struct path *path)
9259 + struct inode *inode = path->dentry->d_inode;
9262 + /* do we need this check? */
9263 + if (IS_RDONLY(inode))
9266 + if (IS_COW(inode)) {
9267 + if (IS_COW_LINK(inode)) {
9268 + struct dentry *new_dentry, *old_dentry = path->dentry;
9271 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
9275 + pp = d_path(path, buf, PATH_MAX);
9276 + new_dentry = cow_break_link(pp);
9278 + if (!IS_ERR(new_dentry)) {
9279 + path->dentry = new_dentry;
9282 + error = PTR_ERR(new_dentry);
9284 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
9285 + inode->i_ctime = CURRENT_TIME;
9286 + mark_inode_dirty(inode);
9293 +#warning duplicate inclusion
9295 diff -NurpP --minimal linux-3.1.6/include/linux/vs_cvirt.h linux-3.1.6-vs2.3.2.5/include/linux/vs_cvirt.h
9296 --- linux-3.1.6/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
9297 +++ linux-3.1.6-vs2.3.2.5/include/linux/vs_cvirt.h 2011-10-24 18:53:33.000000000 +0200
9299 +#ifndef _VS_CVIRT_H
9300 +#define _VS_CVIRT_H
9302 +#include "vserver/cvirt.h"
9303 +#include "vserver/context.h"
9304 +#include "vserver/base.h"
9305 +#include "vserver/check.h"
9306 +#include "vserver/debug.h"
9309 +static inline void vx_activate_task(struct task_struct *p)
9311 + struct vx_info *vxi;
9313 + if ((vxi = p->vx_info)) {
9314 + vx_update_load(vxi);
9315 + atomic_inc(&vxi->cvirt.nr_running);
9319 +static inline void vx_deactivate_task(struct task_struct *p)
9321 + struct vx_info *vxi;
9323 + if ((vxi = p->vx_info)) {
9324 + vx_update_load(vxi);
9325 + atomic_dec(&vxi->cvirt.nr_running);
9329 +static inline void vx_uninterruptible_inc(struct task_struct *p)
9331 + struct vx_info *vxi;
9333 + if ((vxi = p->vx_info))
9334 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
9337 +static inline void vx_uninterruptible_dec(struct task_struct *p)
9339 + struct vx_info *vxi;
9341 + if ((vxi = p->vx_info))
9342 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
9347 +#warning duplicate inclusion
9349 diff -NurpP --minimal linux-3.1.6/include/linux/vs_device.h linux-3.1.6-vs2.3.2.5/include/linux/vs_device.h
9350 --- linux-3.1.6/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
9351 +++ linux-3.1.6-vs2.3.2.5/include/linux/vs_device.h 2011-10-24 18:53:33.000000000 +0200
9353 +#ifndef _VS_DEVICE_H
9354 +#define _VS_DEVICE_H
9356 +#include "vserver/base.h"
9357 +#include "vserver/device.h"
9358 +#include "vserver/debug.h"
9361 +#ifdef CONFIG_VSERVER_DEVICE
9363 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
9365 +#define vs_device_perm(v, d, m, p) \
9366 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
9371 +int vs_map_device(struct vx_info *vxi,
9372 + dev_t device, dev_t *target, umode_t mode)
9379 +#define vs_device_perm(v, d, m, p) ((p) == (p))
9384 +#define vs_map_chrdev(d, t, p) \
9385 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
9386 +#define vs_map_blkdev(d, t, p) \
9387 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
9389 +#define vs_chrdev_perm(d, p) \
9390 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
9391 +#define vs_blkdev_perm(d, p) \
9392 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
9396 +#warning duplicate inclusion
9398 diff -NurpP --minimal linux-3.1.6/include/linux/vs_dlimit.h linux-3.1.6-vs2.3.2.5/include/linux/vs_dlimit.h
9399 --- linux-3.1.6/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
9400 +++ linux-3.1.6-vs2.3.2.5/include/linux/vs_dlimit.h 2011-10-24 18:53:33.000000000 +0200
9402 +#ifndef _VS_DLIMIT_H
9403 +#define _VS_DLIMIT_H
9405 +#include <linux/fs.h>
9407 +#include "vserver/dlimit.h"
9408 +#include "vserver/base.h"
9409 +#include "vserver/debug.h"
9412 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
9414 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
9415 + const char *_file, int _line)
9419 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
9420 + dli, dli ? dli->dl_tag : 0,
9421 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9423 + atomic_inc(&dli->dl_usecnt);
9428 +#define free_dl_info(i) \
9429 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
9431 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
9433 +static inline void __put_dl_info(struct dl_info *dli,
9434 + const char *_file, int _line)
9438 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
9439 + dli, dli ? dli->dl_tag : 0,
9440 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9442 + if (atomic_dec_and_test(&dli->dl_usecnt))
9443 + free_dl_info(dli);
9447 +#define __dlimit_char(d) ((d) ? '*' : ' ')
9449 +static inline int __dl_alloc_space(struct super_block *sb,
9450 + tag_t tag, dlsize_t nr, const char *file, int line)
9452 + struct dl_info *dli = NULL;
9457 + dli = locate_dl_info(sb, tag);
9461 + spin_lock(&dli->dl_lock);
9462 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
9464 + dli->dl_space_used += nr;
9465 + spin_unlock(&dli->dl_lock);
9468 + vxlprintk(VXD_CBIT(dlim, 1),
9469 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
9470 + sb, tag, __dlimit_char(dli), (long long)nr,
9472 + return ret ? -ENOSPC : 0;
9475 +static inline void __dl_free_space(struct super_block *sb,
9476 + tag_t tag, dlsize_t nr, const char *_file, int _line)
9478 + struct dl_info *dli = NULL;
9482 + dli = locate_dl_info(sb, tag);
9486 + spin_lock(&dli->dl_lock);
9487 + if (dli->dl_space_used > nr)
9488 + dli->dl_space_used -= nr;
9490 + dli->dl_space_used = 0;
9491 + spin_unlock(&dli->dl_lock);
9494 + vxlprintk(VXD_CBIT(dlim, 1),
9495 + "FREE (%p,#%d)%c %lld bytes",
9496 + sb, tag, __dlimit_char(dli), (long long)nr,
9500 +static inline int __dl_alloc_inode(struct super_block *sb,
9501 + tag_t tag, const char *_file, int _line)
9503 + struct dl_info *dli;
9506 + dli = locate_dl_info(sb, tag);
9510 + spin_lock(&dli->dl_lock);
9511 + dli->dl_inodes_used++;
9512 + ret = (dli->dl_inodes_used > dli->dl_inodes_total);
9513 + spin_unlock(&dli->dl_lock);
9516 + vxlprintk(VXD_CBIT(dlim, 0),
9517 + "ALLOC (%p,#%d)%c inode (%d)",
9518 + sb, tag, __dlimit_char(dli), ret, _file, _line);
9519 + return ret ? -ENOSPC : 0;
9522 +static inline void __dl_free_inode(struct super_block *sb,
9523 + tag_t tag, const char *_file, int _line)
9525 + struct dl_info *dli;
9527 + dli = locate_dl_info(sb, tag);
9531 + spin_lock(&dli->dl_lock);
9532 + if (dli->dl_inodes_used > 1)
9533 + dli->dl_inodes_used--;
9535 + dli->dl_inodes_used = 0;
9536 + spin_unlock(&dli->dl_lock);
9539 + vxlprintk(VXD_CBIT(dlim, 0),
9540 + "FREE (%p,#%d)%c inode",
9541 + sb, tag, __dlimit_char(dli), _file, _line);
9544 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
9545 + unsigned long long *free_blocks, unsigned long long *root_blocks,
9546 + const char *_file, int _line)
9548 + struct dl_info *dli;
9549 + uint64_t broot, bfree;
9551 + dli = locate_dl_info(sb, tag);
9555 + spin_lock(&dli->dl_lock);
9556 + broot = (dli->dl_space_total -
9557 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
9558 + >> sb->s_blocksize_bits;
9559 + bfree = (dli->dl_space_total - dli->dl_space_used)
9560 + >> sb->s_blocksize_bits;
9561 + spin_unlock(&dli->dl_lock);
9563 + vxlprintk(VXD_CBIT(dlim, 2),
9564 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
9565 + (long long)bfree, (long long)broot,
9566 + *free_blocks, *root_blocks, dli->dl_nrlmult,
9568 + if (free_blocks) {
9569 + if (*free_blocks > bfree)
9570 + *free_blocks = bfree;
9572 + if (root_blocks) {
9573 + if (*root_blocks > broot)
9574 + *root_blocks = broot;
9579 +#define dl_prealloc_space(in, bytes) \
9580 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9581 + __FILE__, __LINE__ )
9583 +#define dl_alloc_space(in, bytes) \
9584 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9585 + __FILE__, __LINE__ )
9587 +#define dl_reserve_space(in, bytes) \
9588 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9589 + __FILE__, __LINE__ )
9591 +#define dl_claim_space(in, bytes) (0)
9593 +#define dl_release_space(in, bytes) \
9594 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9595 + __FILE__, __LINE__ )
9597 +#define dl_free_space(in, bytes) \
9598 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9599 + __FILE__, __LINE__ )
9603 +#define dl_alloc_inode(in) \
9604 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
9606 +#define dl_free_inode(in) \
9607 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
9610 +#define dl_adjust_block(sb, tag, fb, rb) \
9611 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
9615 +#warning duplicate inclusion
9617 diff -NurpP --minimal linux-3.1.6/include/linux/vs_inet.h linux-3.1.6-vs2.3.2.5/include/linux/vs_inet.h
9618 --- linux-3.1.6/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
9619 +++ linux-3.1.6-vs2.3.2.5/include/linux/vs_inet.h 2011-10-24 18:53:33.000000000 +0200
9624 +#include "vserver/base.h"
9625 +#include "vserver/network.h"
9626 +#include "vserver/debug.h"
9628 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
9630 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
9631 + NIPQUAD((a)->mask), (a)->type
9632 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
9634 +#define NIPQUAD(addr) \
9635 + ((unsigned char *)&addr)[0], \
9636 + ((unsigned char *)&addr)[1], \
9637 + ((unsigned char *)&addr)[2], \
9638 + ((unsigned char *)&addr)[3]
9640 +#define NIPQUAD_FMT "%u.%u.%u.%u"
9644 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
9646 + __be32 ip = nxa->ip[0].s_addr;
9647 + __be32 mask = nxa->mask.s_addr;
9648 + __be32 bcast = ip | ~mask;
9651 + switch (nxa->type & tmask) {
9652 + case NXA_TYPE_MASK:
9653 + ret = (ip == (addr & mask));
9655 + case NXA_TYPE_ADDR:
9659 + /* fall through to broadcast */
9660 + case NXA_MOD_BCAST:
9661 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
9663 + case NXA_TYPE_RANGE:
9664 + ret = ((nxa->ip[0].s_addr <= addr) &&
9665 + (nxa->ip[1].s_addr > addr));
9667 + case NXA_TYPE_ANY:
9672 + vxdprintk(VXD_CBIT(net, 0),
9673 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
9674 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
9679 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
9681 + struct nx_addr_v4 *nxa;
9688 + /* allow 127.0.0.1 when remapping lback */
9689 + if ((tmask & NXA_LOOPBACK) &&
9690 + (addr == IPI_LOOPBACK) &&
9691 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9694 + /* check for lback address */
9695 + if ((tmask & NXA_MOD_LBACK) &&
9696 + (nxi->v4_lback.s_addr == addr))
9699 + /* check for broadcast address */
9700 + if ((tmask & NXA_MOD_BCAST) &&
9701 + (nxi->v4_bcast.s_addr == addr))
9704 + /* check for v4 addresses */
9705 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
9706 + if (v4_addr_match(nxa, addr, tmask))
9710 + vxdprintk(VXD_CBIT(net, 0),
9711 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
9712 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
9717 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
9719 + /* FIXME: needs full range checks */
9720 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
9724 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
9726 + struct nx_addr_v4 *ptr;
9728 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
9729 + if (v4_nx_addr_match(ptr, nxa, mask))
9734 +#include <net/inet_sock.h>
9737 + * Check if a given address matches for a socket
9739 + * nxi: the socket's nx_info if any
9740 + * addr: to be verified address
9743 +int v4_sock_addr_match (
9744 + struct nx_info *nxi,
9745 + struct inet_sock *inet,
9748 + __be32 saddr = inet->inet_rcv_saddr;
9749 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
9751 + if (addr && (saddr == addr || bcast == addr))
9754 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
9759 +/* inet related checks and helpers */
9768 +#include <linux/netdevice.h>
9769 +#include <linux/inetdevice.h>
9770 +#include <net/inet_sock.h>
9771 +#include <net/inet_timewait_sock.h>
9774 +int dev_in_nx_info(struct net_device *, struct nx_info *);
9775 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
9776 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
9780 + * check if address is covered by socket
9782 + * sk: the socket to check against
9783 + * addr: the address in question (must be != 0)
9787 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
9789 + struct nx_info *nxi = sk->sk_nx_info;
9790 + __be32 saddr = sk_rcv_saddr(sk);
9792 + vxdprintk(VXD_CBIT(net, 5),
9793 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
9794 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
9795 + (sk->sk_socket?sk->sk_socket->flags:0));
9797 + if (saddr) { /* direct address match */
9798 + return v4_addr_match(nxa, saddr, -1);
9799 + } else if (nxi) { /* match against nx_info */
9800 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
9801 + } else { /* unrestricted any socket */
9809 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
9811 + vxdprintk(VXD_CBIT(net, 1),
9812 + "nx_dev_visible(%p[#%u],%p " VS_Q("%s") ") %d",
9813 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
9814 + nxi ? dev_in_nx_info(dev, nxi) : 0);
9816 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9818 + if (dev_in_nx_info(dev, nxi))
9825 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
9831 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
9835 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
9837 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
9838 + nxi, nxi ? nxi->nx_id : 0, ifa,
9839 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
9841 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9843 + if (v4_ifa_in_nx_info(ifa, nxi))
9849 +struct nx_v4_sock_addr {
9850 + __be32 saddr; /* Address used for validation */
9851 + __be32 baddr; /* Address used for socket bind */
9855 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
9856 + struct nx_v4_sock_addr *nsa)
9858 + struct sock *sk = &inet->sk;
9859 + struct nx_info *nxi = sk->sk_nx_info;
9860 + __be32 saddr = addr->sin_addr.s_addr;
9861 + __be32 baddr = saddr;
9863 + vxdprintk(VXD_CBIT(net, 3),
9864 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
9865 + sk, sk->sk_nx_info, sk->sk_socket,
9866 + (sk->sk_socket ? sk->sk_socket->flags : 0),
9870 + if (saddr == INADDR_ANY) {
9871 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
9872 + baddr = nxi->v4.ip[0].s_addr;
9873 + } else if (saddr == IPI_LOOPBACK) {
9874 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9875 + baddr = nxi->v4_lback.s_addr;
9876 + } else if (!ipv4_is_multicast(saddr) ||
9877 + !nx_info_ncaps(nxi, NXC_MULTICAST)) {
9878 + /* normal address bind */
9879 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
9880 + return -EADDRNOTAVAIL;
9884 + vxdprintk(VXD_CBIT(net, 3),
9885 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
9886 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
9888 + nsa->saddr = saddr;
9889 + nsa->baddr = baddr;
9894 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
9896 + inet->inet_saddr = nsa->baddr;
9897 + inet->inet_rcv_saddr = nsa->baddr;
9902 + * helper to simplify inet_lookup_listener
9904 + * nxi: the socket's nx_info if any
9905 + * addr: to be verified address
9906 + * saddr: socket address
9908 +static inline int v4_inet_addr_match (
9909 + struct nx_info *nxi,
9913 + if (addr && (saddr == addr))
9916 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
9920 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
9922 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
9923 + (addr == nxi->v4_lback.s_addr))
9924 + return IPI_LOOPBACK;
9929 +int nx_info_has_v4(struct nx_info *nxi)
9935 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9940 +#else /* CONFIG_INET */
9943 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
9949 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
9955 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
9961 +int nx_info_has_v4(struct nx_info *nxi)
9966 +#endif /* CONFIG_INET */
9968 +#define current_nx_info_has_v4() \
9969 + nx_info_has_v4(current_nx_info())
9972 +// #warning duplicate inclusion
9974 diff -NurpP --minimal linux-3.1.6/include/linux/vs_inet6.h linux-3.1.6-vs2.3.2.5/include/linux/vs_inet6.h
9975 --- linux-3.1.6/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
9976 +++ linux-3.1.6-vs2.3.2.5/include/linux/vs_inet6.h 2011-10-24 18:53:33.000000000 +0200
9978 +#ifndef _VS_INET6_H
9979 +#define _VS_INET6_H
9981 +#include "vserver/base.h"
9982 +#include "vserver/network.h"
9983 +#include "vserver/debug.h"
9985 +#include <net/ipv6.h>
9987 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
9988 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
9994 +int v6_addr_match(struct nx_addr_v6 *nxa,
9995 + const struct in6_addr *addr, uint16_t mask)
9999 + switch (nxa->type & mask) {
10000 + case NXA_TYPE_MASK:
10001 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
10003 + case NXA_TYPE_ADDR:
10004 + ret = ipv6_addr_equal(&nxa->ip, addr);
10006 + case NXA_TYPE_ANY:
10010 + vxdprintk(VXD_CBIT(net, 0),
10011 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
10012 + nxa, NXAV6(nxa), addr, mask, ret);
10017 +int v6_addr_in_nx_info(struct nx_info *nxi,
10018 + const struct in6_addr *addr, uint16_t mask)
10020 + struct nx_addr_v6 *nxa;
10025 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
10026 + if (v6_addr_match(nxa, addr, mask))
10030 + vxdprintk(VXD_CBIT(net, 0),
10031 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
10032 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
10037 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
10039 + /* FIXME: needs full range checks */
10040 + return v6_addr_match(nxa, &addr->ip, mask);
10044 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
10046 + struct nx_addr_v6 *ptr;
10048 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
10049 + if (v6_nx_addr_match(ptr, nxa, mask))
10056 + * Check if a given address matches for a socket
10058 + * nxi: the socket's nx_info if any
10059 + * addr: to be verified address
10062 +int v6_sock_addr_match (
10063 + struct nx_info *nxi,
10064 + struct inet_sock *inet,
10065 + struct in6_addr *addr)
10067 + struct sock *sk = &inet->sk;
10068 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
10070 + if (!ipv6_addr_any(addr) &&
10071 + ipv6_addr_equal(saddr, addr))
10073 + if (ipv6_addr_any(saddr))
10074 + return v6_addr_in_nx_info(nxi, addr, -1);
10079 + * check if address is covered by socket
10081 + * sk: the socket to check against
10082 + * addr: the address in question (must be != 0)
10086 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
10088 + struct nx_info *nxi = sk->sk_nx_info;
10089 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
10091 + vxdprintk(VXD_CBIT(net, 5),
10092 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
10093 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
10094 + (sk->sk_socket?sk->sk_socket->flags:0));
10096 + if (!ipv6_addr_any(saddr)) { /* direct address match */
10097 + return v6_addr_match(nxa, saddr, -1);
10098 + } else if (nxi) { /* match against nx_info */
10099 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
10100 + } else { /* unrestricted any socket */
10106 +/* inet related checks and helpers */
10110 +struct net_device;
10114 +#include <linux/netdevice.h>
10115 +#include <linux/inetdevice.h>
10116 +#include <net/inet_timewait_sock.h>
10119 +int dev_in_nx_info(struct net_device *, struct nx_info *);
10120 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
10121 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
10126 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
10132 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
10136 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
10138 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
10139 + nxi, nxi ? nxi->nx_id : 0, ifa,
10140 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
10142 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
10144 + if (v6_ifa_in_nx_info(ifa, nxi))
10150 +struct nx_v6_sock_addr {
10151 + struct in6_addr saddr; /* Address used for validation */
10152 + struct in6_addr baddr; /* Address used for socket bind */
10156 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
10157 + struct nx_v6_sock_addr *nsa)
10159 + // struct sock *sk = &inet->sk;
10160 + // struct nx_info *nxi = sk->sk_nx_info;
10161 + struct in6_addr saddr = addr->sin6_addr;
10162 + struct in6_addr baddr = saddr;
10164 + nsa->saddr = saddr;
10165 + nsa->baddr = baddr;
10170 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
10172 + // struct sock *sk = &inet->sk;
10173 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
10175 + // *saddr = nsa->baddr;
10176 + // inet->inet_saddr = nsa->baddr;
10180 +int nx_info_has_v6(struct nx_info *nxi)
10184 + if (NX_IPV6(nxi))
10189 +#else /* CONFIG_IPV6 */
10192 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
10199 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
10205 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
10211 +int nx_info_has_v6(struct nx_info *nxi)
10216 +#endif /* CONFIG_IPV6 */
10218 +#define current_nx_info_has_v6() \
10219 + nx_info_has_v6(current_nx_info())
10222 +#warning duplicate inclusion
10224 diff -NurpP --minimal linux-3.1.6/include/linux/vs_limit.h linux-3.1.6-vs2.3.2.5/include/linux/vs_limit.h
10225 --- linux-3.1.6/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
10226 +++ linux-3.1.6-vs2.3.2.5/include/linux/vs_limit.h 2011-10-24 18:53:33.000000000 +0200
10228 +#ifndef _VS_LIMIT_H
10229 +#define _VS_LIMIT_H
10231 +#include "vserver/limit.h"
10232 +#include "vserver/base.h"
10233 +#include "vserver/context.h"
10234 +#include "vserver/debug.h"
10235 +#include "vserver/context.h"
10236 +#include "vserver/limit_int.h"
10239 +#define vx_acc_cres(v, d, p, r) \
10240 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
10242 +#define vx_acc_cres_cond(x, d, p, r) \
10243 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
10244 + r, d, p, __FILE__, __LINE__)
10247 +#define vx_add_cres(v, a, p, r) \
10248 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
10249 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
10251 +#define vx_add_cres_cond(x, a, p, r) \
10252 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
10253 + r, a, p, __FILE__, __LINE__)
10254 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
10257 +/* process and file limits */
10259 +#define vx_nproc_inc(p) \
10260 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
10262 +#define vx_nproc_dec(p) \
10263 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
10265 +#define vx_files_inc(f) \
10266 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
10268 +#define vx_files_dec(f) \
10269 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
10271 +#define vx_locks_inc(l) \
10272 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
10274 +#define vx_locks_dec(l) \
10275 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
10277 +#define vx_openfd_inc(f) \
10278 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
10280 +#define vx_openfd_dec(f) \
10281 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
10284 +#define vx_cres_avail(v, n, r) \
10285 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
10288 +#define vx_nproc_avail(n) \
10289 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
10291 +#define vx_files_avail(n) \
10292 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
10294 +#define vx_locks_avail(n) \
10295 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
10297 +#define vx_openfd_avail(n) \
10298 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
10301 +/* dentry limits */
10303 +#define vx_dentry_inc(d) do { \
10304 + if ((d)->d_count == 1) \
10305 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
10308 +#define vx_dentry_dec(d) do { \
10309 + if ((d)->d_count == 0) \
10310 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
10313 +#define vx_dentry_avail(n) \
10314 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
10317 +/* socket limits */
10319 +#define vx_sock_inc(s) \
10320 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
10322 +#define vx_sock_dec(s) \
10323 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
10325 +#define vx_sock_avail(n) \
10326 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
10329 +/* ipc resource limits */
10331 +#define vx_ipcmsg_add(v, u, a) \
10332 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
10334 +#define vx_ipcmsg_sub(v, u, a) \
10335 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
10337 +#define vx_ipcmsg_avail(v, a) \
10338 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
10341 +#define vx_ipcshm_add(v, k, a) \
10342 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
10344 +#define vx_ipcshm_sub(v, k, a) \
10345 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
10347 +#define vx_ipcshm_avail(v, a) \
10348 + vx_cres_avail(v, a, VLIMIT_SHMEM)
10351 +#define vx_semary_inc(a) \
10352 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
10354 +#define vx_semary_dec(a) \
10355 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
10358 +#define vx_nsems_add(a,n) \
10359 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10361 +#define vx_nsems_sub(a,n) \
10362 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10366 +#warning duplicate inclusion
10368 diff -NurpP --minimal linux-3.1.6/include/linux/vs_network.h linux-3.1.6-vs2.3.2.5/include/linux/vs_network.h
10369 --- linux-3.1.6/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
10370 +++ linux-3.1.6-vs2.3.2.5/include/linux/vs_network.h 2011-10-24 18:53:33.000000000 +0200
10372 +#ifndef _NX_VS_NETWORK_H
10373 +#define _NX_VS_NETWORK_H
10375 +#include "vserver/context.h"
10376 +#include "vserver/network.h"
10377 +#include "vserver/base.h"
10378 +#include "vserver/check.h"
10379 +#include "vserver/debug.h"
10381 +#include <linux/sched.h>
10384 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
10386 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
10387 + const char *_file, int _line)
10392 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
10393 + nxi, nxi ? nxi->nx_id : 0,
10394 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10397 + atomic_inc(&nxi->nx_usecnt);
10402 +extern void free_nx_info(struct nx_info *);
10404 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
10406 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
10411 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
10412 + nxi, nxi ? nxi->nx_id : 0,
10413 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10416 + if (atomic_dec_and_test(&nxi->nx_usecnt))
10417 + free_nx_info(nxi);
10421 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
10423 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
10424 + const char *_file, int _line)
10427 + vxlprintk(VXD_CBIT(nid, 3),
10428 + "init_nx_info(%p[#%d.%d])",
10429 + nxi, nxi ? nxi->nx_id : 0,
10430 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10433 + atomic_inc(&nxi->nx_usecnt);
10439 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
10441 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
10442 + const char *_file, int _line)
10444 + struct nx_info *nxo;
10449 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
10450 + nxi, nxi ? nxi->nx_id : 0,
10451 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10454 + atomic_inc(&nxi->nx_usecnt);
10455 + nxo = xchg(nxp, nxi);
10459 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
10461 +static inline void __clr_nx_info(struct nx_info **nxp,
10462 + const char *_file, int _line)
10464 + struct nx_info *nxo;
10466 + nxo = xchg(nxp, NULL);
10470 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
10471 + nxo, nxo ? nxo->nx_id : 0,
10472 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
10475 + if (atomic_dec_and_test(&nxo->nx_usecnt))
10476 + free_nx_info(nxo);
10480 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
10482 +static inline void __claim_nx_info(struct nx_info *nxi,
10483 + struct task_struct *task, const char *_file, int _line)
10485 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
10486 + nxi, nxi ? nxi->nx_id : 0,
10487 + nxi?atomic_read(&nxi->nx_usecnt):0,
10488 + nxi?atomic_read(&nxi->nx_tasks):0,
10489 + task, _file, _line);
10491 + atomic_inc(&nxi->nx_tasks);
10495 +extern void unhash_nx_info(struct nx_info *);
10497 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
10499 +static inline void __release_nx_info(struct nx_info *nxi,
10500 + struct task_struct *task, const char *_file, int _line)
10502 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
10503 + nxi, nxi ? nxi->nx_id : 0,
10504 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10505 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
10506 + task, _file, _line);
10510 + if (atomic_dec_and_test(&nxi->nx_tasks))
10511 + unhash_nx_info(nxi);
10515 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
10517 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
10518 + const char *_file, int _line)
10520 + struct nx_info *nxi;
10523 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
10524 + p, _file, _line);
10525 + nxi = __get_nx_info(p->nx_info, _file, _line);
10531 +static inline void exit_nx_info(struct task_struct *p)
10534 + release_nx_info(p->nx_info, p);
10539 +#warning duplicate inclusion
10541 diff -NurpP --minimal linux-3.1.6/include/linux/vs_pid.h linux-3.1.6-vs2.3.2.5/include/linux/vs_pid.h
10542 --- linux-3.1.6/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
10543 +++ linux-3.1.6-vs2.3.2.5/include/linux/vs_pid.h 2011-10-24 18:53:33.000000000 +0200
10548 +#include "vserver/base.h"
10549 +#include "vserver/check.h"
10550 +#include "vserver/context.h"
10551 +#include "vserver/debug.h"
10552 +#include "vserver/pid.h"
10553 +#include <linux/pid_namespace.h>
10556 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
10559 +int vx_proc_task_visible(struct task_struct *task)
10561 + if ((task->pid == 1) &&
10562 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
10563 + /* show a blend through init */
10565 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
10572 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
10576 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
10578 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
10580 + if (task && !vx_proc_task_visible(task)) {
10581 + vxdprintk(VXD_CBIT(misc, 6),
10582 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
10583 + task, task->xid, task->pid,
10584 + current, current->xid, current->pid);
10585 + put_task_struct(task);
10593 +#warning duplicate inclusion
10595 diff -NurpP --minimal linux-3.1.6/include/linux/vs_sched.h linux-3.1.6-vs2.3.2.5/include/linux/vs_sched.h
10596 --- linux-3.1.6/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
10597 +++ linux-3.1.6-vs2.3.2.5/include/linux/vs_sched.h 2011-10-24 18:53:33.000000000 +0200
10599 +#ifndef _VS_SCHED_H
10600 +#define _VS_SCHED_H
10602 +#include "vserver/base.h"
10603 +#include "vserver/context.h"
10604 +#include "vserver/sched.h"
10607 +#define MAX_PRIO_BIAS 20
10608 +#define MIN_PRIO_BIAS -20
10611 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
10613 + struct vx_info *vxi = p->vx_info;
10616 + prio += vx_cpu(vxi, sched_pc).prio_bias;
10620 +static inline void vx_account_user(struct vx_info *vxi,
10621 + cputime_t cputime, int nice)
10625 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
10628 +static inline void vx_account_system(struct vx_info *vxi,
10629 + cputime_t cputime, int idle)
10633 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
10637 +#warning duplicate inclusion
10639 diff -NurpP --minimal linux-3.1.6/include/linux/vs_socket.h linux-3.1.6-vs2.3.2.5/include/linux/vs_socket.h
10640 --- linux-3.1.6/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
10641 +++ linux-3.1.6-vs2.3.2.5/include/linux/vs_socket.h 2011-10-24 18:53:33.000000000 +0200
10643 +#ifndef _VS_SOCKET_H
10644 +#define _VS_SOCKET_H
10646 +#include "vserver/debug.h"
10647 +#include "vserver/base.h"
10648 +#include "vserver/cacct.h"
10649 +#include "vserver/context.h"
10650 +#include "vserver/tag.h"
10653 +/* socket accounting */
10655 +#include <linux/socket.h>
10657 +static inline int vx_sock_type(int family)
10659 + switch (family) {
10661 + return VXA_SOCK_UNSPEC;
10663 + return VXA_SOCK_UNIX;
10665 + return VXA_SOCK_INET;
10667 + return VXA_SOCK_INET6;
10669 + return VXA_SOCK_PACKET;
10671 + return VXA_SOCK_OTHER;
10675 +#define vx_acc_sock(v, f, p, s) \
10676 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
10678 +static inline void __vx_acc_sock(struct vx_info *vxi,
10679 + int family, int pos, int size, char *file, int line)
10682 + int type = vx_sock_type(family);
10684 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
10685 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
10689 +#define vx_sock_recv(sk, s) \
10690 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
10691 +#define vx_sock_send(sk, s) \
10692 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
10693 +#define vx_sock_fail(sk, s) \
10694 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
10697 +#define sock_vx_init(s) do { \
10698 + (s)->sk_xid = 0; \
10699 + (s)->sk_vx_info = NULL; \
10702 +#define sock_nx_init(s) do { \
10703 + (s)->sk_nid = 0; \
10704 + (s)->sk_nx_info = NULL; \
10708 +#warning duplicate inclusion
10710 diff -NurpP --minimal linux-3.1.6/include/linux/vs_tag.h linux-3.1.6-vs2.3.2.5/include/linux/vs_tag.h
10711 --- linux-3.1.6/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
10712 +++ linux-3.1.6-vs2.3.2.5/include/linux/vs_tag.h 2011-10-24 18:53:33.000000000 +0200
10717 +#include <linux/vserver/tag.h>
10719 +/* check conditions */
10721 +#define DX_ADMIN 0x0001
10722 +#define DX_WATCH 0x0002
10723 +#define DX_HOSTID 0x0008
10725 +#define DX_IDENT 0x0010
10727 +#define DX_ARG_MASK 0x0010
10730 +#define dx_task_tag(t) ((t)->tag)
10732 +#define dx_current_tag() dx_task_tag(current)
10734 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
10736 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
10740 + * check current context for ADMIN/WATCH and
10741 + * optionally against supplied argument
10743 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
10745 + if (mode & DX_ARG_MASK) {
10746 + if ((mode & DX_IDENT) && (id == cid))
10749 + return (((mode & DX_ADMIN) && (cid == 0)) ||
10750 + ((mode & DX_WATCH) && (cid == 1)) ||
10751 + ((mode & DX_HOSTID) && (id == 0)));
10755 +int dx_permission(const struct inode *inode, int mask);
10759 +#warning duplicate inclusion
10761 diff -NurpP --minimal linux-3.1.6/include/linux/vs_time.h linux-3.1.6-vs2.3.2.5/include/linux/vs_time.h
10762 --- linux-3.1.6/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
10763 +++ linux-3.1.6-vs2.3.2.5/include/linux/vs_time.h 2011-10-24 18:53:33.000000000 +0200
10765 +#ifndef _VS_TIME_H
10766 +#define _VS_TIME_H
10769 +/* time faking stuff */
10771 +#ifdef CONFIG_VSERVER_VTIME
10773 +extern void vx_adjust_timespec(struct timespec *ts);
10774 +extern int vx_settimeofday(const struct timespec *ts);
10777 +#define vx_adjust_timespec(t) do { } while (0)
10778 +#define vx_settimeofday(t) do_settimeofday(t)
10782 +#warning duplicate inclusion
10784 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/Kbuild linux-3.1.6-vs2.3.2.5/include/linux/vserver/Kbuild
10785 --- linux-3.1.6/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
10786 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/Kbuild 2011-10-24 18:53:33.000000000 +0200
10789 +header-y += context_cmd.h network_cmd.h space_cmd.h \
10790 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
10791 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
10792 + debug_cmd.h device_cmd.h
10794 +header-y += switch.h network.h monitor.h inode.h device.h
10796 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/base.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/base.h
10797 --- linux-3.1.6/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
10798 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/base.h 2011-10-24 18:53:33.000000000 +0200
10800 +#ifndef _VX_BASE_H
10801 +#define _VX_BASE_H
10804 +/* context state changes */
10816 +#define vx_task_xid(t) ((t)->xid)
10818 +#define vx_current_xid() vx_task_xid(current)
10820 +#define current_vx_info() (current->vx_info)
10823 +#define nx_task_nid(t) ((t)->nid)
10825 +#define nx_current_nid() nx_task_nid(current)
10827 +#define current_nx_info() (current->nx_info)
10830 +/* generic flag merging */
10832 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
10834 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
10836 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
10838 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
10841 +/* context flags */
10843 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
10845 +#define vx_current_flags() __vx_flags(current_vx_info())
10847 +#define vx_info_flags(v, m, f) \
10848 + vs_check_flags(__vx_flags(v), m, f)
10850 +#define task_vx_flags(t, m, f) \
10851 + ((t) && vx_info_flags((t)->vx_info, m, f))
10853 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
10856 +/* context caps */
10858 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
10860 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
10862 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
10864 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
10868 +/* network flags */
10870 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
10872 +#define nx_current_flags() __nx_flags(current_nx_info())
10874 +#define nx_info_flags(n, m, f) \
10875 + vs_check_flags(__nx_flags(n), m, f)
10877 +#define task_nx_flags(t, m, f) \
10878 + ((t) && nx_info_flags((t)->nx_info, m, f))
10880 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
10883 +/* network caps */
10885 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
10887 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
10889 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
10891 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
10894 +/* context mask capabilities */
10896 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
10898 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
10900 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
10903 +/* context bcap mask */
10905 +#define __vx_bcaps(v) ((v)->vx_bcaps)
10907 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
10910 +/* mask given bcaps */
10912 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
10914 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
10917 +/* masked cap_bset */
10919 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
10921 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
10924 +#define vx_info_mbcap(v, b) \
10925 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
10926 + vx_info_bcaps(v, b) : (b))
10928 +#define task_vx_mbcap(t, b) \
10929 + vx_info_mbcap((t)->vx_info, (t)->b)
10931 +#define vx_mbcap(b) task_vx_mbcap(current, b)
10934 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
10936 +#define vx_capable(b, c) (capable(b) || \
10937 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10939 +#define vx_ns_capable(n, b, c) (ns_capable(n, b) || \
10940 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10942 +#define nx_capable(b, c) (capable(b) || \
10943 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
10945 +#define vx_task_initpid(t, n) \
10946 + ((t)->vx_info && \
10947 + ((t)->vx_info->vx_initpid == (n)))
10949 +#define vx_current_initpid(n) vx_task_initpid(current, n)
10952 +/* context unshare mask */
10954 +#define __vx_umask(v) ((v)->vx_umask)
10956 +#define vx_current_umask() __vx_umask(current_vx_info())
10958 +#define vx_can_unshare(b, f) (capable(b) || \
10959 + (cap_raised(current_cap(), b) && \
10960 + !((f) & ~vx_current_umask())))
10963 +#define __vx_wmask(v) ((v)->vx_wmask)
10965 +#define vx_current_wmask() __vx_wmask(current_vx_info())
10968 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
10970 +#define vx_info_state(v, m) (__vx_state(v) & (m))
10973 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
10975 +#define nx_info_state(n, m) (__nx_state(n) & (m))
10978 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/cacct.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/cacct.h
10979 --- linux-3.1.6/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
10980 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/cacct.h 2011-10-24 18:53:33.000000000 +0200
10982 +#ifndef _VX_CACCT_H
10983 +#define _VX_CACCT_H
10986 +enum sock_acc_field {
10987 + VXA_SOCK_UNSPEC = 0,
10993 + VXA_SOCK_SIZE /* array size */
10996 +#endif /* _VX_CACCT_H */
10997 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/cacct_cmd.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/cacct_cmd.h
10998 --- linux-3.1.6/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
10999 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/cacct_cmd.h 2011-10-24 18:53:33.000000000 +0200
11001 +#ifndef _VX_CACCT_CMD_H
11002 +#define _VX_CACCT_CMD_H
11005 +/* virtual host info name commands */
11007 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
11009 +struct vcmd_sock_stat_v0 {
11011 + uint32_t count[3];
11012 + uint64_t total[3];
11018 +#include <linux/compiler.h>
11020 +extern int vc_sock_stat(struct vx_info *, void __user *);
11022 +#endif /* __KERNEL__ */
11023 +#endif /* _VX_CACCT_CMD_H */
11024 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/cacct_def.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/cacct_def.h
11025 --- linux-3.1.6/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
11026 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/cacct_def.h 2011-10-24 18:53:33.000000000 +0200
11028 +#ifndef _VX_CACCT_DEF_H
11029 +#define _VX_CACCT_DEF_H
11031 +#include <asm/atomic.h>
11032 +#include <linux/vserver/cacct.h>
11035 +struct _vx_sock_acc {
11036 + atomic_long_t count;
11037 + atomic_long_t total;
11040 +/* context sub struct */
11042 +struct _vx_cacct {
11043 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
11044 + atomic_t slab[8];
11045 + atomic_t page[6][8];
11048 +#ifdef CONFIG_VSERVER_DEBUG
11050 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
11054 + printk("\t_vx_cacct:");
11055 + for (i = 0; i < 6; i++) {
11056 + struct _vx_sock_acc *ptr = cacct->sock[i];
11058 + printk("\t [%d] =", i);
11059 + for (j = 0; j < 3; j++) {
11060 + printk(" [%d] = %8lu, %8lu", j,
11061 + atomic_long_read(&ptr[j].count),
11062 + atomic_long_read(&ptr[j].total));
11070 +#endif /* _VX_CACCT_DEF_H */
11071 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/cacct_int.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/cacct_int.h
11072 --- linux-3.1.6/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
11073 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/cacct_int.h 2011-10-24 18:53:33.000000000 +0200
11075 +#ifndef _VX_CACCT_INT_H
11076 +#define _VX_CACCT_INT_H
11082 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
11084 + return atomic_long_read(&cacct->sock[type][pos].count);
11089 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
11091 + return atomic_long_read(&cacct->sock[type][pos].total);
11094 +#endif /* __KERNEL__ */
11095 +#endif /* _VX_CACCT_INT_H */
11096 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/check.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/check.h
11097 --- linux-3.1.6/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
11098 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/check.h 2011-10-24 18:53:33.000000000 +0200
11100 +#ifndef _VS_CHECK_H
11101 +#define _VS_CHECK_H
11104 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
11106 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
11107 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
11109 +#define MIN_D_CONTEXT 65536
11112 +/* check conditions */
11114 +#define VS_ADMIN 0x0001
11115 +#define VS_WATCH 0x0002
11116 +#define VS_HIDE 0x0004
11117 +#define VS_HOSTID 0x0008
11119 +#define VS_IDENT 0x0010
11120 +#define VS_EQUIV 0x0020
11121 +#define VS_PARENT 0x0040
11122 +#define VS_CHILD 0x0080
11124 +#define VS_ARG_MASK 0x00F0
11126 +#define VS_DYNAMIC 0x0100
11127 +#define VS_STATIC 0x0200
11129 +#define VS_ATR_MASK 0x0F00
11131 +#ifdef CONFIG_VSERVER_PRIVACY
11132 +#define VS_ADMIN_P (0)
11133 +#define VS_WATCH_P (0)
11135 +#define VS_ADMIN_P VS_ADMIN
11136 +#define VS_WATCH_P VS_WATCH
11139 +#define VS_HARDIRQ 0x1000
11140 +#define VS_SOFTIRQ 0x2000
11141 +#define VS_IRQ 0x4000
11143 +#define VS_IRQ_MASK 0xF000
11145 +#include <linux/hardirq.h>
11148 + * check current context for ADMIN/WATCH and
11149 + * optionally against supplied argument
11151 +static inline int __vs_check(int cid, int id, unsigned int mode)
11153 + if (mode & VS_ARG_MASK) {
11154 + if ((mode & VS_IDENT) && (id == cid))
11157 + if (mode & VS_ATR_MASK) {
11158 + if ((mode & VS_DYNAMIC) &&
11159 + (id >= MIN_D_CONTEXT) &&
11160 + (id <= MAX_S_CONTEXT))
11162 + if ((mode & VS_STATIC) &&
11163 + (id > 1) && (id < MIN_D_CONTEXT))
11166 + if (mode & VS_IRQ_MASK) {
11167 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
11169 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
11171 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
11174 + return (((mode & VS_ADMIN) && (cid == 0)) ||
11175 + ((mode & VS_WATCH) && (cid == 1)) ||
11176 + ((mode & VS_HOSTID) && (id == 0)));
11179 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
11181 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
11184 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
11186 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
11189 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/context.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/context.h
11190 --- linux-3.1.6/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
11191 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/context.h 2011-11-18 00:40:25.000000000 +0100
11193 +#ifndef _VX_CONTEXT_H
11194 +#define _VX_CONTEXT_H
11196 +#include <linux/types.h>
11197 +#include <linux/capability.h>
11200 +/* context flags */
11202 +#define VXF_INFO_SCHED 0x00000002
11203 +#define VXF_INFO_NPROC 0x00000004
11204 +#define VXF_INFO_PRIVATE 0x00000008
11206 +#define VXF_INFO_INIT 0x00000010
11207 +#define VXF_INFO_HIDE 0x00000020
11208 +#define VXF_INFO_ULIMIT 0x00000040
11209 +#define VXF_INFO_NSPACE 0x00000080
11211 +#define VXF_SCHED_HARD 0x00000100
11212 +#define VXF_SCHED_PRIO 0x00000200
11213 +#define VXF_SCHED_PAUSE 0x00000400
11215 +#define VXF_VIRT_MEM 0x00010000
11216 +#define VXF_VIRT_UPTIME 0x00020000
11217 +#define VXF_VIRT_CPU 0x00040000
11218 +#define VXF_VIRT_LOAD 0x00080000
11219 +#define VXF_VIRT_TIME 0x00100000
11221 +#define VXF_HIDE_MOUNT 0x01000000
11222 +/* was VXF_HIDE_NETIF 0x02000000 */
11223 +#define VXF_HIDE_VINFO 0x04000000
11225 +#define VXF_STATE_SETUP (1ULL << 32)
11226 +#define VXF_STATE_INIT (1ULL << 33)
11227 +#define VXF_STATE_ADMIN (1ULL << 34)
11229 +#define VXF_SC_HELPER (1ULL << 36)
11230 +#define VXF_REBOOT_KILL (1ULL << 37)
11231 +#define VXF_PERSISTENT (1ULL << 38)
11233 +#define VXF_FORK_RSS (1ULL << 48)
11234 +#define VXF_PROLIFIC (1ULL << 49)
11236 +#define VXF_IGNEG_NICE (1ULL << 52)
11238 +#define VXF_ONE_TIME (0x0007ULL << 32)
11240 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
11243 +/* context migration */
11245 +#define VXM_SET_INIT 0x00000001
11246 +#define VXM_SET_REAPER 0x00000002
11248 +/* context caps */
11250 +#define VXC_SET_UTSNAME 0x00000001
11251 +#define VXC_SET_RLIMIT 0x00000002
11252 +#define VXC_FS_SECURITY 0x00000004
11253 +#define VXC_FS_TRUSTED 0x00000008
11254 +#define VXC_TIOCSTI 0x00000010
11256 +/* was VXC_RAW_ICMP 0x00000100 */
11257 +#define VXC_SYSLOG 0x00001000
11258 +#define VXC_OOM_ADJUST 0x00002000
11259 +#define VXC_AUDIT_CONTROL 0x00004000
11261 +#define VXC_SECURE_MOUNT 0x00010000
11262 +#define VXC_SECURE_REMOUNT 0x00020000
11263 +#define VXC_BINARY_MOUNT 0x00040000
11265 +#define VXC_QUOTA_CTL 0x00100000
11266 +#define VXC_ADMIN_MAPPER 0x00200000
11267 +#define VXC_ADMIN_CLOOP 0x00400000
11269 +#define VXC_KTHREAD 0x01000000
11270 +#define VXC_NAMESPACE 0x02000000
11275 +#include <linux/list.h>
11276 +#include <linux/spinlock.h>
11277 +#include <linux/rcupdate.h>
11279 +#include "limit_def.h"
11280 +#include "sched_def.h"
11281 +#include "cvirt_def.h"
11282 +#include "cacct_def.h"
11283 +#include "device_def.h"
11285 +#define VX_SPACES 2
11287 +struct _vx_info_pc {
11288 + struct _vx_sched_pc sched_pc;
11289 + struct _vx_cvirt_pc cvirt_pc;
11292 +struct _vx_space {
11293 + unsigned long vx_nsmask; /* assignment mask */
11294 + struct nsproxy *vx_nsproxy; /* private namespaces */
11295 + struct fs_struct *vx_fs; /* private namespace fs */
11296 + const struct cred *vx_cred; /* task credentials */
11300 + struct hlist_node vx_hlist; /* linked list of contexts */
11301 + xid_t vx_id; /* context id */
11302 + atomic_t vx_usecnt; /* usage count */
11303 + atomic_t vx_tasks; /* tasks count */
11304 + struct vx_info *vx_parent; /* parent context */
11305 + int vx_state; /* context state */
11307 + struct _vx_space space[VX_SPACES]; /* namespace store */
11309 + uint64_t vx_flags; /* context flags */
11310 + uint64_t vx_ccaps; /* context caps (vserver) */
11311 + uint64_t vx_umask; /* unshare mask (guest) */
11312 + uint64_t vx_wmask; /* warn mask (guest) */
11313 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
11315 + struct task_struct *vx_reaper; /* guest reaper process */
11316 + pid_t vx_initpid; /* PID of guest init */
11317 + int64_t vx_badness_bias; /* OOM points bias */
11319 + struct _vx_limit limit; /* vserver limits */
11320 + struct _vx_sched sched; /* vserver scheduler */
11321 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
11322 + struct _vx_cacct cacct; /* context accounting */
11324 + struct _vx_device dmap; /* default device map targets */
11326 +#ifndef CONFIG_SMP
11327 + struct _vx_info_pc info_pc; /* per cpu data */
11329 + struct _vx_info_pc *ptr_pc; /* per cpu array */
11332 + wait_queue_head_t vx_wait; /* context exit waitqueue */
11333 + int reboot_cmd; /* last sys_reboot() cmd */
11334 + int exit_code; /* last process exit code */
11336 + char vx_name[65]; /* vserver name */
11339 +#ifndef CONFIG_SMP
11340 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
11341 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
11343 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
11344 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
11347 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
11350 +struct vx_info_save {
11351 + struct vx_info *vxi;
11356 +/* status flags */
11358 +#define VXS_HASHED 0x0001
11359 +#define VXS_PAUSED 0x0010
11360 +#define VXS_SHUTDOWN 0x0100
11361 +#define VXS_HELPER 0x1000
11362 +#define VXS_RELEASED 0x8000
11365 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
11366 +extern void release_vx_info(struct vx_info *, struct task_struct *);
11368 +extern struct vx_info *lookup_vx_info(int);
11369 +extern struct vx_info *lookup_or_create_vx_info(int);
11371 +extern int get_xid_list(int, unsigned int *, int);
11372 +extern int xid_is_hashed(xid_t);
11374 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
11376 +extern long vs_state_change(struct vx_info *, unsigned int);
11379 +#endif /* __KERNEL__ */
11380 +#endif /* _VX_CONTEXT_H */
11381 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/context_cmd.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/context_cmd.h
11382 --- linux-3.1.6/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
11383 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/context_cmd.h 2011-10-24 18:53:33.000000000 +0200
11385 +#ifndef _VX_CONTEXT_CMD_H
11386 +#define _VX_CONTEXT_CMD_H
11389 +/* vinfo commands */
11391 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
11394 +extern int vc_task_xid(uint32_t);
11396 +#endif /* __KERNEL__ */
11398 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
11400 +struct vcmd_vx_info_v0 {
11402 + uint32_t initpid;
11403 + /* more to come */
11407 +extern int vc_vx_info(struct vx_info *, void __user *);
11409 +#endif /* __KERNEL__ */
11411 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
11413 +struct vcmd_ctx_stat_v0 {
11416 + /* more to come */
11420 +extern int vc_ctx_stat(struct vx_info *, void __user *);
11422 +#endif /* __KERNEL__ */
11424 +/* context commands */
11426 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
11427 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
11429 +struct vcmd_ctx_create {
11430 + uint64_t flagword;
11433 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
11434 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
11436 +struct vcmd_ctx_migrate {
11437 + uint64_t flagword;
11441 +extern int vc_ctx_create(uint32_t, void __user *);
11442 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
11444 +#endif /* __KERNEL__ */
11447 +/* flag commands */
11449 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
11450 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
11452 +struct vcmd_ctx_flags_v0 {
11453 + uint64_t flagword;
11458 +extern int vc_get_cflags(struct vx_info *, void __user *);
11459 +extern int vc_set_cflags(struct vx_info *, void __user *);
11461 +#endif /* __KERNEL__ */
11464 +/* context caps commands */
11466 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
11467 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
11469 +struct vcmd_ctx_caps_v1 {
11475 +extern int vc_get_ccaps(struct vx_info *, void __user *);
11476 +extern int vc_set_ccaps(struct vx_info *, void __user *);
11478 +#endif /* __KERNEL__ */
11481 +/* bcaps commands */
11483 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
11484 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
11486 +struct vcmd_bcaps {
11492 +extern int vc_get_bcaps(struct vx_info *, void __user *);
11493 +extern int vc_set_bcaps(struct vx_info *, void __user *);
11495 +#endif /* __KERNEL__ */
11498 +/* umask commands */
11500 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
11501 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
11503 +struct vcmd_umask {
11509 +extern int vc_get_umask(struct vx_info *, void __user *);
11510 +extern int vc_set_umask(struct vx_info *, void __user *);
11512 +#endif /* __KERNEL__ */
11515 +/* wmask commands */
11517 +#define VCMD_get_wmask VC_CMD(FLAGS, 15, 0)
11518 +#define VCMD_set_wmask VC_CMD(FLAGS, 16, 0)
11520 +struct vcmd_wmask {
11526 +extern int vc_get_wmask(struct vx_info *, void __user *);
11527 +extern int vc_set_wmask(struct vx_info *, void __user *);
11529 +#endif /* __KERNEL__ */
11534 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
11535 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
11537 +struct vcmd_badness_v0 {
11542 +extern int vc_get_badness(struct vx_info *, void __user *);
11543 +extern int vc_set_badness(struct vx_info *, void __user *);
11545 +#endif /* __KERNEL__ */
11546 +#endif /* _VX_CONTEXT_CMD_H */
11547 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/cvirt.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/cvirt.h
11548 --- linux-3.1.6/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
11549 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/cvirt.h 2011-10-24 18:53:33.000000000 +0200
11551 +#ifndef _VX_CVIRT_H
11552 +#define _VX_CVIRT_H
11559 +void vx_vsi_uptime(struct timespec *, struct timespec *);
11564 +void vx_update_load(struct vx_info *);
11567 +int vx_do_syslog(int, char __user *, int);
11569 +#endif /* __KERNEL__ */
11570 +#endif /* _VX_CVIRT_H */
11571 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/cvirt_cmd.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/cvirt_cmd.h
11572 --- linux-3.1.6/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
11573 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/cvirt_cmd.h 2011-10-24 18:53:33.000000000 +0200
11575 +#ifndef _VX_CVIRT_CMD_H
11576 +#define _VX_CVIRT_CMD_H
11579 +/* virtual host info name commands */
11581 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
11582 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
11584 +struct vcmd_vhi_name_v0 {
11590 +enum vhi_name_field {
11591 + VHIN_CONTEXT = 0,
11603 +#include <linux/compiler.h>
11605 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
11606 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
11608 +#endif /* __KERNEL__ */
11610 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
11612 +struct vcmd_virt_stat_v0 {
11615 + uint32_t nr_threads;
11616 + uint32_t nr_running;
11617 + uint32_t nr_uninterruptible;
11618 + uint32_t nr_onhold;
11619 + uint32_t nr_forks;
11620 + uint32_t load[3];
11624 +extern int vc_virt_stat(struct vx_info *, void __user *);
11626 +#endif /* __KERNEL__ */
11627 +#endif /* _VX_CVIRT_CMD_H */
11628 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/cvirt_def.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/cvirt_def.h
11629 --- linux-3.1.6/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
11630 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/cvirt_def.h 2011-10-24 18:53:33.000000000 +0200
11632 +#ifndef _VX_CVIRT_DEF_H
11633 +#define _VX_CVIRT_DEF_H
11635 +#include <linux/jiffies.h>
11636 +#include <linux/spinlock.h>
11637 +#include <linux/wait.h>
11638 +#include <linux/time.h>
11639 +#include <asm/atomic.h>
11642 +struct _vx_usage_stat {
11646 + uint64_t softirq;
11652 +struct _vx_syslog {
11653 + wait_queue_head_t log_wait;
11654 + spinlock_t logbuf_lock; /* lock for the log buffer */
11656 + unsigned long log_start; /* next char to be read by syslog() */
11657 + unsigned long con_start; /* next char to be sent to consoles */
11658 + unsigned long log_end; /* most-recently-written-char + 1 */
11659 + unsigned long logged_chars; /* #chars since last read+clear operation */
11661 + char log_buf[1024];
11665 +/* context sub struct */
11667 +struct _vx_cvirt {
11668 + atomic_t nr_threads; /* number of current threads */
11669 + atomic_t nr_running; /* number of running threads */
11670 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
11672 + atomic_t nr_onhold; /* processes on hold */
11673 + uint32_t onhold_last; /* jiffies when put on hold */
11675 + struct timespec bias_ts; /* time offset to the host */
11676 + struct timespec bias_idle;
11677 + struct timespec bias_uptime; /* context creation point */
11678 + uint64_t bias_clock; /* offset in clock_t */
11680 + spinlock_t load_lock; /* lock for the load averages */
11681 + atomic_t load_updates; /* nr of load updates done so far */
11682 + uint32_t load_last; /* last time load was calculated */
11683 + uint32_t load[3]; /* load averages 1,5,15 */
11685 + atomic_t total_forks; /* number of forks so far */
11687 + struct _vx_syslog syslog;
11690 +struct _vx_cvirt_pc {
11691 + struct _vx_usage_stat cpustat;
11695 +#ifdef CONFIG_VSERVER_DEBUG
11697 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
11699 + printk("\t_vx_cvirt:\n");
11700 + printk("\t threads: %4d, %4d, %4d, %4d\n",
11701 + atomic_read(&cvirt->nr_threads),
11702 + atomic_read(&cvirt->nr_running),
11703 + atomic_read(&cvirt->nr_uninterruptible),
11704 + atomic_read(&cvirt->nr_onhold));
11705 + /* add rest here */
11706 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
11711 +#endif /* _VX_CVIRT_DEF_H */
11712 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/debug.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/debug.h
11713 --- linux-3.1.6/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
11714 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/debug.h 2011-11-18 12:56:11.000000000 +0100
11716 +#ifndef _VX_DEBUG_H
11717 +#define _VX_DEBUG_H
11720 +#define VXD_CBIT(n, m) (vs_debug_ ## n & (1 << (m)))
11721 +#define VXD_CMIN(n, m) (vs_debug_ ## n > (m))
11722 +#define VXD_MASK(n, m) (vs_debug_ ## n & (m))
11724 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
11725 + imajor((d)->bd_inode), iminor((d)->bd_inode)
11726 +#define VXF_DEV "%p[%lu,%d:%d]"
11728 +#if defined(CONFIG_QUOTES_UTF8)
11729 +#define VS_Q_LQM "\xc2\xbb"
11730 +#define VS_Q_RQM "\xc2\xab"
11731 +#elif defined(CONFIG_QUOTES_ASCII)
11732 +#define VS_Q_LQM "\x27"
11733 +#define VS_Q_RQM "\x27"
11735 +#define VS_Q_LQM "\xbb"
11736 +#define VS_Q_RQM "\xab"
11739 +#define VS_Q(f) VS_Q_LQM f VS_Q_RQM
11742 +#define vxd_path(p) \
11743 + ({ static char _buffer[PATH_MAX]; \
11744 + d_path(p, _buffer, sizeof(_buffer)); })
11746 +#define vxd_cond_path(n) \
11747 + ((n) ? vxd_path(&(n)->path) : "<null>" )
11750 +#ifdef CONFIG_VSERVER_DEBUG
11752 +extern unsigned int vs_debug_switch;
11753 +extern unsigned int vs_debug_xid;
11754 +extern unsigned int vs_debug_nid;
11755 +extern unsigned int vs_debug_tag;
11756 +extern unsigned int vs_debug_net;
11757 +extern unsigned int vs_debug_limit;
11758 +extern unsigned int vs_debug_cres;
11759 +extern unsigned int vs_debug_dlim;
11760 +extern unsigned int vs_debug_quota;
11761 +extern unsigned int vs_debug_cvirt;
11762 +extern unsigned int vs_debug_space;
11763 +extern unsigned int vs_debug_perm;
11764 +extern unsigned int vs_debug_misc;
11767 +#define VX_LOGLEVEL "vxD: "
11768 +#define VX_PROC_FMT "%p: "
11769 +#define VX_PROCESS current
11771 +#define vxdprintk(c, f, x...) \
11774 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
11775 + VX_PROCESS , ##x); \
11778 +#define vxlprintk(c, f, x...) \
11781 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
11784 +#define vxfprintk(c, f, x...) \
11787 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
11793 +void dump_vx_info(struct vx_info *, int);
11794 +void dump_vx_info_inactive(int);
11796 +#else /* CONFIG_VSERVER_DEBUG */
11798 +#define vs_debug_switch 0
11799 +#define vs_debug_xid 0
11800 +#define vs_debug_nid 0
11801 +#define vs_debug_tag 0
11802 +#define vs_debug_net 0
11803 +#define vs_debug_limit 0
11804 +#define vs_debug_cres 0
11805 +#define vs_debug_dlim 0
11806 +#define vs_debug_quota 0
11807 +#define vs_debug_cvirt 0
11808 +#define vs_debug_space 0
11809 +#define vs_debug_perm 0
11810 +#define vs_debug_misc 0
11812 +#define vxdprintk(x...) do { } while (0)
11813 +#define vxlprintk(x...) do { } while (0)
11814 +#define vxfprintk(x...) do { } while (0)
11816 +#endif /* CONFIG_VSERVER_DEBUG */
11819 +#ifdef CONFIG_VSERVER_WARN
11821 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
11822 +#define VX_WARN_TASK "[" VS_Q("%s") ",%u:#%u|%u|%u] "
11823 +#define VX_WARN_XID "[xid #%u] "
11824 +#define VX_WARN_NID "[nid #%u] "
11825 +#define VX_WARN_TAG "[tag #%u] "
11827 +#define vxwprintk(c, f, x...) \
11830 + printk(VX_WARNLEVEL f "\n", ##x); \
11833 +#else /* CONFIG_VSERVER_WARN */
11835 +#define vxwprintk(x...) do { } while (0)
11837 +#endif /* CONFIG_VSERVER_WARN */
11839 +#define vxwprintk_task(c, f, x...) \
11840 + vxwprintk(c, VX_WARN_TASK f, \
11841 + current->comm, current->pid, \
11842 + current->xid, current->nid, current->tag, ##x)
11843 +#define vxwprintk_xid(c, f, x...) \
11844 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
11845 +#define vxwprintk_nid(c, f, x...) \
11846 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
11847 +#define vxwprintk_tag(c, f, x...) \
11848 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
11850 +#ifdef CONFIG_VSERVER_DEBUG
11851 +#define vxd_assert_lock(l) assert_spin_locked(l)
11852 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
11853 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
11855 +#define vxd_assert_lock(l) do { } while (0)
11856 +#define vxd_assert(c, f, x...) do { } while (0)
11860 +#endif /* _VX_DEBUG_H */
11861 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/debug_cmd.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/debug_cmd.h
11862 --- linux-3.1.6/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
11863 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/debug_cmd.h 2011-10-24 18:53:33.000000000 +0200
11865 +#ifndef _VX_DEBUG_CMD_H
11866 +#define _VX_DEBUG_CMD_H
11869 +/* debug commands */
11871 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
11873 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
11874 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
11876 +struct vcmd_read_history_v0 {
11879 + char __user *data;
11882 +struct vcmd_read_monitor_v0 {
11885 + char __user *data;
11891 +#ifdef CONFIG_COMPAT
11893 +#include <asm/compat.h>
11895 +struct vcmd_read_history_v0_x32 {
11898 + compat_uptr_t data_ptr;
11901 +struct vcmd_read_monitor_v0_x32 {
11904 + compat_uptr_t data_ptr;
11907 +#endif /* CONFIG_COMPAT */
11909 +extern int vc_dump_history(uint32_t);
11911 +extern int vc_read_history(uint32_t, void __user *);
11912 +extern int vc_read_monitor(uint32_t, void __user *);
11914 +#ifdef CONFIG_COMPAT
11916 +extern int vc_read_history_x32(uint32_t, void __user *);
11917 +extern int vc_read_monitor_x32(uint32_t, void __user *);
11919 +#endif /* CONFIG_COMPAT */
11921 +#endif /* __KERNEL__ */
11922 +#endif /* _VX_DEBUG_CMD_H */
11923 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/device.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/device.h
11924 --- linux-3.1.6/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
11925 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/device.h 2011-10-24 18:53:33.000000000 +0200
11927 +#ifndef _VX_DEVICE_H
11928 +#define _VX_DEVICE_H
11931 +#define DATTR_CREATE 0x00000001
11932 +#define DATTR_OPEN 0x00000002
11934 +#define DATTR_REMAP 0x00000010
11936 +#define DATTR_MASK 0x00000013
11939 +#else /* _VX_DEVICE_H */
11940 +#warning duplicate inclusion
11941 +#endif /* _VX_DEVICE_H */
11942 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/device_cmd.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/device_cmd.h
11943 --- linux-3.1.6/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
11944 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/device_cmd.h 2011-10-24 18:53:33.000000000 +0200
11946 +#ifndef _VX_DEVICE_CMD_H
11947 +#define _VX_DEVICE_CMD_H
11950 +/* device vserver commands */
11952 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
11953 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
11955 +struct vcmd_set_mapping_v0 {
11956 + const char __user *device;
11957 + const char __user *target;
11964 +#ifdef CONFIG_COMPAT
11966 +#include <asm/compat.h>
11968 +struct vcmd_set_mapping_v0_x32 {
11969 + compat_uptr_t device_ptr;
11970 + compat_uptr_t target_ptr;
11974 +#endif /* CONFIG_COMPAT */
11976 +#include <linux/compiler.h>
11978 +extern int vc_set_mapping(struct vx_info *, void __user *);
11979 +extern int vc_unset_mapping(struct vx_info *, void __user *);
11981 +#ifdef CONFIG_COMPAT
11983 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
11984 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
11986 +#endif /* CONFIG_COMPAT */
11988 +#endif /* __KERNEL__ */
11989 +#endif /* _VX_DEVICE_CMD_H */
11990 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/device_def.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/device_def.h
11991 --- linux-3.1.6/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
11992 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/device_def.h 2011-10-24 18:53:33.000000000 +0200
11994 +#ifndef _VX_DEVICE_DEF_H
11995 +#define _VX_DEVICE_DEF_H
11997 +#include <linux/types.h>
11999 +struct vx_dmap_target {
12004 +struct _vx_device {
12005 +#ifdef CONFIG_VSERVER_DEVICE
12006 + struct vx_dmap_target targets[2];
12010 +#endif /* _VX_DEVICE_DEF_H */
12011 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/dlimit.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/dlimit.h
12012 --- linux-3.1.6/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
12013 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/dlimit.h 2011-10-24 18:53:33.000000000 +0200
12015 +#ifndef _VX_DLIMIT_H
12016 +#define _VX_DLIMIT_H
12018 +#include "switch.h"
12023 +/* keep in sync with CDLIM_INFINITY */
12025 +#define DLIM_INFINITY (~0ULL)
12027 +#include <linux/spinlock.h>
12028 +#include <linux/rcupdate.h>
12030 +struct super_block;
12033 + struct hlist_node dl_hlist; /* linked list of contexts */
12034 + struct rcu_head dl_rcu; /* the rcu head */
12035 + tag_t dl_tag; /* context tag */
12036 + atomic_t dl_usecnt; /* usage count */
12037 + atomic_t dl_refcnt; /* reference count */
12039 + struct super_block *dl_sb; /* associated superblock */
12041 + spinlock_t dl_lock; /* protect the values */
12043 + unsigned long long dl_space_used; /* used space in bytes */
12044 + unsigned long long dl_space_total; /* maximum space in bytes */
12045 + unsigned long dl_inodes_used; /* used inodes */
12046 + unsigned long dl_inodes_total; /* maximum inodes */
12048 + unsigned int dl_nrlmult; /* non root limit mult */
12053 +extern void rcu_free_dl_info(struct rcu_head *);
12054 +extern void unhash_dl_info(struct dl_info *);
12056 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
12061 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
12063 +typedef uint64_t dlsize_t;
12065 +#endif /* __KERNEL__ */
12066 +#else /* _VX_DLIMIT_H */
12067 +#warning duplicate inclusion
12068 +#endif /* _VX_DLIMIT_H */
12069 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/dlimit_cmd.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/dlimit_cmd.h
12070 --- linux-3.1.6/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
12071 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/dlimit_cmd.h 2011-10-24 18:53:33.000000000 +0200
12073 +#ifndef _VX_DLIMIT_CMD_H
12074 +#define _VX_DLIMIT_CMD_H
12077 +/* dlimit vserver commands */
12079 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
12080 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
12082 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
12083 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
12085 +struct vcmd_ctx_dlimit_base_v0 {
12086 + const char __user *name;
12090 +struct vcmd_ctx_dlimit_v0 {
12091 + const char __user *name;
12092 + uint32_t space_used; /* used space in kbytes */
12093 + uint32_t space_total; /* maximum space in kbytes */
12094 + uint32_t inodes_used; /* used inodes */
12095 + uint32_t inodes_total; /* maximum inodes */
12096 + uint32_t reserved; /* reserved for root in % */
12100 +#define CDLIM_UNSET ((uint32_t)0UL)
12101 +#define CDLIM_INFINITY ((uint32_t)~0UL)
12102 +#define CDLIM_KEEP ((uint32_t)~1UL)
12104 +#define DLIME_UNIT 0
12105 +#define DLIME_KILO 1
12106 +#define DLIME_MEGA 2
12107 +#define DLIME_GIGA 3
12109 +#define DLIMF_SHIFT 0x10
12111 +#define DLIMS_USED 0
12112 +#define DLIMS_TOTAL 2
12115 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
12117 + int exp = (flags & DLIMF_SHIFT) ?
12118 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
12119 + return ((uint64_t)val) << (10 * exp);
12123 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
12127 + if (*flags & DLIMF_SHIFT) {
12128 + while (val > (1LL << 32) && (exp < 3)) {
12132 + *flags &= ~(DLIME_GIGA << shift);
12133 + *flags |= exp << shift;
12141 +#ifdef CONFIG_COMPAT
12143 +#include <asm/compat.h>
12145 +struct vcmd_ctx_dlimit_base_v0_x32 {
12146 + compat_uptr_t name_ptr;
12150 +struct vcmd_ctx_dlimit_v0_x32 {
12151 + compat_uptr_t name_ptr;
12152 + uint32_t space_used; /* used space in kbytes */
12153 + uint32_t space_total; /* maximum space in kbytes */
12154 + uint32_t inodes_used; /* used inodes */
12155 + uint32_t inodes_total; /* maximum inodes */
12156 + uint32_t reserved; /* reserved for root in % */
12160 +#endif /* CONFIG_COMPAT */
12162 +#include <linux/compiler.h>
12164 +extern int vc_add_dlimit(uint32_t, void __user *);
12165 +extern int vc_rem_dlimit(uint32_t, void __user *);
12167 +extern int vc_set_dlimit(uint32_t, void __user *);
12168 +extern int vc_get_dlimit(uint32_t, void __user *);
12170 +#ifdef CONFIG_COMPAT
12172 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
12173 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
12175 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
12176 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
12178 +#endif /* CONFIG_COMPAT */
12180 +#endif /* __KERNEL__ */
12181 +#endif /* _VX_DLIMIT_CMD_H */
12182 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/global.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/global.h
12183 --- linux-3.1.6/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
12184 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/global.h 2011-10-24 18:53:33.000000000 +0200
12186 +#ifndef _VX_GLOBAL_H
12187 +#define _VX_GLOBAL_H
12190 +extern atomic_t vx_global_ctotal;
12191 +extern atomic_t vx_global_cactive;
12193 +extern atomic_t nx_global_ctotal;
12194 +extern atomic_t nx_global_cactive;
12196 +extern atomic_t vs_global_nsproxy;
12197 +extern atomic_t vs_global_fs;
12198 +extern atomic_t vs_global_mnt_ns;
12199 +extern atomic_t vs_global_uts_ns;
12200 +extern atomic_t vs_global_user_ns;
12201 +extern atomic_t vs_global_pid_ns;
12204 +#endif /* _VX_GLOBAL_H */
12205 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/history.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/history.h
12206 --- linux-3.1.6/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
12207 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/history.h 2011-10-24 18:53:33.000000000 +0200
12209 +#ifndef _VX_HISTORY_H
12210 +#define _VX_HISTORY_H
12215 + VXH_THROW_OOPS = 1,
12219 + VXH_INIT_VX_INFO,
12222 + VXH_CLAIM_VX_INFO,
12223 + VXH_RELEASE_VX_INFO,
12224 + VXH_ALLOC_VX_INFO,
12225 + VXH_DEALLOC_VX_INFO,
12226 + VXH_HASH_VX_INFO,
12227 + VXH_UNHASH_VX_INFO,
12229 + VXH_LOOKUP_VX_INFO,
12230 + VXH_CREATE_VX_INFO,
12233 +struct _vxhe_vxi {
12234 + struct vx_info *ptr;
12240 +struct _vxhe_set_clr {
12244 +struct _vxhe_loc_lookup {
12248 +struct _vx_hist_entry {
12250 + unsigned short seq;
12251 + unsigned short type;
12252 + struct _vxhe_vxi vxi;
12254 + struct _vxhe_set_clr sc;
12255 + struct _vxhe_loc_lookup ll;
12259 +#ifdef CONFIG_VSERVER_HISTORY
12261 +extern unsigned volatile int vxh_active;
12263 +struct _vx_hist_entry *vxh_advance(void *loc);
12267 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
12269 + entry->vxi.ptr = vxi;
12271 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
12272 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
12273 + entry->vxi.xid = vxi->vx_id;
12278 +#define __HERE__ current_text_addr()
12280 +#define __VXH_BODY(__type, __data, __here) \
12281 + struct _vx_hist_entry *entry; \
12283 + preempt_disable(); \
12284 + entry = vxh_advance(__here); \
12286 + entry->type = __type; \
12287 + preempt_enable();
12290 + /* pass vxi only */
12292 +#define __VXH_SMPL \
12293 + __vxh_copy_vxi(entry, vxi)
12296 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
12298 + __VXH_BODY(__type, __VXH_SMPL, __here)
12301 + /* pass vxi and data (void *) */
12303 +#define __VXH_DATA \
12304 + __vxh_copy_vxi(entry, vxi); \
12305 + entry->sc.data = data
12308 +void __vxh_data(struct vx_info *vxi, void *data,
12309 + int __type, void *__here)
12311 + __VXH_BODY(__type, __VXH_DATA, __here)
12314 + /* pass vxi and arg (long) */
12316 +#define __VXH_LONG \
12317 + __vxh_copy_vxi(entry, vxi); \
12318 + entry->ll.arg = arg
12321 +void __vxh_long(struct vx_info *vxi, long arg,
12322 + int __type, void *__here)
12324 + __VXH_BODY(__type, __VXH_LONG, __here)
12329 +void __vxh_throw_oops(void *__here)
12331 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
12332 + /* prevent further acquisition */
12337 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
12339 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
12340 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
12342 +#define __vxh_init_vx_info(v, d, h) \
12343 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
12344 +#define __vxh_set_vx_info(v, d, h) \
12345 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
12346 +#define __vxh_clr_vx_info(v, d, h) \
12347 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
12349 +#define __vxh_claim_vx_info(v, d, h) \
12350 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
12351 +#define __vxh_release_vx_info(v, d, h) \
12352 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
12354 +#define vxh_alloc_vx_info(v) \
12355 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
12356 +#define vxh_dealloc_vx_info(v) \
12357 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
12359 +#define vxh_hash_vx_info(v) \
12360 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
12361 +#define vxh_unhash_vx_info(v) \
12362 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
12364 +#define vxh_loc_vx_info(v, l) \
12365 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
12366 +#define vxh_lookup_vx_info(v, l) \
12367 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
12368 +#define vxh_create_vx_info(v, l) \
12369 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
12371 +extern void vxh_dump_history(void);
12374 +#else /* CONFIG_VSERVER_HISTORY */
12376 +#define __HERE__ 0
12378 +#define vxh_throw_oops() do { } while (0)
12380 +#define __vxh_get_vx_info(v, h) do { } while (0)
12381 +#define __vxh_put_vx_info(v, h) do { } while (0)
12383 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
12384 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
12385 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
12387 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
12388 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
12390 +#define vxh_alloc_vx_info(v) do { } while (0)
12391 +#define vxh_dealloc_vx_info(v) do { } while (0)
12393 +#define vxh_hash_vx_info(v) do { } while (0)
12394 +#define vxh_unhash_vx_info(v) do { } while (0)
12396 +#define vxh_loc_vx_info(v, l) do { } while (0)
12397 +#define vxh_lookup_vx_info(v, l) do { } while (0)
12398 +#define vxh_create_vx_info(v, l) do { } while (0)
12400 +#define vxh_dump_history() do { } while (0)
12403 +#endif /* CONFIG_VSERVER_HISTORY */
12405 +#endif /* _VX_HISTORY_H */
12406 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/inode.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/inode.h
12407 --- linux-3.1.6/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
12408 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/inode.h 2011-10-24 18:53:33.000000000 +0200
12410 +#ifndef _VX_INODE_H
12411 +#define _VX_INODE_H
12414 +#define IATTR_TAG 0x01000000
12416 +#define IATTR_ADMIN 0x00000001
12417 +#define IATTR_WATCH 0x00000002
12418 +#define IATTR_HIDE 0x00000004
12419 +#define IATTR_FLAGS 0x00000007
12421 +#define IATTR_BARRIER 0x00010000
12422 +#define IATTR_IXUNLINK 0x00020000
12423 +#define IATTR_IMMUTABLE 0x00040000
12424 +#define IATTR_COW 0x00080000
12429 +#ifdef CONFIG_VSERVER_PROC_SECURE
12430 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
12431 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
12433 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
12434 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
12437 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
12439 +#endif /* __KERNEL__ */
12441 +/* inode ioctls */
12443 +#define FIOC_GETXFLG _IOR('x', 5, long)
12444 +#define FIOC_SETXFLG _IOW('x', 6, long)
12446 +#else /* _VX_INODE_H */
12447 +#warning duplicate inclusion
12448 +#endif /* _VX_INODE_H */
12449 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/inode_cmd.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/inode_cmd.h
12450 --- linux-3.1.6/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
12451 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/inode_cmd.h 2011-10-24 18:53:33.000000000 +0200
12453 +#ifndef _VX_INODE_CMD_H
12454 +#define _VX_INODE_CMD_H
12457 +/* inode vserver commands */
12459 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
12460 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
12462 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
12463 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
12465 +struct vcmd_ctx_iattr_v1 {
12466 + const char __user *name;
12472 +struct vcmd_ctx_fiattr_v0 {
12482 +#ifdef CONFIG_COMPAT
12484 +#include <asm/compat.h>
12486 +struct vcmd_ctx_iattr_v1_x32 {
12487 + compat_uptr_t name_ptr;
12493 +#endif /* CONFIG_COMPAT */
12495 +#include <linux/compiler.h>
12497 +extern int vc_get_iattr(void __user *);
12498 +extern int vc_set_iattr(void __user *);
12500 +extern int vc_fget_iattr(uint32_t, void __user *);
12501 +extern int vc_fset_iattr(uint32_t, void __user *);
12503 +#ifdef CONFIG_COMPAT
12505 +extern int vc_get_iattr_x32(void __user *);
12506 +extern int vc_set_iattr_x32(void __user *);
12508 +#endif /* CONFIG_COMPAT */
12510 +#endif /* __KERNEL__ */
12511 +#endif /* _VX_INODE_CMD_H */
12512 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/limit.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/limit.h
12513 --- linux-3.1.6/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
12514 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/limit.h 2011-10-24 18:53:33.000000000 +0200
12516 +#ifndef _VX_LIMIT_H
12517 +#define _VX_LIMIT_H
12519 +#define VLIMIT_NSOCK 16
12520 +#define VLIMIT_OPENFD 17
12521 +#define VLIMIT_ANON 18
12522 +#define VLIMIT_SHMEM 19
12523 +#define VLIMIT_SEMARY 20
12524 +#define VLIMIT_NSEMS 21
12525 +#define VLIMIT_DENTRY 22
12526 +#define VLIMIT_MAPPED 23
12531 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
12533 +/* keep in sync with CRLIM_INFINITY */
12535 +#define VLIM_INFINITY (~0ULL)
12537 +#include <asm/atomic.h>
12538 +#include <asm/resource.h>
12540 +#ifndef RLIM_INFINITY
12541 +#warning RLIM_INFINITY is undefined
12544 +#define __rlim_val(l, r, v) ((l)->res[r].v)
12546 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
12547 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
12549 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
12550 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
12551 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
12553 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
12554 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
12556 +typedef atomic_long_t rlim_atomic_t;
12557 +typedef unsigned long rlim_t;
12559 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
12560 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
12561 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
12562 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
12563 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
12564 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
12567 +#if (RLIM_INFINITY == VLIM_INFINITY)
12568 +#define VX_VLIM(r) ((long long)(long)(r))
12569 +#define VX_RLIM(v) ((rlim_t)(v))
12571 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
12572 + ? VLIM_INFINITY : (long long)(r))
12573 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
12574 + ? RLIM_INFINITY : (rlim_t)(v))
12579 +void vx_vsi_meminfo(struct sysinfo *);
12580 +void vx_vsi_swapinfo(struct sysinfo *);
12581 +long vx_vsi_cached(struct sysinfo *);
12583 +#define NUM_LIMITS 24
12585 +#endif /* __KERNEL__ */
12586 +#endif /* _VX_LIMIT_H */
12587 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/limit_cmd.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/limit_cmd.h
12588 --- linux-3.1.6/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
12589 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/limit_cmd.h 2011-10-24 18:53:33.000000000 +0200
12591 +#ifndef _VX_LIMIT_CMD_H
12592 +#define _VX_LIMIT_CMD_H
12595 +/* rlimit vserver commands */
12597 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
12598 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
12599 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
12600 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
12601 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
12603 +struct vcmd_ctx_rlimit_v0 {
12605 + uint64_t minimum;
12606 + uint64_t softlimit;
12607 + uint64_t maximum;
12610 +struct vcmd_ctx_rlimit_mask_v0 {
12611 + uint32_t minimum;
12612 + uint32_t softlimit;
12613 + uint32_t maximum;
12616 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
12618 +struct vcmd_rlimit_stat_v0 {
12622 + uint64_t minimum;
12623 + uint64_t maximum;
12626 +#define CRLIM_UNSET (0ULL)
12627 +#define CRLIM_INFINITY (~0ULL)
12628 +#define CRLIM_KEEP (~1ULL)
12632 +#ifdef CONFIG_IA32_EMULATION
12634 +struct vcmd_ctx_rlimit_v0_x32 {
12636 + uint64_t minimum;
12637 + uint64_t softlimit;
12638 + uint64_t maximum;
12639 +} __attribute__ ((packed));
12641 +#endif /* CONFIG_IA32_EMULATION */
12643 +#include <linux/compiler.h>
12645 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
12646 +extern int vc_get_rlimit(struct vx_info *, void __user *);
12647 +extern int vc_set_rlimit(struct vx_info *, void __user *);
12648 +extern int vc_reset_hits(struct vx_info *, void __user *);
12649 +extern int vc_reset_minmax(struct vx_info *, void __user *);
12651 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
12653 +#ifdef CONFIG_IA32_EMULATION
12655 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
12656 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
12658 +#endif /* CONFIG_IA32_EMULATION */
12660 +#endif /* __KERNEL__ */
12661 +#endif /* _VX_LIMIT_CMD_H */
12662 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/limit_def.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/limit_def.h
12663 --- linux-3.1.6/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
12664 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/limit_def.h 2011-10-24 18:53:33.000000000 +0200
12666 +#ifndef _VX_LIMIT_DEF_H
12667 +#define _VX_LIMIT_DEF_H
12669 +#include <asm/atomic.h>
12670 +#include <asm/resource.h>
12672 +#include "limit.h"
12675 +struct _vx_res_limit {
12676 + rlim_t soft; /* Context soft limit */
12677 + rlim_t hard; /* Context hard limit */
12679 + rlim_atomic_t rcur; /* Current value */
12680 + rlim_t rmin; /* Context minimum */
12681 + rlim_t rmax; /* Context maximum */
12683 + atomic_t lhit; /* Limit hits */
12686 +/* context sub struct */
12688 +struct _vx_limit {
12689 + struct _vx_res_limit res[NUM_LIMITS];
12692 +#ifdef CONFIG_VSERVER_DEBUG
12694 +static inline void __dump_vx_limit(struct _vx_limit *limit)
12698 + printk("\t_vx_limit:");
12699 + for (i = 0; i < NUM_LIMITS; i++) {
12700 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
12701 + i, (unsigned long)__rlim_get(limit, i),
12702 + (unsigned long)__rlim_rmin(limit, i),
12703 + (unsigned long)__rlim_rmax(limit, i),
12704 + (long)__rlim_soft(limit, i),
12705 + (long)__rlim_hard(limit, i),
12706 + atomic_read(&__rlim_lhit(limit, i)));
12712 +#endif /* _VX_LIMIT_DEF_H */
12713 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/limit_int.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/limit_int.h
12714 --- linux-3.1.6/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
12715 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/limit_int.h 2011-10-24 18:53:33.000000000 +0200
12717 +#ifndef _VX_LIMIT_INT_H
12718 +#define _VX_LIMIT_INT_H
12720 +#include "context.h"
12724 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
12725 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
12727 +extern const char *vlimit_name[NUM_LIMITS];
12729 +static inline void __vx_acc_cres(struct vx_info *vxi,
12730 + int res, int dir, void *_data, char *_file, int _line)
12732 + if (VXD_RCRES_COND(res))
12733 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
12734 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12735 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12736 + (dir > 0) ? "++" : "--", _data, _file, _line);
12741 + __rlim_inc(&vxi->limit, res);
12743 + __rlim_dec(&vxi->limit, res);
12746 +static inline void __vx_add_cres(struct vx_info *vxi,
12747 + int res, int amount, void *_data, char *_file, int _line)
12749 + if (VXD_RCRES_COND(res))
12750 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
12751 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12752 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12753 + amount, _data, _file, _line);
12758 + __rlim_add(&vxi->limit, res, amount);
12762 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
12764 + int cond = (value > __rlim_rmax(limit, res));
12767 + __rlim_rmax(limit, res) = value;
12772 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
12774 + int cond = (value < __rlim_rmin(limit, res));
12777 + __rlim_rmin(limit, res) = value;
12782 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
12784 + if (!__vx_cres_adjust_max(limit, res, value))
12785 + __vx_cres_adjust_min(limit, res, value);
12790 + +1 ... no limit hit
12791 + -1 ... over soft limit
12792 + 0 ... over hard limit */
12794 +static inline int __vx_cres_avail(struct vx_info *vxi,
12795 + int res, int num, char *_file, int _line)
12797 + struct _vx_limit *limit;
12800 + if (VXD_RLIMIT_COND(res))
12801 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
12802 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12803 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
12804 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
12805 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12806 + num, _file, _line);
12810 + limit = &vxi->limit;
12811 + value = __rlim_get(limit, res);
12813 + if (!__vx_cres_adjust_max(limit, res, value))
12814 + __vx_cres_adjust_min(limit, res, value);
12819 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
12821 + if (value + num <= __rlim_soft(limit, res))
12824 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
12826 + if (value + num <= __rlim_hard(limit, res))
12829 + __rlim_hit(limit, res);
12834 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
12837 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
12839 + rlim_t value, sum = 0;
12842 + while ((res = *array++)) {
12843 + value = __rlim_get(limit, res);
12844 + __vx_cres_fixup(limit, res, value);
12851 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
12853 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
12854 + int res = *array;
12856 + if (value == __rlim_get(limit, res))
12859 + __rlim_set(limit, res, value);
12860 + /* now adjust min/max */
12861 + if (!__vx_cres_adjust_max(limit, res, value))
12862 + __vx_cres_adjust_min(limit, res, value);
12867 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
12868 + const int *array, int num, char *_file, int _line)
12870 + struct _vx_limit *limit;
12871 + rlim_t value = 0;
12879 + limit = &vxi->limit;
12881 + value = __vx_cres_array_sum(limit, array + 1);
12883 + __rlim_set(limit, res, value);
12884 + __vx_cres_fixup(limit, res, value);
12886 + return __vx_cres_avail(vxi, res, num, _file, _line);
12890 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
12895 + /* complex resources first */
12896 + if ((id < 0) || (id == RLIMIT_RSS))
12897 + __vx_cres_array_fixup(limit, VLA_RSS);
12899 + for (res = 0; res < NUM_LIMITS; res++) {
12900 + if ((id > 0) && (res != id))
12903 + value = __rlim_get(limit, res);
12904 + __vx_cres_fixup(limit, res, value);
12906 + /* not supposed to happen, maybe warn? */
12907 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
12908 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
12913 +#endif /* __KERNEL__ */
12914 +#endif /* _VX_LIMIT_INT_H */
12915 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/monitor.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/monitor.h
12916 --- linux-3.1.6/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
12917 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/monitor.h 2011-10-24 18:53:33.000000000 +0200
12919 +#ifndef _VX_MONITOR_H
12920 +#define _VX_MONITOR_H
12922 +#include <linux/types.h>
12929 + VXM_UPDATE = 0x20,
12933 + VXM_RQINFO_1 = 0x24,
12936 + VXM_ACTIVATE = 0x40,
12943 + VXM_MIGRATE = 0x48,
12946 + /* all other bits are flags */
12947 + VXM_SCHED = 0x80,
12950 +struct _vxm_update_1 {
12951 + uint32_t tokens_max;
12952 + uint32_t fill_rate;
12953 + uint32_t interval;
12956 +struct _vxm_update_2 {
12957 + uint32_t tokens_min;
12958 + uint32_t fill_rate;
12959 + uint32_t interval;
12962 +struct _vxm_rqinfo_1 {
12963 + uint16_t running;
12967 + uint32_t idle_tokens;
12970 +struct _vxm_rqinfo_2 {
12971 + uint32_t norm_time;
12972 + uint32_t idle_time;
12973 + uint32_t idle_skip;
12976 +struct _vxm_sched {
12978 + uint32_t norm_time;
12979 + uint32_t idle_time;
12982 +struct _vxm_task {
12987 +struct _vxm_event {
12996 + struct _vxm_task tsk;
13000 +struct _vx_mon_entry {
13004 + struct _vxm_event ev;
13005 + struct _vxm_sched sd;
13006 + struct _vxm_update_1 u1;
13007 + struct _vxm_update_2 u2;
13008 + struct _vxm_rqinfo_1 q1;
13009 + struct _vxm_rqinfo_2 q2;
13014 +#endif /* _VX_MONITOR_H */
13015 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/network.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/network.h
13016 --- linux-3.1.6/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
13017 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/network.h 2011-10-24 18:53:33.000000000 +0200
13019 +#ifndef _VX_NETWORK_H
13020 +#define _VX_NETWORK_H
13022 +#include <linux/types.h>
13025 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
13028 +/* network flags */
13030 +#define NXF_INFO_PRIVATE 0x00000008
13032 +#define NXF_SINGLE_IP 0x00000100
13033 +#define NXF_LBACK_REMAP 0x00000200
13034 +#define NXF_LBACK_ALLOW 0x00000400
13036 +#define NXF_HIDE_NETIF 0x02000000
13037 +#define NXF_HIDE_LBACK 0x04000000
13039 +#define NXF_STATE_SETUP (1ULL << 32)
13040 +#define NXF_STATE_ADMIN (1ULL << 34)
13042 +#define NXF_SC_HELPER (1ULL << 36)
13043 +#define NXF_PERSISTENT (1ULL << 38)
13045 +#define NXF_ONE_TIME (0x0005ULL << 32)
13048 +#define NXF_INIT_SET (__nxf_init_set())
13050 +static inline uint64_t __nxf_init_set(void) {
13051 + return NXF_STATE_ADMIN
13052 +#ifdef CONFIG_VSERVER_AUTO_LBACK
13053 + | NXF_LBACK_REMAP
13056 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
13059 + | NXF_HIDE_NETIF;
13063 +/* network caps */
13065 +#define NXC_TUN_CREATE 0x00000001
13067 +#define NXC_RAW_ICMP 0x00000100
13069 +#define NXC_MULTICAST 0x00001000
13072 +/* address types */
13074 +#define NXA_TYPE_IPV4 0x0001
13075 +#define NXA_TYPE_IPV6 0x0002
13077 +#define NXA_TYPE_NONE 0x0000
13078 +#define NXA_TYPE_ANY 0x00FF
13080 +#define NXA_TYPE_ADDR 0x0010
13081 +#define NXA_TYPE_MASK 0x0020
13082 +#define NXA_TYPE_RANGE 0x0040
13084 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
13086 +#define NXA_MOD_BCAST 0x0100
13087 +#define NXA_MOD_LBACK 0x0200
13089 +#define NXA_LOOPBACK 0x1000
13091 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
13092 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
13096 +#include <linux/list.h>
13097 +#include <linux/spinlock.h>
13098 +#include <linux/rcupdate.h>
13099 +#include <linux/in.h>
13100 +#include <linux/in6.h>
13101 +#include <asm/atomic.h>
13103 +struct nx_addr_v4 {
13104 + struct nx_addr_v4 *next;
13105 + struct in_addr ip[2];
13106 + struct in_addr mask;
13111 +struct nx_addr_v6 {
13112 + struct nx_addr_v6 *next;
13113 + struct in6_addr ip;
13114 + struct in6_addr mask;
13121 + struct hlist_node nx_hlist; /* linked list of nxinfos */
13122 + nid_t nx_id; /* vnet id */
13123 + atomic_t nx_usecnt; /* usage count */
13124 + atomic_t nx_tasks; /* tasks count */
13125 + int nx_state; /* context state */
13127 + uint64_t nx_flags; /* network flag word */
13128 + uint64_t nx_ncaps; /* network capabilities */
13130 + struct in_addr v4_lback; /* Loopback address */
13131 + struct in_addr v4_bcast; /* Broadcast address */
13132 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
13133 +#ifdef CONFIG_IPV6
13134 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
13136 + char nx_name[65]; /* network context name */
13140 +/* status flags */
13142 +#define NXS_HASHED 0x0001
13143 +#define NXS_SHUTDOWN 0x0100
13144 +#define NXS_RELEASED 0x8000
13146 +extern struct nx_info *lookup_nx_info(int);
13148 +extern int get_nid_list(int, unsigned int *, int);
13149 +extern int nid_is_hashed(nid_t);
13151 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
13153 +extern long vs_net_change(struct nx_info *, unsigned int);
13158 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
13159 +#ifdef CONFIG_IPV6
13160 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
13162 +#define NX_IPV6(n) (0)
13165 +#endif /* __KERNEL__ */
13166 +#endif /* _VX_NETWORK_H */
13167 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/network_cmd.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/network_cmd.h
13168 --- linux-3.1.6/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
13169 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/network_cmd.h 2011-10-24 18:53:33.000000000 +0200
13171 +#ifndef _VX_NETWORK_CMD_H
13172 +#define _VX_NETWORK_CMD_H
13175 +/* vinfo commands */
13177 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
13180 +extern int vc_task_nid(uint32_t);
13182 +#endif /* __KERNEL__ */
13184 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
13186 +struct vcmd_nx_info_v0 {
13188 + /* more to come */
13192 +extern int vc_nx_info(struct nx_info *, void __user *);
13194 +#endif /* __KERNEL__ */
13196 +#include <linux/in.h>
13197 +#include <linux/in6.h>
13199 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
13200 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
13202 +struct vcmd_net_create {
13203 + uint64_t flagword;
13206 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
13208 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
13209 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
13211 +struct vcmd_net_addr_v0 {
13214 + struct in_addr ip[4];
13215 + struct in_addr mask[4];
13218 +#define VCMD_net_add_ipv4_v1 VC_CMD(NETALT, 1, 1)
13219 +#define VCMD_net_rem_ipv4_v1 VC_CMD(NETALT, 2, 1)
13221 +struct vcmd_net_addr_ipv4_v1 {
13224 + struct in_addr ip;
13225 + struct in_addr mask;
13228 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 2)
13229 +#define VCMD_net_rem_ipv4 VC_CMD(NETALT, 2, 2)
13231 +struct vcmd_net_addr_ipv4_v2 {
13234 + struct in_addr ip;
13235 + struct in_addr ip2;
13236 + struct in_addr mask;
13239 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
13240 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
13242 +struct vcmd_net_addr_ipv6_v1 {
13246 + struct in6_addr ip;
13247 + struct in6_addr mask;
13250 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
13251 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
13253 +struct vcmd_match_ipv4_v0 {
13258 + struct in_addr ip;
13259 + struct in_addr ip2;
13260 + struct in_addr mask;
13263 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
13264 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
13266 +struct vcmd_match_ipv6_v0 {
13271 + struct in6_addr ip;
13272 + struct in6_addr ip2;
13273 + struct in6_addr mask;
13278 +extern int vc_net_create(uint32_t, void __user *);
13279 +extern int vc_net_migrate(struct nx_info *, void __user *);
13281 +extern int vc_net_add(struct nx_info *, void __user *);
13282 +extern int vc_net_remove(struct nx_info *, void __user *);
13284 +extern int vc_net_add_ipv4_v1(struct nx_info *, void __user *);
13285 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
13287 +extern int vc_net_rem_ipv4_v1(struct nx_info *, void __user *);
13288 +extern int vc_net_rem_ipv4(struct nx_info *, void __user *);
13290 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
13291 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
13293 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
13294 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
13296 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
13297 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
13299 +#endif /* __KERNEL__ */
13302 +/* flag commands */
13304 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
13305 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
13307 +struct vcmd_net_flags_v0 {
13308 + uint64_t flagword;
13313 +extern int vc_get_nflags(struct nx_info *, void __user *);
13314 +extern int vc_set_nflags(struct nx_info *, void __user *);
13316 +#endif /* __KERNEL__ */
13319 +/* network caps commands */
13321 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
13322 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
13324 +struct vcmd_net_caps_v0 {
13330 +extern int vc_get_ncaps(struct nx_info *, void __user *);
13331 +extern int vc_set_ncaps(struct nx_info *, void __user *);
13333 +#endif /* __KERNEL__ */
13334 +#endif /* _VX_CONTEXT_CMD_H */
13335 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/percpu.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/percpu.h
13336 --- linux-3.1.6/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
13337 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/percpu.h 2011-10-24 18:53:33.000000000 +0200
13339 +#ifndef _VX_PERCPU_H
13340 +#define _VX_PERCPU_H
13342 +#include "cvirt_def.h"
13343 +#include "sched_def.h"
13345 +struct _vx_percpu {
13346 + struct _vx_cvirt_pc cvirt;
13347 + struct _vx_sched_pc sched;
13350 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
13352 +#endif /* _VX_PERCPU_H */
13353 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/pid.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/pid.h
13354 --- linux-3.1.6/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
13355 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/pid.h 2011-10-24 18:53:33.000000000 +0200
13357 +#ifndef _VSERVER_PID_H
13358 +#define _VSERVER_PID_H
13360 +/* pid faking stuff */
13362 +#define vx_info_map_pid(v, p) \
13363 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
13364 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
13365 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
13366 +#define vx_map_tgid(p) vx_map_pid(p)
13368 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
13369 + const char *func, const char *file, int line)
13371 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13372 + vxfprintk(VXD_CBIT(cvirt, 2),
13373 + "vx_map_tgid: %p/%llx: %d -> %d",
13374 + vxi, (long long)vxi->vx_flags, pid,
13375 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
13376 + func, file, line);
13379 + if (pid == vxi->vx_initpid)
13385 +#define vx_info_rmap_pid(v, p) \
13386 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
13387 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
13388 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
13390 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
13391 + const char *func, const char *file, int line)
13393 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13394 + vxfprintk(VXD_CBIT(cvirt, 2),
13395 + "vx_rmap_tgid: %p/%llx: %d -> %d",
13396 + vxi, (long long)vxi->vx_flags, pid,
13397 + (pid == 1) ? vxi->vx_initpid : pid,
13398 + func, file, line);
13399 + if ((pid == 1) && vxi->vx_initpid)
13400 + return vxi->vx_initpid;
13401 + if (pid == vxi->vx_initpid)
13408 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/sched.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/sched.h
13409 --- linux-3.1.6/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
13410 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/sched.h 2011-10-24 18:53:33.000000000 +0200
13412 +#ifndef _VX_SCHED_H
13413 +#define _VX_SCHED_H
13420 +void vx_vsi_uptime(struct timespec *, struct timespec *);
13425 +void vx_update_load(struct vx_info *);
13428 +void vx_update_sched_param(struct _vx_sched *sched,
13429 + struct _vx_sched_pc *sched_pc);
13431 +#endif /* __KERNEL__ */
13432 +#else /* _VX_SCHED_H */
13433 +#warning duplicate inclusion
13434 +#endif /* _VX_SCHED_H */
13435 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/sched_cmd.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/sched_cmd.h
13436 --- linux-3.1.6/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
13437 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/sched_cmd.h 2011-10-24 18:53:33.000000000 +0200
13439 +#ifndef _VX_SCHED_CMD_H
13440 +#define _VX_SCHED_CMD_H
13443 +struct vcmd_prio_bias {
13445 + int32_t prio_bias;
13448 +#define VCMD_set_prio_bias VC_CMD(SCHED, 4, 0)
13449 +#define VCMD_get_prio_bias VC_CMD(SCHED, 5, 0)
13453 +#include <linux/compiler.h>
13455 +extern int vc_set_prio_bias(struct vx_info *, void __user *);
13456 +extern int vc_get_prio_bias(struct vx_info *, void __user *);
13458 +#endif /* __KERNEL__ */
13459 +#endif /* _VX_SCHED_CMD_H */
13460 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/sched_def.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/sched_def.h
13461 --- linux-3.1.6/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
13462 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/sched_def.h 2011-10-24 18:53:33.000000000 +0200
13464 +#ifndef _VX_SCHED_DEF_H
13465 +#define _VX_SCHED_DEF_H
13467 +#include <linux/spinlock.h>
13468 +#include <linux/jiffies.h>
13469 +#include <linux/cpumask.h>
13470 +#include <asm/atomic.h>
13471 +#include <asm/param.h>
13474 +/* context sub struct */
13476 +struct _vx_sched {
13477 + int prio_bias; /* bias offset for priority */
13479 + cpumask_t update; /* CPUs which should update */
13482 +struct _vx_sched_pc {
13483 + int prio_bias; /* bias offset for priority */
13485 + uint64_t user_ticks; /* token tick events */
13486 + uint64_t sys_ticks; /* token tick events */
13487 + uint64_t hold_ticks; /* token ticks paused */
13491 +#ifdef CONFIG_VSERVER_DEBUG
13493 +static inline void __dump_vx_sched(struct _vx_sched *sched)
13495 + printk("\t_vx_sched:\n");
13496 + printk("\t priority = %4d\n", sched->prio_bias);
13501 +#endif /* _VX_SCHED_DEF_H */
13502 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/signal.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/signal.h
13503 --- linux-3.1.6/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
13504 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/signal.h 2011-10-24 18:53:33.000000000 +0200
13506 +#ifndef _VX_SIGNAL_H
13507 +#define _VX_SIGNAL_H
13514 +int vx_info_kill(struct vx_info *, int, int);
13516 +#endif /* __KERNEL__ */
13517 +#else /* _VX_SIGNAL_H */
13518 +#warning duplicate inclusion
13519 +#endif /* _VX_SIGNAL_H */
13520 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/signal_cmd.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/signal_cmd.h
13521 --- linux-3.1.6/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
13522 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/signal_cmd.h 2011-10-24 18:53:33.000000000 +0200
13524 +#ifndef _VX_SIGNAL_CMD_H
13525 +#define _VX_SIGNAL_CMD_H
13528 +/* signalling vserver commands */
13530 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
13531 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
13533 +struct vcmd_ctx_kill_v0 {
13538 +struct vcmd_wait_exit_v0 {
13539 + int32_t reboot_cmd;
13540 + int32_t exit_code;
13545 +extern int vc_ctx_kill(struct vx_info *, void __user *);
13546 +extern int vc_wait_exit(struct vx_info *, void __user *);
13548 +#endif /* __KERNEL__ */
13550 +/* process alteration commands */
13552 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
13553 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
13555 +struct vcmd_pflags_v0 {
13556 + uint32_t flagword;
13562 +extern int vc_get_pflags(uint32_t pid, void __user *);
13563 +extern int vc_set_pflags(uint32_t pid, void __user *);
13565 +#endif /* __KERNEL__ */
13566 +#endif /* _VX_SIGNAL_CMD_H */
13567 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/space.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/space.h
13568 --- linux-3.1.6/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
13569 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/space.h 2011-10-24 18:53:33.000000000 +0200
13571 +#ifndef _VX_SPACE_H
13572 +#define _VX_SPACE_H
13574 +#include <linux/types.h>
13578 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
13580 +#else /* _VX_SPACE_H */
13581 +#warning duplicate inclusion
13582 +#endif /* _VX_SPACE_H */
13583 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/space_cmd.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/space_cmd.h
13584 --- linux-3.1.6/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
13585 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/space_cmd.h 2011-10-24 18:53:33.000000000 +0200
13587 +#ifndef _VX_SPACE_CMD_H
13588 +#define _VX_SPACE_CMD_H
13591 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
13592 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
13593 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
13595 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
13596 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
13597 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
13599 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
13601 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
13602 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
13605 +struct vcmd_space_mask_v1 {
13609 +struct vcmd_space_mask_v2 {
13617 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
13618 +extern int vc_set_space_v1(struct vx_info *, void __user *);
13619 +extern int vc_enter_space(struct vx_info *, void __user *);
13620 +extern int vc_set_space(struct vx_info *, void __user *);
13621 +extern int vc_get_space_mask(void __user *, int);
13623 +#endif /* __KERNEL__ */
13624 +#endif /* _VX_SPACE_CMD_H */
13625 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/switch.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/switch.h
13626 --- linux-3.1.6/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
13627 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/switch.h 2011-10-24 18:53:33.000000000 +0200
13629 +#ifndef _VX_SWITCH_H
13630 +#define _VX_SWITCH_H
13632 +#include <linux/types.h>
13635 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
13636 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
13637 +#define VC_VERSION(c) ((c) & 0xFFF)
13639 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
13640 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
13644 + Syscall Matrix V2.8
13646 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
13647 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
13648 + |INFO |SETUP | |MOVE | | | | | |
13649 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13650 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
13651 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
13652 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13653 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
13654 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
13655 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13656 + MEMORY | | | | |MEMCTRL| | |SWAP | |
13657 + | 16| 17| 18| 19| 20| 21| | 22| 23|
13658 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13659 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
13660 + | 24| 25| 26| 27| 28| 29| | 30| 31|
13661 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13662 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
13663 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
13664 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13665 + OTHER |VSTAT | | | | | | |VINFO | |
13666 + | 40| 41| 42| 43| 44| 45| | 46| 47|
13667 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
13668 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
13669 + | 48| 49| 50| 51| 52| 53| | 54| 55|
13670 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13671 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
13672 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
13673 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13677 +#define VC_CAT_VERSION 0
13679 +#define VC_CAT_VSETUP 1
13680 +#define VC_CAT_VHOST 2
13682 +#define VC_CAT_DEVICE 6
13684 +#define VC_CAT_VPROC 9
13685 +#define VC_CAT_PROCALT 10
13686 +#define VC_CAT_PROCMIG 11
13687 +#define VC_CAT_PROCTRL 12
13689 +#define VC_CAT_SCHED 14
13690 +#define VC_CAT_MEMCTRL 20
13692 +#define VC_CAT_VNET 25
13693 +#define VC_CAT_NETALT 26
13694 +#define VC_CAT_NETMIG 27
13695 +#define VC_CAT_NETCTRL 28
13697 +#define VC_CAT_TAGMIG 35
13698 +#define VC_CAT_DLIMIT 36
13699 +#define VC_CAT_INODE 38
13701 +#define VC_CAT_VSTAT 40
13702 +#define VC_CAT_VINFO 46
13703 +#define VC_CAT_EVENT 48
13705 +#define VC_CAT_FLAGS 52
13706 +#define VC_CAT_VSPACE 54
13707 +#define VC_CAT_DEBUG 56
13708 +#define VC_CAT_RLIMIT 60
13710 +#define VC_CAT_SYSTEST 61
13711 +#define VC_CAT_COMPAT 63
13713 +/* query version */
13715 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
13716 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
13721 +#include <linux/errno.h>
13723 +#endif /* __KERNEL__ */
13725 +#endif /* _VX_SWITCH_H */
13727 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/tag.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/tag.h
13728 --- linux-3.1.6/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
13729 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/tag.h 2011-10-24 18:53:33.000000000 +0200
13734 +#include <linux/types.h>
13737 +#define DX_TAG(in) (IS_TAGGED(in))
13740 +#ifdef CONFIG_TAG_NFSD
13741 +#define DX_TAG_NFSD 1
13743 +#define DX_TAG_NFSD 0
13747 +#ifdef CONFIG_TAGGING_NONE
13749 +#define MAX_UID 0xFFFFFFFF
13750 +#define MAX_GID 0xFFFFFFFF
13752 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
13754 +#define TAGINO_UID(cond, uid, tag) (uid)
13755 +#define TAGINO_GID(cond, gid, tag) (gid)
13760 +#ifdef CONFIG_TAGGING_GID16
13762 +#define MAX_UID 0xFFFFFFFF
13763 +#define MAX_GID 0x0000FFFF
13765 +#define INOTAG_TAG(cond, uid, gid, tag) \
13766 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
13768 +#define TAGINO_UID(cond, uid, tag) (uid)
13769 +#define TAGINO_GID(cond, gid, tag) \
13770 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
13775 +#ifdef CONFIG_TAGGING_ID24
13777 +#define MAX_UID 0x00FFFFFF
13778 +#define MAX_GID 0x00FFFFFF
13780 +#define INOTAG_TAG(cond, uid, gid, tag) \
13781 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
13783 +#define TAGINO_UID(cond, uid, tag) \
13784 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
13785 +#define TAGINO_GID(cond, gid, tag) \
13786 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
13791 +#ifdef CONFIG_TAGGING_UID16
13793 +#define MAX_UID 0x0000FFFF
13794 +#define MAX_GID 0xFFFFFFFF
13796 +#define INOTAG_TAG(cond, uid, gid, tag) \
13797 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
13799 +#define TAGINO_UID(cond, uid, tag) \
13800 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
13801 +#define TAGINO_GID(cond, gid, tag) (gid)
13806 +#ifdef CONFIG_TAGGING_INTERN
13808 +#define MAX_UID 0xFFFFFFFF
13809 +#define MAX_GID 0xFFFFFFFF
13811 +#define INOTAG_TAG(cond, uid, gid, tag) \
13812 + ((cond) ? (tag) : 0)
13814 +#define TAGINO_UID(cond, uid, tag) (uid)
13815 +#define TAGINO_GID(cond, gid, tag) (gid)
13820 +#ifndef CONFIG_TAGGING_NONE
13821 +#define dx_current_fstag(sb) \
13822 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
13824 +#define dx_current_fstag(sb) (0)
13827 +#ifndef CONFIG_TAGGING_INTERN
13828 +#define TAGINO_TAG(cond, tag) (0)
13830 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
13833 +#define INOTAG_UID(cond, uid, gid) \
13834 + ((cond) ? ((uid) & MAX_UID) : (uid))
13835 +#define INOTAG_GID(cond, uid, gid) \
13836 + ((cond) ? ((gid) & MAX_GID) : (gid))
13839 +static inline uid_t dx_map_uid(uid_t uid)
13841 + if ((uid > MAX_UID) && (uid != -1))
13843 + return (uid & MAX_UID);
13846 +static inline gid_t dx_map_gid(gid_t gid)
13848 + if ((gid > MAX_GID) && (gid != -1))
13850 + return (gid & MAX_GID);
13858 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
13860 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
13861 + unsigned long *flags);
13863 +#ifdef CONFIG_PROPAGATE
13865 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
13867 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
13870 +#define dx_propagate_tag(n, i) do { } while (0)
13873 +#endif /* _DX_TAG_H */
13874 diff -NurpP --minimal linux-3.1.6/include/linux/vserver/tag_cmd.h linux-3.1.6-vs2.3.2.5/include/linux/vserver/tag_cmd.h
13875 --- linux-3.1.6/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
13876 +++ linux-3.1.6-vs2.3.2.5/include/linux/vserver/tag_cmd.h 2011-10-24 18:53:33.000000000 +0200
13878 +#ifndef _VX_TAG_CMD_H
13879 +#define _VX_TAG_CMD_H
13882 +/* vinfo commands */
13884 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
13887 +extern int vc_task_tag(uint32_t);
13889 +#endif /* __KERNEL__ */
13891 +/* context commands */
13893 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
13896 +extern int vc_tag_migrate(uint32_t);
13898 +#endif /* __KERNEL__ */
13899 +#endif /* _VX_TAG_CMD_H */
13900 diff -NurpP --minimal linux-3.1.6/include/net/addrconf.h linux-3.1.6-vs2.3.2.5/include/net/addrconf.h
13901 --- linux-3.1.6/include/net/addrconf.h 2011-07-22 11:18:11.000000000 +0200
13902 +++ linux-3.1.6-vs2.3.2.5/include/net/addrconf.h 2011-10-24 18:53:33.000000000 +0200
13903 @@ -80,7 +80,8 @@ extern int ipv6_dev_get_saddr(struct n
13904 struct net_device *dev,
13905 const struct in6_addr *daddr,
13906 unsigned int srcprefs,
13907 - struct in6_addr *saddr);
13908 + struct in6_addr *saddr,
13909 + struct nx_info *nxi);
13910 extern int ipv6_get_lladdr(struct net_device *dev,
13911 struct in6_addr *addr,
13912 unsigned char banned_flags);
13913 diff -NurpP --minimal linux-3.1.6/include/net/af_unix.h linux-3.1.6-vs2.3.2.5/include/net/af_unix.h
13914 --- linux-3.1.6/include/net/af_unix.h 2011-07-22 11:18:11.000000000 +0200
13915 +++ linux-3.1.6-vs2.3.2.5/include/net/af_unix.h 2011-10-24 18:53:33.000000000 +0200
13917 #include <linux/socket.h>
13918 #include <linux/un.h>
13919 #include <linux/mutex.h>
13920 +#include <linux/vs_base.h>
13921 #include <net/sock.h>
13923 extern void unix_inflight(struct file *fp);
13924 diff -NurpP --minimal linux-3.1.6/include/net/inet_timewait_sock.h linux-3.1.6-vs2.3.2.5/include/net/inet_timewait_sock.h
13925 --- linux-3.1.6/include/net/inet_timewait_sock.h 2011-10-24 18:45:32.000000000 +0200
13926 +++ linux-3.1.6-vs2.3.2.5/include/net/inet_timewait_sock.h 2011-10-24 18:53:33.000000000 +0200
13927 @@ -113,6 +113,10 @@ struct inet_timewait_sock {
13928 #define tw_net __tw_common.skc_net
13929 #define tw_daddr __tw_common.skc_daddr
13930 #define tw_rcv_saddr __tw_common.skc_rcv_saddr
13931 +#define tw_xid __tw_common.skc_xid
13932 +#define tw_vx_info __tw_common.skc_vx_info
13933 +#define tw_nid __tw_common.skc_nid
13934 +#define tw_nx_info __tw_common.skc_nx_info
13936 volatile unsigned char tw_substate;
13937 unsigned char tw_rcv_wscale;
13938 diff -NurpP --minimal linux-3.1.6/include/net/ip6_route.h linux-3.1.6-vs2.3.2.5/include/net/ip6_route.h
13939 --- linux-3.1.6/include/net/ip6_route.h 2011-07-22 11:18:11.000000000 +0200
13940 +++ linux-3.1.6-vs2.3.2.5/include/net/ip6_route.h 2011-10-24 18:53:33.000000000 +0200
13941 @@ -86,7 +86,8 @@ extern int ip6_route_get_saddr(struct
13942 struct rt6_info *rt,
13943 const struct in6_addr *daddr,
13944 unsigned int prefs,
13945 - struct in6_addr *saddr);
13946 + struct in6_addr *saddr,
13947 + struct nx_info *nxi);
13949 extern struct rt6_info *rt6_lookup(struct net *net,
13950 const struct in6_addr *daddr,
13951 diff -NurpP --minimal linux-3.1.6/include/net/route.h linux-3.1.6-vs2.3.2.5/include/net/route.h
13952 --- linux-3.1.6/include/net/route.h 2011-07-22 11:18:11.000000000 +0200
13953 +++ linux-3.1.6-vs2.3.2.5/include/net/route.h 2011-10-24 18:53:33.000000000 +0200
13954 @@ -202,6 +202,9 @@ static inline void ip_rt_put(struct rtab
13955 dst_release(&rt->dst);
13958 +#include <linux/vs_base.h>
13959 +#include <linux/vs_inet.h>
13961 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
13963 extern const __u8 ip_tos2prio[16];
13964 @@ -253,6 +256,9 @@ static inline void ip_route_connect_init
13965 protocol, flow_flags, dst, src, dport, sport);
13968 +extern struct rtable *ip_v4_find_src(struct net *net, struct nx_info *,
13969 + struct flowi4 *);
13971 static inline struct rtable *ip_route_connect(struct flowi4 *fl4,
13972 __be32 dst, __be32 src, u32 tos,
13973 int oif, u8 protocol,
13974 @@ -261,11 +267,25 @@ static inline struct rtable *ip_route_co
13976 struct net *net = sock_net(sk);
13978 + struct nx_info *nx_info = current_nx_info();
13980 ip_route_connect_init(fl4, dst, src, tos, oif, protocol,
13981 sport, dport, sk, can_sleep);
13983 - if (!dst || !src) {
13985 + nx_info = sk->sk_nx_info;
13987 + vxdprintk(VXD_CBIT(net, 4),
13988 + "ip_route_connect(%p) %p,%p;%lx",
13989 + sk, nx_info, sk->sk_socket,
13990 + (sk->sk_socket?sk->sk_socket->flags:0));
13992 + rt = ip_v4_find_src(net, nx_info, fl4);
13997 + if (!fl4->daddr || !fl4->saddr) {
13998 rt = __ip_route_output_key(net, fl4);
14001 diff -NurpP --minimal linux-3.1.6/include/net/sock.h linux-3.1.6-vs2.3.2.5/include/net/sock.h
14002 --- linux-3.1.6/include/net/sock.h 2011-10-24 18:45:32.000000000 +0200
14003 +++ linux-3.1.6-vs2.3.2.5/include/net/sock.h 2011-10-24 18:53:33.000000000 +0200
14004 @@ -150,6 +150,10 @@ struct sock_common {
14005 #ifdef CONFIG_NET_NS
14006 struct net *skc_net;
14009 + struct vx_info *skc_vx_info;
14011 + struct nx_info *skc_nx_info;
14013 * fields between dontcopy_begin/dontcopy_end
14014 * are not copied in sock_copy()
14015 @@ -257,6 +261,10 @@ struct sock {
14016 #define sk_bind_node __sk_common.skc_bind_node
14017 #define sk_prot __sk_common.skc_prot
14018 #define sk_net __sk_common.skc_net
14019 +#define sk_xid __sk_common.skc_xid
14020 +#define sk_vx_info __sk_common.skc_vx_info
14021 +#define sk_nid __sk_common.skc_nid
14022 +#define sk_nx_info __sk_common.skc_nx_info
14023 socket_lock_t sk_lock;
14024 struct sk_buff_head sk_receive_queue;
14026 diff -NurpP --minimal linux-3.1.6/init/Kconfig linux-3.1.6-vs2.3.2.5/init/Kconfig
14027 --- linux-3.1.6/init/Kconfig 2011-10-24 18:45:33.000000000 +0200
14028 +++ linux-3.1.6-vs2.3.2.5/init/Kconfig 2011-10-24 18:53:33.000000000 +0200
14029 @@ -574,6 +574,7 @@ config HAVE_UNSTABLE_SCHED_CLOCK
14031 boolean "Control Group support"
14035 This option adds support for grouping sets of processes together, for
14036 use with process control subsystems such as Cpusets, CFS, memory
14037 @@ -790,6 +791,7 @@ config IPC_NS
14039 bool "User namespace (EXPERIMENTAL)"
14040 depends on EXPERIMENTAL
14041 + depends on VSERVER_DISABLED
14044 This allows containers, i.e. vservers, to use user namespaces
14045 diff -NurpP --minimal linux-3.1.6/init/main.c linux-3.1.6-vs2.3.2.5/init/main.c
14046 --- linux-3.1.6/init/main.c 2011-10-24 18:45:33.000000000 +0200
14047 +++ linux-3.1.6-vs2.3.2.5/init/main.c 2011-10-24 18:53:33.000000000 +0200
14049 #include <linux/shmem_fs.h>
14050 #include <linux/slab.h>
14051 #include <linux/perf_event.h>
14052 +#include <linux/vserver/percpu.h>
14054 #include <asm/io.h>
14055 #include <asm/bugs.h>
14056 diff -NurpP --minimal linux-3.1.6/ipc/mqueue.c linux-3.1.6-vs2.3.2.5/ipc/mqueue.c
14057 --- linux-3.1.6/ipc/mqueue.c 2011-10-24 18:45:33.000000000 +0200
14058 +++ linux-3.1.6-vs2.3.2.5/ipc/mqueue.c 2011-10-24 18:53:33.000000000 +0200
14060 #include <linux/pid.h>
14061 #include <linux/ipc_namespace.h>
14062 #include <linux/slab.h>
14063 +#include <linux/vs_context.h>
14064 +#include <linux/vs_limit.h>
14066 #include <net/sock.h>
14068 @@ -66,6 +68,7 @@ struct mqueue_inode_info {
14069 struct sigevent notify;
14070 struct pid* notify_owner;
14071 struct user_struct *user; /* user who created, for accounting */
14072 + struct vx_info *vxi;
14073 struct sock *notify_sock;
14074 struct sk_buff *notify_cookie;
14076 @@ -128,6 +131,7 @@ static struct inode *mqueue_get_inode(st
14077 if (S_ISREG(mode)) {
14078 struct mqueue_inode_info *info;
14079 struct task_struct *p = current;
14080 + struct vx_info *vxi = p->vx_info;
14081 unsigned long mq_bytes, mq_msg_tblsz;
14083 inode->i_fop = &mqueue_file_operations;
14084 @@ -141,6 +145,7 @@ static struct inode *mqueue_get_inode(st
14085 info->notify_owner = NULL;
14087 info->user = NULL; /* set when all is ok */
14088 + info->vxi = NULL;
14089 memset(&info->attr, 0, sizeof(info->attr));
14090 info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
14091 info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
14092 @@ -158,17 +163,20 @@ static struct inode *mqueue_get_inode(st
14094 spin_lock(&mq_lock);
14095 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
14096 - u->mq_bytes + mq_bytes > task_rlimit(p, RLIMIT_MSGQUEUE)) {
14097 + u->mq_bytes + mq_bytes > task_rlimit(p, RLIMIT_MSGQUEUE) ||
14098 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
14099 spin_unlock(&mq_lock);
14100 /* mqueue_evict_inode() releases info->messages */
14104 u->mq_bytes += mq_bytes;
14105 + vx_ipcmsg_add(vxi, u, mq_bytes);
14106 spin_unlock(&mq_lock);
14109 info->user = get_uid(u);
14110 + info->vxi = get_vx_info(vxi);
14111 } else if (S_ISDIR(mode)) {
14113 /* Some things misbehave if size == 0 on a directory */
14114 @@ -278,8 +286,11 @@ static void mqueue_evict_inode(struct in
14115 + info->attr.mq_msgsize);
14118 + struct vx_info *vxi = info->vxi;
14120 spin_lock(&mq_lock);
14121 user->mq_bytes -= mq_bytes;
14122 + vx_ipcmsg_sub(vxi, user, mq_bytes);
14124 * get_ns_from_inode() ensures that the
14125 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
14126 @@ -289,6 +300,7 @@ static void mqueue_evict_inode(struct in
14128 ipc_ns->mq_queues_count--;
14129 spin_unlock(&mq_lock);
14130 + put_vx_info(vxi);
14134 diff -NurpP --minimal linux-3.1.6/ipc/msg.c linux-3.1.6-vs2.3.2.5/ipc/msg.c
14135 --- linux-3.1.6/ipc/msg.c 2011-05-22 16:17:59.000000000 +0200
14136 +++ linux-3.1.6-vs2.3.2.5/ipc/msg.c 2011-10-24 18:53:33.000000000 +0200
14138 #include <linux/rwsem.h>
14139 #include <linux/nsproxy.h>
14140 #include <linux/ipc_namespace.h>
14141 +#include <linux/vs_base.h>
14143 #include <asm/current.h>
14144 #include <asm/uaccess.h>
14145 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
14147 msq->q_perm.mode = msgflg & S_IRWXUGO;
14148 msq->q_perm.key = key;
14149 + msq->q_perm.xid = vx_current_xid();
14151 msq->q_perm.security = NULL;
14152 retval = security_msg_queue_alloc(msq);
14153 diff -NurpP --minimal linux-3.1.6/ipc/namespace.c linux-3.1.6-vs2.3.2.5/ipc/namespace.c
14154 --- linux-3.1.6/ipc/namespace.c 2011-07-22 11:18:12.000000000 +0200
14155 +++ linux-3.1.6-vs2.3.2.5/ipc/namespace.c 2011-10-24 18:53:33.000000000 +0200
14156 @@ -13,11 +13,12 @@
14157 #include <linux/mount.h>
14158 #include <linux/user_namespace.h>
14159 #include <linux/proc_fs.h>
14160 +#include <linux/vs_base.h>
14161 +#include <linux/vserver/global.h>
14165 -static struct ipc_namespace *create_ipc_ns(struct task_struct *tsk,
14166 - struct ipc_namespace *old_ns)
14167 +static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns)
14169 struct ipc_namespace *ns;
14171 @@ -46,19 +47,18 @@ static struct ipc_namespace *create_ipc_
14172 ipcns_notify(IPCNS_CREATED);
14173 register_ipcns_notifier(ns);
14175 - ns->user_ns = get_user_ns(task_cred_xxx(tsk, user)->user_ns);
14176 + ns->user_ns = get_user_ns(user_ns);
14181 struct ipc_namespace *copy_ipcs(unsigned long flags,
14182 - struct task_struct *tsk)
14183 + struct ipc_namespace *old_ns,
14184 + struct user_namespace *user_ns)
14186 - struct ipc_namespace *ns = tsk->nsproxy->ipc_ns;
14188 if (!(flags & CLONE_NEWIPC))
14189 - return get_ipc_ns(ns);
14190 - return create_ipc_ns(tsk, ns);
14191 + return get_ipc_ns(old_ns);
14192 + return create_ipc_ns(user_ns);
14196 diff -NurpP --minimal linux-3.1.6/ipc/sem.c linux-3.1.6-vs2.3.2.5/ipc/sem.c
14197 --- linux-3.1.6/ipc/sem.c 2011-10-24 18:45:33.000000000 +0200
14198 +++ linux-3.1.6-vs2.3.2.5/ipc/sem.c 2011-10-24 18:53:33.000000000 +0200
14200 #include <linux/rwsem.h>
14201 #include <linux/nsproxy.h>
14202 #include <linux/ipc_namespace.h>
14203 +#include <linux/vs_base.h>
14204 +#include <linux/vs_limit.h>
14206 #include <asm/uaccess.h>
14208 @@ -260,6 +262,7 @@ static int newary(struct ipc_namespace *
14210 sma->sem_perm.mode = (semflg & S_IRWXUGO);
14211 sma->sem_perm.key = key;
14212 + sma->sem_perm.xid = vx_current_xid();
14214 sma->sem_perm.security = NULL;
14215 retval = security_sem_alloc(sma);
14216 @@ -275,6 +278,9 @@ static int newary(struct ipc_namespace *
14219 ns->used_sems += nsems;
14220 + /* FIXME: obsoleted? */
14221 + vx_semary_inc(sma);
14222 + vx_nsems_add(sma, nsems);
14224 sma->sem_base = (struct sem *) &sma[1];
14226 @@ -724,6 +730,9 @@ static void freeary(struct ipc_namespace
14228 wake_up_sem_queue_do(&tasks);
14229 ns->used_sems -= sma->sem_nsems;
14230 + /* FIXME: obsoleted? */
14231 + vx_nsems_sub(sma, sma->sem_nsems);
14232 + vx_semary_dec(sma);
14233 security_sem_free(sma);
14234 ipc_rcu_putref(sma);
14236 diff -NurpP --minimal linux-3.1.6/ipc/shm.c linux-3.1.6-vs2.3.2.5/ipc/shm.c
14237 --- linux-3.1.6/ipc/shm.c 2011-10-24 18:45:33.000000000 +0200
14238 +++ linux-3.1.6-vs2.3.2.5/ipc/shm.c 2011-10-24 18:53:33.000000000 +0200
14240 #include <linux/nsproxy.h>
14241 #include <linux/mount.h>
14242 #include <linux/ipc_namespace.h>
14243 +#include <linux/vs_context.h>
14244 +#include <linux/vs_limit.h>
14246 #include <asm/uaccess.h>
14248 @@ -187,7 +189,12 @@ static void shm_open(struct vm_area_stru
14250 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
14252 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14253 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
14254 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14256 + vx_ipcshm_sub(vxi, shp, numpages);
14257 + ns->shm_tot -= numpages;
14261 if (!is_file_hugepages(shp->shm_file))
14262 @@ -197,6 +204,7 @@ static void shm_destroy(struct ipc_names
14264 fput (shp->shm_file);
14265 security_shm_free(shp);
14266 + put_vx_info(vxi);
14267 ipc_rcu_putref(shp);
14270 @@ -462,11 +470,15 @@ static int newseg(struct ipc_namespace *
14271 if (ns->shm_tot + numpages > ns->shm_ctlall)
14274 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
14277 shp = ipc_rcu_alloc(sizeof(*shp));
14281 shp->shm_perm.key = key;
14282 + shp->shm_perm.xid = vx_current_xid();
14283 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
14284 shp->mlock_user = NULL;
14286 @@ -521,6 +533,7 @@ static int newseg(struct ipc_namespace *
14287 ns->shm_tot += numpages;
14288 error = shp->shm_perm.id;
14290 + vx_ipcshm_add(current_vx_info(), key, numpages);
14294 diff -NurpP --minimal linux-3.1.6/kernel/Makefile linux-3.1.6-vs2.3.2.5/kernel/Makefile
14295 --- linux-3.1.6/kernel/Makefile 2011-10-24 18:45:33.000000000 +0200
14296 +++ linux-3.1.6-vs2.3.2.5/kernel/Makefile 2011-10-24 18:53:33.000000000 +0200
14297 @@ -24,6 +24,7 @@ CFLAGS_REMOVE_sched_clock.o = -pg
14298 CFLAGS_REMOVE_irq_work.o = -pg
14302 obj-$(CONFIG_FREEZER) += freezer.o
14303 obj-$(CONFIG_PROFILING) += profile.o
14304 obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
14305 diff -NurpP --minimal linux-3.1.6/kernel/capability.c linux-3.1.6-vs2.3.2.5/kernel/capability.c
14306 --- linux-3.1.6/kernel/capability.c 2011-07-22 11:18:12.000000000 +0200
14307 +++ linux-3.1.6-vs2.3.2.5/kernel/capability.c 2011-11-18 00:38:57.000000000 +0100
14309 #include <linux/syscalls.h>
14310 #include <linux/pid_namespace.h>
14311 #include <linux/user_namespace.h>
14312 +#include <linux/vs_context.h>
14313 #include <asm/uaccess.h>
14316 @@ -116,6 +117,7 @@ static int cap_validate_magic(cap_user_h
14322 * The only thing that can change the capabilities of the current
14323 * process is the current process. As such, we can't be in this code
14324 @@ -340,6 +342,8 @@ bool has_capability_noaudit(struct task_
14328 +#include <linux/vserver/base.h>
14331 * capable - Determine if the current task has a superior capability in effect
14332 * @cap: The capability to be tested for
14333 diff -NurpP --minimal linux-3.1.6/kernel/compat.c linux-3.1.6-vs2.3.2.5/kernel/compat.c
14334 --- linux-3.1.6/kernel/compat.c 2011-10-24 18:45:33.000000000 +0200
14335 +++ linux-3.1.6-vs2.3.2.5/kernel/compat.c 2011-10-24 18:53:33.000000000 +0200
14336 @@ -972,7 +972,7 @@ asmlinkage long compat_sys_stime(compat_
14340 - do_settimeofday(&tv);
14341 + vx_settimeofday(&tv);
14345 diff -NurpP --minimal linux-3.1.6/kernel/cred.c linux-3.1.6-vs2.3.2.5/kernel/cred.c
14346 --- linux-3.1.6/kernel/cred.c 2011-10-24 18:45:33.000000000 +0200
14347 +++ linux-3.1.6-vs2.3.2.5/kernel/cred.c 2011-10-24 18:53:33.000000000 +0200
14348 @@ -61,31 +61,6 @@ struct cred init_cred = {
14352 -static inline void set_cred_subscribers(struct cred *cred, int n)
14354 -#ifdef CONFIG_DEBUG_CREDENTIALS
14355 - atomic_set(&cred->subscribers, n);
14359 -static inline int read_cred_subscribers(const struct cred *cred)
14361 -#ifdef CONFIG_DEBUG_CREDENTIALS
14362 - return atomic_read(&cred->subscribers);
14368 -static inline void alter_cred_subscribers(const struct cred *_cred, int n)
14370 -#ifdef CONFIG_DEBUG_CREDENTIALS
14371 - struct cred *cred = (struct cred *) _cred;
14373 - atomic_add(n, &cred->subscribers);
14378 * Dispose of the shared task group credentials
14380 @@ -281,21 +256,16 @@ error:
14382 * Call commit_creds() or abort_creds() to clean up.
14384 -struct cred *prepare_creds(void)
14385 +struct cred *__prepare_creds(const struct cred *old)
14387 - struct task_struct *task = current;
14388 - const struct cred *old;
14391 - validate_process_creds();
14393 new = kmem_cache_alloc(cred_jar, GFP_KERNEL);
14397 kdebug("prepare_creds() alloc %p", new);
14399 - old = task->cred;
14400 memcpy(new, old, sizeof(struct cred));
14402 atomic_set(&new->usage, 1);
14403 @@ -322,6 +292,13 @@ error:
14408 +struct cred *prepare_creds(void)
14410 + validate_process_creds();
14412 + return __prepare_creds(current->cred);
14414 EXPORT_SYMBOL(prepare_creds);
14417 diff -NurpP --minimal linux-3.1.6/kernel/exit.c linux-3.1.6-vs2.3.2.5/kernel/exit.c
14418 --- linux-3.1.6/kernel/exit.c 2011-10-24 18:45:33.000000000 +0200
14419 +++ linux-3.1.6-vs2.3.2.5/kernel/exit.c 2011-10-24 18:53:33.000000000 +0200
14421 #include <linux/fs_struct.h>
14422 #include <linux/init_task.h>
14423 #include <linux/perf_event.h>
14424 +#include <linux/vs_limit.h>
14425 +#include <linux/vs_context.h>
14426 +#include <linux/vs_network.h>
14427 +#include <linux/vs_pid.h>
14428 #include <trace/events/sched.h>
14429 #include <linux/hw_breakpoint.h>
14430 #include <linux/oom.h>
14431 @@ -480,9 +484,11 @@ static void close_files(struct files_str
14432 filp_close(file, files);
14435 + vx_openfd_dec(i);
14443 @@ -1038,11 +1044,16 @@ NORET_TYPE void do_exit(long code)
14445 validate_creds_for_do_exit(tsk);
14447 + /* needs to stay after exit_notify() */
14448 + exit_vx_info(tsk, code);
14449 + exit_nx_info(tsk);
14453 /* causes final put_task_struct in finish_task_switch(). */
14454 tsk->state = TASK_DEAD;
14456 + printk("bad task: %p [%lx]\n", current, current->state);
14458 /* Avoid "noreturn function does return". */
14460 diff -NurpP --minimal linux-3.1.6/kernel/fork.c linux-3.1.6-vs2.3.2.5/kernel/fork.c
14461 --- linux-3.1.6/kernel/fork.c 2011-10-24 18:45:33.000000000 +0200
14462 +++ linux-3.1.6-vs2.3.2.5/kernel/fork.c 2011-12-07 04:19:36.000000000 +0100
14464 #include <linux/user-return-notifier.h>
14465 #include <linux/oom.h>
14466 #include <linux/khugepaged.h>
14467 +#include <linux/vs_context.h>
14468 +#include <linux/vs_network.h>
14469 +#include <linux/vs_limit.h>
14471 #include <asm/pgtable.h>
14472 #include <asm/pgalloc.h>
14473 @@ -166,6 +169,8 @@ void free_task(struct task_struct *tsk)
14474 account_kernel_stack(tsk->stack, -1);
14475 free_thread_info(tsk->stack);
14476 rt_mutex_debug_task_free(tsk);
14477 + clr_vx_info(&tsk->vx_info);
14478 + clr_nx_info(&tsk->nx_info);
14479 ftrace_graph_exit_task(tsk);
14480 free_task_struct(tsk);
14482 @@ -506,6 +511,7 @@ static struct mm_struct *mm_init(struct
14483 if (likely(!mm_alloc_pgd(mm))) {
14485 mmu_notifier_mm_init(mm);
14486 + set_vx_info(&mm->mm_vx_info, p->vx_info);
14490 @@ -543,6 +549,7 @@ void __mmdrop(struct mm_struct *mm)
14491 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
14492 VM_BUG_ON(mm->pmd_huge_pte);
14494 + clr_vx_info(&mm->mm_vx_info);
14497 EXPORT_SYMBOL_GPL(__mmdrop);
14498 @@ -730,6 +737,7 @@ struct mm_struct *dup_mm(struct task_str
14501 memcpy(mm, oldmm, sizeof(*mm));
14502 + mm->mm_vx_info = NULL;
14503 mm_init_cpumask(mm);
14505 /* Initializing for Swap token stuff */
14506 @@ -773,6 +781,7 @@ fail_nocontext:
14507 * If init_new_context() failed, we cannot use mmput() to free the mm
14508 * because it calls destroy_context()
14510 + clr_vx_info(&mm->mm_vx_info);
14514 @@ -1058,6 +1067,8 @@ static struct task_struct *copy_process(
14516 struct task_struct *p;
14517 int cgroup_callbacks_done = 0;
14518 + struct vx_info *vxi;
14519 + struct nx_info *nxi;
14521 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
14522 return ERR_PTR(-EINVAL);
14523 @@ -1104,7 +1115,12 @@ static struct task_struct *copy_process(
14524 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
14525 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
14527 + init_vx_info(&p->vx_info, current_vx_info());
14528 + init_nx_info(&p->nx_info, current_nx_info());
14531 + if (!vx_nproc_avail(1))
14532 + goto bad_fork_free;
14533 if (atomic_read(&p->real_cred->user->processes) >=
14534 task_rlimit(p, RLIMIT_NPROC)) {
14535 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
14536 @@ -1374,6 +1390,18 @@ static struct task_struct *copy_process(
14539 spin_unlock(¤t->sighand->siglock);
14541 + /* p is copy of current */
14542 + vxi = p->vx_info;
14544 + claim_vx_info(vxi, p);
14545 + atomic_inc(&vxi->cvirt.nr_threads);
14546 + atomic_inc(&vxi->cvirt.total_forks);
14549 + nxi = p->nx_info;
14551 + claim_nx_info(nxi, p);
14552 write_unlock_irq(&tasklist_lock);
14553 proc_fork_connector(p);
14554 cgroup_post_fork(p);
14555 diff -NurpP --minimal linux-3.1.6/kernel/kthread.c linux-3.1.6-vs2.3.2.5/kernel/kthread.c
14556 --- linux-3.1.6/kernel/kthread.c 2011-07-22 11:18:12.000000000 +0200
14557 +++ linux-3.1.6-vs2.3.2.5/kernel/kthread.c 2011-10-24 18:53:33.000000000 +0200
14559 #include <linux/mutex.h>
14560 #include <linux/slab.h>
14561 #include <linux/freezer.h>
14562 +#include <linux/vs_pid.h>
14563 #include <trace/events/sched.h>
14565 static DEFINE_SPINLOCK(kthread_create_lock);
14566 diff -NurpP --minimal linux-3.1.6/kernel/nsproxy.c linux-3.1.6-vs2.3.2.5/kernel/nsproxy.c
14567 --- linux-3.1.6/kernel/nsproxy.c 2011-10-24 18:45:33.000000000 +0200
14568 +++ linux-3.1.6-vs2.3.2.5/kernel/nsproxy.c 2011-10-24 18:53:33.000000000 +0200
14570 #include <linux/mnt_namespace.h>
14571 #include <linux/utsname.h>
14572 #include <linux/pid_namespace.h>
14573 +#include <linux/vserver/global.h>
14574 +#include <linux/vserver/debug.h>
14575 #include <net/net_namespace.h>
14576 #include <linux/ipc_namespace.h>
14577 #include <linux/proc_fs.h>
14578 @@ -46,8 +48,11 @@ static inline struct nsproxy *create_nsp
14579 struct nsproxy *nsproxy;
14581 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
14584 atomic_set(&nsproxy->count, 1);
14585 + atomic_inc(&vs_global_nsproxy);
14587 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
14591 @@ -56,8 +61,11 @@ static inline struct nsproxy *create_nsp
14592 * Return the newly created nsproxy. Do not attach this to the task,
14593 * leave it to the caller to do proper locking and attach it to task.
14595 -static struct nsproxy *create_new_namespaces(unsigned long flags,
14596 - struct task_struct *tsk, struct fs_struct *new_fs)
14597 +static struct nsproxy *unshare_namespaces(unsigned long flags,
14598 + struct nsproxy *orig,
14599 + struct fs_struct *new_fs,
14600 + struct user_namespace *new_user,
14601 + struct pid_namespace *new_pid)
14603 struct nsproxy *new_nsp;
14605 @@ -66,31 +74,31 @@ static struct nsproxy *create_new_namesp
14607 return ERR_PTR(-ENOMEM);
14609 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
14610 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
14611 if (IS_ERR(new_nsp->mnt_ns)) {
14612 err = PTR_ERR(new_nsp->mnt_ns);
14616 - new_nsp->uts_ns = copy_utsname(flags, tsk);
14617 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns, new_user);
14618 if (IS_ERR(new_nsp->uts_ns)) {
14619 err = PTR_ERR(new_nsp->uts_ns);
14623 - new_nsp->ipc_ns = copy_ipcs(flags, tsk);
14624 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns, new_user);
14625 if (IS_ERR(new_nsp->ipc_ns)) {
14626 err = PTR_ERR(new_nsp->ipc_ns);
14630 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
14631 + new_nsp->pid_ns = copy_pid_ns(flags, new_pid);
14632 if (IS_ERR(new_nsp->pid_ns)) {
14633 err = PTR_ERR(new_nsp->pid_ns);
14637 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
14638 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
14639 if (IS_ERR(new_nsp->net_ns)) {
14640 err = PTR_ERR(new_nsp->net_ns);
14642 @@ -115,6 +123,40 @@ out_ns:
14643 return ERR_PTR(err);
14646 +static struct nsproxy *create_new_namespaces(unsigned long flags,
14647 + struct task_struct *tsk, struct fs_struct *new_fs)
14649 + return unshare_namespaces(flags, tsk->nsproxy,
14650 + new_fs, task_cred_xxx(tsk, user)->user_ns,
14651 + task_active_pid_ns(tsk));
14655 + * copies the nsproxy, setting refcount to 1, and grabbing a
14656 + * reference to all contained namespaces.
14658 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
14660 + struct nsproxy *ns = create_nsproxy();
14663 + memcpy(ns, orig, sizeof(struct nsproxy));
14664 + atomic_set(&ns->count, 1);
14667 + get_mnt_ns(ns->mnt_ns);
14669 + get_uts_ns(ns->uts_ns);
14671 + get_ipc_ns(ns->ipc_ns);
14673 + get_pid_ns(ns->pid_ns);
14675 + get_net(ns->net_ns);
14681 * called from clone. This now handles copy for nsproxy and all
14682 * namespaces therein.
14683 @@ -122,9 +164,12 @@ out_ns:
14684 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
14686 struct nsproxy *old_ns = tsk->nsproxy;
14687 - struct nsproxy *new_ns;
14688 + struct nsproxy *new_ns = NULL;
14691 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
14692 + flags, tsk, old_ns);
14697 @@ -134,7 +179,7 @@ int copy_namespaces(unsigned long flags,
14698 CLONE_NEWPID | CLONE_NEWNET)))
14701 - if (!capable(CAP_SYS_ADMIN)) {
14702 + if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
14706 @@ -161,6 +206,9 @@ int copy_namespaces(unsigned long flags,
14709 put_nsproxy(old_ns);
14710 + vxdprintk(VXD_CBIT(space, 3),
14711 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
14712 + flags, tsk, old_ns, err, new_ns);
14716 @@ -174,7 +222,9 @@ void free_nsproxy(struct nsproxy *ns)
14717 put_ipc_ns(ns->ipc_ns);
14719 put_pid_ns(ns->pid_ns);
14720 - put_net(ns->net_ns);
14722 + put_net(ns->net_ns);
14723 + atomic_dec(&vs_global_nsproxy);
14724 kmem_cache_free(nsproxy_cachep, ns);
14727 @@ -187,11 +237,15 @@ int unshare_nsproxy_namespaces(unsigned
14731 + vxdprintk(VXD_CBIT(space, 4),
14732 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
14733 + unshare_flags, current->nsproxy);
14735 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
14739 - if (!capable(CAP_SYS_ADMIN))
14740 + if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
14743 *new_nsp = create_new_namespaces(unshare_flags, current,
14744 diff -NurpP --minimal linux-3.1.6/kernel/pid.c linux-3.1.6-vs2.3.2.5/kernel/pid.c
14745 --- linux-3.1.6/kernel/pid.c 2011-10-24 18:45:33.000000000 +0200
14746 +++ linux-3.1.6-vs2.3.2.5/kernel/pid.c 2011-10-24 18:53:33.000000000 +0200
14748 #include <linux/pid_namespace.h>
14749 #include <linux/init_task.h>
14750 #include <linux/syscalls.h>
14751 +#include <linux/vs_pid.h>
14753 #define pid_hashfn(nr, ns) \
14754 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
14755 @@ -342,7 +343,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
14757 struct pid *find_vpid(int nr)
14759 - return find_pid_ns(nr, current->nsproxy->pid_ns);
14760 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
14762 EXPORT_SYMBOL_GPL(find_vpid);
14764 @@ -402,6 +403,9 @@ void transfer_pid(struct task_struct *ol
14765 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
14767 struct task_struct *result = NULL;
14769 + if (type == PIDTYPE_REALPID)
14770 + type = PIDTYPE_PID;
14772 struct hlist_node *first;
14773 first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]),
14774 @@ -419,7 +423,7 @@ EXPORT_SYMBOL(pid_task);
14775 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
14777 rcu_lockdep_assert(rcu_read_lock_held());
14778 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
14779 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
14782 struct task_struct *find_task_by_vpid(pid_t vnr)
14783 @@ -463,7 +467,7 @@ struct pid *find_get_pid(pid_t nr)
14785 EXPORT_SYMBOL_GPL(find_get_pid);
14787 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
14788 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
14792 @@ -476,6 +480,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
14796 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
14798 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
14801 pid_t pid_vnr(struct pid *pid)
14803 return pid_nr_ns(pid, current->nsproxy->pid_ns);
14804 diff -NurpP --minimal linux-3.1.6/kernel/pid_namespace.c linux-3.1.6-vs2.3.2.5/kernel/pid_namespace.c
14805 --- linux-3.1.6/kernel/pid_namespace.c 2011-05-22 16:17:59.000000000 +0200
14806 +++ linux-3.1.6-vs2.3.2.5/kernel/pid_namespace.c 2011-10-24 18:53:33.000000000 +0200
14808 #include <linux/acct.h>
14809 #include <linux/slab.h>
14810 #include <linux/proc_fs.h>
14811 +#include <linux/vserver/global.h>
14813 #define BITS_PER_PAGE (PAGE_SIZE*8)
14815 @@ -88,6 +89,7 @@ static struct pid_namespace *create_pid_
14818 kref_init(&ns->kref);
14819 + atomic_inc(&vs_global_pid_ns);
14821 ns->parent = get_pid_ns(parent_pid_ns);
14823 @@ -119,6 +121,7 @@ static void destroy_pid_namespace(struct
14825 for (i = 0; i < PIDMAP_ENTRIES; i++)
14826 kfree(ns->pidmap[i].page);
14827 + atomic_dec(&vs_global_pid_ns);
14828 kmem_cache_free(pid_ns_cachep, ns);
14831 diff -NurpP --minimal linux-3.1.6/kernel/posix-timers.c linux-3.1.6-vs2.3.2.5/kernel/posix-timers.c
14832 --- linux-3.1.6/kernel/posix-timers.c 2011-07-22 11:18:12.000000000 +0200
14833 +++ linux-3.1.6-vs2.3.2.5/kernel/posix-timers.c 2011-10-24 18:53:33.000000000 +0200
14835 #include <linux/wait.h>
14836 #include <linux/workqueue.h>
14837 #include <linux/module.h>
14838 +#include <linux/vs_context.h>
14841 * Management arrays for POSIX timers. Timers are kept in slab memory
14842 @@ -340,6 +341,7 @@ int posix_timer_event(struct k_itimer *t
14844 struct task_struct *task;
14845 int shared, ret = -1;
14848 * FIXME: if ->sigq is queued we can race with
14849 * dequeue_signal()->do_schedule_next_timer().
14850 @@ -356,10 +358,18 @@ int posix_timer_event(struct k_itimer *t
14852 task = pid_task(timr->it_pid, PIDTYPE_PID);
14854 + struct vx_info_save vxis;
14855 + struct vx_info *vxi;
14857 + vxi = get_vx_info(task->vx_info);
14858 + enter_vx_info(vxi, &vxis);
14859 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
14860 ret = send_sigqueue(timr->sigq, task, shared);
14861 + leave_vx_info(&vxis);
14862 + put_vx_info(vxi);
14866 /* If we failed to send the signal the timer stops. */
14869 diff -NurpP --minimal linux-3.1.6/kernel/printk.c linux-3.1.6-vs2.3.2.5/kernel/printk.c
14870 --- linux-3.1.6/kernel/printk.c 2011-10-24 18:45:33.000000000 +0200
14871 +++ linux-3.1.6-vs2.3.2.5/kernel/printk.c 2011-10-24 18:53:33.000000000 +0200
14873 #include <linux/cpu.h>
14874 #include <linux/notifier.h>
14875 #include <linux/rculist.h>
14876 +#include <linux/vs_cvirt.h>
14878 #include <asm/uaccess.h>
14880 @@ -314,7 +315,7 @@ static int check_syslog_permissions(int
14883 if (syslog_action_restricted(type)) {
14884 - if (capable(CAP_SYSLOG))
14885 + if (vx_capable(CAP_SYSLOG, VXC_SYSLOG))
14887 /* For historical reasons, accept CAP_SYS_ADMIN too, with a warning */
14888 if (capable(CAP_SYS_ADMIN)) {
14889 @@ -344,12 +345,9 @@ int do_syslog(int type, char __user *buf
14894 - case SYSLOG_ACTION_CLOSE: /* Close log */
14896 - case SYSLOG_ACTION_OPEN: /* Open log */
14898 - case SYSLOG_ACTION_READ: /* Read from log */
14899 + if ((type == SYSLOG_ACTION_READ) ||
14900 + (type == SYSLOG_ACTION_READ_ALL) ||
14901 + (type == SYSLOG_ACTION_READ_CLEAR)) {
14903 if (!buf || len < 0)
14905 @@ -360,6 +358,16 @@ int do_syslog(int type, char __user *buf
14910 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
14911 + return vx_do_syslog(type, buf, len);
14914 + case SYSLOG_ACTION_CLOSE: /* Close log */
14916 + case SYSLOG_ACTION_OPEN: /* Open log */
14918 + case SYSLOG_ACTION_READ: /* Read from log */
14919 error = wait_event_interruptible(log_wait,
14920 (log_start - log_end));
14922 @@ -386,16 +394,6 @@ int do_syslog(int type, char __user *buf
14924 /* Read last kernel messages */
14925 case SYSLOG_ACTION_READ_ALL:
14927 - if (!buf || len < 0)
14932 - if (!access_ok(VERIFY_WRITE, buf, len)) {
14937 if (count > log_buf_len)
14938 count = log_buf_len;
14939 diff -NurpP --minimal linux-3.1.6/kernel/ptrace.c linux-3.1.6-vs2.3.2.5/kernel/ptrace.c
14940 --- linux-3.1.6/kernel/ptrace.c 2011-10-24 18:45:33.000000000 +0200
14941 +++ linux-3.1.6-vs2.3.2.5/kernel/ptrace.c 2011-10-24 18:53:33.000000000 +0200
14943 #include <linux/syscalls.h>
14944 #include <linux/uaccess.h>
14945 #include <linux/regset.h>
14946 +#include <linux/vs_context.h>
14947 #include <linux/hw_breakpoint.h>
14948 #include <linux/cn_proc.h>
14950 @@ -198,6 +199,11 @@ ok:
14951 dumpable = get_dumpable(task->mm);
14952 if (!dumpable && !task_ns_capable(task, CAP_SYS_PTRACE))
14954 + if (!vx_check(task->xid, VS_ADMIN_P|VS_WATCH_P|VS_IDENT))
14956 + if (!vx_check(task->xid, VS_IDENT) &&
14957 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
14960 return security_ptrace_access_check(task, mode);
14962 diff -NurpP --minimal linux-3.1.6/kernel/sched.c linux-3.1.6-vs2.3.2.5/kernel/sched.c
14963 --- linux-3.1.6/kernel/sched.c 2011-10-24 18:45:33.000000000 +0200
14964 +++ linux-3.1.6-vs2.3.2.5/kernel/sched.c 2011-10-24 18:53:33.000000000 +0200
14966 #include <linux/ctype.h>
14967 #include <linux/ftrace.h>
14968 #include <linux/slab.h>
14969 +#include <linux/vs_sched.h>
14970 +#include <linux/vs_cvirt.h>
14972 #include <asm/tlb.h>
14973 #include <asm/irq_regs.h>
14974 @@ -3473,9 +3475,17 @@ static void calc_global_nohz(unsigned lo
14976 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
14978 - loads[0] = (avenrun[0] + offset) << shift;
14979 - loads[1] = (avenrun[1] + offset) << shift;
14980 - loads[2] = (avenrun[2] + offset) << shift;
14981 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
14982 + struct vx_info *vxi = current_vx_info();
14984 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
14985 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
14986 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
14988 + loads[0] = (avenrun[0] + offset) << shift;
14989 + loads[1] = (avenrun[1] + offset) << shift;
14990 + loads[2] = (avenrun[2] + offset) << shift;
14995 @@ -3734,16 +3744,19 @@ void account_user_time(struct task_struc
14996 cputime_t cputime_scaled)
14998 struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
14999 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15001 + int nice = (TASK_NICE(p) > 0);
15003 /* Add user time to process. */
15004 p->utime = cputime_add(p->utime, cputime);
15005 p->utimescaled = cputime_add(p->utimescaled, cputime_scaled);
15006 + vx_account_user(vxi, cputime, nice);
15007 account_group_user_time(p, cputime);
15009 /* Add user time to cpustat. */
15010 tmp = cputime_to_cputime64(cputime);
15011 - if (TASK_NICE(p) > 0)
15013 cpustat->nice = cputime64_add(cpustat->nice, tmp);
15015 cpustat->user = cputime64_add(cpustat->user, tmp);
15016 @@ -3795,10 +3808,12 @@ void __account_system_time(struct task_s
15017 cputime_t cputime_scaled, cputime64_t *target_cputime64)
15019 cputime64_t tmp = cputime_to_cputime64(cputime);
15020 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15022 /* Add system time to process. */
15023 p->stime = cputime_add(p->stime, cputime);
15024 p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
15025 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
15026 account_group_system_time(p, cputime);
15028 /* Add system time to cpustat. */
15029 @@ -4984,7 +4999,7 @@ SYSCALL_DEFINE1(nice, int, increment)
15032 if (increment < 0 && !can_nice(current, nice))
15034 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
15036 retval = security_task_setnice(current, nice);
15038 diff -NurpP --minimal linux-3.1.6/kernel/sched_fair.c linux-3.1.6-vs2.3.2.5/kernel/sched_fair.c
15039 --- linux-3.1.6/kernel/sched_fair.c 2011-10-24 18:45:33.000000000 +0200
15040 +++ linux-3.1.6-vs2.3.2.5/kernel/sched_fair.c 2011-10-24 18:53:33.000000000 +0200
15041 @@ -979,6 +979,8 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
15042 __enqueue_entity(cfs_rq, se);
15045 + if (entity_is_task(se))
15046 + vx_activate_task(task_of(se));
15047 if (cfs_rq->nr_running == 1)
15048 list_add_leaf_cfs_rq(cfs_rq);
15050 @@ -1055,6 +1057,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
15051 if (se != cfs_rq->curr)
15052 __dequeue_entity(cfs_rq, se);
15054 + if (entity_is_task(se))
15055 + vx_deactivate_task(task_of(se));
15056 update_cfs_load(cfs_rq, 0);
15057 account_entity_dequeue(cfs_rq, se);
15059 diff -NurpP --minimal linux-3.1.6/kernel/signal.c linux-3.1.6-vs2.3.2.5/kernel/signal.c
15060 --- linux-3.1.6/kernel/signal.c 2011-10-24 18:45:33.000000000 +0200
15061 +++ linux-3.1.6-vs2.3.2.5/kernel/signal.c 2011-10-24 18:53:33.000000000 +0200
15063 #include <linux/freezer.h>
15064 #include <linux/pid_namespace.h>
15065 #include <linux/nsproxy.h>
15066 +#include <linux/vs_context.h>
15067 +#include <linux/vs_pid.h>
15068 #define CREATE_TRACE_POINTS
15069 #include <trace/events/signal.h>
15071 @@ -789,9 +791,18 @@ static int check_kill_permission(int sig
15075 + vxdprintk(VXD_CBIT(misc, 7),
15076 + "check_kill_permission(%d,%p,%p[#%u,%u])",
15077 + sig, info, t, vx_task_xid(t), t->pid);
15079 if (!valid_signal(sig))
15082 +/* FIXME: needed? if so, why?
15083 + if ((info != SEND_SIG_NOINFO) &&
15084 + (is_si_special(info) || !si_fromuser(info)))
15087 if (!si_fromuser(info))
15090 @@ -815,6 +826,20 @@ static int check_kill_permission(int sig
15095 + if (t->pid == 1 && current->xid)
15099 + /* FIXME: we shouldn't return ESRCH ever, to avoid
15100 + loops, maybe ENOENT or EACCES? */
15101 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
15102 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
15103 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
15104 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
15108 return security_task_kill(t, info, sig, 0);
15111 @@ -1319,7 +1344,7 @@ int kill_pid_info(int sig, struct siginf
15114 p = pid_task(pid, PIDTYPE_PID);
15116 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
15117 error = group_send_sig_info(sig, info, p);
15118 if (unlikely(error == -ESRCH))
15120 @@ -1358,7 +1383,7 @@ int kill_pid_info_as_uid(int sig, struct
15123 p = pid_task(pid, PIDTYPE_PID);
15125 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
15129 @@ -1413,8 +1438,10 @@ static int kill_something_info(int sig,
15130 struct task_struct * p;
15132 for_each_process(p) {
15133 - if (task_pid_vnr(p) > 1 &&
15134 - !same_thread_group(p, current)) {
15135 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
15136 + task_pid_vnr(p) > 1 &&
15137 + !same_thread_group(p, current) &&
15138 + !vx_current_initpid(p->pid)) {
15139 int err = group_send_sig_info(sig, info, p);
15142 @@ -2249,6 +2276,11 @@ relock:
15143 !sig_kernel_only(signr))
15146 + /* virtual init is protected against user signals */
15147 + if ((info->si_code == SI_USER) &&
15148 + vx_current_initpid(current->pid))
15151 if (sig_kernel_stop(signr)) {
15153 * The default action is to stop all threads in
15154 diff -NurpP --minimal linux-3.1.6/kernel/softirq.c linux-3.1.6-vs2.3.2.5/kernel/softirq.c
15155 --- linux-3.1.6/kernel/softirq.c 2011-07-22 11:18:12.000000000 +0200
15156 +++ linux-3.1.6-vs2.3.2.5/kernel/softirq.c 2011-10-24 18:53:33.000000000 +0200
15158 #include <linux/ftrace.h>
15159 #include <linux/smp.h>
15160 #include <linux/tick.h>
15161 +#include <linux/vs_context.h>
15163 #define CREATE_TRACE_POINTS
15164 #include <trace/events/irq.h>
15165 diff -NurpP --minimal linux-3.1.6/kernel/sys.c linux-3.1.6-vs2.3.2.5/kernel/sys.c
15166 --- linux-3.1.6/kernel/sys.c 2011-10-24 18:45:33.000000000 +0200
15167 +++ linux-3.1.6-vs2.3.2.5/kernel/sys.c 2011-10-24 18:53:33.000000000 +0200
15169 #include <linux/syscalls.h>
15170 #include <linux/kprobes.h>
15171 #include <linux/user_namespace.h>
15172 +#include <linux/vs_pid.h>
15174 #include <linux/kmsg_dump.h>
15175 /* Move somewhere else to avoid recompiling? */
15176 @@ -154,7 +155,10 @@ static int set_one_prio(struct task_stru
15179 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
15181 + if (vx_flags(VXF_IGNEG_NICE, 0))
15187 no_nice = security_task_setnice(p, niceval);
15188 @@ -204,6 +208,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
15190 pgrp = task_pgrp(current);
15191 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15192 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15194 error = set_one_prio(p, niceval, error);
15195 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
15197 @@ -267,6 +273,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
15199 pgrp = task_pgrp(current);
15200 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15201 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15203 niceval = 20 - task_nice(p);
15204 if (niceval > retval)
15206 @@ -417,6 +425,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
15208 static DEFINE_MUTEX(reboot_mutex);
15210 +long vs_reboot(unsigned int, void __user *);
15213 * Reboot system call: for obvious reasons only root may call it,
15214 * and even root needs to set up some magic numbers in the registers
15215 @@ -449,6 +459,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
15216 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
15217 cmd = LINUX_REBOOT_CMD_HALT;
15219 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15220 + return vs_reboot(cmd, arg);
15222 mutex_lock(&reboot_mutex);
15224 case LINUX_REBOOT_CMD_RESTART:
15225 @@ -1272,7 +1285,8 @@ SYSCALL_DEFINE2(sethostname, char __user
15227 char tmp[__NEW_UTS_LEN];
15229 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
15230 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
15231 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15234 if (len < 0 || len > __NEW_UTS_LEN)
15235 @@ -1322,7 +1336,8 @@ SYSCALL_DEFINE2(setdomainname, char __us
15237 char tmp[__NEW_UTS_LEN];
15239 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
15240 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
15241 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15243 if (len < 0 || len > __NEW_UTS_LEN)
15245 @@ -1440,7 +1455,7 @@ int do_prlimit(struct task_struct *tsk,
15246 /* Keep the capable check against init_user_ns until
15247 cgroups can contain all limits */
15248 if (new_rlim->rlim_max > rlim->rlim_max &&
15249 - !capable(CAP_SYS_RESOURCE))
15250 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
15253 retval = security_task_setrlimit(tsk->group_leader,
15254 @@ -1494,7 +1509,8 @@ static int check_prlimit_permission(stru
15255 cred->gid == tcred->sgid &&
15256 cred->gid == tcred->gid))
15258 - if (ns_capable(tcred->user->user_ns, CAP_SYS_RESOURCE))
15259 + if (vx_ns_capable(tcred->user->user_ns,
15260 + CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
15264 diff -NurpP --minimal linux-3.1.6/kernel/sysctl.c linux-3.1.6-vs2.3.2.5/kernel/sysctl.c
15265 --- linux-3.1.6/kernel/sysctl.c 2011-10-24 18:45:33.000000000 +0200
15266 +++ linux-3.1.6-vs2.3.2.5/kernel/sysctl.c 2011-10-24 18:53:33.000000000 +0200
15268 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
15269 #include <linux/lockdep.h>
15271 +extern char vshelper_path[];
15272 #ifdef CONFIG_CHR_DEV_SG
15273 #include <scsi/sg.h>
15275 @@ -568,6 +569,13 @@ static struct ctl_table kern_table[] = {
15276 .proc_handler = proc_dostring,
15280 + .procname = "vshelper",
15281 + .data = &vshelper_path,
15284 + .proc_handler = &proc_dostring,
15286 #ifdef CONFIG_CHR_DEV_SG
15288 .procname = "sg-big-buff",
15289 diff -NurpP --minimal linux-3.1.6/kernel/sysctl_binary.c linux-3.1.6-vs2.3.2.5/kernel/sysctl_binary.c
15290 --- linux-3.1.6/kernel/sysctl_binary.c 2011-10-24 18:45:33.000000000 +0200
15291 +++ linux-3.1.6-vs2.3.2.5/kernel/sysctl_binary.c 2011-10-24 18:53:33.000000000 +0200
15292 @@ -73,6 +73,7 @@ static const struct bin_table bin_kern_t
15294 { CTL_INT, KERN_PANIC, "panic" },
15295 { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
15296 + { CTL_STR, KERN_VSHELPER, "vshelper" },
15298 { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
15299 { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
15300 diff -NurpP --minimal linux-3.1.6/kernel/time/timekeeping.c linux-3.1.6-vs2.3.2.5/kernel/time/timekeeping.c
15301 --- linux-3.1.6/kernel/time/timekeeping.c 2011-12-23 16:04:07.000000000 +0100
15302 +++ linux-3.1.6-vs2.3.2.5/kernel/time/timekeeping.c 2011-12-15 01:07:58.000000000 +0100
15303 @@ -233,6 +233,7 @@ void getnstimeofday(struct timespec *ts)
15304 } while (read_seqretry(&xtime_lock, seq));
15306 timespec_add_ns(ts, nsecs);
15307 + vx_adjust_timespec(ts);
15310 EXPORT_SYMBOL(getnstimeofday);
15311 diff -NurpP --minimal linux-3.1.6/kernel/time.c linux-3.1.6-vs2.3.2.5/kernel/time.c
15312 --- linux-3.1.6/kernel/time.c 2011-12-23 16:04:07.000000000 +0100
15313 +++ linux-3.1.6-vs2.3.2.5/kernel/time.c 2011-11-15 17:08:44.000000000 +0100
15314 @@ -92,7 +92,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
15318 - do_settimeofday(&tv);
15319 + vx_settimeofday(&tv);
15323 @@ -177,7 +177,7 @@ int do_sys_settimeofday(const struct tim
15324 /* SMP safe, again the code in arch/foo/time.c should
15325 * globally block out interrupts when it runs.
15327 - return do_settimeofday(tv);
15328 + return vx_settimeofday(tv);
15332 diff -NurpP --minimal linux-3.1.6/kernel/timer.c linux-3.1.6-vs2.3.2.5/kernel/timer.c
15333 --- linux-3.1.6/kernel/timer.c 2011-07-22 11:18:12.000000000 +0200
15334 +++ linux-3.1.6-vs2.3.2.5/kernel/timer.c 2011-10-24 18:53:33.000000000 +0200
15336 #include <linux/irq_work.h>
15337 #include <linux/sched.h>
15338 #include <linux/slab.h>
15339 +#include <linux/vs_base.h>
15340 +#include <linux/vs_cvirt.h>
15341 +#include <linux/vs_pid.h>
15342 +#include <linux/vserver/sched.h>
15344 #include <asm/uaccess.h>
15345 #include <asm/unistd.h>
15346 @@ -1336,12 +1340,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
15353 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
15354 - * should be moved into arch/i386 instead?
15358 * sys_getpid - return the thread group id of the current process
15359 @@ -1370,10 +1368,23 @@ SYSCALL_DEFINE0(getppid)
15361 pid = task_tgid_vnr(current->real_parent);
15363 + return vx_map_pid(pid);
15370 + * The Alpha uses getxpid, getxuid, and getxgid instead.
15373 +asmlinkage long do_getxpid(long *ppid)
15375 + *ppid = sys_getppid();
15376 + return sys_getpid();
15379 +#else /* _alpha_ */
15381 SYSCALL_DEFINE0(getuid)
15383 /* Only we change this so SMP safe */
15384 diff -NurpP --minimal linux-3.1.6/kernel/user_namespace.c linux-3.1.6-vs2.3.2.5/kernel/user_namespace.c
15385 --- linux-3.1.6/kernel/user_namespace.c 2011-03-15 18:07:42.000000000 +0100
15386 +++ linux-3.1.6-vs2.3.2.5/kernel/user_namespace.c 2011-10-24 18:53:33.000000000 +0200
15388 #include <linux/user_namespace.h>
15389 #include <linux/highuid.h>
15390 #include <linux/cred.h>
15391 +#include <linux/vserver/global.h>
15393 static struct kmem_cache *user_ns_cachep __read_mostly;
15395 @@ -33,6 +34,7 @@ int create_user_ns(struct cred *new)
15398 kref_init(&ns->kref);
15399 + atomic_inc(&vs_global_user_ns);
15401 for (n = 0; n < UIDHASH_SZ; ++n)
15402 INIT_HLIST_HEAD(ns->uidhash_table + n);
15403 @@ -81,6 +83,8 @@ void free_user_ns(struct kref *kref)
15404 struct user_namespace *ns =
15405 container_of(kref, struct user_namespace, kref);
15407 + /* FIXME: maybe move into destroyer? */
15408 + atomic_dec(&vs_global_user_ns);
15409 INIT_WORK(&ns->destroyer, free_user_ns_work);
15410 schedule_work(&ns->destroyer);
15412 diff -NurpP --minimal linux-3.1.6/kernel/utsname.c linux-3.1.6-vs2.3.2.5/kernel/utsname.c
15413 --- linux-3.1.6/kernel/utsname.c 2011-07-22 11:18:12.000000000 +0200
15414 +++ linux-3.1.6-vs2.3.2.5/kernel/utsname.c 2011-10-24 18:53:33.000000000 +0200
15415 @@ -16,14 +16,17 @@
15416 #include <linux/slab.h>
15417 #include <linux/user_namespace.h>
15418 #include <linux/proc_fs.h>
15419 +#include <linux/vserver/global.h>
15421 static struct uts_namespace *create_uts_ns(void)
15423 struct uts_namespace *uts_ns;
15425 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
15428 kref_init(&uts_ns->kref);
15429 + atomic_inc(&vs_global_uts_ns);
15434 @@ -32,8 +35,8 @@ static struct uts_namespace *create_uts_
15435 * @old_ns: namespace to clone
15436 * Return NULL on error (failure to kmalloc), new ns otherwise
15438 -static struct uts_namespace *clone_uts_ns(struct task_struct *tsk,
15439 - struct uts_namespace *old_ns)
15440 +static struct uts_namespace *clone_uts_ns(struct uts_namespace *old_ns,
15441 + struct user_namespace *old_user)
15443 struct uts_namespace *ns;
15445 @@ -43,7 +46,7 @@ static struct uts_namespace *clone_uts_n
15447 down_read(&uts_sem);
15448 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
15449 - ns->user_ns = get_user_ns(task_cred_xxx(tsk, user)->user_ns);
15450 + ns->user_ns = get_user_ns(old_user);
15454 @@ -55,9 +58,9 @@ static struct uts_namespace *clone_uts_n
15457 struct uts_namespace *copy_utsname(unsigned long flags,
15458 - struct task_struct *tsk)
15459 + struct uts_namespace *old_ns,
15460 + struct user_namespace *user_ns)
15462 - struct uts_namespace *old_ns = tsk->nsproxy->uts_ns;
15463 struct uts_namespace *new_ns;
15466 @@ -66,7 +69,7 @@ struct uts_namespace *copy_utsname(unsig
15467 if (!(flags & CLONE_NEWUTS))
15470 - new_ns = clone_uts_ns(tsk, old_ns);
15471 + new_ns = clone_uts_ns(old_ns, user_ns);
15473 put_uts_ns(old_ns);
15475 @@ -78,6 +81,7 @@ void free_uts_ns(struct kref *kref)
15477 ns = container_of(kref, struct uts_namespace, kref);
15478 put_user_ns(ns->user_ns);
15479 + atomic_dec(&vs_global_uts_ns);
15483 diff -NurpP --minimal linux-3.1.6/kernel/vserver/Kconfig linux-3.1.6-vs2.3.2.5/kernel/vserver/Kconfig
15484 --- linux-3.1.6/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
15485 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/Kconfig 2011-12-07 05:08:42.000000000 +0100
15488 +# Linux VServer configuration
15491 +menu "Linux VServer"
15493 +config VSERVER_AUTO_LBACK
15494 + bool "Automatically Assign Loopback IP"
15497 + Automatically assign a guest specific loopback
15498 + IP and add it to the kernel network stack on
15501 +config VSERVER_AUTO_SINGLE
15502 + bool "Automatic Single IP Special Casing"
15503 + depends on EXPERIMENTAL
15506 + This allows network contexts with a single IP to
15507 + automatically remap 0.0.0.0 bindings to that IP,
15508 + avoiding further network checks and improving
15511 + (note: such guests do not allow to change the ip
15512 + on the fly and do not show loopback addresses)
15514 +config VSERVER_COWBL
15515 + bool "Enable COW Immutable Link Breaking"
15518 + This enables the COW (Copy-On-Write) link break code.
15519 + It allows you to treat unified files like normal files
15520 + when writing to them (which will implicitely break the
15521 + link and create a copy of the unified file)
15523 +config VSERVER_VTIME
15524 + bool "Enable Virtualized Guest Time"
15525 + depends on EXPERIMENTAL
15528 + This enables per guest time offsets to allow for
15529 + adjusting the system clock individually per guest.
15530 + this adds some overhead to the time functions and
15531 + therefore should not be enabled without good reason.
15533 +config VSERVER_DEVICE
15534 + bool "Enable Guest Device Mapping"
15535 + depends on EXPERIMENTAL
15538 + This enables generic device remapping.
15540 +config VSERVER_PROC_SECURE
15541 + bool "Enable Proc Security"
15542 + depends on PROC_FS
15545 + This configures ProcFS security to initially hide
15546 + non-process entries for all contexts except the main and
15547 + spectator context (i.e. for all guests), which is a secure
15550 + (note: on 1.2x the entries were visible by default)
15553 + prompt "Persistent Inode Tagging"
15554 + default TAGGING_ID24
15556 + This adds persistent context information to filesystems
15557 + mounted with the tagxid option. Tagging is a requirement
15558 + for per-context disk limits and per-context quota.
15561 +config TAGGING_NONE
15564 + do not store per-context information in inodes.
15566 +config TAGGING_UID16
15567 + bool "UID16/GID32"
15569 + reduces UID to 16 bit, but leaves GID at 32 bit.
15571 +config TAGGING_GID16
15572 + bool "UID32/GID16"
15574 + reduces GID to 16 bit, but leaves UID at 32 bit.
15576 +config TAGGING_ID24
15577 + bool "UID24/GID24"
15579 + uses the upper 8bit from UID and GID for XID tagging
15580 + which leaves 24bit for UID/GID each, which should be
15581 + more than sufficient for normal use.
15583 +config TAGGING_INTERN
15584 + bool "UID32/GID32"
15586 + this uses otherwise reserved inode fields in the on
15587 + disk representation, which limits the use to a few
15588 + filesystems (currently ext2 and ext3)
15593 + bool "Tag NFSD User Auth and Files"
15596 + Enable this if you do want the in-kernel NFS
15597 + Server to use the tagging specified above.
15598 + (will require patched clients too)
15600 +config VSERVER_PRIVACY
15601 + bool "Honor Privacy Aspects of Guests"
15604 + When enabled, most context checks will disallow
15605 + access to structures assigned to a specific context,
15606 + like ptys or loop devices.
15608 +config VSERVER_CONTEXTS
15609 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
15611 + default "768" if 64BIT
15614 + This setting will optimize certain data structures
15615 + and memory allocations according to the expected
15618 + note: this is not a strict upper limit.
15620 +config VSERVER_WARN
15621 + bool "VServer Warnings"
15624 + This enables various runtime warnings, which will
15625 + notify about potential manipulation attempts or
15626 + resource shortage. It is generally considered to
15627 + be a good idea to have that enabled.
15629 +config VSERVER_WARN_DEVPTS
15630 + bool "VServer DevPTS Warnings"
15631 + depends on VSERVER_WARN
15634 + This enables DevPTS related warnings, issued when a
15635 + process inside a context tries to lookup or access
15636 + a dynamic pts from the host or a different context.
15638 +config VSERVER_DEBUG
15639 + bool "VServer Debugging Code"
15642 + Set this to yes if you want to be able to activate
15643 + debugging output at runtime. It adds a very small
15644 + overhead to all vserver related functions and
15645 + increases the kernel size by about 20k.
15647 +config VSERVER_HISTORY
15648 + bool "VServer History Tracing"
15649 + depends on VSERVER_DEBUG
15652 + Set this to yes if you want to record the history of
15653 + linux-vserver activities, so they can be replayed in
15654 + the event of a kernel panic or oops.
15656 +config VSERVER_HISTORY_SIZE
15657 + int "Per-CPU History Size (32-65536)"
15658 + depends on VSERVER_HISTORY
15662 + This allows you to specify the number of entries in
15663 + the per-CPU history buffer.
15666 + prompt "Quotes used in debug and warn messages"
15667 + default QUOTES_ISO8859
15669 +config QUOTES_ISO8859
15670 + bool "Extended ASCII (ISO 8859) angle quotes"
15672 + This uses the extended ASCII characters \xbb
15673 + and \xab for quoting file and process names.
15675 +config QUOTES_UTF8
15676 + bool "UTF-8 angle quotes"
15678 + This uses the the UTF-8 sequences for angle
15679 + quotes to quote file and process names.
15681 +config QUOTES_ASCII
15682 + bool "ASCII single quotes"
15684 + This uses the ASCII single quote character
15685 + (\x27) to quote file and process names.
15695 + select NAMESPACES
15701 +config VSERVER_SECURITY
15703 + depends on SECURITY
15705 + select SECURITY_CAPABILITIES
15707 +config VSERVER_DISABLED
15711 diff -NurpP --minimal linux-3.1.6/kernel/vserver/Makefile linux-3.1.6-vs2.3.2.5/kernel/vserver/Makefile
15712 --- linux-3.1.6/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
15713 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/Makefile 2011-10-24 18:53:33.000000000 +0200
15716 +# Makefile for the Linux vserver routines.
15720 +obj-y += vserver.o
15722 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
15723 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
15726 +vserver-$(CONFIG_INET) += inet.o
15727 +vserver-$(CONFIG_PROC_FS) += proc.o
15728 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
15729 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
15730 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
15731 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
15733 diff -NurpP --minimal linux-3.1.6/kernel/vserver/cacct.c linux-3.1.6-vs2.3.2.5/kernel/vserver/cacct.c
15734 --- linux-3.1.6/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
15735 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/cacct.c 2011-10-24 18:53:33.000000000 +0200
15738 + * linux/kernel/vserver/cacct.c
15740 + * Virtual Server: Context Accounting
15742 + * Copyright (C) 2006-2007 Herbert Pötzl
15744 + * V0.01 added accounting stats
15748 +#include <linux/types.h>
15749 +#include <linux/vs_context.h>
15750 +#include <linux/vserver/cacct_cmd.h>
15751 +#include <linux/vserver/cacct_int.h>
15753 +#include <asm/errno.h>
15754 +#include <asm/uaccess.h>
15757 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
15759 + struct vcmd_sock_stat_v0 vc_data;
15762 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
15765 + field = vc_data.field;
15766 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
15769 + for (j = 0; j < 3; j++) {
15770 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
15771 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
15774 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
15779 diff -NurpP --minimal linux-3.1.6/kernel/vserver/cacct_init.h linux-3.1.6-vs2.3.2.5/kernel/vserver/cacct_init.h
15780 --- linux-3.1.6/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
15781 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/cacct_init.h 2011-10-24 18:53:33.000000000 +0200
15785 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
15790 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
15791 + for (j = 0; j < 3; j++) {
15792 + atomic_long_set(&cacct->sock[i][j].count, 0);
15793 + atomic_long_set(&cacct->sock[i][j].total, 0);
15796 + for (i = 0; i < 8; i++)
15797 + atomic_set(&cacct->slab[i], 0);
15798 + for (i = 0; i < 5; i++)
15799 + for (j = 0; j < 4; j++)
15800 + atomic_set(&cacct->page[i][j], 0);
15803 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
15808 diff -NurpP --minimal linux-3.1.6/kernel/vserver/cacct_proc.h linux-3.1.6-vs2.3.2.5/kernel/vserver/cacct_proc.h
15809 --- linux-3.1.6/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
15810 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/cacct_proc.h 2011-10-24 18:53:33.000000000 +0200
15812 +#ifndef _VX_CACCT_PROC_H
15813 +#define _VX_CACCT_PROC_H
15815 +#include <linux/vserver/cacct_int.h>
15818 +#define VX_SOCKA_TOP \
15819 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
15821 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
15823 + int i, j, length = 0;
15824 + static char *type[VXA_SOCK_SIZE] = {
15825 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
15828 + length += sprintf(buffer + length, VX_SOCKA_TOP);
15829 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
15830 + length += sprintf(buffer + length, "%s:", type[i]);
15831 + for (j = 0; j < 3; j++) {
15832 + length += sprintf(buffer + length,
15833 + "\t%10lu/%-10lu",
15834 + vx_sock_count(cacct, i, j),
15835 + vx_sock_total(cacct, i, j));
15837 + buffer[length++] = '\n';
15840 + length += sprintf(buffer + length, "\n");
15841 + length += sprintf(buffer + length,
15842 + "slab:\t %8u %8u %8u %8u\n",
15843 + atomic_read(&cacct->slab[1]),
15844 + atomic_read(&cacct->slab[4]),
15845 + atomic_read(&cacct->slab[0]),
15846 + atomic_read(&cacct->slab[2]));
15848 + length += sprintf(buffer + length, "\n");
15849 + for (i = 0; i < 5; i++) {
15850 + length += sprintf(buffer + length,
15851 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
15852 + atomic_read(&cacct->page[i][0]),
15853 + atomic_read(&cacct->page[i][1]),
15854 + atomic_read(&cacct->page[i][2]),
15855 + atomic_read(&cacct->page[i][3]),
15856 + atomic_read(&cacct->page[i][4]),
15857 + atomic_read(&cacct->page[i][5]),
15858 + atomic_read(&cacct->page[i][6]),
15859 + atomic_read(&cacct->page[i][7]));
15864 +#endif /* _VX_CACCT_PROC_H */
15865 diff -NurpP --minimal linux-3.1.6/kernel/vserver/context.c linux-3.1.6-vs2.3.2.5/kernel/vserver/context.c
15866 --- linux-3.1.6/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
15867 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/context.c 2011-10-24 18:53:33.000000000 +0200
15870 + * linux/kernel/vserver/context.c
15872 + * Virtual Server: Context Support
15874 + * Copyright (C) 2003-2011 Herbert Pötzl
15876 + * V0.01 context helper
15877 + * V0.02 vx_ctx_kill syscall command
15878 + * V0.03 replaced context_info calls
15879 + * V0.04 redesign of struct (de)alloc
15880 + * V0.05 rlimit basic implementation
15881 + * V0.06 task_xid and info commands
15882 + * V0.07 context flags and caps
15883 + * V0.08 switch to RCU based hash
15884 + * V0.09 revert to non RCU for now
15885 + * V0.10 and back to working RCU hash
15886 + * V0.11 and back to locking again
15887 + * V0.12 referenced context store
15888 + * V0.13 separate per cpu data
15889 + * V0.14 changed vcmds to vxi arg
15890 + * V0.15 added context stat
15891 + * V0.16 have __create claim() the vxi
15892 + * V0.17 removed older and legacy stuff
15893 + * V0.18 added user credentials
15894 + * V0.19 added warn mask
15898 +#include <linux/slab.h>
15899 +#include <linux/types.h>
15900 +#include <linux/security.h>
15901 +#include <linux/pid_namespace.h>
15902 +#include <linux/capability.h>
15904 +#include <linux/vserver/context.h>
15905 +#include <linux/vserver/network.h>
15906 +#include <linux/vserver/debug.h>
15907 +#include <linux/vserver/limit.h>
15908 +#include <linux/vserver/limit_int.h>
15909 +#include <linux/vserver/space.h>
15910 +#include <linux/init_task.h>
15911 +#include <linux/fs_struct.h>
15912 +#include <linux/cred.h>
15914 +#include <linux/vs_context.h>
15915 +#include <linux/vs_limit.h>
15916 +#include <linux/vs_pid.h>
15917 +#include <linux/vserver/context_cmd.h>
15919 +#include "cvirt_init.h"
15920 +#include "cacct_init.h"
15921 +#include "limit_init.h"
15922 +#include "sched_init.h"
15925 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
15926 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
15929 +/* now inactive context structures */
15931 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
15933 +static DEFINE_SPINLOCK(vx_info_inactive_lock);
15936 +/* __alloc_vx_info()
15938 + * allocate an initialized vx_info struct
15939 + * doesn't make it visible (hash) */
15941 +static struct vx_info *__alloc_vx_info(xid_t xid)
15943 + struct vx_info *new = NULL;
15946 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
15948 + /* would this benefit from a slab cache? */
15949 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
15953 + memset(new, 0, sizeof(struct vx_info));
15955 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
15956 + if (!new->ptr_pc)
15959 + new->vx_id = xid;
15960 + INIT_HLIST_NODE(&new->vx_hlist);
15961 + atomic_set(&new->vx_usecnt, 0);
15962 + atomic_set(&new->vx_tasks, 0);
15963 + new->vx_parent = NULL;
15964 + new->vx_state = 0;
15965 + init_waitqueue_head(&new->vx_wait);
15967 + /* prepare reaper */
15968 + get_task_struct(init_pid_ns.child_reaper);
15969 + new->vx_reaper = init_pid_ns.child_reaper;
15970 + new->vx_badness_bias = 0;
15972 + /* rest of init goes here */
15973 + vx_info_init_limit(&new->limit);
15974 + vx_info_init_sched(&new->sched);
15975 + vx_info_init_cvirt(&new->cvirt);
15976 + vx_info_init_cacct(&new->cacct);
15978 + /* per cpu data structures */
15979 + for_each_possible_cpu(cpu) {
15980 + vx_info_init_sched_pc(
15981 + &vx_per_cpu(new, sched_pc, cpu), cpu);
15982 + vx_info_init_cvirt_pc(
15983 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
15986 + new->vx_flags = VXF_INIT_SET;
15987 + new->vx_bcaps = CAP_FULL_SET; // maybe ~CAP_SETPCAP
15988 + new->vx_ccaps = 0;
15989 + new->vx_umask = 0;
15990 + new->vx_wmask = 0;
15992 + new->reboot_cmd = 0;
15993 + new->exit_code = 0;
15995 + // preconfig spaces
15996 + for (index = 0; index < VX_SPACES; index++) {
15997 + struct _vx_space *space = &new->space[index];
16000 + spin_lock(&init_fs.lock);
16002 + spin_unlock(&init_fs.lock);
16003 + space->vx_fs = &init_fs;
16005 + /* FIXME: do we want defaults? */
16006 + // space->vx_real_cred = 0;
16007 + // space->vx_cred = 0;
16011 + vxdprintk(VXD_CBIT(xid, 0),
16012 + "alloc_vx_info(%d) = %p", xid, new);
16013 + vxh_alloc_vx_info(new);
16014 + atomic_inc(&vx_global_ctotal);
16023 +/* __dealloc_vx_info()
16025 + * final disposal of vx_info */
16027 +static void __dealloc_vx_info(struct vx_info *vxi)
16029 +#ifdef CONFIG_VSERVER_WARN
16030 + struct vx_info_save vxis;
16033 + vxdprintk(VXD_CBIT(xid, 0),
16034 + "dealloc_vx_info(%p)", vxi);
16035 + vxh_dealloc_vx_info(vxi);
16037 +#ifdef CONFIG_VSERVER_WARN
16038 + enter_vx_info(vxi, &vxis);
16039 + vx_info_exit_limit(&vxi->limit);
16040 + vx_info_exit_sched(&vxi->sched);
16041 + vx_info_exit_cvirt(&vxi->cvirt);
16042 + vx_info_exit_cacct(&vxi->cacct);
16044 + for_each_possible_cpu(cpu) {
16045 + vx_info_exit_sched_pc(
16046 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
16047 + vx_info_exit_cvirt_pc(
16048 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
16050 + leave_vx_info(&vxis);
16054 + vxi->vx_state |= VXS_RELEASED;
16057 + free_percpu(vxi->ptr_pc);
16060 + atomic_dec(&vx_global_ctotal);
16063 +static void __shutdown_vx_info(struct vx_info *vxi)
16065 + struct nsproxy *nsproxy;
16066 + struct fs_struct *fs;
16067 + struct cred *cred;
16072 + vxi->vx_state |= VXS_SHUTDOWN;
16073 + vs_state_change(vxi, VSC_SHUTDOWN);
16075 + for (index = 0; index < VX_SPACES; index++) {
16076 + struct _vx_space *space = &vxi->space[index];
16078 + nsproxy = xchg(&space->vx_nsproxy, NULL);
16080 + put_nsproxy(nsproxy);
16082 + fs = xchg(&space->vx_fs, NULL);
16083 + spin_lock(&fs->lock);
16084 + kill = !--fs->users;
16085 + spin_unlock(&fs->lock);
16087 + free_fs_struct(fs);
16089 + cred = (struct cred *)xchg(&space->vx_cred, NULL);
16091 + abort_creds(cred);
16095 +/* exported stuff */
16097 +void free_vx_info(struct vx_info *vxi)
16099 + unsigned long flags;
16102 + /* check for reference counts first */
16103 + BUG_ON(atomic_read(&vxi->vx_usecnt));
16104 + BUG_ON(atomic_read(&vxi->vx_tasks));
16106 + /* context must not be hashed */
16107 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16109 + /* context shutdown is mandatory */
16110 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
16112 + /* spaces check */
16113 + for (index = 0; index < VX_SPACES; index++) {
16114 + struct _vx_space *space = &vxi->space[index];
16116 + BUG_ON(space->vx_nsproxy);
16117 + BUG_ON(space->vx_fs);
16118 + // BUG_ON(space->vx_real_cred);
16119 + // BUG_ON(space->vx_cred);
16122 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16123 + hlist_del(&vxi->vx_hlist);
16124 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16126 + __dealloc_vx_info(vxi);
16130 +/* hash table for vx_info hash */
16132 +#define VX_HASH_SIZE 13
16134 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
16135 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
16137 +static DEFINE_SPINLOCK(vx_info_hash_lock);
16140 +static inline unsigned int __hashval(xid_t xid)
16142 + return (xid % VX_HASH_SIZE);
16147 +/* __hash_vx_info()
16149 + * add the vxi to the global hash table
16150 + * requires the hash_lock to be held */
16152 +static inline void __hash_vx_info(struct vx_info *vxi)
16154 + struct hlist_head *head;
16156 + vxd_assert_lock(&vx_info_hash_lock);
16157 + vxdprintk(VXD_CBIT(xid, 4),
16158 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
16159 + vxh_hash_vx_info(vxi);
16161 + /* context must not be hashed */
16162 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16164 + vxi->vx_state |= VXS_HASHED;
16165 + head = &vx_info_hash[__hashval(vxi->vx_id)];
16166 + hlist_add_head(&vxi->vx_hlist, head);
16167 + atomic_inc(&vx_global_cactive);
16170 +/* __unhash_vx_info()
16172 + * remove the vxi from the global hash table
16173 + * requires the hash_lock to be held */
16175 +static inline void __unhash_vx_info(struct vx_info *vxi)
16177 + unsigned long flags;
16179 + vxd_assert_lock(&vx_info_hash_lock);
16180 + vxdprintk(VXD_CBIT(xid, 4),
16181 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
16182 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
16183 + vxh_unhash_vx_info(vxi);
16185 + /* context must be hashed */
16186 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
16187 + /* but without tasks */
16188 + BUG_ON(atomic_read(&vxi->vx_tasks));
16190 + vxi->vx_state &= ~VXS_HASHED;
16191 + hlist_del_init(&vxi->vx_hlist);
16192 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16193 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
16194 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16195 + atomic_dec(&vx_global_cactive);
16199 +/* __lookup_vx_info()
16201 + * requires the hash_lock to be held
16202 + * doesn't increment the vx_refcnt */
16204 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
16206 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
16207 + struct hlist_node *pos;
16208 + struct vx_info *vxi;
16210 + vxd_assert_lock(&vx_info_hash_lock);
16211 + hlist_for_each(pos, head) {
16212 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16214 + if (vxi->vx_id == xid)
16219 + vxdprintk(VXD_CBIT(xid, 0),
16220 + "__lookup_vx_info(#%u): %p[#%u]",
16221 + xid, vxi, vxi ? vxi->vx_id : 0);
16222 + vxh_lookup_vx_info(vxi, xid);
16227 +/* __create_vx_info()
16229 + * create the requested context
16230 + * get(), claim() and hash it */
16232 +static struct vx_info *__create_vx_info(int id)
16234 + struct vx_info *new, *vxi = NULL;
16236 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
16238 + if (!(new = __alloc_vx_info(id)))
16239 + return ERR_PTR(-ENOMEM);
16241 + /* required to make dynamic xids unique */
16242 + spin_lock(&vx_info_hash_lock);
16244 + /* static context requested */
16245 + if ((vxi = __lookup_vx_info(id))) {
16246 + vxdprintk(VXD_CBIT(xid, 0),
16247 + "create_vx_info(%d) = %p (already there)", id, vxi);
16248 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16249 + vxi = ERR_PTR(-EBUSY);
16251 + vxi = ERR_PTR(-EEXIST);
16254 + /* new context */
16255 + vxdprintk(VXD_CBIT(xid, 0),
16256 + "create_vx_info(%d) = %p (new)", id, new);
16257 + claim_vx_info(new, NULL);
16258 + __hash_vx_info(get_vx_info(new));
16259 + vxi = new, new = NULL;
16262 + spin_unlock(&vx_info_hash_lock);
16263 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
16265 + __dealloc_vx_info(new);
16270 +/* exported stuff */
16273 +void unhash_vx_info(struct vx_info *vxi)
16275 + spin_lock(&vx_info_hash_lock);
16276 + __unhash_vx_info(vxi);
16277 + spin_unlock(&vx_info_hash_lock);
16278 + __shutdown_vx_info(vxi);
16279 + __wakeup_vx_info(vxi);
16283 +/* lookup_vx_info()
16285 + * search for a vx_info and get() it
16286 + * negative id means current */
16288 +struct vx_info *lookup_vx_info(int id)
16290 + struct vx_info *vxi = NULL;
16293 + vxi = get_vx_info(current_vx_info());
16294 + } else if (id > 1) {
16295 + spin_lock(&vx_info_hash_lock);
16296 + vxi = get_vx_info(__lookup_vx_info(id));
16297 + spin_unlock(&vx_info_hash_lock);
16302 +/* xid_is_hashed()
16304 + * verify that xid is still hashed */
16306 +int xid_is_hashed(xid_t xid)
16310 + spin_lock(&vx_info_hash_lock);
16311 + hashed = (__lookup_vx_info(xid) != NULL);
16312 + spin_unlock(&vx_info_hash_lock);
16316 +#ifdef CONFIG_PROC_FS
16320 + * get a subset of hashed xids for proc
16321 + * assumes size is at least one */
16323 +int get_xid_list(int index, unsigned int *xids, int size)
16325 + int hindex, nr_xids = 0;
16327 + /* only show current and children */
16328 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
16331 + xids[nr_xids] = vx_current_xid();
16335 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
16336 + struct hlist_head *head = &vx_info_hash[hindex];
16337 + struct hlist_node *pos;
16339 + spin_lock(&vx_info_hash_lock);
16340 + hlist_for_each(pos, head) {
16341 + struct vx_info *vxi;
16346 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16347 + xids[nr_xids] = vxi->vx_id;
16348 + if (++nr_xids >= size) {
16349 + spin_unlock(&vx_info_hash_lock);
16353 + /* keep the lock time short */
16354 + spin_unlock(&vx_info_hash_lock);
16361 +#ifdef CONFIG_VSERVER_DEBUG
16363 +void dump_vx_info_inactive(int level)
16365 + struct hlist_node *entry, *next;
16367 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
16368 + struct vx_info *vxi =
16369 + list_entry(entry, struct vx_info, vx_hlist);
16371 + dump_vx_info(vxi, level);
16378 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
16380 + struct user_struct *new_user, *old_user;
16385 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
16388 + new_user = alloc_uid(vxi->vx_id, p->uid);
16392 + old_user = p->user;
16393 + if (new_user != old_user) {
16394 + atomic_inc(&new_user->processes);
16395 + atomic_dec(&old_user->processes);
16396 + p->user = new_user;
16398 + free_uid(old_user);
16404 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
16406 + // p->cap_effective &= vxi->vx_cap_bset;
16407 + p->cap_effective =
16408 + cap_intersect(p->cap_effective, vxi->cap_bset);
16409 + // p->cap_inheritable &= vxi->vx_cap_bset;
16410 + p->cap_inheritable =
16411 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
16412 + // p->cap_permitted &= vxi->vx_cap_bset;
16413 + p->cap_permitted =
16414 + cap_intersect(p->cap_permitted, vxi->cap_bset);
16419 +#include <linux/file.h>
16420 +#include <linux/fdtable.h>
16422 +static int vx_openfd_task(struct task_struct *tsk)
16424 + struct files_struct *files = tsk->files;
16425 + struct fdtable *fdt;
16426 + const unsigned long *bptr;
16427 + int count, total;
16429 + /* no rcu_read_lock() because of spin_lock() */
16430 + spin_lock(&files->file_lock);
16431 + fdt = files_fdtable(files);
16432 + bptr = fdt->open_fds->fds_bits;
16433 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
16434 + for (total = 0; count > 0; count--) {
16436 + total += hweight_long(*bptr);
16439 + spin_unlock(&files->file_lock);
16444 +/* for *space compatibility */
16446 +asmlinkage long sys_unshare(unsigned long);
16449 + * migrate task to new context
16450 + * gets vxi, puts old_vxi on change
16451 + * optionally unshares namespaces (hack)
16454 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
16456 + struct vx_info *old_vxi;
16462 + vxdprintk(VXD_CBIT(xid, 5),
16463 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
16464 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
16466 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
16467 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16470 + if (vx_info_state(vxi, VXS_SHUTDOWN))
16473 + old_vxi = task_get_vx_info(p);
16474 + if (old_vxi == vxi)
16477 +// if (!(ret = vx_migrate_user(p, vxi))) {
16482 + openfd = vx_openfd_task(p);
16485 + atomic_dec(&old_vxi->cvirt.nr_threads);
16486 + atomic_dec(&old_vxi->cvirt.nr_running);
16487 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
16488 + /* FIXME: what about the struct files here? */
16489 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
16490 + /* account for the executable */
16491 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
16493 + atomic_inc(&vxi->cvirt.nr_threads);
16494 + atomic_inc(&vxi->cvirt.nr_running);
16495 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
16496 + /* FIXME: what about the struct files here? */
16497 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
16498 + /* account for the executable */
16499 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
16502 + release_vx_info(old_vxi, p);
16503 + clr_vx_info(&p->vx_info);
16505 + claim_vx_info(vxi, p);
16506 + set_vx_info(&p->vx_info, vxi);
16507 + p->xid = vxi->vx_id;
16509 + vxdprintk(VXD_CBIT(xid, 5),
16510 + "moved task %p into vxi:%p[#%d]",
16511 + p, vxi, vxi->vx_id);
16513 + // vx_mask_cap_bset(vxi, p);
16516 + /* hack for *spaces to provide compatibility */
16518 + struct nsproxy *old_nsp, *new_nsp;
16520 + ret = unshare_nsproxy_namespaces(
16521 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
16526 + old_nsp = xchg(&p->nsproxy, new_nsp);
16527 + vx_set_space(vxi,
16528 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
16529 + put_nsproxy(old_nsp);
16533 + put_vx_info(old_vxi);
16537 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
16539 + struct task_struct *old_reaper;
16544 + vxdprintk(VXD_CBIT(xid, 6),
16545 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
16546 + vxi, vxi->vx_id, p, p->xid, p->pid);
16548 + old_reaper = vxi->vx_reaper;
16549 + if (old_reaper == p)
16552 + /* set new child reaper */
16553 + get_task_struct(p);
16554 + vxi->vx_reaper = p;
16555 + put_task_struct(old_reaper);
16559 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
16564 + vxdprintk(VXD_CBIT(xid, 6),
16565 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
16566 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16568 + vxi->vx_flags &= ~VXF_STATE_INIT;
16569 + // vxi->vx_initpid = p->tgid;
16570 + vxi->vx_initpid = p->pid;
16574 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
16576 + vxdprintk(VXD_CBIT(xid, 6),
16577 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
16578 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16580 + vxi->exit_code = code;
16581 + vxi->vx_initpid = 0;
16585 +void vx_set_persistent(struct vx_info *vxi)
16587 + vxdprintk(VXD_CBIT(xid, 6),
16588 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
16590 + get_vx_info(vxi);
16591 + claim_vx_info(vxi, NULL);
16594 +void vx_clear_persistent(struct vx_info *vxi)
16596 + vxdprintk(VXD_CBIT(xid, 6),
16597 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
16599 + release_vx_info(vxi, NULL);
16600 + put_vx_info(vxi);
16603 +void vx_update_persistent(struct vx_info *vxi)
16605 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
16606 + vx_set_persistent(vxi);
16608 + vx_clear_persistent(vxi);
16612 +/* task must be current or locked */
16614 +void exit_vx_info(struct task_struct *p, int code)
16616 + struct vx_info *vxi = p->vx_info;
16619 + atomic_dec(&vxi->cvirt.nr_threads);
16622 + vxi->exit_code = code;
16623 + release_vx_info(vxi, p);
16627 +void exit_vx_info_early(struct task_struct *p, int code)
16629 + struct vx_info *vxi = p->vx_info;
16632 + if (vxi->vx_initpid == p->pid)
16633 + vx_exit_init(vxi, p, code);
16634 + if (vxi->vx_reaper == p)
16635 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
16640 +/* vserver syscall commands below here */
16642 +/* taks xid and vx_info functions */
16644 +#include <asm/uaccess.h>
16647 +int vc_task_xid(uint32_t id)
16652 + struct task_struct *tsk;
16655 + tsk = find_task_by_real_pid(id);
16656 + xid = (tsk) ? tsk->xid : -ESRCH;
16657 + rcu_read_unlock();
16659 + xid = vx_current_xid();
16664 +int vc_vx_info(struct vx_info *vxi, void __user *data)
16666 + struct vcmd_vx_info_v0 vc_data;
16668 + vc_data.xid = vxi->vx_id;
16669 + vc_data.initpid = vxi->vx_initpid;
16671 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16677 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
16679 + struct vcmd_ctx_stat_v0 vc_data;
16681 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
16682 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
16684 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16690 +/* context functions */
16692 +int vc_ctx_create(uint32_t xid, void __user *data)
16694 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
16695 + struct vx_info *new_vxi;
16698 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16701 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
16704 + new_vxi = __create_vx_info(xid);
16705 + if (IS_ERR(new_vxi))
16706 + return PTR_ERR(new_vxi);
16708 + /* initial flags */
16709 + new_vxi->vx_flags = vc_data.flagword;
16712 + if (vs_state_change(new_vxi, VSC_STARTUP))
16715 + ret = vx_migrate_task(current, new_vxi, (!data));
16719 + /* return context id on success */
16720 + ret = new_vxi->vx_id;
16722 + /* get a reference for persistent contexts */
16723 + if ((vc_data.flagword & VXF_PERSISTENT))
16724 + vx_set_persistent(new_vxi);
16726 + release_vx_info(new_vxi, NULL);
16727 + put_vx_info(new_vxi);
16732 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
16734 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
16737 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16740 + ret = vx_migrate_task(current, vxi, 0);
16743 + if (vc_data.flagword & VXM_SET_INIT)
16744 + ret = vx_set_init(vxi, current);
16747 + if (vc_data.flagword & VXM_SET_REAPER)
16748 + ret = vx_set_reaper(vxi, current);
16753 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
16755 + struct vcmd_ctx_flags_v0 vc_data;
16757 + vc_data.flagword = vxi->vx_flags;
16759 + /* special STATE flag handling */
16760 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
16762 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16767 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
16769 + struct vcmd_ctx_flags_v0 vc_data;
16770 + uint64_t mask, trigger;
16772 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16775 + /* special STATE flag handling */
16776 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
16777 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
16779 + if (vxi == current_vx_info()) {
16780 + /* if (trigger & VXF_STATE_SETUP)
16781 + vx_mask_cap_bset(vxi, current); */
16782 + if (trigger & VXF_STATE_INIT) {
16785 + ret = vx_set_init(vxi, current);
16788 + ret = vx_set_reaper(vxi, current);
16794 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
16795 + vc_data.flagword, mask);
16796 + if (trigger & VXF_PERSISTENT)
16797 + vx_update_persistent(vxi);
16803 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
16805 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
16807 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
16811 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
16813 + kernel_cap_t c = __cap_empty_set;
16815 + c.cap[0] = v & 0xFFFFFFFF;
16816 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
16818 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
16823 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
16826 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
16828 + *ccaps = vxi->vx_ccaps;
16833 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
16835 + struct vcmd_ctx_caps_v1 vc_data;
16838 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
16841 + vc_data.cmask = ~0ULL;
16843 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16848 +static int do_set_caps(struct vx_info *vxi,
16849 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
16851 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
16854 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
16855 + bcaps, bmask, ccaps, cmask);
16857 + vxi->vx_bcaps = cap_t_from_caps(
16858 + vs_mask_flags(bcold, bcaps, bmask));
16859 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
16864 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
16866 + struct vcmd_ctx_caps_v1 vc_data;
16868 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16871 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
16874 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
16876 + struct vcmd_bcaps vc_data;
16879 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
16882 + vc_data.bmask = ~0ULL;
16884 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16889 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
16891 + struct vcmd_bcaps vc_data;
16893 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16896 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
16900 +int vc_get_umask(struct vx_info *vxi, void __user *data)
16902 + struct vcmd_umask vc_data;
16904 + vc_data.umask = vxi->vx_umask;
16905 + vc_data.mask = ~0ULL;
16907 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16912 +int vc_set_umask(struct vx_info *vxi, void __user *data)
16914 + struct vcmd_umask vc_data;
16916 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16919 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
16920 + vc_data.umask, vc_data.mask);
16925 +int vc_get_wmask(struct vx_info *vxi, void __user *data)
16927 + struct vcmd_wmask vc_data;
16929 + vc_data.wmask = vxi->vx_wmask;
16930 + vc_data.mask = ~0ULL;
16932 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16937 +int vc_set_wmask(struct vx_info *vxi, void __user *data)
16939 + struct vcmd_wmask vc_data;
16941 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16944 + vxi->vx_wmask = vs_mask_flags(vxi->vx_wmask,
16945 + vc_data.wmask, vc_data.mask);
16950 +int vc_get_badness(struct vx_info *vxi, void __user *data)
16952 + struct vcmd_badness_v0 vc_data;
16954 + vc_data.bias = vxi->vx_badness_bias;
16956 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16961 +int vc_set_badness(struct vx_info *vxi, void __user *data)
16963 + struct vcmd_badness_v0 vc_data;
16965 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16968 + vxi->vx_badness_bias = vc_data.bias;
16972 +#include <linux/module.h>
16974 +EXPORT_SYMBOL_GPL(free_vx_info);
16976 diff -NurpP --minimal linux-3.1.6/kernel/vserver/cvirt.c linux-3.1.6-vs2.3.2.5/kernel/vserver/cvirt.c
16977 --- linux-3.1.6/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
16978 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/cvirt.c 2011-10-24 18:53:33.000000000 +0200
16981 + * linux/kernel/vserver/cvirt.c
16983 + * Virtual Server: Context Virtualization
16985 + * Copyright (C) 2004-2007 Herbert Pötzl
16987 + * V0.01 broken out from limit.c
16988 + * V0.02 added utsname stuff
16989 + * V0.03 changed vcmds to vxi arg
16993 +#include <linux/types.h>
16994 +#include <linux/utsname.h>
16995 +#include <linux/vs_cvirt.h>
16996 +#include <linux/vserver/switch.h>
16997 +#include <linux/vserver/cvirt_cmd.h>
16999 +#include <asm/uaccess.h>
17002 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
17004 + struct vx_info *vxi = current_vx_info();
17006 + set_normalized_timespec(uptime,
17007 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
17008 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
17011 + set_normalized_timespec(idle,
17012 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
17013 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
17017 +uint64_t vx_idle_jiffies(void)
17019 + return init_task.utime + init_task.stime;
17024 +static inline uint32_t __update_loadavg(uint32_t load,
17025 + int wsize, int delta, int n)
17027 + unsigned long long calc, prev;
17029 + /* just set it to n */
17030 + if (unlikely(delta >= wsize))
17031 + return (n << FSHIFT);
17033 + calc = delta * n;
17035 + prev = (wsize - delta);
17038 + do_div(calc, wsize);
17043 +void vx_update_load(struct vx_info *vxi)
17045 + uint32_t now, last, delta;
17046 + unsigned int nr_running, nr_uninterruptible;
17047 + unsigned int total;
17048 + unsigned long flags;
17050 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
17053 + last = vxi->cvirt.load_last;
17054 + delta = now - last;
17056 + if (delta < 5*HZ)
17059 + nr_running = atomic_read(&vxi->cvirt.nr_running);
17060 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
17061 + total = nr_running + nr_uninterruptible;
17063 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
17064 + 60*HZ, delta, total);
17065 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
17066 + 5*60*HZ, delta, total);
17067 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
17068 + 15*60*HZ, delta, total);
17070 + vxi->cvirt.load_last = now;
17072 + atomic_inc(&vxi->cvirt.load_updates);
17073 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
17078 + * Commands to do_syslog:
17080 + * 0 -- Close the log. Currently a NOP.
17081 + * 1 -- Open the log. Currently a NOP.
17082 + * 2 -- Read from the log.
17083 + * 3 -- Read all messages remaining in the ring buffer.
17084 + * 4 -- Read and clear all messages remaining in the ring buffer
17085 + * 5 -- Clear ring buffer.
17086 + * 6 -- Disable printk's to console
17087 + * 7 -- Enable printk's to console
17088 + * 8 -- Set level of messages printed to console
17089 + * 9 -- Return number of unread characters in the log buffer
17090 + * 10 -- Return size of the log buffer
17092 +int vx_do_syslog(int type, char __user *buf, int len)
17095 + int do_clear = 0;
17096 + struct vx_info *vxi = current_vx_info();
17097 + struct _vx_syslog *log;
17101 + log = &vxi->cvirt.syslog;
17104 + case 0: /* Close log */
17105 + case 1: /* Open log */
17107 + case 2: /* Read from log */
17108 + error = wait_event_interruptible(log->log_wait,
17109 + (log->log_start - log->log_end));
17112 + spin_lock_irq(&log->logbuf_lock);
17113 + spin_unlock_irq(&log->logbuf_lock);
17115 + case 4: /* Read/clear last kernel messages */
17117 + /* fall through */
17118 + case 3: /* Read last kernel messages */
17121 + case 5: /* Clear ring buffer */
17124 + case 6: /* Disable logging to console */
17125 + case 7: /* Enable logging to console */
17126 + case 8: /* Set level of messages printed to console */
17129 + case 9: /* Number of chars in the log buffer */
17131 + case 10: /* Size of the log buffer */
17141 +/* virtual host info names */
17143 +static char *vx_vhi_name(struct vx_info *vxi, int id)
17145 + struct nsproxy *nsproxy;
17146 + struct uts_namespace *uts;
17148 + if (id == VHIN_CONTEXT)
17149 + return vxi->vx_name;
17151 + nsproxy = vxi->space[0].vx_nsproxy;
17155 + uts = nsproxy->uts_ns;
17160 + case VHIN_SYSNAME:
17161 + return uts->name.sysname;
17162 + case VHIN_NODENAME:
17163 + return uts->name.nodename;
17164 + case VHIN_RELEASE:
17165 + return uts->name.release;
17166 + case VHIN_VERSION:
17167 + return uts->name.version;
17168 + case VHIN_MACHINE:
17169 + return uts->name.machine;
17170 + case VHIN_DOMAINNAME:
17171 + return uts->name.domainname;
17178 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
17180 + struct vcmd_vhi_name_v0 vc_data;
17183 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17186 + name = vx_vhi_name(vxi, vc_data.field);
17190 + memcpy(name, vc_data.name, 65);
17194 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
17196 + struct vcmd_vhi_name_v0 vc_data;
17199 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17202 + name = vx_vhi_name(vxi, vc_data.field);
17206 + memcpy(vc_data.name, name, 65);
17207 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17213 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
17215 + struct vcmd_virt_stat_v0 vc_data;
17216 + struct _vx_cvirt *cvirt = &vxi->cvirt;
17217 + struct timespec uptime;
17219 + do_posix_clock_monotonic_gettime(&uptime);
17220 + set_normalized_timespec(&uptime,
17221 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
17222 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
17224 + vc_data.offset = timespec_to_ns(&cvirt->bias_ts);
17225 + vc_data.uptime = timespec_to_ns(&uptime);
17226 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
17227 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
17228 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
17229 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
17230 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
17231 + vc_data.load[0] = cvirt->load[0];
17232 + vc_data.load[1] = cvirt->load[1];
17233 + vc_data.load[2] = cvirt->load[2];
17235 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17241 +#ifdef CONFIG_VSERVER_VTIME
17243 +/* virtualized time base */
17245 +void vx_adjust_timespec(struct timespec *ts)
17247 + struct vx_info *vxi;
17249 + if (!vx_flags(VXF_VIRT_TIME, 0))
17252 + vxi = current_vx_info();
17253 + ts->tv_sec += vxi->cvirt.bias_ts.tv_sec;
17254 + ts->tv_nsec += vxi->cvirt.bias_ts.tv_nsec;
17256 + if (ts->tv_nsec >= NSEC_PER_SEC) {
17258 + ts->tv_nsec -= NSEC_PER_SEC;
17259 + } else if (ts->tv_nsec < 0) {
17261 + ts->tv_nsec += NSEC_PER_SEC;
17265 +int vx_settimeofday(const struct timespec *ts)
17267 + struct timespec ats, delta;
17268 + struct vx_info *vxi;
17270 + if (!vx_flags(VXF_VIRT_TIME, 0))
17271 + return do_settimeofday(ts);
17273 + getnstimeofday(&ats);
17274 + delta = timespec_sub(*ts, ats);
17276 + vxi = current_vx_info();
17277 + vxi->cvirt.bias_ts = timespec_add(vxi->cvirt.bias_ts, delta);
17283 diff -NurpP --minimal linux-3.1.6/kernel/vserver/cvirt_init.h linux-3.1.6-vs2.3.2.5/kernel/vserver/cvirt_init.h
17284 --- linux-3.1.6/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
17285 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/cvirt_init.h 2011-10-24 18:53:33.000000000 +0200
17289 +extern uint64_t vx_idle_jiffies(void);
17291 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
17293 + uint64_t idle_jiffies = vx_idle_jiffies();
17294 + uint64_t nsuptime;
17296 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
17297 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
17298 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
17299 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
17300 + cvirt->bias_ts.tv_sec = 0;
17301 + cvirt->bias_ts.tv_nsec = 0;
17303 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
17304 + atomic_set(&cvirt->nr_threads, 0);
17305 + atomic_set(&cvirt->nr_running, 0);
17306 + atomic_set(&cvirt->nr_uninterruptible, 0);
17307 + atomic_set(&cvirt->nr_onhold, 0);
17309 + spin_lock_init(&cvirt->load_lock);
17310 + cvirt->load_last = jiffies;
17311 + atomic_set(&cvirt->load_updates, 0);
17312 + cvirt->load[0] = 0;
17313 + cvirt->load[1] = 0;
17314 + cvirt->load[2] = 0;
17315 + atomic_set(&cvirt->total_forks, 0);
17317 + spin_lock_init(&cvirt->syslog.logbuf_lock);
17318 + init_waitqueue_head(&cvirt->syslog.log_wait);
17319 + cvirt->syslog.log_start = 0;
17320 + cvirt->syslog.log_end = 0;
17321 + cvirt->syslog.con_start = 0;
17322 + cvirt->syslog.logged_chars = 0;
17326 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17328 + // cvirt_pc->cpustat = { 0 };
17331 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
17333 +#ifdef CONFIG_VSERVER_WARN
17336 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
17337 + "!!! cvirt: %p[nr_threads] = %d on exit.",
17339 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
17340 + "!!! cvirt: %p[nr_running] = %d on exit.",
17342 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
17343 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
17345 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
17346 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
17352 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17357 diff -NurpP --minimal linux-3.1.6/kernel/vserver/cvirt_proc.h linux-3.1.6-vs2.3.2.5/kernel/vserver/cvirt_proc.h
17358 --- linux-3.1.6/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
17359 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/cvirt_proc.h 2011-10-24 18:53:33.000000000 +0200
17361 +#ifndef _VX_CVIRT_PROC_H
17362 +#define _VX_CVIRT_PROC_H
17364 +#include <linux/nsproxy.h>
17365 +#include <linux/mnt_namespace.h>
17366 +#include <linux/ipc_namespace.h>
17367 +#include <linux/utsname.h>
17368 +#include <linux/ipc.h>
17372 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
17374 + struct mnt_namespace *ns;
17375 + struct uts_namespace *uts;
17376 + struct ipc_namespace *ipc;
17377 + struct path path;
17378 + char *pstr, *root;
17384 + length += sprintf(buffer + length,
17385 + "NSProxy:\t%p [%p,%p,%p]\n",
17386 + nsproxy, nsproxy->mnt_ns,
17387 + nsproxy->uts_ns, nsproxy->ipc_ns);
17389 + ns = nsproxy->mnt_ns;
17393 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
17397 + path.mnt = ns->root;
17398 + path.dentry = ns->root->mnt_root;
17399 + root = d_path(&path, pstr, PATH_MAX - 2);
17400 + length += sprintf(buffer + length,
17401 + "Namespace:\t%p [#%u]\n"
17402 + "RootPath:\t%s\n",
17403 + ns, atomic_read(&ns->count),
17408 + uts = nsproxy->uts_ns;
17412 + length += sprintf(buffer + length,
17413 + "SysName:\t%.*s\n"
17414 + "NodeName:\t%.*s\n"
17415 + "Release:\t%.*s\n"
17416 + "Version:\t%.*s\n"
17417 + "Machine:\t%.*s\n"
17418 + "DomainName:\t%.*s\n",
17419 + __NEW_UTS_LEN, uts->name.sysname,
17420 + __NEW_UTS_LEN, uts->name.nodename,
17421 + __NEW_UTS_LEN, uts->name.release,
17422 + __NEW_UTS_LEN, uts->name.version,
17423 + __NEW_UTS_LEN, uts->name.machine,
17424 + __NEW_UTS_LEN, uts->name.domainname);
17427 + ipc = nsproxy->ipc_ns;
17431 + length += sprintf(buffer + length,
17432 + "SEMS:\t\t%d %d %d %d %d\n"
17433 + "MSG:\t\t%d %d %d\n"
17434 + "SHM:\t\t%lu %lu %d %d\n",
17435 + ipc->sem_ctls[0], ipc->sem_ctls[1],
17436 + ipc->sem_ctls[2], ipc->sem_ctls[3],
17438 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
17439 + (unsigned long)ipc->shm_ctlmax,
17440 + (unsigned long)ipc->shm_ctlall,
17441 + ipc->shm_ctlmni, ipc->shm_tot);
17448 +#include <linux/sched.h>
17450 +#define LOAD_INT(x) ((x) >> FSHIFT)
17451 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
17454 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
17459 + length += sprintf(buffer + length,
17460 + "BiasUptime:\t%lu.%02lu\n",
17461 + (unsigned long)cvirt->bias_uptime.tv_sec,
17462 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
17464 + a = cvirt->load[0] + (FIXED_1 / 200);
17465 + b = cvirt->load[1] + (FIXED_1 / 200);
17466 + c = cvirt->load[2] + (FIXED_1 / 200);
17467 + length += sprintf(buffer + length,
17468 + "nr_threads:\t%d\n"
17469 + "nr_running:\t%d\n"
17470 + "nr_unintr:\t%d\n"
17471 + "nr_onhold:\t%d\n"
17472 + "load_updates:\t%d\n"
17473 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
17474 + "total_forks:\t%d\n",
17475 + atomic_read(&cvirt->nr_threads),
17476 + atomic_read(&cvirt->nr_running),
17477 + atomic_read(&cvirt->nr_uninterruptible),
17478 + atomic_read(&cvirt->nr_onhold),
17479 + atomic_read(&cvirt->load_updates),
17480 + LOAD_INT(a), LOAD_FRAC(a),
17481 + LOAD_INT(b), LOAD_FRAC(b),
17482 + LOAD_INT(c), LOAD_FRAC(c),
17483 + atomic_read(&cvirt->total_forks));
17488 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
17489 + char *buffer, int cpu)
17495 +#endif /* _VX_CVIRT_PROC_H */
17496 diff -NurpP --minimal linux-3.1.6/kernel/vserver/debug.c linux-3.1.6-vs2.3.2.5/kernel/vserver/debug.c
17497 --- linux-3.1.6/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
17498 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/debug.c 2011-10-24 18:53:33.000000000 +0200
17501 + * kernel/vserver/debug.c
17503 + * Copyright (C) 2005-2007 Herbert Pötzl
17505 + * V0.01 vx_info dump support
17509 +#include <linux/module.h>
17511 +#include <linux/vserver/context.h>
17514 +void dump_vx_info(struct vx_info *vxi, int level)
17516 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
17517 + atomic_read(&vxi->vx_usecnt),
17518 + atomic_read(&vxi->vx_tasks),
17521 + __dump_vx_limit(&vxi->limit);
17522 + __dump_vx_sched(&vxi->sched);
17523 + __dump_vx_cvirt(&vxi->cvirt);
17524 + __dump_vx_cacct(&vxi->cacct);
17530 +EXPORT_SYMBOL_GPL(dump_vx_info);
17532 diff -NurpP --minimal linux-3.1.6/kernel/vserver/device.c linux-3.1.6-vs2.3.2.5/kernel/vserver/device.c
17533 --- linux-3.1.6/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
17534 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/device.c 2011-10-24 18:53:33.000000000 +0200
17537 + * linux/kernel/vserver/device.c
17539 + * Linux-VServer: Device Support
17541 + * Copyright (C) 2006 Herbert Pötzl
17542 + * Copyright (C) 2007 Daniel Hokka Zakrisson
17544 + * V0.01 device mapping basics
17545 + * V0.02 added defaults
17549 +#include <linux/slab.h>
17550 +#include <linux/rcupdate.h>
17551 +#include <linux/fs.h>
17552 +#include <linux/namei.h>
17553 +#include <linux/hash.h>
17555 +#include <asm/errno.h>
17556 +#include <asm/uaccess.h>
17557 +#include <linux/vserver/base.h>
17558 +#include <linux/vserver/debug.h>
17559 +#include <linux/vserver/context.h>
17560 +#include <linux/vserver/device.h>
17561 +#include <linux/vserver/device_cmd.h>
17564 +#define DMAP_HASH_BITS 4
17567 +struct vs_mapping {
17569 + struct hlist_node hlist;
17570 + struct list_head list;
17572 +#define dm_hlist u.hlist
17573 +#define dm_list u.list
17576 + struct vx_dmap_target target;
17580 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
17582 +static DEFINE_SPINLOCK(dmap_main_hash_lock);
17584 +static struct vx_dmap_target dmap_defaults[2] = {
17585 + { .flags = DATTR_OPEN },
17586 + { .flags = DATTR_OPEN },
17590 +struct kmem_cache *dmap_cachep __read_mostly;
17592 +int __init dmap_cache_init(void)
17594 + dmap_cachep = kmem_cache_create("dmap_cache",
17595 + sizeof(struct vs_mapping), 0,
17596 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
17600 +__initcall(dmap_cache_init);
17603 +static inline unsigned int __hashval(dev_t dev, int bits)
17605 + return hash_long((unsigned long)dev, bits);
17609 +/* __hash_mapping()
17610 + * add the mapping to the hash table
17612 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
17614 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17615 + struct hlist_head *head, *hash = dmap_main_hash;
17616 + int device = vdm->device;
17618 + spin_lock(hash_lock);
17619 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
17620 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
17622 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
17623 + hlist_add_head(&vdm->dm_hlist, head);
17624 + spin_unlock(hash_lock);
17628 +static inline int __mode_to_default(umode_t mode)
17641 +/* __set_default()
17644 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
17645 + struct vx_dmap_target *vdmt)
17647 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17648 + spin_lock(hash_lock);
17651 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
17653 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
17656 + spin_unlock(hash_lock);
17658 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
17659 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
17663 +/* __remove_default()
17664 + * remove a default
17666 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
17668 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17669 + spin_lock(hash_lock);
17672 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
17673 + else /* remove == reset */
17674 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
17676 + spin_unlock(hash_lock);
17681 +/* __find_mapping()
17682 + * find a mapping in the hash table
17684 + * caller must hold hash_lock
17686 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
17687 + struct vs_mapping **local, struct vs_mapping **global)
17689 + struct hlist_head *hash = dmap_main_hash;
17690 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
17691 + struct hlist_node *pos;
17692 + struct vs_mapping *vdm;
17698 + hlist_for_each(pos, head) {
17699 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
17701 + if ((vdm->device == device) &&
17702 + !((vdm->target.flags ^ mode) & S_IFMT)) {
17703 + if (vdm->xid == xid) {
17706 + } else if (global && vdm->xid == 0)
17711 + if (global && *global)
17718 +/* __lookup_mapping()
17719 + * find a mapping and store the result in target and flags
17721 +static inline int __lookup_mapping(struct vx_info *vxi,
17722 + dev_t device, dev_t *target, int *flags, umode_t mode)
17724 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17725 + struct vs_mapping *vdm, *global;
17726 + struct vx_dmap_target *vdmt;
17728 + xid_t xid = vxi->vx_id;
17731 + spin_lock(hash_lock);
17732 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
17734 + vdmt = &vdm->target;
17738 + index = __mode_to_default(mode);
17739 + if (vxi && vxi->dmap.targets[index].flags) {
17741 + vdmt = &vxi->dmap.targets[index];
17742 + } else if (global) {
17744 + vdmt = &global->target;
17748 + vdmt = &dmap_defaults[index];
17752 + if (target && (vdmt->flags & DATTR_REMAP))
17753 + *target = vdmt->target;
17755 + *target = device;
17757 + *flags = vdmt->flags;
17759 + spin_unlock(hash_lock);
17765 +/* __remove_mapping()
17766 + * remove a mapping from the hash table
17768 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
17771 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17772 + struct vs_mapping *vdm = NULL;
17775 + spin_lock(hash_lock);
17777 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
17779 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
17780 + vxi, vxi ? vxi->vx_id : 0, device, mode);
17783 + hlist_del(&vdm->dm_hlist);
17786 + spin_unlock(hash_lock);
17788 + kmem_cache_free(dmap_cachep, vdm);
17794 +int vs_map_device(struct vx_info *vxi,
17795 + dev_t device, dev_t *target, umode_t mode)
17797 + int ret, flags = DATTR_MASK;
17801 + *target = device;
17804 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
17805 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
17806 + device, target ? *target : 0, flags, mode, ret);
17808 + return (flags & DATTR_MASK);
17813 +static int do_set_mapping(struct vx_info *vxi,
17814 + dev_t device, dev_t target, int flags, umode_t mode)
17817 + struct vs_mapping *new;
17819 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
17823 + INIT_HLIST_NODE(&new->dm_hlist);
17824 + new->device = device;
17825 + new->target.target = target;
17826 + new->target.flags = flags | mode;
17827 + new->xid = (vxi ? vxi->vx_id : 0);
17829 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
17830 + __hash_mapping(vxi, new);
17832 + struct vx_dmap_target new = {
17833 + .target = target,
17834 + .flags = flags | mode,
17836 + __set_default(vxi, mode, &new);
17842 +static int do_unset_mapping(struct vx_info *vxi,
17843 + dev_t device, dev_t target, int flags, umode_t mode)
17845 + int ret = -EINVAL;
17848 + ret = __remove_mapping(vxi, device, mode);
17852 + ret = __remove_default(vxi, mode);
17862 +static inline int __user_device(const char __user *name, dev_t *dev,
17865 + struct nameidata nd;
17872 + ret = user_lpath(name, &nd.path);
17875 + if (nd.path.dentry->d_inode) {
17876 + *dev = nd.path.dentry->d_inode->i_rdev;
17877 + *mode = nd.path.dentry->d_inode->i_mode;
17879 + path_put(&nd.path);
17883 +static inline int __mapping_mode(dev_t device, dev_t target,
17884 + umode_t device_mode, umode_t target_mode, umode_t *mode)
17887 + *mode = device_mode & S_IFMT;
17889 + *mode = target_mode & S_IFMT;
17893 + /* if both given, device and target mode have to match */
17894 + if (device && target &&
17895 + ((device_mode ^ target_mode) & S_IFMT))
17901 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
17902 + const char __user *target_path, int flags, int set)
17904 + dev_t device = ~0, target = ~0;
17905 + umode_t device_mode = 0, target_mode = 0, mode;
17908 + ret = __user_device(device_path, &device, &device_mode);
17911 + ret = __user_device(target_path, &target, &target_mode);
17915 + ret = __mapping_mode(device, target,
17916 + device_mode, target_mode, &mode);
17921 + return do_set_mapping(vxi, device, target,
17924 + return do_unset_mapping(vxi, device, target,
17929 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
17931 + struct vcmd_set_mapping_v0 vc_data;
17933 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17936 + return do_mapping(vxi, vc_data.device, vc_data.target,
17937 + vc_data.flags, 1);
17940 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
17942 + struct vcmd_set_mapping_v0 vc_data;
17944 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17947 + return do_mapping(vxi, vc_data.device, vc_data.target,
17948 + vc_data.flags, 0);
17952 +#ifdef CONFIG_COMPAT
17954 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
17956 + struct vcmd_set_mapping_v0_x32 vc_data;
17958 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17961 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
17962 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
17965 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
17967 + struct vcmd_set_mapping_v0_x32 vc_data;
17969 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17972 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
17973 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
17976 +#endif /* CONFIG_COMPAT */
17979 diff -NurpP --minimal linux-3.1.6/kernel/vserver/dlimit.c linux-3.1.6-vs2.3.2.5/kernel/vserver/dlimit.c
17980 --- linux-3.1.6/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
17981 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/dlimit.c 2011-10-24 18:53:33.000000000 +0200
17984 + * linux/kernel/vserver/dlimit.c
17986 + * Virtual Server: Context Disk Limits
17988 + * Copyright (C) 2004-2009 Herbert Pötzl
17990 + * V0.01 initial version
17991 + * V0.02 compat32 splitup
17992 + * V0.03 extended interface
17996 +#include <linux/statfs.h>
17997 +#include <linux/sched.h>
17998 +#include <linux/namei.h>
17999 +#include <linux/vs_tag.h>
18000 +#include <linux/vs_dlimit.h>
18001 +#include <linux/vserver/dlimit_cmd.h>
18002 +#include <linux/slab.h>
18003 +// #include <linux/gfp.h>
18005 +#include <asm/uaccess.h>
18007 +/* __alloc_dl_info()
18009 + * allocate an initialized dl_info struct
18010 + * doesn't make it visible (hash) */
18012 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
18014 + struct dl_info *new = NULL;
18016 + vxdprintk(VXD_CBIT(dlim, 5),
18017 + "alloc_dl_info(%p,%d)*", sb, tag);
18019 + /* would this benefit from a slab cache? */
18020 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
18024 + memset(new, 0, sizeof(struct dl_info));
18025 + new->dl_tag = tag;
18027 + // INIT_RCU_HEAD(&new->dl_rcu);
18028 + INIT_HLIST_NODE(&new->dl_hlist);
18029 + spin_lock_init(&new->dl_lock);
18030 + atomic_set(&new->dl_refcnt, 0);
18031 + atomic_set(&new->dl_usecnt, 0);
18033 + /* rest of init goes here */
18035 + vxdprintk(VXD_CBIT(dlim, 4),
18036 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
18040 +/* __dealloc_dl_info()
18042 + * final disposal of dl_info */
18044 +static void __dealloc_dl_info(struct dl_info *dli)
18046 + vxdprintk(VXD_CBIT(dlim, 4),
18047 + "dealloc_dl_info(%p)", dli);
18049 + dli->dl_hlist.next = LIST_POISON1;
18050 + dli->dl_tag = -1;
18053 + BUG_ON(atomic_read(&dli->dl_usecnt));
18054 + BUG_ON(atomic_read(&dli->dl_refcnt));
18060 +/* hash table for dl_info hash */
18062 +#define DL_HASH_SIZE 13
18064 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
18066 +static DEFINE_SPINLOCK(dl_info_hash_lock);
18069 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
18071 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
18076 +/* __hash_dl_info()
18078 + * add the dli to the global hash table
18079 + * requires the hash_lock to be held */
18081 +static inline void __hash_dl_info(struct dl_info *dli)
18083 + struct hlist_head *head;
18085 + vxdprintk(VXD_CBIT(dlim, 6),
18086 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
18087 + get_dl_info(dli);
18088 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
18089 + hlist_add_head_rcu(&dli->dl_hlist, head);
18092 +/* __unhash_dl_info()
18094 + * remove the dli from the global hash table
18095 + * requires the hash_lock to be held */
18097 +static inline void __unhash_dl_info(struct dl_info *dli)
18099 + vxdprintk(VXD_CBIT(dlim, 6),
18100 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
18101 + hlist_del_rcu(&dli->dl_hlist);
18102 + put_dl_info(dli);
18106 +/* __lookup_dl_info()
18108 + * requires the rcu_read_lock()
18109 + * doesn't increment the dl_refcnt */
18111 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
18113 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
18114 + struct hlist_node *pos;
18115 + struct dl_info *dli;
18117 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
18119 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
18127 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
18129 + struct dl_info *dli;
18132 + dli = get_dl_info(__lookup_dl_info(sb, tag));
18133 + vxdprintk(VXD_CBIT(dlim, 7),
18134 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
18135 + rcu_read_unlock();
18139 +void rcu_free_dl_info(struct rcu_head *head)
18141 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
18142 + int usecnt, refcnt;
18144 + BUG_ON(!dli || !head);
18146 + usecnt = atomic_read(&dli->dl_usecnt);
18147 + BUG_ON(usecnt < 0);
18149 + refcnt = atomic_read(&dli->dl_refcnt);
18150 + BUG_ON(refcnt < 0);
18152 + vxdprintk(VXD_CBIT(dlim, 3),
18153 + "rcu_free_dl_info(%p)", dli);
18155 + __dealloc_dl_info(dli);
18157 + printk("!!! rcu didn't free\n");
18163 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
18164 + uint32_t flags, int add)
18166 + struct path path;
18169 + ret = user_lpath(name, &path);
18171 + struct super_block *sb;
18172 + struct dl_info *dli;
18175 + if (!path.dentry->d_inode)
18176 + goto out_release;
18177 + if (!(sb = path.dentry->d_inode->i_sb))
18178 + goto out_release;
18181 + dli = __alloc_dl_info(sb, id);
18182 + spin_lock(&dl_info_hash_lock);
18185 + if (__lookup_dl_info(sb, id))
18187 + __hash_dl_info(dli);
18190 + spin_lock(&dl_info_hash_lock);
18191 + dli = __lookup_dl_info(sb, id);
18196 + __unhash_dl_info(dli);
18200 + spin_unlock(&dl_info_hash_lock);
18202 + __dealloc_dl_info(dli);
18209 +int vc_add_dlimit(uint32_t id, void __user *data)
18211 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18213 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18216 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
18219 +int vc_rem_dlimit(uint32_t id, void __user *data)
18221 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18223 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18226 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
18229 +#ifdef CONFIG_COMPAT
18231 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
18233 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18235 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18238 + return do_addrem_dlimit(id,
18239 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
18242 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
18244 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18246 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18249 + return do_addrem_dlimit(id,
18250 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
18253 +#endif /* CONFIG_COMPAT */
18257 +int do_set_dlimit(uint32_t id, const char __user *name,
18258 + uint32_t space_used, uint32_t space_total,
18259 + uint32_t inodes_used, uint32_t inodes_total,
18260 + uint32_t reserved, uint32_t flags)
18262 + struct path path;
18265 + ret = user_lpath(name, &path);
18267 + struct super_block *sb;
18268 + struct dl_info *dli;
18271 + if (!path.dentry->d_inode)
18272 + goto out_release;
18273 + if (!(sb = path.dentry->d_inode->i_sb))
18274 + goto out_release;
18276 + /* sanity checks */
18277 + if ((reserved != CDLIM_KEEP &&
18278 + reserved > 100) ||
18279 + (inodes_used != CDLIM_KEEP &&
18280 + inodes_used > inodes_total) ||
18281 + (space_used != CDLIM_KEEP &&
18282 + space_used > space_total))
18283 + goto out_release;
18286 + dli = locate_dl_info(sb, id);
18288 + goto out_release;
18290 + spin_lock(&dli->dl_lock);
18292 + if (inodes_used != CDLIM_KEEP)
18293 + dli->dl_inodes_used = inodes_used;
18294 + if (inodes_total != CDLIM_KEEP)
18295 + dli->dl_inodes_total = inodes_total;
18296 + if (space_used != CDLIM_KEEP)
18297 + dli->dl_space_used = dlimit_space_32to64(
18298 + space_used, flags, DLIMS_USED);
18300 + if (space_total == CDLIM_INFINITY)
18301 + dli->dl_space_total = DLIM_INFINITY;
18302 + else if (space_total != CDLIM_KEEP)
18303 + dli->dl_space_total = dlimit_space_32to64(
18304 + space_total, flags, DLIMS_TOTAL);
18306 + if (reserved != CDLIM_KEEP)
18307 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
18309 + spin_unlock(&dli->dl_lock);
18311 + put_dl_info(dli);
18320 +int vc_set_dlimit(uint32_t id, void __user *data)
18322 + struct vcmd_ctx_dlimit_v0 vc_data;
18324 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18327 + return do_set_dlimit(id, vc_data.name,
18328 + vc_data.space_used, vc_data.space_total,
18329 + vc_data.inodes_used, vc_data.inodes_total,
18330 + vc_data.reserved, vc_data.flags);
18333 +#ifdef CONFIG_COMPAT
18335 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
18337 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18339 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18342 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
18343 + vc_data.space_used, vc_data.space_total,
18344 + vc_data.inodes_used, vc_data.inodes_total,
18345 + vc_data.reserved, vc_data.flags);
18348 +#endif /* CONFIG_COMPAT */
18352 +int do_get_dlimit(uint32_t id, const char __user *name,
18353 + uint32_t *space_used, uint32_t *space_total,
18354 + uint32_t *inodes_used, uint32_t *inodes_total,
18355 + uint32_t *reserved, uint32_t *flags)
18357 + struct path path;
18360 + ret = user_lpath(name, &path);
18362 + struct super_block *sb;
18363 + struct dl_info *dli;
18366 + if (!path.dentry->d_inode)
18367 + goto out_release;
18368 + if (!(sb = path.dentry->d_inode->i_sb))
18369 + goto out_release;
18372 + dli = locate_dl_info(sb, id);
18374 + goto out_release;
18376 + spin_lock(&dli->dl_lock);
18377 + *inodes_used = dli->dl_inodes_used;
18378 + *inodes_total = dli->dl_inodes_total;
18380 + *space_used = dlimit_space_64to32(
18381 + dli->dl_space_used, flags, DLIMS_USED);
18383 + if (dli->dl_space_total == DLIM_INFINITY)
18384 + *space_total = CDLIM_INFINITY;
18386 + *space_total = dlimit_space_64to32(
18387 + dli->dl_space_total, flags, DLIMS_TOTAL);
18389 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
18390 + spin_unlock(&dli->dl_lock);
18392 + put_dl_info(dli);
18403 +int vc_get_dlimit(uint32_t id, void __user *data)
18405 + struct vcmd_ctx_dlimit_v0 vc_data;
18408 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18411 + ret = do_get_dlimit(id, vc_data.name,
18412 + &vc_data.space_used, &vc_data.space_total,
18413 + &vc_data.inodes_used, &vc_data.inodes_total,
18414 + &vc_data.reserved, &vc_data.flags);
18418 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18423 +#ifdef CONFIG_COMPAT
18425 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
18427 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18430 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18433 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
18434 + &vc_data.space_used, &vc_data.space_total,
18435 + &vc_data.inodes_used, &vc_data.inodes_total,
18436 + &vc_data.reserved, &vc_data.flags);
18440 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18445 +#endif /* CONFIG_COMPAT */
18448 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
18450 + struct dl_info *dli;
18451 + __u64 blimit, bfree, bavail;
18454 + dli = locate_dl_info(sb, dx_current_tag());
18458 + spin_lock(&dli->dl_lock);
18459 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
18462 + /* reduce max inodes available to limit */
18463 + if (buf->f_files > dli->dl_inodes_total)
18464 + buf->f_files = dli->dl_inodes_total;
18466 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
18467 + /* reduce free inodes to min */
18468 + if (ifree < buf->f_ffree)
18469 + buf->f_ffree = ifree;
18472 + if (dli->dl_space_total == DLIM_INFINITY)
18475 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
18477 + if (dli->dl_space_total < dli->dl_space_used)
18480 + bfree = (dli->dl_space_total - dli->dl_space_used)
18481 + >> sb->s_blocksize_bits;
18483 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
18484 + if (bavail < dli->dl_space_used)
18487 + bavail = (bavail - dli->dl_space_used)
18488 + >> sb->s_blocksize_bits;
18490 + /* reduce max space available to limit */
18491 + if (buf->f_blocks > blimit)
18492 + buf->f_blocks = blimit;
18494 + /* reduce free space to min */
18495 + if (bfree < buf->f_bfree)
18496 + buf->f_bfree = bfree;
18498 + /* reduce avail space to min */
18499 + if (bavail < buf->f_bavail)
18500 + buf->f_bavail = bavail;
18503 + spin_unlock(&dli->dl_lock);
18504 + put_dl_info(dli);
18509 +#include <linux/module.h>
18511 +EXPORT_SYMBOL_GPL(locate_dl_info);
18512 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
18514 diff -NurpP --minimal linux-3.1.6/kernel/vserver/helper.c linux-3.1.6-vs2.3.2.5/kernel/vserver/helper.c
18515 --- linux-3.1.6/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
18516 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/helper.c 2011-10-24 18:53:33.000000000 +0200
18519 + * linux/kernel/vserver/helper.c
18521 + * Virtual Context Support
18523 + * Copyright (C) 2004-2007 Herbert Pötzl
18525 + * V0.01 basic helper
18529 +#include <linux/kmod.h>
18530 +#include <linux/reboot.h>
18531 +#include <linux/vs_context.h>
18532 +#include <linux/vs_network.h>
18533 +#include <linux/vserver/signal.h>
18536 +char vshelper_path[255] = "/sbin/vshelper";
18539 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
18543 + if ((ret = call_usermodehelper(name, argv, envp, sync))) {
18544 + printk( KERN_WARNING
18545 + "%s: (%s %s) returned %s with %d\n",
18546 + name, argv[1], argv[2],
18547 + sync ? "sync" : "async", ret);
18549 + vxdprintk(VXD_CBIT(switch, 4),
18550 + "%s: (%s %s) returned %s with %d",
18551 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
18556 + * vshelper path is set via /proc/sys
18557 + * invoked by vserver sys_reboot(), with
18558 + * the following arguments
18560 + * argv [0] = vshelper_path;
18561 + * argv [1] = action: "restart", "halt", "poweroff", ...
18562 + * argv [2] = context identifier
18564 + * envp [*] = type-specific parameters
18567 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
18569 + char id_buf[8], cmd_buf[16];
18570 + char uid_buf[16], pid_buf[16];
18573 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18574 + char *envp[] = {"HOME=/", "TERM=linux",
18575 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
18576 + uid_buf, pid_buf, cmd_buf, 0};
18578 + if (vx_info_state(vxi, VXS_HELPER))
18580 + vxi->vx_state |= VXS_HELPER;
18582 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
18584 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18585 + snprintf(uid_buf, sizeof(uid_buf)-1, "VS_UID=%d", current_uid());
18586 + snprintf(pid_buf, sizeof(pid_buf)-1, "VS_PID=%d", current->pid);
18589 + case LINUX_REBOOT_CMD_RESTART:
18590 + argv[1] = "restart";
18593 + case LINUX_REBOOT_CMD_HALT:
18594 + argv[1] = "halt";
18597 + case LINUX_REBOOT_CMD_POWER_OFF:
18598 + argv[1] = "poweroff";
18601 + case LINUX_REBOOT_CMD_SW_SUSPEND:
18602 + argv[1] = "swsusp";
18605 + case LINUX_REBOOT_CMD_OOM:
18610 + vxi->vx_state &= ~VXS_HELPER;
18614 + ret = do_vshelper(vshelper_path, argv, envp, 0);
18615 + vxi->vx_state &= ~VXS_HELPER;
18616 + __wakeup_vx_info(vxi);
18617 + return (ret) ? -EPERM : 0;
18621 +long vs_reboot(unsigned int cmd, void __user *arg)
18623 + struct vx_info *vxi = current_vx_info();
18626 + vxdprintk(VXD_CBIT(misc, 5),
18627 + "vs_reboot(%p[#%d],%u)",
18628 + vxi, vxi ? vxi->vx_id : 0, cmd);
18630 + ret = vs_reboot_helper(vxi, cmd, arg);
18634 + vxi->reboot_cmd = cmd;
18635 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18637 + case LINUX_REBOOT_CMD_RESTART:
18638 + case LINUX_REBOOT_CMD_HALT:
18639 + case LINUX_REBOOT_CMD_POWER_OFF:
18640 + vx_info_kill(vxi, 0, SIGKILL);
18641 + vx_info_kill(vxi, 1, SIGKILL);
18649 +long vs_oom_action(unsigned int cmd)
18651 + struct vx_info *vxi = current_vx_info();
18654 + vxdprintk(VXD_CBIT(misc, 5),
18655 + "vs_oom_action(%p[#%d],%u)",
18656 + vxi, vxi ? vxi->vx_id : 0, cmd);
18658 + ret = vs_reboot_helper(vxi, cmd, NULL);
18662 + vxi->reboot_cmd = cmd;
18663 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18664 + vx_info_kill(vxi, 0, SIGKILL);
18665 + vx_info_kill(vxi, 1, SIGKILL);
18671 + * argv [0] = vshelper_path;
18672 + * argv [1] = action: "startup", "shutdown"
18673 + * argv [2] = context identifier
18675 + * envp [*] = type-specific parameters
18678 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
18680 + char id_buf[8], cmd_buf[16];
18681 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18682 + char *envp[] = {"HOME=/", "TERM=linux",
18683 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18685 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
18688 + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id);
18689 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18692 + case VSC_STARTUP:
18693 + argv[1] = "startup";
18695 + case VSC_SHUTDOWN:
18696 + argv[1] = "shutdown";
18702 + return do_vshelper(vshelper_path, argv, envp, 1);
18707 + * argv [0] = vshelper_path;
18708 + * argv [1] = action: "netup", "netdown"
18709 + * argv [2] = context identifier
18711 + * envp [*] = type-specific parameters
18714 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
18716 + char id_buf[8], cmd_buf[16];
18717 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18718 + char *envp[] = {"HOME=/", "TERM=linux",
18719 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18721 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
18724 + snprintf(id_buf, sizeof(id_buf)-1, "%d", nxi->nx_id);
18725 + snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd);
18729 + argv[1] = "netup";
18731 + case VSC_NETDOWN:
18732 + argv[1] = "netdown";
18738 + return do_vshelper(vshelper_path, argv, envp, 1);
18741 diff -NurpP --minimal linux-3.1.6/kernel/vserver/history.c linux-3.1.6-vs2.3.2.5/kernel/vserver/history.c
18742 --- linux-3.1.6/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
18743 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/history.c 2011-10-24 18:53:33.000000000 +0200
18746 + * kernel/vserver/history.c
18748 + * Virtual Context History Backtrace
18750 + * Copyright (C) 2004-2007 Herbert Pötzl
18752 + * V0.01 basic structure
18753 + * V0.02 hash/unhash and trace
18754 + * V0.03 preemption fixes
18758 +#include <linux/module.h>
18759 +#include <asm/uaccess.h>
18761 +#include <linux/vserver/context.h>
18762 +#include <linux/vserver/debug.h>
18763 +#include <linux/vserver/debug_cmd.h>
18764 +#include <linux/vserver/history.h>
18767 +#ifdef CONFIG_VSERVER_HISTORY
18768 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
18770 +#define VXH_SIZE 64
18773 +struct _vx_history {
18774 + unsigned int counter;
18776 + struct _vx_hist_entry entry[VXH_SIZE + 1];
18780 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
18782 +unsigned volatile int vxh_active = 1;
18784 +static atomic_t sequence = ATOMIC_INIT(0);
18789 + * requires disabled preemption */
18791 +struct _vx_hist_entry *vxh_advance(void *loc)
18793 + unsigned int cpu = smp_processor_id();
18794 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
18795 + struct _vx_hist_entry *entry;
18796 + unsigned int index;
18798 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
18799 + entry = &hist->entry[index];
18801 + entry->seq = atomic_inc_return(&sequence);
18802 + entry->loc = loc;
18806 +EXPORT_SYMBOL_GPL(vxh_advance);
18809 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
18811 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
18814 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
18816 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
18817 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
18818 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
18819 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
18821 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
18823 + switch (e->type) {
18824 + case VXH_THROW_OOPS:
18825 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
18828 + case VXH_GET_VX_INFO:
18829 + case VXH_PUT_VX_INFO:
18830 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
18832 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
18833 + VXH_VXI_ARGS(e));
18836 + case VXH_INIT_VX_INFO:
18837 + case VXH_SET_VX_INFO:
18838 + case VXH_CLR_VX_INFO:
18839 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
18841 + (e->type == VXH_INIT_VX_INFO) ? "init" :
18842 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
18843 + VXH_VXI_ARGS(e), e->sc.data);
18846 + case VXH_CLAIM_VX_INFO:
18847 + case VXH_RELEASE_VX_INFO:
18848 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
18850 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
18851 + VXH_VXI_ARGS(e), e->sc.data);
18854 + case VXH_ALLOC_VX_INFO:
18855 + case VXH_DEALLOC_VX_INFO:
18856 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
18858 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
18859 + VXH_VXI_ARGS(e));
18862 + case VXH_HASH_VX_INFO:
18863 + case VXH_UNHASH_VX_INFO:
18864 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
18866 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
18867 + VXH_VXI_ARGS(e));
18870 + case VXH_LOC_VX_INFO:
18871 + case VXH_LOOKUP_VX_INFO:
18872 + case VXH_CREATE_VX_INFO:
18873 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
18875 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
18876 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
18877 + e->ll.arg, VXH_VXI_ARGS(e));
18882 +static void __vxh_dump_history(void)
18884 + unsigned int i, cpu;
18886 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
18887 + atomic_read(&sequence), NR_CPUS);
18889 + for (i = 0; i < VXH_SIZE; i++) {
18890 + for_each_online_cpu(cpu) {
18891 + struct _vx_history *hist =
18892 + &per_cpu(vx_history_buffer, cpu);
18893 + unsigned int index = (hist->counter - i) % VXH_SIZE;
18894 + struct _vx_hist_entry *entry = &hist->entry[index];
18896 + vxh_dump_entry(entry, cpu);
18901 +void vxh_dump_history(void)
18905 + local_irq_enable();
18907 + local_irq_disable();
18909 + __vxh_dump_history();
18913 +/* vserver syscall commands below here */
18916 +int vc_dump_history(uint32_t id)
18919 + __vxh_dump_history();
18926 +int do_read_history(struct __user _vx_hist_entry *data,
18927 + int cpu, uint32_t *index, uint32_t *count)
18929 + int pos, ret = 0;
18930 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
18931 + int end = hist->counter;
18932 + int start = end - VXH_SIZE + 2;
18933 + int idx = *index;
18935 + /* special case: get current pos */
18941 + /* have we lost some data? */
18945 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
18946 + struct _vx_hist_entry *entry =
18947 + &hist->entry[idx % VXH_SIZE];
18949 + /* send entry to userspace */
18950 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
18954 + /* save new index and count */
18957 + return ret ? ret : (*index < end);
18960 +int vc_read_history(uint32_t id, void __user *data)
18962 + struct vcmd_read_history_v0 vc_data;
18965 + if (id >= NR_CPUS)
18968 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18971 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
18972 + id, &vc_data.index, &vc_data.count);
18974 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18979 +#ifdef CONFIG_COMPAT
18981 +int vc_read_history_x32(uint32_t id, void __user *data)
18983 + struct vcmd_read_history_v0_x32 vc_data;
18986 + if (id >= NR_CPUS)
18989 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18992 + ret = do_read_history((struct __user _vx_hist_entry *)
18993 + compat_ptr(vc_data.data_ptr),
18994 + id, &vc_data.index, &vc_data.count);
18996 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19001 +#endif /* CONFIG_COMPAT */
19003 diff -NurpP --minimal linux-3.1.6/kernel/vserver/inet.c linux-3.1.6-vs2.3.2.5/kernel/vserver/inet.c
19004 --- linux-3.1.6/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
19005 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/inet.c 2011-10-24 18:53:33.000000000 +0200
19008 +#include <linux/in.h>
19009 +#include <linux/inetdevice.h>
19010 +#include <linux/vs_inet.h>
19011 +#include <linux/vs_inet6.h>
19012 +#include <linux/vserver/debug.h>
19013 +#include <net/route.h>
19014 +#include <net/addrconf.h>
19017 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19021 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19024 + struct nx_addr_v4 *ptr;
19026 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
19027 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19034 + vxdprintk(VXD_CBIT(net, 2),
19035 + "nx_v4_addr_conflict(%p,%p): %d",
19036 + nxi1, nxi2, ret);
19042 +#ifdef CONFIG_IPV6
19044 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19048 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19051 + struct nx_addr_v6 *ptr;
19053 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
19054 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19061 + vxdprintk(VXD_CBIT(net, 2),
19062 + "nx_v6_addr_conflict(%p,%p): %d",
19063 + nxi1, nxi2, ret);
19070 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19072 + struct in_device *in_dev;
19073 + struct in_ifaddr **ifap;
19074 + struct in_ifaddr *ifa;
19079 + in_dev = in_dev_get(dev);
19083 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
19084 + ifap = &ifa->ifa_next) {
19085 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
19090 + in_dev_put(in_dev);
19096 +#ifdef CONFIG_IPV6
19098 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19100 + struct inet6_dev *in_dev;
19101 + struct inet6_ifaddr *ifa;
19106 + in_dev = in6_dev_get(dev);
19110 + // for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
19111 + list_for_each_entry(ifa, &in_dev->addr_list, if_list) {
19112 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
19117 + in6_dev_put(in_dev);
19124 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19130 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
19132 +#ifdef CONFIG_IPV6
19134 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
19139 + vxdprintk(VXD_CBIT(net, 3),
19140 + "dev_in_nx_info(%p,%p[#%d]) = %d",
19141 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
19145 +struct rtable *ip_v4_find_src(struct net *net, struct nx_info *nxi,
19146 + struct flowi4 *fl4)
19148 + struct rtable *rt;
19153 + /* FIXME: handle lback only case */
19154 + if (!NX_IPV4(nxi))
19155 + return ERR_PTR(-EPERM);
19157 + vxdprintk(VXD_CBIT(net, 4),
19158 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
19159 + nxi, nxi ? nxi->nx_id : 0,
19160 + NIPQUAD(fl4->saddr), NIPQUAD(fl4->daddr));
19162 + /* single IP is unconditional */
19163 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
19164 + (fl4->saddr == INADDR_ANY))
19165 + fl4->saddr = nxi->v4.ip[0].s_addr;
19167 + if (fl4->saddr == INADDR_ANY) {
19168 + struct nx_addr_v4 *ptr;
19169 + __be32 found = 0;
19171 + rt = __ip_route_output_key(net, fl4);
19172 + if (!IS_ERR(rt)) {
19173 + found = fl4->saddr;
19175 + vxdprintk(VXD_CBIT(net, 4),
19176 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19177 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(found));
19178 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
19182 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
19183 + __be32 primary = ptr->ip[0].s_addr;
19184 + __be32 mask = ptr->mask.s_addr;
19185 + __be32 neta = primary & mask;
19187 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
19188 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
19189 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
19190 + NIPQUAD(mask), NIPQUAD(neta));
19191 + if ((found & mask) != neta)
19194 + fl4->saddr = primary;
19195 + rt = __ip_route_output_key(net, fl4);
19196 + vxdprintk(VXD_CBIT(net, 4),
19197 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19198 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(primary));
19199 + if (!IS_ERR(rt)) {
19200 + found = fl4->saddr;
19202 + if (found == primary)
19206 + /* still no source ip? */
19207 + found = ipv4_is_loopback(fl4->daddr)
19208 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
19210 + /* assign src ip to flow */
19211 + fl4->saddr = found;
19214 + if (!v4_addr_in_nx_info(nxi, fl4->saddr, NXA_MASK_BIND))
19215 + return ERR_PTR(-EPERM);
19218 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
19219 + if (ipv4_is_loopback(fl4->daddr))
19220 + fl4->daddr = nxi->v4_lback.s_addr;
19221 + if (ipv4_is_loopback(fl4->saddr))
19222 + fl4->saddr = nxi->v4_lback.s_addr;
19223 + } else if (ipv4_is_loopback(fl4->daddr) &&
19224 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
19225 + return ERR_PTR(-EPERM);
19230 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
19232 diff -NurpP --minimal linux-3.1.6/kernel/vserver/init.c linux-3.1.6-vs2.3.2.5/kernel/vserver/init.c
19233 --- linux-3.1.6/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
19234 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/init.c 2011-10-24 18:53:33.000000000 +0200
19237 + * linux/kernel/init.c
19239 + * Virtual Server Init
19241 + * Copyright (C) 2004-2007 Herbert Pötzl
19243 + * V0.01 basic structure
19247 +#include <linux/init.h>
19249 +int vserver_register_sysctl(void);
19250 +void vserver_unregister_sysctl(void);
19253 +static int __init init_vserver(void)
19257 +#ifdef CONFIG_VSERVER_DEBUG
19258 + vserver_register_sysctl();
19264 +static void __exit exit_vserver(void)
19267 +#ifdef CONFIG_VSERVER_DEBUG
19268 + vserver_unregister_sysctl();
19273 +/* FIXME: GFP_ZONETYPES gone
19274 +long vx_slab[GFP_ZONETYPES]; */
19278 +module_init(init_vserver);
19279 +module_exit(exit_vserver);
19281 diff -NurpP --minimal linux-3.1.6/kernel/vserver/inode.c linux-3.1.6-vs2.3.2.5/kernel/vserver/inode.c
19282 --- linux-3.1.6/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
19283 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/inode.c 2011-12-06 23:58:02.000000000 +0100
19286 + * linux/kernel/vserver/inode.c
19288 + * Virtual Server: File System Support
19290 + * Copyright (C) 2004-2007 Herbert Pötzl
19292 + * V0.01 separated from vcontext V0.05
19293 + * V0.02 moved to tag (instead of xid)
19297 +#include <linux/tty.h>
19298 +#include <linux/proc_fs.h>
19299 +#include <linux/devpts_fs.h>
19300 +#include <linux/fs.h>
19301 +#include <linux/file.h>
19302 +#include <linux/mount.h>
19303 +#include <linux/parser.h>
19304 +#include <linux/namei.h>
19305 +#include <linux/vserver/inode.h>
19306 +#include <linux/vserver/inode_cmd.h>
19307 +#include <linux/vs_base.h>
19308 +#include <linux/vs_tag.h>
19310 +#include <asm/uaccess.h>
19313 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19315 + struct proc_dir_entry *entry;
19317 + if (!in || !in->i_sb)
19320 + *flags = IATTR_TAG
19321 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
19322 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
19323 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
19324 + | (IS_COW(in) ? IATTR_COW : 0);
19325 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
19327 + if (S_ISDIR(in->i_mode))
19328 + *mask |= IATTR_BARRIER;
19330 + if (IS_TAGGED(in)) {
19331 + *tag = in->i_tag;
19332 + *mask |= IATTR_TAG;
19335 + switch (in->i_sb->s_magic) {
19336 + case PROC_SUPER_MAGIC:
19337 + entry = PROC_I(in)->pde;
19339 + /* check for specific inodes? */
19341 + *mask |= IATTR_FLAGS;
19343 + *flags |= (entry->vx_flags & IATTR_FLAGS);
19345 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
19348 + case DEVPTS_SUPER_MAGIC:
19349 + *tag = in->i_tag;
19350 + *mask |= IATTR_TAG;
19359 +int vc_get_iattr(void __user *data)
19361 + struct path path;
19362 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
19365 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19368 + ret = user_lpath(vc_data.name, &path);
19370 + ret = __vc_get_iattr(path.dentry->d_inode,
19371 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19377 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19382 +#ifdef CONFIG_COMPAT
19384 +int vc_get_iattr_x32(void __user *data)
19386 + struct path path;
19387 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
19390 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19393 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19395 + ret = __vc_get_iattr(path.dentry->d_inode,
19396 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19402 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19407 +#endif /* CONFIG_COMPAT */
19410 +int vc_fget_iattr(uint32_t fd, void __user *data)
19412 + struct file *filp;
19413 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
19416 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19420 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19423 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
19424 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19428 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19434 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19436 + struct inode *in = de->d_inode;
19437 + int error = 0, is_proc = 0, has_tag = 0;
19438 + struct iattr attr = { 0 };
19440 + if (!in || !in->i_sb)
19443 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
19444 + if ((*mask & IATTR_FLAGS) && !is_proc)
19447 + has_tag = IS_TAGGED(in) ||
19448 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
19449 + if ((*mask & IATTR_TAG) && !has_tag)
19452 + mutex_lock(&in->i_mutex);
19453 + if (*mask & IATTR_TAG) {
19454 + attr.ia_tag = *tag;
19455 + attr.ia_valid |= ATTR_TAG;
19458 + if (*mask & IATTR_FLAGS) {
19459 + struct proc_dir_entry *entry = PROC_I(in)->pde;
19460 + unsigned int iflags = PROC_I(in)->vx_flags;
19462 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
19463 + | (*flags & IATTR_FLAGS);
19464 + PROC_I(in)->vx_flags = iflags;
19466 + entry->vx_flags = iflags;
19469 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
19470 + IATTR_BARRIER | IATTR_COW)) {
19471 + int iflags = in->i_flags;
19472 + int vflags = in->i_vflags;
19474 + if (*mask & IATTR_IMMUTABLE) {
19475 + if (*flags & IATTR_IMMUTABLE)
19476 + iflags |= S_IMMUTABLE;
19478 + iflags &= ~S_IMMUTABLE;
19480 + if (*mask & IATTR_IXUNLINK) {
19481 + if (*flags & IATTR_IXUNLINK)
19482 + iflags |= S_IXUNLINK;
19484 + iflags &= ~S_IXUNLINK;
19486 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
19487 + if (*flags & IATTR_BARRIER)
19488 + vflags |= V_BARRIER;
19490 + vflags &= ~V_BARRIER;
19492 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
19493 + if (*flags & IATTR_COW)
19496 + vflags &= ~V_COW;
19498 + if (in->i_op && in->i_op->sync_flags) {
19499 + error = in->i_op->sync_flags(in, iflags, vflags);
19505 + if (attr.ia_valid) {
19506 + if (in->i_op && in->i_op->setattr)
19507 + error = in->i_op->setattr(de, &attr);
19509 + error = inode_change_ok(in, &attr);
19511 + setattr_copy(in, &attr);
19512 + mark_inode_dirty(in);
19518 + mutex_unlock(&in->i_mutex);
19522 +int vc_set_iattr(void __user *data)
19524 + struct path path;
19525 + struct vcmd_ctx_iattr_v1 vc_data;
19528 + if (!capable(CAP_LINUX_IMMUTABLE))
19530 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19533 + ret = user_lpath(vc_data.name, &path);
19535 + ret = __vc_set_iattr(path.dentry,
19536 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19540 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19545 +#ifdef CONFIG_COMPAT
19547 +int vc_set_iattr_x32(void __user *data)
19549 + struct path path;
19550 + struct vcmd_ctx_iattr_v1_x32 vc_data;
19553 + if (!capable(CAP_LINUX_IMMUTABLE))
19555 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19558 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19560 + ret = __vc_set_iattr(path.dentry,
19561 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19565 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19570 +#endif /* CONFIG_COMPAT */
19572 +int vc_fset_iattr(uint32_t fd, void __user *data)
19574 + struct file *filp;
19575 + struct vcmd_ctx_fiattr_v0 vc_data;
19578 + if (!capable(CAP_LINUX_IMMUTABLE))
19580 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19584 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19587 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
19588 + &vc_data.flags, &vc_data.mask);
19592 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19598 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
19600 +static match_table_t tokens = {
19601 + {Opt_notagcheck, "notagcheck"},
19602 +#ifdef CONFIG_PROPAGATE
19603 + {Opt_notag, "notag"},
19604 + {Opt_tag, "tag"},
19605 + {Opt_tagid, "tagid=%u"},
19611 +static void __dx_parse_remove(char *string, char *opt)
19613 + char *p = strstr(string, opt);
19617 + while (*q != '\0' && *q != ',')
19626 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
19627 + unsigned long *flags)
19630 + substring_t args[MAX_OPT_ARGS];
19632 + char *s, *p, *opts;
19633 +#if defined(CONFIG_PROPAGATE) || defined(CONFIG_VSERVER_DEBUG)
19639 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
19644 + while ((p = strsep(&opts, ",")) != NULL) {
19645 + token = match_token(p, tokens, args);
19648 +#ifdef CONFIG_PROPAGATE
19653 + __dx_parse_remove(s, "tag");
19654 + *mnt_flags |= MNT_TAGID;
19655 + set |= MNT_TAGID;
19659 + __dx_parse_remove(s, "notag");
19660 + *mnt_flags |= MNT_NOTAG;
19661 + set |= MNT_NOTAG;
19664 + if (tag && !match_int(args, &option))
19667 + __dx_parse_remove(s, "tagid");
19668 + *mnt_flags |= MNT_TAGID;
19669 + set |= MNT_TAGID;
19671 +#endif /* CONFIG_PROPAGATE */
19672 + case Opt_notagcheck:
19674 + __dx_parse_remove(s, "notagcheck");
19675 + *flags |= MS_NOTAGCHECK;
19676 + set |= MS_NOTAGCHECK;
19679 + vxdprintk(VXD_CBIT(tag, 7),
19680 + "dx_parse_tag(" VS_Q("%s") "): %d:#%d",
19681 + p, token, option);
19684 + strcpy(string, s);
19689 +#ifdef CONFIG_PROPAGATE
19691 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
19693 + tag_t new_tag = 0;
19694 + struct vfsmount *mnt;
19699 + mnt = nd->path.mnt;
19703 + propagate = (mnt->mnt_flags & MNT_TAGID);
19705 + new_tag = mnt->mnt_tag;
19707 + vxdprintk(VXD_CBIT(tag, 7),
19708 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
19709 + inode, inode->i_ino, inode->i_tag,
19710 + new_tag, (propagate) ? 1 : 0);
19713 + inode->i_tag = new_tag;
19716 +#include <linux/module.h>
19718 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
19720 +#endif /* CONFIG_PROPAGATE */
19722 diff -NurpP --minimal linux-3.1.6/kernel/vserver/limit.c linux-3.1.6-vs2.3.2.5/kernel/vserver/limit.c
19723 --- linux-3.1.6/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
19724 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/limit.c 2011-12-07 05:08:10.000000000 +0100
19727 + * linux/kernel/vserver/limit.c
19729 + * Virtual Server: Context Limits
19731 + * Copyright (C) 2004-2010 Herbert Pötzl
19733 + * V0.01 broken out from vcontext V0.05
19734 + * V0.02 changed vcmds to vxi arg
19735 + * V0.03 added memory cgroup support
19739 +#include <linux/sched.h>
19740 +#include <linux/module.h>
19741 +#include <linux/memcontrol.h>
19742 +#include <linux/res_counter.h>
19743 +#include <linux/vs_limit.h>
19744 +#include <linux/vserver/limit.h>
19745 +#include <linux/vserver/limit_cmd.h>
19747 +#include <asm/uaccess.h>
19750 +const char *vlimit_name[NUM_LIMITS] = {
19751 + [RLIMIT_CPU] = "CPU",
19752 + [RLIMIT_NPROC] = "NPROC",
19753 + [RLIMIT_NOFILE] = "NOFILE",
19754 + [RLIMIT_LOCKS] = "LOCKS",
19755 + [RLIMIT_SIGPENDING] = "SIGP",
19756 + [RLIMIT_MSGQUEUE] = "MSGQ",
19758 + [VLIMIT_NSOCK] = "NSOCK",
19759 + [VLIMIT_OPENFD] = "OPENFD",
19760 + [VLIMIT_SHMEM] = "SHMEM",
19761 + [VLIMIT_DENTRY] = "DENTRY",
19764 +EXPORT_SYMBOL_GPL(vlimit_name);
19766 +#define MASK_ENTRY(x) (1 << (x))
19768 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
19771 + , /* softlimit */
19774 + MASK_ENTRY( RLIMIT_NPROC ) |
19775 + MASK_ENTRY( RLIMIT_NOFILE ) |
19776 + MASK_ENTRY( RLIMIT_LOCKS ) |
19777 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
19779 + MASK_ENTRY( VLIMIT_NSOCK ) |
19780 + MASK_ENTRY( VLIMIT_OPENFD ) |
19781 + MASK_ENTRY( VLIMIT_SHMEM ) |
19782 + MASK_ENTRY( VLIMIT_DENTRY ) |
19785 + /* accounting only */
19786 +uint32_t account_mask =
19787 + MASK_ENTRY( VLIMIT_SEMARY ) |
19788 + MASK_ENTRY( VLIMIT_NSEMS ) |
19789 + MASK_ENTRY( VLIMIT_MAPPED ) |
19793 +static int is_valid_vlimit(int id)
19795 + uint32_t mask = vlimit_mask.minimum |
19796 + vlimit_mask.softlimit | vlimit_mask.maximum;
19797 + return mask & (1 << id);
19800 +static int is_accounted_vlimit(int id)
19802 + if (is_valid_vlimit(id))
19804 + return account_mask & (1 << id);
19808 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
19810 + rlim_t limit = __rlim_soft(&vxi->limit, id);
19811 + return VX_VLIM(limit);
19814 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
19816 + rlim_t limit = __rlim_hard(&vxi->limit, id);
19817 + return VX_VLIM(limit);
19820 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
19821 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
19823 + if (!is_valid_vlimit(id))
19827 + *minimum = CRLIM_UNSET;
19829 + *softlimit = vc_get_soft(vxi, id);
19831 + *maximum = vc_get_hard(vxi, id);
19835 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
19837 + struct vcmd_ctx_rlimit_v0 vc_data;
19840 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19843 + ret = do_get_rlimit(vxi, vc_data.id,
19844 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
19848 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19853 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
19854 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
19856 + if (!is_valid_vlimit(id))
19859 + if (maximum != CRLIM_KEEP)
19860 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
19861 + if (softlimit != CRLIM_KEEP)
19862 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
19864 + /* clamp soft limit */
19865 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
19866 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
19871 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
19873 + struct vcmd_ctx_rlimit_v0 vc_data;
19875 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19878 + return do_set_rlimit(vxi, vc_data.id,
19879 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
19882 +#ifdef CONFIG_IA32_EMULATION
19884 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
19886 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
19888 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19891 + return do_set_rlimit(vxi, vc_data.id,
19892 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
19895 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
19897 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
19900 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19903 + ret = do_get_rlimit(vxi, vc_data.id,
19904 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
19908 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19913 +#endif /* CONFIG_IA32_EMULATION */
19916 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
19918 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
19924 +static inline void vx_reset_hits(struct _vx_limit *limit)
19928 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19929 + atomic_set(&__rlim_lhit(limit, lim), 0);
19933 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
19935 + vx_reset_hits(&vxi->limit);
19939 +static inline void vx_reset_minmax(struct _vx_limit *limit)
19944 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19945 + value = __rlim_get(limit, lim);
19946 + __rlim_rmax(limit, lim) = value;
19947 + __rlim_rmin(limit, lim) = value;
19951 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
19953 + vx_reset_minmax(&vxi->limit);
19958 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
19960 + struct vcmd_rlimit_stat_v0 vc_data;
19961 + struct _vx_limit *limit = &vxi->limit;
19964 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19968 + if (!is_accounted_vlimit(id))
19971 + vx_limit_fixup(limit, id);
19972 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
19973 + vc_data.value = __rlim_get(limit, id);
19974 + vc_data.minimum = __rlim_rmin(limit, id);
19975 + vc_data.maximum = __rlim_rmax(limit, id);
19977 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19983 +void vx_vsi_meminfo(struct sysinfo *val)
19985 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
19986 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
19987 + u64 res_limit, res_usage;
19992 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
19993 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
19995 + if (res_limit != RESOURCE_MAX)
19996 + val->totalram = (res_limit >> PAGE_SHIFT);
19997 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
19998 + val->bufferram = 0;
19999 + val->totalhigh = 0;
20000 + val->freehigh = 0;
20001 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20005 +void vx_vsi_swapinfo(struct sysinfo *val)
20007 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20008 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
20009 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20010 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
20011 + s64 swap_limit, swap_usage;
20016 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
20017 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20018 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
20019 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
20021 + /* memory unlimited */
20022 + if (res_limit == RESOURCE_MAX)
20025 + swap_limit = memsw_limit - res_limit;
20026 + /* we have a swap limit? */
20027 + if (memsw_limit != RESOURCE_MAX)
20028 + val->totalswap = swap_limit >> PAGE_SHIFT;
20030 + /* calculate swap part */
20031 + swap_usage = (memsw_usage > res_usage) ?
20032 + memsw_usage - res_usage : 0;
20034 + /* total shown minus usage gives free swap */
20035 + val->freeswap = (swap_usage < swap_limit) ?
20036 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
20037 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20038 + val->totalswap = 0;
20039 + val->freeswap = 0;
20040 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20041 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20045 +long vx_vsi_cached(struct sysinfo *val)
20047 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20048 + struct mem_cgroup *mcg = mem_cgroup_from_task(current);
20050 + return mem_cgroup_stat_read_cache(mcg);
20056 diff -NurpP --minimal linux-3.1.6/kernel/vserver/limit_init.h linux-3.1.6-vs2.3.2.5/kernel/vserver/limit_init.h
20057 --- linux-3.1.6/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
20058 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/limit_init.h 2011-10-24 18:53:33.000000000 +0200
20062 +static inline void vx_info_init_limit(struct _vx_limit *limit)
20066 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20067 + __rlim_soft(limit, lim) = RLIM_INFINITY;
20068 + __rlim_hard(limit, lim) = RLIM_INFINITY;
20069 + __rlim_set(limit, lim, 0);
20070 + atomic_set(&__rlim_lhit(limit, lim), 0);
20071 + __rlim_rmin(limit, lim) = 0;
20072 + __rlim_rmax(limit, lim) = 0;
20076 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
20081 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20082 + if ((1 << lim) & VLIM_NOCHECK)
20084 + value = __rlim_get(limit, lim);
20085 + vxwprintk_xid(value,
20086 + "!!! limit: %p[%s,%d] = %ld on exit.",
20087 + limit, vlimit_name[lim], lim, (long)value);
20091 diff -NurpP --minimal linux-3.1.6/kernel/vserver/limit_proc.h linux-3.1.6-vs2.3.2.5/kernel/vserver/limit_proc.h
20092 --- linux-3.1.6/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
20093 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/limit_proc.h 2011-10-24 18:53:33.000000000 +0200
20095 +#ifndef _VX_LIMIT_PROC_H
20096 +#define _VX_LIMIT_PROC_H
20098 +#include <linux/vserver/limit_int.h>
20101 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
20102 +#define VX_LIMIT_TOP \
20103 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
20105 +#define VX_LIMIT_ARG(r) \
20106 + (unsigned long)__rlim_get(limit, r), \
20107 + (unsigned long)__rlim_rmin(limit, r), \
20108 + (unsigned long)__rlim_rmax(limit, r), \
20109 + VX_VLIM(__rlim_soft(limit, r)), \
20110 + VX_VLIM(__rlim_hard(limit, r)), \
20111 + atomic_read(&__rlim_lhit(limit, r))
20113 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
20115 + vx_limit_fixup(limit, -1);
20116 + return sprintf(buffer, VX_LIMIT_TOP
20117 + "PROC" VX_LIMIT_FMT
20118 + "VM" VX_LIMIT_FMT
20119 + "VML" VX_LIMIT_FMT
20120 + "RSS" VX_LIMIT_FMT
20121 + "ANON" VX_LIMIT_FMT
20122 + "RMAP" VX_LIMIT_FMT
20123 + "FILES" VX_LIMIT_FMT
20124 + "OFD" VX_LIMIT_FMT
20125 + "LOCKS" VX_LIMIT_FMT
20126 + "SOCK" VX_LIMIT_FMT
20127 + "MSGQ" VX_LIMIT_FMT
20128 + "SHM" VX_LIMIT_FMT
20129 + "SEMA" VX_LIMIT_FMT
20130 + "SEMS" VX_LIMIT_FMT
20131 + "DENT" VX_LIMIT_FMT,
20132 + VX_LIMIT_ARG(RLIMIT_NPROC),
20133 + VX_LIMIT_ARG(RLIMIT_AS),
20134 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
20135 + VX_LIMIT_ARG(RLIMIT_RSS),
20136 + VX_LIMIT_ARG(VLIMIT_ANON),
20137 + VX_LIMIT_ARG(VLIMIT_MAPPED),
20138 + VX_LIMIT_ARG(RLIMIT_NOFILE),
20139 + VX_LIMIT_ARG(VLIMIT_OPENFD),
20140 + VX_LIMIT_ARG(RLIMIT_LOCKS),
20141 + VX_LIMIT_ARG(VLIMIT_NSOCK),
20142 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
20143 + VX_LIMIT_ARG(VLIMIT_SHMEM),
20144 + VX_LIMIT_ARG(VLIMIT_SEMARY),
20145 + VX_LIMIT_ARG(VLIMIT_NSEMS),
20146 + VX_LIMIT_ARG(VLIMIT_DENTRY));
20149 +#endif /* _VX_LIMIT_PROC_H */
20152 diff -NurpP --minimal linux-3.1.6/kernel/vserver/network.c linux-3.1.6-vs2.3.2.5/kernel/vserver/network.c
20153 --- linux-3.1.6/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
20154 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/network.c 2011-10-24 18:53:33.000000000 +0200
20157 + * linux/kernel/vserver/network.c
20159 + * Virtual Server: Network Support
20161 + * Copyright (C) 2003-2007 Herbert Pötzl
20163 + * V0.01 broken out from vcontext V0.05
20164 + * V0.02 cleaned up implementation
20165 + * V0.03 added equiv nx commands
20166 + * V0.04 switch to RCU based hash
20167 + * V0.05 and back to locking again
20168 + * V0.06 changed vcmds to nxi arg
20169 + * V0.07 have __create claim() the nxi
20173 +#include <linux/err.h>
20174 +#include <linux/slab.h>
20175 +#include <linux/rcupdate.h>
20177 +#include <linux/vs_network.h>
20178 +#include <linux/vs_pid.h>
20179 +#include <linux/vserver/network_cmd.h>
20182 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
20183 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
20185 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
20186 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
20189 +static int __init init_network(void)
20191 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
20192 + sizeof(struct nx_addr_v4), 0,
20193 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20194 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
20195 + sizeof(struct nx_addr_v6), 0,
20196 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20201 +/* __alloc_nx_addr_v4() */
20203 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
20205 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
20206 + nx_addr_v4_cachep, GFP_KERNEL);
20208 + if (!IS_ERR(nxa))
20209 + memset(nxa, 0, sizeof(*nxa));
20213 +/* __dealloc_nx_addr_v4() */
20215 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
20217 + kmem_cache_free(nx_addr_v4_cachep, nxa);
20220 +/* __dealloc_nx_addr_v4_all() */
20222 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
20225 + struct nx_addr_v4 *next = nxa->next;
20227 + __dealloc_nx_addr_v4(nxa);
20233 +#ifdef CONFIG_IPV6
20235 +/* __alloc_nx_addr_v6() */
20237 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
20239 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
20240 + nx_addr_v6_cachep, GFP_KERNEL);
20242 + if (!IS_ERR(nxa))
20243 + memset(nxa, 0, sizeof(*nxa));
20247 +/* __dealloc_nx_addr_v6() */
20249 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
20251 + kmem_cache_free(nx_addr_v6_cachep, nxa);
20254 +/* __dealloc_nx_addr_v6_all() */
20256 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
20259 + struct nx_addr_v6 *next = nxa->next;
20261 + __dealloc_nx_addr_v6(nxa);
20266 +#endif /* CONFIG_IPV6 */
20268 +/* __alloc_nx_info()
20270 + * allocate an initialized nx_info struct
20271 + * doesn't make it visible (hash) */
20273 +static struct nx_info *__alloc_nx_info(nid_t nid)
20275 + struct nx_info *new = NULL;
20277 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
20279 + /* would this benefit from a slab cache? */
20280 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
20284 + memset(new, 0, sizeof(struct nx_info));
20285 + new->nx_id = nid;
20286 + INIT_HLIST_NODE(&new->nx_hlist);
20287 + atomic_set(&new->nx_usecnt, 0);
20288 + atomic_set(&new->nx_tasks, 0);
20289 + new->nx_state = 0;
20291 + new->nx_flags = NXF_INIT_SET;
20293 + /* rest of init goes here */
20295 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
20296 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
20298 + vxdprintk(VXD_CBIT(nid, 0),
20299 + "alloc_nx_info(%d) = %p", nid, new);
20300 + atomic_inc(&nx_global_ctotal);
20304 +/* __dealloc_nx_info()
20306 + * final disposal of nx_info */
20308 +static void __dealloc_nx_info(struct nx_info *nxi)
20310 + vxdprintk(VXD_CBIT(nid, 0),
20311 + "dealloc_nx_info(%p)", nxi);
20313 + nxi->nx_hlist.next = LIST_POISON1;
20316 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20317 + BUG_ON(atomic_read(&nxi->nx_tasks));
20319 + __dealloc_nx_addr_v4_all(nxi->v4.next);
20321 + nxi->nx_state |= NXS_RELEASED;
20323 + atomic_dec(&nx_global_ctotal);
20326 +static void __shutdown_nx_info(struct nx_info *nxi)
20328 + nxi->nx_state |= NXS_SHUTDOWN;
20329 + vs_net_change(nxi, VSC_NETDOWN);
20332 +/* exported stuff */
20334 +void free_nx_info(struct nx_info *nxi)
20336 + /* context shutdown is mandatory */
20337 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
20339 + /* context must not be hashed */
20340 + BUG_ON(nxi->nx_state & NXS_HASHED);
20342 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20343 + BUG_ON(atomic_read(&nxi->nx_tasks));
20345 + __dealloc_nx_info(nxi);
20349 +void __nx_set_lback(struct nx_info *nxi)
20351 + int nid = nxi->nx_id;
20352 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
20354 + nxi->v4_lback.s_addr = lback;
20357 +extern int __nx_inet_add_lback(__be32 addr);
20358 +extern int __nx_inet_del_lback(__be32 addr);
20361 +/* hash table for nx_info hash */
20363 +#define NX_HASH_SIZE 13
20365 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
20367 +static DEFINE_SPINLOCK(nx_info_hash_lock);
20370 +static inline unsigned int __hashval(nid_t nid)
20372 + return (nid % NX_HASH_SIZE);
20377 +/* __hash_nx_info()
20379 + * add the nxi to the global hash table
20380 + * requires the hash_lock to be held */
20382 +static inline void __hash_nx_info(struct nx_info *nxi)
20384 + struct hlist_head *head;
20386 + vxd_assert_lock(&nx_info_hash_lock);
20387 + vxdprintk(VXD_CBIT(nid, 4),
20388 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
20390 + /* context must not be hashed */
20391 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
20393 + nxi->nx_state |= NXS_HASHED;
20394 + head = &nx_info_hash[__hashval(nxi->nx_id)];
20395 + hlist_add_head(&nxi->nx_hlist, head);
20396 + atomic_inc(&nx_global_cactive);
20399 +/* __unhash_nx_info()
20401 + * remove the nxi from the global hash table
20402 + * requires the hash_lock to be held */
20404 +static inline void __unhash_nx_info(struct nx_info *nxi)
20406 + vxd_assert_lock(&nx_info_hash_lock);
20407 + vxdprintk(VXD_CBIT(nid, 4),
20408 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
20409 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
20411 + /* context must be hashed */
20412 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
20413 + /* but without tasks */
20414 + BUG_ON(atomic_read(&nxi->nx_tasks));
20416 + nxi->nx_state &= ~NXS_HASHED;
20417 + hlist_del(&nxi->nx_hlist);
20418 + atomic_dec(&nx_global_cactive);
20422 +/* __lookup_nx_info()
20424 + * requires the hash_lock to be held
20425 + * doesn't increment the nx_refcnt */
20427 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
20429 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
20430 + struct hlist_node *pos;
20431 + struct nx_info *nxi;
20433 + vxd_assert_lock(&nx_info_hash_lock);
20434 + hlist_for_each(pos, head) {
20435 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20437 + if (nxi->nx_id == nid)
20442 + vxdprintk(VXD_CBIT(nid, 0),
20443 + "__lookup_nx_info(#%u): %p[#%u]",
20444 + nid, nxi, nxi ? nxi->nx_id : 0);
20449 +/* __create_nx_info()
20451 + * create the requested context
20452 + * get(), claim() and hash it */
20454 +static struct nx_info *__create_nx_info(int id)
20456 + struct nx_info *new, *nxi = NULL;
20458 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
20460 + if (!(new = __alloc_nx_info(id)))
20461 + return ERR_PTR(-ENOMEM);
20463 + /* required to make dynamic xids unique */
20464 + spin_lock(&nx_info_hash_lock);
20466 + /* static context requested */
20467 + if ((nxi = __lookup_nx_info(id))) {
20468 + vxdprintk(VXD_CBIT(nid, 0),
20469 + "create_nx_info(%d) = %p (already there)", id, nxi);
20470 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20471 + nxi = ERR_PTR(-EBUSY);
20473 + nxi = ERR_PTR(-EEXIST);
20476 + /* new context */
20477 + vxdprintk(VXD_CBIT(nid, 0),
20478 + "create_nx_info(%d) = %p (new)", id, new);
20479 + claim_nx_info(new, NULL);
20480 + __nx_set_lback(new);
20481 + __hash_nx_info(get_nx_info(new));
20482 + nxi = new, new = NULL;
20485 + spin_unlock(&nx_info_hash_lock);
20487 + __dealloc_nx_info(new);
20493 +/* exported stuff */
20496 +void unhash_nx_info(struct nx_info *nxi)
20498 + __shutdown_nx_info(nxi);
20499 + spin_lock(&nx_info_hash_lock);
20500 + __unhash_nx_info(nxi);
20501 + spin_unlock(&nx_info_hash_lock);
20504 +/* lookup_nx_info()
20506 + * search for a nx_info and get() it
20507 + * negative id means current */
20509 +struct nx_info *lookup_nx_info(int id)
20511 + struct nx_info *nxi = NULL;
20514 + nxi = get_nx_info(current_nx_info());
20515 + } else if (id > 1) {
20516 + spin_lock(&nx_info_hash_lock);
20517 + nxi = get_nx_info(__lookup_nx_info(id));
20518 + spin_unlock(&nx_info_hash_lock);
20523 +/* nid_is_hashed()
20525 + * verify that nid is still hashed */
20527 +int nid_is_hashed(nid_t nid)
20531 + spin_lock(&nx_info_hash_lock);
20532 + hashed = (__lookup_nx_info(nid) != NULL);
20533 + spin_unlock(&nx_info_hash_lock);
20538 +#ifdef CONFIG_PROC_FS
20542 + * get a subset of hashed nids for proc
20543 + * assumes size is at least one */
20545 +int get_nid_list(int index, unsigned int *nids, int size)
20547 + int hindex, nr_nids = 0;
20549 + /* only show current and children */
20550 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
20553 + nids[nr_nids] = nx_current_nid();
20557 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
20558 + struct hlist_head *head = &nx_info_hash[hindex];
20559 + struct hlist_node *pos;
20561 + spin_lock(&nx_info_hash_lock);
20562 + hlist_for_each(pos, head) {
20563 + struct nx_info *nxi;
20568 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20569 + nids[nr_nids] = nxi->nx_id;
20570 + if (++nr_nids >= size) {
20571 + spin_unlock(&nx_info_hash_lock);
20575 + /* keep the lock time short */
20576 + spin_unlock(&nx_info_hash_lock);
20585 + * migrate task to new network
20586 + * gets nxi, puts old_nxi on change
20589 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
20591 + struct nx_info *old_nxi;
20597 + vxdprintk(VXD_CBIT(nid, 5),
20598 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
20599 + p, nxi, nxi->nx_id,
20600 + atomic_read(&nxi->nx_usecnt),
20601 + atomic_read(&nxi->nx_tasks));
20603 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
20604 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20607 + if (nx_info_state(nxi, NXS_SHUTDOWN))
20610 + /* maybe disallow this completely? */
20611 + old_nxi = task_get_nx_info(p);
20612 + if (old_nxi == nxi)
20617 + clr_nx_info(&p->nx_info);
20618 + claim_nx_info(nxi, p);
20619 + set_nx_info(&p->nx_info, nxi);
20620 + p->nid = nxi->nx_id;
20623 + vxdprintk(VXD_CBIT(nid, 5),
20624 + "moved task %p into nxi:%p[#%d]",
20625 + p, nxi, nxi->nx_id);
20628 + release_nx_info(old_nxi, p);
20631 + put_nx_info(old_nxi);
20636 +void nx_set_persistent(struct nx_info *nxi)
20638 + vxdprintk(VXD_CBIT(nid, 6),
20639 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
20641 + get_nx_info(nxi);
20642 + claim_nx_info(nxi, NULL);
20645 +void nx_clear_persistent(struct nx_info *nxi)
20647 + vxdprintk(VXD_CBIT(nid, 6),
20648 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
20650 + release_nx_info(nxi, NULL);
20651 + put_nx_info(nxi);
20654 +void nx_update_persistent(struct nx_info *nxi)
20656 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
20657 + nx_set_persistent(nxi);
20659 + nx_clear_persistent(nxi);
20662 +/* vserver syscall commands below here */
20664 +/* taks nid and nx_info functions */
20666 +#include <asm/uaccess.h>
20669 +int vc_task_nid(uint32_t id)
20674 + struct task_struct *tsk;
20677 + tsk = find_task_by_real_pid(id);
20678 + nid = (tsk) ? tsk->nid : -ESRCH;
20679 + rcu_read_unlock();
20681 + nid = nx_current_nid();
20686 +int vc_nx_info(struct nx_info *nxi, void __user *data)
20688 + struct vcmd_nx_info_v0 vc_data;
20690 + vc_data.nid = nxi->nx_id;
20692 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20698 +/* network functions */
20700 +int vc_net_create(uint32_t nid, void __user *data)
20702 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
20703 + struct nx_info *new_nxi;
20706 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20709 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
20712 + new_nxi = __create_nx_info(nid);
20713 + if (IS_ERR(new_nxi))
20714 + return PTR_ERR(new_nxi);
20716 + /* initial flags */
20717 + new_nxi->nx_flags = vc_data.flagword;
20720 + if (vs_net_change(new_nxi, VSC_NETUP))
20723 + ret = nx_migrate_task(current, new_nxi);
20727 + /* return context id on success */
20728 + ret = new_nxi->nx_id;
20730 + /* get a reference for persistent contexts */
20731 + if ((vc_data.flagword & NXF_PERSISTENT))
20732 + nx_set_persistent(new_nxi);
20734 + release_nx_info(new_nxi, NULL);
20735 + put_nx_info(new_nxi);
20740 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
20742 + return nx_migrate_task(current, nxi);
20747 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
20748 + uint16_t type, uint16_t flags)
20750 + struct nx_addr_v4 *nxa = &nxi->v4;
20752 + if (NX_IPV4(nxi)) {
20753 + /* locate last entry */
20754 + for (; nxa->next; nxa = nxa->next);
20755 + nxa->next = __alloc_nx_addr_v4();
20759 + return PTR_ERR(nxa);
20762 + if (nxi->v4.next)
20763 + /* remove single ip for ip list */
20764 + nxi->nx_flags &= ~NXF_SINGLE_IP;
20766 + nxa->ip[0].s_addr = ip;
20767 + nxa->ip[1].s_addr = ip2;
20768 + nxa->mask.s_addr = mask;
20769 + nxa->type = type;
20770 + nxa->flags = flags;
20774 +int do_remove_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
20775 + uint16_t type, uint16_t flags)
20777 + struct nx_addr_v4 *nxa = &nxi->v4;
20780 +/* case NXA_TYPE_ADDR:
20783 + case NXA_TYPE_ANY:
20784 + __dealloc_nx_addr_v4_all(xchg(&nxa->next, NULL));
20785 + memset(nxa, 0, sizeof(*nxa));
20795 +int vc_net_add(struct nx_info *nxi, void __user *data)
20797 + struct vcmd_net_addr_v0 vc_data;
20798 + int index, ret = 0;
20800 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20803 + switch (vc_data.type) {
20804 + case NXA_TYPE_IPV4:
20805 + if ((vc_data.count < 1) || (vc_data.count > 4))
20809 + while (index < vc_data.count) {
20810 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
20811 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
20819 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
20820 + nxi->v4_bcast = vc_data.ip[0];
20824 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
20825 + nxi->v4_lback = vc_data.ip[0];
20836 +int vc_net_remove(struct nx_info *nxi, void __user *data)
20838 + struct vcmd_net_addr_v0 vc_data;
20840 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20843 + switch (vc_data.type) {
20844 + case NXA_TYPE_ANY:
20845 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
20846 + memset(&nxi->v4, 0, sizeof(nxi->v4));
20856 +int vc_net_add_ipv4_v1(struct nx_info *nxi, void __user *data)
20858 + struct vcmd_net_addr_ipv4_v1 vc_data;
20860 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20863 + switch (vc_data.type) {
20864 + case NXA_TYPE_ADDR:
20865 + case NXA_TYPE_MASK:
20866 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
20867 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20869 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
20870 + nxi->v4_bcast = vc_data.ip;
20873 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
20874 + nxi->v4_lback = vc_data.ip;
20883 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
20885 + struct vcmd_net_addr_ipv4_v2 vc_data;
20887 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20890 + switch (vc_data.type) {
20891 + case NXA_TYPE_ADDR:
20892 + case NXA_TYPE_MASK:
20893 + case NXA_TYPE_RANGE:
20894 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
20895 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20897 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
20898 + nxi->v4_bcast = vc_data.ip;
20901 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
20902 + nxi->v4_lback = vc_data.ip;
20911 +int vc_net_rem_ipv4_v1(struct nx_info *nxi, void __user *data)
20913 + struct vcmd_net_addr_ipv4_v1 vc_data;
20915 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20918 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, 0,
20919 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20922 +int vc_net_rem_ipv4(struct nx_info *nxi, void __user *data)
20924 + struct vcmd_net_addr_ipv4_v2 vc_data;
20926 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20929 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
20930 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20933 +#ifdef CONFIG_IPV6
20935 +int do_add_v6_addr(struct nx_info *nxi,
20936 + struct in6_addr *ip, struct in6_addr *mask,
20937 + uint32_t prefix, uint16_t type, uint16_t flags)
20939 + struct nx_addr_v6 *nxa = &nxi->v6;
20941 + if (NX_IPV6(nxi)) {
20942 + /* locate last entry */
20943 + for (; nxa->next; nxa = nxa->next);
20944 + nxa->next = __alloc_nx_addr_v6();
20948 + return PTR_ERR(nxa);
20952 + nxa->mask = *mask;
20953 + nxa->prefix = prefix;
20954 + nxa->type = type;
20955 + nxa->flags = flags;
20960 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
20962 + struct vcmd_net_addr_ipv6_v1 vc_data;
20964 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20967 + switch (vc_data.type) {
20968 + case NXA_TYPE_ADDR:
20969 + memset(&vc_data.mask, ~0, sizeof(vc_data.mask));
20970 + /* fallthrough */
20971 + case NXA_TYPE_MASK:
20972 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
20973 + vc_data.prefix, vc_data.type, vc_data.flags);
20980 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
20982 + struct vcmd_net_addr_ipv6_v1 vc_data;
20984 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20987 + switch (vc_data.type) {
20988 + case NXA_TYPE_ANY:
20989 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
20990 + memset(&nxi->v6, 0, sizeof(nxi->v6));
20999 +#endif /* CONFIG_IPV6 */
21002 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
21004 + struct vcmd_net_flags_v0 vc_data;
21006 + vc_data.flagword = nxi->nx_flags;
21008 + /* special STATE flag handling */
21009 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
21011 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21016 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
21018 + struct vcmd_net_flags_v0 vc_data;
21019 + uint64_t mask, trigger;
21021 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21024 + /* special STATE flag handling */
21025 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
21026 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
21028 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
21029 + vc_data.flagword, mask);
21030 + if (trigger & NXF_PERSISTENT)
21031 + nx_update_persistent(nxi);
21036 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
21038 + struct vcmd_net_caps_v0 vc_data;
21040 + vc_data.ncaps = nxi->nx_ncaps;
21041 + vc_data.cmask = ~0ULL;
21043 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21048 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
21050 + struct vcmd_net_caps_v0 vc_data;
21052 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21055 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
21056 + vc_data.ncaps, vc_data.cmask);
21061 +#include <linux/module.h>
21063 +module_init(init_network);
21065 +EXPORT_SYMBOL_GPL(free_nx_info);
21066 +EXPORT_SYMBOL_GPL(unhash_nx_info);
21068 diff -NurpP --minimal linux-3.1.6/kernel/vserver/proc.c linux-3.1.6-vs2.3.2.5/kernel/vserver/proc.c
21069 --- linux-3.1.6/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
21070 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/proc.c 2011-10-24 18:53:33.000000000 +0200
21073 + * linux/kernel/vserver/proc.c
21075 + * Virtual Context Support
21077 + * Copyright (C) 2003-2011 Herbert Pötzl
21079 + * V0.01 basic structure
21080 + * V0.02 adaptation vs1.3.0
21081 + * V0.03 proc permissions
21082 + * V0.04 locking/generic
21083 + * V0.05 next generation procfs
21084 + * V0.06 inode validation
21085 + * V0.07 generic rewrite vid
21086 + * V0.08 remove inode type
21087 + * V0.09 added u/wmask info
21091 +#include <linux/proc_fs.h>
21092 +#include <linux/fs_struct.h>
21093 +#include <linux/mount.h>
21094 +#include <asm/unistd.h>
21096 +#include <linux/vs_context.h>
21097 +#include <linux/vs_network.h>
21098 +#include <linux/vs_cvirt.h>
21100 +#include <linux/in.h>
21101 +#include <linux/inetdevice.h>
21102 +#include <linux/vs_inet.h>
21103 +#include <linux/vs_inet6.h>
21105 +#include <linux/vserver/global.h>
21107 +#include "cvirt_proc.h"
21108 +#include "cacct_proc.h"
21109 +#include "limit_proc.h"
21110 +#include "sched_proc.h"
21111 +#include "vci_config.h"
21114 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
21118 + CAP_FOR_EACH_U32(__capi) {
21119 + buffer += sprintf(buffer, "%08x",
21120 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
21126 +static struct proc_dir_entry *proc_virtual;
21128 +static struct proc_dir_entry *proc_virtnet;
21131 +/* first the actual feeds */
21134 +static int proc_vci(char *buffer)
21136 + return sprintf(buffer,
21137 + "VCIVersion:\t%04x:%04x\n"
21138 + "VCISyscall:\t%d\n"
21139 + "VCIKernel:\t%08x\n",
21140 + VCI_VERSION >> 16,
21141 + VCI_VERSION & 0xFFFF,
21143 + vci_kernel_config());
21146 +static int proc_virtual_info(char *buffer)
21148 + return proc_vci(buffer);
21151 +static int proc_virtual_status(char *buffer)
21153 + return sprintf(buffer,
21155 + "#CActive:\t%d\n"
21156 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
21157 + "#InitTask:\t%d\t%d %d\n",
21158 + atomic_read(&vx_global_ctotal),
21159 + atomic_read(&vx_global_cactive),
21160 + atomic_read(&vs_global_nsproxy),
21161 + atomic_read(&vs_global_fs),
21162 + atomic_read(&vs_global_mnt_ns),
21163 + atomic_read(&vs_global_uts_ns),
21164 + atomic_read(&nr_ipc_ns),
21165 + atomic_read(&vs_global_user_ns),
21166 + atomic_read(&vs_global_pid_ns),
21167 + atomic_read(&init_task.usage),
21168 + atomic_read(&init_task.nsproxy->count),
21169 + init_task.fs->users);
21173 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
21177 + length = sprintf(buffer,
21185 + vxi->vx_badness_bias);
21189 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
21191 + char *orig = buffer;
21193 + buffer += sprintf(buffer,
21196 + "Flags:\t%016llx\n",
21197 + atomic_read(&vxi->vx_usecnt),
21198 + atomic_read(&vxi->vx_tasks),
21199 + (unsigned long long)vxi->vx_flags);
21201 + buffer += sprintf(buffer, "BCaps:\t");
21202 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
21203 + buffer += sprintf(buffer, "\n");
21205 + buffer += sprintf(buffer,
21206 + "CCaps:\t%016llx\n"
21207 + "Umask:\t%16llx\n"
21208 + "Wmask:\t%16llx\n"
21209 + "Spaces:\t%08lx %08lx\n",
21210 + (unsigned long long)vxi->vx_ccaps,
21211 + (unsigned long long)vxi->vx_umask,
21212 + (unsigned long long)vxi->vx_wmask,
21213 + vxi->space[0].vx_nsmask, vxi->space[1].vx_nsmask);
21214 + return buffer - orig;
21217 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
21219 + return vx_info_proc_limit(&vxi->limit, buffer);
21222 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
21226 + length = vx_info_proc_sched(&vxi->sched, buffer);
21227 + for_each_online_cpu(cpu) {
21228 + length += vx_info_proc_sched_pc(
21229 + &vx_per_cpu(vxi, sched_pc, cpu),
21230 + buffer + length, cpu);
21235 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
21237 + return vx_info_proc_nsproxy(vxi->space[0].vx_nsproxy, buffer);
21240 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
21242 + return vx_info_proc_nsproxy(vxi->space[1].vx_nsproxy, buffer);
21245 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
21249 + vx_update_load(vxi);
21250 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
21251 + for_each_online_cpu(cpu) {
21252 + length += vx_info_proc_cvirt_pc(
21253 + &vx_per_cpu(vxi, cvirt_pc, cpu),
21254 + buffer + length, cpu);
21259 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
21261 + return vx_info_proc_cacct(&vxi->cacct, buffer);
21265 +static int proc_virtnet_info(char *buffer)
21267 + return proc_vci(buffer);
21270 +static int proc_virtnet_status(char *buffer)
21272 + return sprintf(buffer,
21274 + "#CActive:\t%d\n",
21275 + atomic_read(&nx_global_ctotal),
21276 + atomic_read(&nx_global_cactive));
21279 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
21281 + struct nx_addr_v4 *v4a;
21282 +#ifdef CONFIG_IPV6
21283 + struct nx_addr_v6 *v6a;
21287 + length = sprintf(buffer,
21290 + "Bcast:\t" NIPQUAD_FMT "\n"
21291 + "Lback:\t" NIPQUAD_FMT "\n",
21294 + NIPQUAD(nxi->v4_bcast.s_addr),
21295 + NIPQUAD(nxi->v4_lback.s_addr));
21297 + if (!NX_IPV4(nxi))
21299 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
21300 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
21303 +#ifdef CONFIG_IPV6
21304 + if (!NX_IPV6(nxi))
21306 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
21307 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
21314 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
21318 + length = sprintf(buffer,
21321 + "Flags:\t%016llx\n"
21322 + "NCaps:\t%016llx\n",
21323 + atomic_read(&nxi->nx_usecnt),
21324 + atomic_read(&nxi->nx_tasks),
21325 + (unsigned long long)nxi->nx_flags,
21326 + (unsigned long long)nxi->nx_ncaps);
21332 +/* here the inode helpers */
21338 + struct inode_operations *iop;
21339 + struct file_operations *fop;
21340 + union proc_op op;
21343 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
21345 + struct inode *inode = new_inode(sb);
21350 + inode->i_mode = p->mode;
21352 + inode->i_op = p->iop;
21354 + inode->i_fop = p->fop;
21356 + inode->i_nlink = (p->mode & S_IFDIR) ? 2 : 1;
21357 + inode->i_flags |= S_IMMUTABLE;
21359 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
21361 + inode->i_uid = 0;
21362 + inode->i_gid = 0;
21363 + inode->i_tag = 0;
21368 +static struct dentry *vs_proc_instantiate(struct inode *dir,
21369 + struct dentry *dentry, int id, void *ptr)
21371 + struct vs_entry *p = ptr;
21372 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
21373 + struct dentry *error = ERR_PTR(-EINVAL);
21378 + PROC_I(inode)->op = p->op;
21379 + PROC_I(inode)->fd = id;
21380 + d_add(dentry, inode);
21388 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
21391 + * Fill a directory entry.
21393 + * If possible create the dcache entry and derive our inode number and
21394 + * file type from dcache entry.
21396 + * Since all of the proc inode numbers are dynamically generated, the inode
21397 + * numbers do not exist until the inode is cache. This means creating the
21398 + * the dcache entry in readdir is necessary to keep the inode numbers
21399 + * reported by readdir in sync with the inode numbers reported
21402 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
21403 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
21405 + struct dentry *child, *dir = filp->f_dentry;
21406 + struct inode *inode;
21407 + struct qstr qname;
21409 + unsigned type = DT_UNKNOWN;
21411 + qname.name = name;
21413 + qname.hash = full_name_hash(name, len);
21415 + child = d_lookup(dir, &qname);
21417 + struct dentry *new;
21418 + new = d_alloc(dir, &qname);
21420 + child = instantiate(dir->d_inode, new, id, ptr);
21427 + if (!child || IS_ERR(child) || !child->d_inode)
21428 + goto end_instantiate;
21429 + inode = child->d_inode;
21431 + ino = inode->i_ino;
21432 + type = inode->i_mode >> 12;
21437 + ino = find_inode_number(dir, &qname);
21440 + return filldir(dirent, name, len, filp->f_pos, ino, type);
21445 +/* get and revalidate vx_info/xid */
21448 +struct vx_info *get_proc_vx_info(struct inode *inode)
21450 + return lookup_vx_info(PROC_I(inode)->fd);
21453 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
21455 + struct inode *inode = dentry->d_inode;
21456 + xid_t xid = PROC_I(inode)->fd;
21458 + if (!xid || xid_is_hashed(xid))
21465 +/* get and revalidate nx_info/nid */
21467 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
21469 + struct inode *inode = dentry->d_inode;
21470 + nid_t nid = PROC_I(inode)->fd;
21472 + if (!nid || nid_is_hashed(nid))
21480 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
21482 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
21483 + size_t count, loff_t *ppos)
21485 + struct inode *inode = file->f_dentry->d_inode;
21486 + unsigned long page;
21487 + ssize_t length = 0;
21489 + if (count > PROC_BLOCK_SIZE)
21490 + count = PROC_BLOCK_SIZE;
21492 + /* fade that out as soon as stable */
21493 + WARN_ON(PROC_I(inode)->fd);
21495 + if (!(page = __get_free_page(GFP_KERNEL)))
21498 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
21499 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
21502 + length = simple_read_from_buffer(buf, count, ppos,
21503 + (char *)page, length);
21509 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
21510 + size_t count, loff_t *ppos)
21512 + struct inode *inode = file->f_dentry->d_inode;
21513 + struct vx_info *vxi = NULL;
21514 + xid_t xid = PROC_I(inode)->fd;
21515 + unsigned long page;
21516 + ssize_t length = 0;
21518 + if (count > PROC_BLOCK_SIZE)
21519 + count = PROC_BLOCK_SIZE;
21521 + /* fade that out as soon as stable */
21523 + vxi = lookup_vx_info(xid);
21527 + length = -ENOMEM;
21528 + if (!(page = __get_free_page(GFP_KERNEL)))
21531 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
21532 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
21535 + length = simple_read_from_buffer(buf, count, ppos,
21536 + (char *)page, length);
21540 + put_vx_info(vxi);
21545 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
21546 + size_t count, loff_t *ppos)
21548 + struct inode *inode = file->f_dentry->d_inode;
21549 + struct nx_info *nxi = NULL;
21550 + nid_t nid = PROC_I(inode)->fd;
21551 + unsigned long page;
21552 + ssize_t length = 0;
21554 + if (count > PROC_BLOCK_SIZE)
21555 + count = PROC_BLOCK_SIZE;
21557 + /* fade that out as soon as stable */
21559 + nxi = lookup_nx_info(nid);
21563 + length = -ENOMEM;
21564 + if (!(page = __get_free_page(GFP_KERNEL)))
21567 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
21568 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
21571 + length = simple_read_from_buffer(buf, count, ppos,
21572 + (char *)page, length);
21576 + put_nx_info(nxi);
21583 +/* here comes the lower level */
21586 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
21587 + .len = sizeof(NAME) - 1, \
21588 + .name = (NAME), \
21596 +#define DIR(NAME, MODE, OTYPE) \
21597 + NOD(NAME, (S_IFDIR | (MODE)), \
21598 + &proc_ ## OTYPE ## _inode_operations, \
21599 + &proc_ ## OTYPE ## _file_operations, { } )
21601 +#define INF(NAME, MODE, OTYPE) \
21602 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21603 + &proc_vs_info_file_operations, \
21604 + { .proc_vs_read = &proc_##OTYPE } )
21606 +#define VINF(NAME, MODE, OTYPE) \
21607 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21608 + &proc_vx_info_file_operations, \
21609 + { .proc_vxi_read = &proc_##OTYPE } )
21611 +#define NINF(NAME, MODE, OTYPE) \
21612 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21613 + &proc_nx_info_file_operations, \
21614 + { .proc_nxi_read = &proc_##OTYPE } )
21617 +static struct file_operations proc_vs_info_file_operations = {
21618 + .read = proc_vs_info_read,
21621 +static struct file_operations proc_vx_info_file_operations = {
21622 + .read = proc_vx_info_read,
21625 +static struct dentry_operations proc_xid_dentry_operations = {
21626 + .d_revalidate = proc_xid_revalidate,
21629 +static struct vs_entry vx_base_stuff[] = {
21630 + VINF("info", S_IRUGO, vxi_info),
21631 + VINF("status", S_IRUGO, vxi_status),
21632 + VINF("limit", S_IRUGO, vxi_limit),
21633 + VINF("sched", S_IRUGO, vxi_sched),
21634 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
21635 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
21636 + VINF("cvirt", S_IRUGO, vxi_cvirt),
21637 + VINF("cacct", S_IRUGO, vxi_cacct),
21644 +static struct dentry *proc_xid_instantiate(struct inode *dir,
21645 + struct dentry *dentry, int id, void *ptr)
21647 + dentry->d_op = &proc_xid_dentry_operations;
21648 + return vs_proc_instantiate(dir, dentry, id, ptr);
21651 +static struct dentry *proc_xid_lookup(struct inode *dir,
21652 + struct dentry *dentry, struct nameidata *nd)
21654 + struct vs_entry *p = vx_base_stuff;
21655 + struct dentry *error = ERR_PTR(-ENOENT);
21657 + for (; p->name; p++) {
21658 + if (p->len != dentry->d_name.len)
21660 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21666 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
21671 +static int proc_xid_readdir(struct file *filp,
21672 + void *dirent, filldir_t filldir)
21674 + struct dentry *dentry = filp->f_dentry;
21675 + struct inode *inode = dentry->d_inode;
21676 + struct vs_entry *p = vx_base_stuff;
21677 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
21681 + pos = filp->f_pos;
21684 + ino = inode->i_ino;
21685 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21688 + /* fall through */
21690 + ino = parent_ino(dentry);
21691 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21694 + /* fall through */
21697 + if (index >= size)
21699 + for (p += index; p->name; p++) {
21700 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21701 + vs_proc_instantiate, PROC_I(inode)->fd, p))
21707 + filp->f_pos = pos;
21713 +static struct file_operations proc_nx_info_file_operations = {
21714 + .read = proc_nx_info_read,
21717 +static struct dentry_operations proc_nid_dentry_operations = {
21718 + .d_revalidate = proc_nid_revalidate,
21721 +static struct vs_entry nx_base_stuff[] = {
21722 + NINF("info", S_IRUGO, nxi_info),
21723 + NINF("status", S_IRUGO, nxi_status),
21728 +static struct dentry *proc_nid_instantiate(struct inode *dir,
21729 + struct dentry *dentry, int id, void *ptr)
21731 + dentry->d_op = &proc_nid_dentry_operations;
21732 + return vs_proc_instantiate(dir, dentry, id, ptr);
21735 +static struct dentry *proc_nid_lookup(struct inode *dir,
21736 + struct dentry *dentry, struct nameidata *nd)
21738 + struct vs_entry *p = nx_base_stuff;
21739 + struct dentry *error = ERR_PTR(-ENOENT);
21741 + for (; p->name; p++) {
21742 + if (p->len != dentry->d_name.len)
21744 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21750 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
21755 +static int proc_nid_readdir(struct file *filp,
21756 + void *dirent, filldir_t filldir)
21758 + struct dentry *dentry = filp->f_dentry;
21759 + struct inode *inode = dentry->d_inode;
21760 + struct vs_entry *p = nx_base_stuff;
21761 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
21765 + pos = filp->f_pos;
21768 + ino = inode->i_ino;
21769 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21772 + /* fall through */
21774 + ino = parent_ino(dentry);
21775 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21778 + /* fall through */
21781 + if (index >= size)
21783 + for (p += index; p->name; p++) {
21784 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21785 + vs_proc_instantiate, PROC_I(inode)->fd, p))
21791 + filp->f_pos = pos;
21796 +#define MAX_MULBY10 ((~0U - 9) / 10)
21798 +static inline int atovid(const char *str, int len)
21803 + while (len-- > 0) {
21808 + if (vid >= MAX_MULBY10)
21818 +/* now the upper level (virtual) */
21821 +static struct file_operations proc_xid_file_operations = {
21822 + .read = generic_read_dir,
21823 + .readdir = proc_xid_readdir,
21826 +static struct inode_operations proc_xid_inode_operations = {
21827 + .lookup = proc_xid_lookup,
21830 +static struct vs_entry vx_virtual_stuff[] = {
21831 + INF("info", S_IRUGO, virtual_info),
21832 + INF("status", S_IRUGO, virtual_status),
21833 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
21837 +static struct dentry *proc_virtual_lookup(struct inode *dir,
21838 + struct dentry *dentry, struct nameidata *nd)
21840 + struct vs_entry *p = vx_virtual_stuff;
21841 + struct dentry *error = ERR_PTR(-ENOENT);
21844 + for (; p->name; p++) {
21845 + if (p->len != dentry->d_name.len)
21847 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21851 + goto instantiate;
21853 + id = atovid(dentry->d_name.name, dentry->d_name.len);
21854 + if ((id < 0) || !xid_is_hashed(id))
21858 + error = proc_xid_instantiate(dir, dentry, id, p);
21863 +static struct file_operations proc_nid_file_operations = {
21864 + .read = generic_read_dir,
21865 + .readdir = proc_nid_readdir,
21868 +static struct inode_operations proc_nid_inode_operations = {
21869 + .lookup = proc_nid_lookup,
21872 +static struct vs_entry nx_virtnet_stuff[] = {
21873 + INF("info", S_IRUGO, virtnet_info),
21874 + INF("status", S_IRUGO, virtnet_status),
21875 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
21879 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
21880 + struct dentry *dentry, struct nameidata *nd)
21882 + struct vs_entry *p = nx_virtnet_stuff;
21883 + struct dentry *error = ERR_PTR(-ENOENT);
21886 + for (; p->name; p++) {
21887 + if (p->len != dentry->d_name.len)
21889 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21893 + goto instantiate;
21895 + id = atovid(dentry->d_name.name, dentry->d_name.len);
21896 + if ((id < 0) || !nid_is_hashed(id))
21900 + error = proc_nid_instantiate(dir, dentry, id, p);
21906 +#define PROC_MAXVIDS 32
21908 +int proc_virtual_readdir(struct file *filp,
21909 + void *dirent, filldir_t filldir)
21911 + struct dentry *dentry = filp->f_dentry;
21912 + struct inode *inode = dentry->d_inode;
21913 + struct vs_entry *p = vx_virtual_stuff;
21914 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
21916 + unsigned int xid_array[PROC_MAXVIDS];
21917 + char buf[PROC_NUMBUF];
21918 + unsigned int nr_xids, i;
21921 + pos = filp->f_pos;
21924 + ino = inode->i_ino;
21925 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21928 + /* fall through */
21930 + ino = parent_ino(dentry);
21931 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21934 + /* fall through */
21937 + if (index >= size)
21939 + for (p += index; p->name; p++) {
21940 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21941 + vs_proc_instantiate, 0, p))
21946 + index = pos - size;
21947 + p = &vx_virtual_stuff[size - 1];
21948 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
21949 + for (i = 0; i < nr_xids; i++) {
21950 + int n, xid = xid_array[i];
21951 + unsigned int j = PROC_NUMBUF;
21955 + buf[--j] = '0' + (n % 10);
21958 + if (proc_fill_cache(filp, dirent, filldir,
21959 + buf + j, PROC_NUMBUF - j,
21960 + vs_proc_instantiate, xid, p))
21966 + filp->f_pos = pos;
21970 +static int proc_virtual_getattr(struct vfsmount *mnt,
21971 + struct dentry *dentry, struct kstat *stat)
21973 + struct inode *inode = dentry->d_inode;
21975 + generic_fillattr(inode, stat);
21976 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
21980 +static struct file_operations proc_virtual_dir_operations = {
21981 + .read = generic_read_dir,
21982 + .readdir = proc_virtual_readdir,
21985 +static struct inode_operations proc_virtual_dir_inode_operations = {
21986 + .getattr = proc_virtual_getattr,
21987 + .lookup = proc_virtual_lookup,
21994 +int proc_virtnet_readdir(struct file *filp,
21995 + void *dirent, filldir_t filldir)
21997 + struct dentry *dentry = filp->f_dentry;
21998 + struct inode *inode = dentry->d_inode;
21999 + struct vs_entry *p = nx_virtnet_stuff;
22000 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
22002 + unsigned int nid_array[PROC_MAXVIDS];
22003 + char buf[PROC_NUMBUF];
22004 + unsigned int nr_nids, i;
22007 + pos = filp->f_pos;
22010 + ino = inode->i_ino;
22011 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22014 + /* fall through */
22016 + ino = parent_ino(dentry);
22017 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22020 + /* fall through */
22023 + if (index >= size)
22025 + for (p += index; p->name; p++) {
22026 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22027 + vs_proc_instantiate, 0, p))
22032 + index = pos - size;
22033 + p = &nx_virtnet_stuff[size - 1];
22034 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
22035 + for (i = 0; i < nr_nids; i++) {
22036 + int n, nid = nid_array[i];
22037 + unsigned int j = PROC_NUMBUF;
22041 + buf[--j] = '0' + (n % 10);
22044 + if (proc_fill_cache(filp, dirent, filldir,
22045 + buf + j, PROC_NUMBUF - j,
22046 + vs_proc_instantiate, nid, p))
22052 + filp->f_pos = pos;
22056 +static int proc_virtnet_getattr(struct vfsmount *mnt,
22057 + struct dentry *dentry, struct kstat *stat)
22059 + struct inode *inode = dentry->d_inode;
22061 + generic_fillattr(inode, stat);
22062 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
22066 +static struct file_operations proc_virtnet_dir_operations = {
22067 + .read = generic_read_dir,
22068 + .readdir = proc_virtnet_readdir,
22071 +static struct inode_operations proc_virtnet_dir_inode_operations = {
22072 + .getattr = proc_virtnet_getattr,
22073 + .lookup = proc_virtnet_lookup,
22078 +void proc_vx_init(void)
22080 + struct proc_dir_entry *ent;
22082 + ent = proc_mkdir("virtual", 0);
22084 + ent->proc_fops = &proc_virtual_dir_operations;
22085 + ent->proc_iops = &proc_virtual_dir_inode_operations;
22087 + proc_virtual = ent;
22089 + ent = proc_mkdir("virtnet", 0);
22091 + ent->proc_fops = &proc_virtnet_dir_operations;
22092 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
22094 + proc_virtnet = ent;
22100 +/* per pid info */
22103 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
22105 + struct vx_info *vxi;
22106 + char *orig = buffer;
22108 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
22110 + vxi = task_get_vx_info(p);
22114 + buffer += sprintf(buffer, "BCaps:\t");
22115 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
22116 + buffer += sprintf(buffer, "\n");
22117 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
22118 + (unsigned long long)vxi->vx_ccaps);
22119 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
22120 + (unsigned long long)vxi->vx_flags);
22121 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
22123 + put_vx_info(vxi);
22125 + return buffer - orig;
22129 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
22131 + struct nx_info *nxi;
22132 + struct nx_addr_v4 *v4a;
22133 +#ifdef CONFIG_IPV6
22134 + struct nx_addr_v6 *v6a;
22136 + char *orig = buffer;
22139 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
22141 + nxi = task_get_nx_info(p);
22145 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
22146 + (unsigned long long)nxi->nx_ncaps);
22147 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
22148 + (unsigned long long)nxi->nx_flags);
22150 + buffer += sprintf(buffer,
22151 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
22152 + NIPQUAD(nxi->v4_bcast.s_addr));
22153 + buffer += sprintf (buffer,
22154 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
22155 + NIPQUAD(nxi->v4_lback.s_addr));
22156 + if (!NX_IPV4(nxi))
22158 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
22159 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
22162 +#ifdef CONFIG_IPV6
22163 + if (!NX_IPV6(nxi))
22165 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
22166 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
22170 + put_nx_info(nxi);
22172 + return buffer - orig;
22175 diff -NurpP --minimal linux-3.1.6/kernel/vserver/sched.c linux-3.1.6-vs2.3.2.5/kernel/vserver/sched.c
22176 --- linux-3.1.6/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
22177 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/sched.c 2011-10-24 18:53:33.000000000 +0200
22180 + * linux/kernel/vserver/sched.c
22182 + * Virtual Server: Scheduler Support
22184 + * Copyright (C) 2004-2010 Herbert Pötzl
22186 + * V0.01 adapted Sam Vilains version to 2.6.3
22187 + * V0.02 removed legacy interface
22188 + * V0.03 changed vcmds to vxi arg
22189 + * V0.04 removed older and legacy interfaces
22190 + * V0.05 removed scheduler code/commands
22194 +#include <linux/vs_context.h>
22195 +#include <linux/vs_sched.h>
22196 +#include <linux/vserver/sched_cmd.h>
22198 +#include <asm/uaccess.h>
22201 +void vx_update_sched_param(struct _vx_sched *sched,
22202 + struct _vx_sched_pc *sched_pc)
22204 + sched_pc->prio_bias = sched->prio_bias;
22207 +static int do_set_prio_bias(struct vx_info *vxi, struct vcmd_prio_bias *data)
22211 + if (data->prio_bias > MAX_PRIO_BIAS)
22212 + data->prio_bias = MAX_PRIO_BIAS;
22213 + if (data->prio_bias < MIN_PRIO_BIAS)
22214 + data->prio_bias = MIN_PRIO_BIAS;
22216 + if (data->cpu_id != ~0) {
22217 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
22218 + cpus_and(vxi->sched.update, cpu_online_map,
22219 + vxi->sched.update);
22221 + vxi->sched.update = cpu_online_map;
22223 + for_each_cpu_mask(cpu, vxi->sched.update)
22224 + vx_update_sched_param(&vxi->sched,
22225 + &vx_per_cpu(vxi, sched_pc, cpu));
22229 +int vc_set_prio_bias(struct vx_info *vxi, void __user *data)
22231 + struct vcmd_prio_bias vc_data;
22233 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22236 + return do_set_prio_bias(vxi, &vc_data);
22239 +int vc_get_prio_bias(struct vx_info *vxi, void __user *data)
22241 + struct vcmd_prio_bias vc_data;
22242 + struct _vx_sched_pc *pcd;
22245 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22248 + cpu = vc_data.cpu_id;
22250 + if (!cpu_possible(cpu))
22253 + pcd = &vx_per_cpu(vxi, sched_pc, cpu);
22254 + vc_data.prio_bias = pcd->prio_bias;
22256 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22261 diff -NurpP --minimal linux-3.1.6/kernel/vserver/sched_init.h linux-3.1.6-vs2.3.2.5/kernel/vserver/sched_init.h
22262 --- linux-3.1.6/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
22263 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/sched_init.h 2011-10-24 18:53:33.000000000 +0200
22266 +static inline void vx_info_init_sched(struct _vx_sched *sched)
22268 + /* scheduling; hard code starting values as constants */
22269 + sched->prio_bias = 0;
22273 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22275 + sched_pc->prio_bias = 0;
22277 + sched_pc->user_ticks = 0;
22278 + sched_pc->sys_ticks = 0;
22279 + sched_pc->hold_ticks = 0;
22282 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
22288 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22292 diff -NurpP --minimal linux-3.1.6/kernel/vserver/sched_proc.h linux-3.1.6-vs2.3.2.5/kernel/vserver/sched_proc.h
22293 --- linux-3.1.6/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
22294 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/sched_proc.h 2011-10-24 18:53:33.000000000 +0200
22296 +#ifndef _VX_SCHED_PROC_H
22297 +#define _VX_SCHED_PROC_H
22301 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
22305 + length += sprintf(buffer,
22306 + "PrioBias:\t%8d\n",
22307 + sched->prio_bias);
22312 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
22313 + char *buffer, int cpu)
22317 + length += sprintf(buffer + length,
22318 + "cpu %d: %lld %lld %lld", cpu,
22319 + (unsigned long long)sched_pc->user_ticks,
22320 + (unsigned long long)sched_pc->sys_ticks,
22321 + (unsigned long long)sched_pc->hold_ticks);
22322 + length += sprintf(buffer + length,
22323 + " %d\n", sched_pc->prio_bias);
22327 +#endif /* _VX_SCHED_PROC_H */
22328 diff -NurpP --minimal linux-3.1.6/kernel/vserver/signal.c linux-3.1.6-vs2.3.2.5/kernel/vserver/signal.c
22329 --- linux-3.1.6/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
22330 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/signal.c 2011-10-24 18:53:33.000000000 +0200
22333 + * linux/kernel/vserver/signal.c
22335 + * Virtual Server: Signal Support
22337 + * Copyright (C) 2003-2007 Herbert Pötzl
22339 + * V0.01 broken out from vcontext V0.05
22340 + * V0.02 changed vcmds to vxi arg
22341 + * V0.03 adjusted siginfo for kill
22345 +#include <asm/uaccess.h>
22347 +#include <linux/vs_context.h>
22348 +#include <linux/vs_pid.h>
22349 +#include <linux/vserver/signal_cmd.h>
22352 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
22354 + int retval, count = 0;
22355 + struct task_struct *p;
22356 + struct siginfo *sip = SEND_SIG_PRIV;
22359 + vxdprintk(VXD_CBIT(misc, 4),
22360 + "vx_info_kill(%p[#%d],%d,%d)*",
22361 + vxi, vxi->vx_id, pid, sig);
22362 + read_lock(&tasklist_lock);
22366 + for_each_process(p) {
22369 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
22370 + (pid && vxi->vx_initpid == p->pid))
22373 + err = group_send_sig_info(sig, sip, p);
22375 + if (err != -EPERM)
22381 + if (vxi->vx_initpid) {
22382 + pid = vxi->vx_initpid;
22383 + /* for now, only SIGINT to private init ... */
22384 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22385 + /* ... as long as there are tasks left */
22386 + (atomic_read(&vxi->vx_tasks) > 1))
22389 + /* fallthrough */
22392 + p = find_task_by_real_pid(pid);
22393 + rcu_read_unlock();
22395 + if (vx_task_xid(p) == vxi->vx_id)
22396 + retval = group_send_sig_info(sig, sip, p);
22400 + read_unlock(&tasklist_lock);
22401 + vxdprintk(VXD_CBIT(misc, 4),
22402 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
22403 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
22407 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
22409 + struct vcmd_ctx_kill_v0 vc_data;
22411 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22414 + /* special check to allow guest shutdown */
22415 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22416 + /* forbid killall pid=0 when init is present */
22417 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
22418 + (vc_data.pid > 1)))
22421 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
22425 +static int __wait_exit(struct vx_info *vxi)
22427 + DECLARE_WAITQUEUE(wait, current);
22430 + add_wait_queue(&vxi->vx_wait, &wait);
22431 + set_current_state(TASK_INTERRUPTIBLE);
22434 + if (vx_info_state(vxi,
22435 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
22437 + if (signal_pending(current)) {
22438 + ret = -ERESTARTSYS;
22445 + set_current_state(TASK_RUNNING);
22446 + remove_wait_queue(&vxi->vx_wait, &wait);
22452 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
22454 + struct vcmd_wait_exit_v0 vc_data;
22457 + ret = __wait_exit(vxi);
22458 + vc_data.reboot_cmd = vxi->reboot_cmd;
22459 + vc_data.exit_code = vxi->exit_code;
22461 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22466 diff -NurpP --minimal linux-3.1.6/kernel/vserver/space.c linux-3.1.6-vs2.3.2.5/kernel/vserver/space.c
22467 --- linux-3.1.6/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
22468 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/space.c 2011-10-24 18:53:33.000000000 +0200
22471 + * linux/kernel/vserver/space.c
22473 + * Virtual Server: Context Space Support
22475 + * Copyright (C) 2003-2010 Herbert Pötzl
22477 + * V0.01 broken out from context.c 0.07
22478 + * V0.02 added task locking for namespace
22479 + * V0.03 broken out vx_enter_namespace
22480 + * V0.04 added *space support and commands
22481 + * V0.05 added credential support
22485 +#include <linux/utsname.h>
22486 +#include <linux/nsproxy.h>
22487 +#include <linux/err.h>
22488 +#include <linux/fs_struct.h>
22489 +#include <linux/cred.h>
22490 +#include <asm/uaccess.h>
22492 +#include <linux/vs_context.h>
22493 +#include <linux/vserver/space.h>
22494 +#include <linux/vserver/space_cmd.h>
22496 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
22497 +atomic_t vs_global_fs = ATOMIC_INIT(0);
22498 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
22499 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
22500 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
22501 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
22504 +/* namespace functions */
22506 +#include <linux/mnt_namespace.h>
22507 +#include <linux/user_namespace.h>
22508 +#include <linux/pid_namespace.h>
22509 +#include <linux/ipc_namespace.h>
22510 +#include <net/net_namespace.h>
22513 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
22514 + .mask = CLONE_FS |
22516 +#ifdef CONFIG_UTS_NS
22519 +#ifdef CONFIG_IPC_NS
22522 +#ifdef CONFIG_USER_NS
22528 +static const struct vcmd_space_mask_v1 space_mask = {
22529 + .mask = CLONE_FS |
22531 +#ifdef CONFIG_UTS_NS
22534 +#ifdef CONFIG_IPC_NS
22537 +#ifdef CONFIG_USER_NS
22540 +#ifdef CONFIG_PID_NS
22543 +#ifdef CONFIG_NET_NS
22549 +static const struct vcmd_space_mask_v1 default_space_mask = {
22550 + .mask = CLONE_FS |
22552 +#ifdef CONFIG_UTS_NS
22555 +#ifdef CONFIG_IPC_NS
22558 +#ifdef CONFIG_USER_NS
22561 +#ifdef CONFIG_PID_NS
22568 + * build a new nsproxy mix
22569 + * assumes that both proxies are 'const'
22570 + * does not touch nsproxy refcounts
22571 + * will hold a reference on the result.
22574 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
22575 + struct nsproxy *new_nsproxy, unsigned long mask)
22577 + struct mnt_namespace *old_ns;
22578 + struct uts_namespace *old_uts;
22579 + struct ipc_namespace *old_ipc;
22580 +#ifdef CONFIG_PID_NS
22581 + struct pid_namespace *old_pid;
22583 +#ifdef CONFIG_NET_NS
22584 + struct net *old_net;
22586 + struct nsproxy *nsproxy;
22588 + nsproxy = copy_nsproxy(old_nsproxy);
22592 + if (mask & CLONE_NEWNS) {
22593 + old_ns = nsproxy->mnt_ns;
22594 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
22595 + if (nsproxy->mnt_ns)
22596 + get_mnt_ns(nsproxy->mnt_ns);
22600 + if (mask & CLONE_NEWUTS) {
22601 + old_uts = nsproxy->uts_ns;
22602 + nsproxy->uts_ns = new_nsproxy->uts_ns;
22603 + if (nsproxy->uts_ns)
22604 + get_uts_ns(nsproxy->uts_ns);
22608 + if (mask & CLONE_NEWIPC) {
22609 + old_ipc = nsproxy->ipc_ns;
22610 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
22611 + if (nsproxy->ipc_ns)
22612 + get_ipc_ns(nsproxy->ipc_ns);
22616 +#ifdef CONFIG_PID_NS
22617 + if (mask & CLONE_NEWPID) {
22618 + old_pid = nsproxy->pid_ns;
22619 + nsproxy->pid_ns = new_nsproxy->pid_ns;
22620 + if (nsproxy->pid_ns)
22621 + get_pid_ns(nsproxy->pid_ns);
22625 +#ifdef CONFIG_NET_NS
22626 + if (mask & CLONE_NEWNET) {
22627 + old_net = nsproxy->net_ns;
22628 + nsproxy->net_ns = new_nsproxy->net_ns;
22629 + if (nsproxy->net_ns)
22630 + get_net(nsproxy->net_ns);
22635 + put_mnt_ns(old_ns);
22637 + put_uts_ns(old_uts);
22639 + put_ipc_ns(old_ipc);
22640 +#ifdef CONFIG_PID_NS
22642 + put_pid_ns(old_pid);
22644 +#ifdef CONFIG_NET_NS
22646 + put_net(old_net);
22654 + * merge two nsproxy structs into a new one.
22655 + * will hold a reference on the result.
22659 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
22660 + struct nsproxy *proxy, unsigned long mask)
22662 + struct nsproxy null_proxy = { .mnt_ns = NULL };
22668 + /* vs_mix_nsproxy returns with reference */
22669 + return vs_mix_nsproxy(old ? old : &null_proxy,
22672 + get_nsproxy(proxy);
22677 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
22679 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
22680 + struct fs_struct *fs_cur, *fs = NULL;
22681 + struct _vx_space *space;
22682 + int ret, kill = 0;
22684 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
22685 + vxi, vxi->vx_id, mask, index);
22687 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
22690 + if (index >= VX_SPACES)
22693 + space = &vxi->space[index];
22696 + mask = space->vx_nsmask;
22698 + if ((mask & space->vx_nsmask) != mask)
22701 + if (mask & CLONE_FS) {
22702 + fs = copy_fs_struct(space->vx_fs);
22706 + proxy = space->vx_nsproxy;
22708 + vxdprintk(VXD_CBIT(space, 9),
22709 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
22710 + vxi, vxi->vx_id, mask, index, proxy, fs);
22712 + task_lock(current);
22713 + fs_cur = current->fs;
22715 + if (mask & CLONE_FS) {
22716 + spin_lock(&fs_cur->lock);
22717 + current->fs = fs;
22718 + kill = !--fs_cur->users;
22719 + spin_unlock(&fs_cur->lock);
22722 + proxy_cur = current->nsproxy;
22723 + get_nsproxy(proxy_cur);
22724 + task_unlock(current);
22727 + free_fs_struct(fs_cur);
22729 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
22730 + if (IS_ERR(proxy_new)) {
22731 + ret = PTR_ERR(proxy_new);
22735 + proxy_new = xchg(¤t->nsproxy, proxy_new);
22737 + if (mask & CLONE_NEWUSER) {
22738 + struct cred *cred;
22740 + vxdprintk(VXD_CBIT(space, 10),
22741 + "vx_enter_space(%p[#%u],%p) cred (%p,%p)",
22742 + vxi, vxi->vx_id, space->vx_cred,
22743 + current->real_cred, current->cred);
22745 + if (space->vx_cred) {
22746 + cred = __prepare_creds(space->vx_cred);
22748 + commit_creds(cred);
22755 + put_nsproxy(proxy_new);
22758 + put_nsproxy(proxy_cur);
22763 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
22765 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
22766 + struct fs_struct *fs_vxi, *fs;
22767 + struct _vx_space *space;
22768 + int ret, kill = 0;
22770 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
22771 + vxi, vxi->vx_id, mask, index);
22773 + if ((mask & space_mask.mask) != mask)
22776 + if (index >= VX_SPACES)
22779 + space = &vxi->space[index];
22781 + proxy_vxi = space->vx_nsproxy;
22782 + fs_vxi = space->vx_fs;
22784 + if (mask & CLONE_FS) {
22785 + fs = copy_fs_struct(current->fs);
22790 + task_lock(current);
22792 + if (mask & CLONE_FS) {
22793 + spin_lock(&fs_vxi->lock);
22794 + space->vx_fs = fs;
22795 + kill = !--fs_vxi->users;
22796 + spin_unlock(&fs_vxi->lock);
22799 + proxy_cur = current->nsproxy;
22800 + get_nsproxy(proxy_cur);
22801 + task_unlock(current);
22804 + free_fs_struct(fs_vxi);
22806 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
22807 + if (IS_ERR(proxy_new)) {
22808 + ret = PTR_ERR(proxy_new);
22812 + proxy_new = xchg(&space->vx_nsproxy, proxy_new);
22813 + space->vx_nsmask |= mask;
22815 + if (mask & CLONE_NEWUSER) {
22816 + struct cred *cred;
22818 + vxdprintk(VXD_CBIT(space, 10),
22819 + "vx_set_space(%p[#%u],%p) cred (%p,%p)",
22820 + vxi, vxi->vx_id, space->vx_cred,
22821 + current->real_cred, current->cred);
22823 + cred = prepare_creds();
22824 + cred = (struct cred *)xchg(&space->vx_cred, cred);
22826 + abort_creds(cred);
22832 + put_nsproxy(proxy_new);
22835 + put_nsproxy(proxy_cur);
22840 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
22842 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
22844 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22847 + return vx_enter_space(vxi, vc_data.mask, 0);
22850 +int vc_enter_space(struct vx_info *vxi, void __user *data)
22852 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
22854 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22857 + if (vc_data.index >= VX_SPACES)
22860 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
22863 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
22865 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
22867 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22870 + return vx_set_space(vxi, vc_data.mask, 0);
22873 +int vc_set_space(struct vx_info *vxi, void __user *data)
22875 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
22877 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22880 + if (vc_data.index >= VX_SPACES)
22883 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
22886 +int vc_get_space_mask(void __user *data, int type)
22888 + const struct vcmd_space_mask_v1 *mask;
22891 + mask = &space_mask_v0;
22892 + else if (type == 1)
22893 + mask = &space_mask;
22895 + mask = &default_space_mask;
22897 + vxdprintk(VXD_CBIT(space, 10),
22898 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
22900 + if (copy_to_user(data, mask, sizeof(*mask)))
22905 diff -NurpP --minimal linux-3.1.6/kernel/vserver/switch.c linux-3.1.6-vs2.3.2.5/kernel/vserver/switch.c
22906 --- linux-3.1.6/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
22907 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/switch.c 2011-10-24 18:53:33.000000000 +0200
22910 + * linux/kernel/vserver/switch.c
22912 + * Virtual Server: Syscall Switch
22914 + * Copyright (C) 2003-2011 Herbert Pötzl
22916 + * V0.01 syscall switch
22917 + * V0.02 added signal to context
22918 + * V0.03 added rlimit functions
22919 + * V0.04 added iattr, task/xid functions
22920 + * V0.05 added debug/history stuff
22921 + * V0.06 added compat32 layer
22922 + * V0.07 vcmd args and perms
22923 + * V0.08 added status commands
22924 + * V0.09 added tag commands
22925 + * V0.10 added oom bias
22926 + * V0.11 added device commands
22927 + * V0.12 added warn mask
22931 +#include <linux/vs_context.h>
22932 +#include <linux/vs_network.h>
22933 +#include <linux/vserver/switch.h>
22935 +#include "vci_config.h"
22939 +int vc_get_version(uint32_t id)
22941 + return VCI_VERSION;
22945 +int vc_get_vci(uint32_t id)
22947 + return vci_kernel_config();
22950 +#include <linux/vserver/context_cmd.h>
22951 +#include <linux/vserver/cvirt_cmd.h>
22952 +#include <linux/vserver/cacct_cmd.h>
22953 +#include <linux/vserver/limit_cmd.h>
22954 +#include <linux/vserver/network_cmd.h>
22955 +#include <linux/vserver/sched_cmd.h>
22956 +#include <linux/vserver/debug_cmd.h>
22957 +#include <linux/vserver/inode_cmd.h>
22958 +#include <linux/vserver/dlimit_cmd.h>
22959 +#include <linux/vserver/signal_cmd.h>
22960 +#include <linux/vserver/space_cmd.h>
22961 +#include <linux/vserver/tag_cmd.h>
22962 +#include <linux/vserver/device_cmd.h>
22964 +#include <linux/vserver/inode.h>
22965 +#include <linux/vserver/dlimit.h>
22968 +#ifdef CONFIG_COMPAT
22969 +#define __COMPAT(name, id, data, compat) \
22970 + (compat) ? name ## _x32(id, data) : name(id, data)
22971 +#define __COMPAT_NO_ID(name, data, compat) \
22972 + (compat) ? name ## _x32(data) : name(data)
22974 +#define __COMPAT(name, id, data, compat) \
22976 +#define __COMPAT_NO_ID(name, data, compat) \
22982 +long do_vcmd(uint32_t cmd, uint32_t id,
22983 + struct vx_info *vxi, struct nx_info *nxi,
22984 + void __user *data, int compat)
22988 + case VCMD_get_version:
22989 + return vc_get_version(id);
22990 + case VCMD_get_vci:
22991 + return vc_get_vci(id);
22993 + case VCMD_task_xid:
22994 + return vc_task_xid(id);
22995 + case VCMD_vx_info:
22996 + return vc_vx_info(vxi, data);
22998 + case VCMD_task_nid:
22999 + return vc_task_nid(id);
23000 + case VCMD_nx_info:
23001 + return vc_nx_info(nxi, data);
23003 + case VCMD_task_tag:
23004 + return vc_task_tag(id);
23006 + case VCMD_set_space_v1:
23007 + return vc_set_space_v1(vxi, data);
23008 + /* this is version 2 */
23009 + case VCMD_set_space:
23010 + return vc_set_space(vxi, data);
23012 + case VCMD_get_space_mask_v0:
23013 + return vc_get_space_mask(data, 0);
23014 + /* this is version 1 */
23015 + case VCMD_get_space_mask:
23016 + return vc_get_space_mask(data, 1);
23018 + case VCMD_get_space_default:
23019 + return vc_get_space_mask(data, -1);
23021 + case VCMD_set_umask:
23022 + return vc_set_umask(vxi, data);
23024 + case VCMD_get_umask:
23025 + return vc_get_umask(vxi, data);
23027 + case VCMD_set_wmask:
23028 + return vc_set_wmask(vxi, data);
23030 + case VCMD_get_wmask:
23031 + return vc_get_wmask(vxi, data);
23032 +#ifdef CONFIG_IA32_EMULATION
23033 + case VCMD_get_rlimit:
23034 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
23035 + case VCMD_set_rlimit:
23036 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
23038 + case VCMD_get_rlimit:
23039 + return vc_get_rlimit(vxi, data);
23040 + case VCMD_set_rlimit:
23041 + return vc_set_rlimit(vxi, data);
23043 + case VCMD_get_rlimit_mask:
23044 + return vc_get_rlimit_mask(id, data);
23045 + case VCMD_reset_hits:
23046 + return vc_reset_hits(vxi, data);
23047 + case VCMD_reset_minmax:
23048 + return vc_reset_minmax(vxi, data);
23050 + case VCMD_get_vhi_name:
23051 + return vc_get_vhi_name(vxi, data);
23052 + case VCMD_set_vhi_name:
23053 + return vc_set_vhi_name(vxi, data);
23055 + case VCMD_ctx_stat:
23056 + return vc_ctx_stat(vxi, data);
23057 + case VCMD_virt_stat:
23058 + return vc_virt_stat(vxi, data);
23059 + case VCMD_sock_stat:
23060 + return vc_sock_stat(vxi, data);
23061 + case VCMD_rlimit_stat:
23062 + return vc_rlimit_stat(vxi, data);
23064 + case VCMD_set_cflags:
23065 + return vc_set_cflags(vxi, data);
23066 + case VCMD_get_cflags:
23067 + return vc_get_cflags(vxi, data);
23069 + /* this is version 1 */
23070 + case VCMD_set_ccaps:
23071 + return vc_set_ccaps(vxi, data);
23072 + /* this is version 1 */
23073 + case VCMD_get_ccaps:
23074 + return vc_get_ccaps(vxi, data);
23075 + case VCMD_set_bcaps:
23076 + return vc_set_bcaps(vxi, data);
23077 + case VCMD_get_bcaps:
23078 + return vc_get_bcaps(vxi, data);
23080 + case VCMD_set_badness:
23081 + return vc_set_badness(vxi, data);
23082 + case VCMD_get_badness:
23083 + return vc_get_badness(vxi, data);
23085 + case VCMD_set_nflags:
23086 + return vc_set_nflags(nxi, data);
23087 + case VCMD_get_nflags:
23088 + return vc_get_nflags(nxi, data);
23090 + case VCMD_set_ncaps:
23091 + return vc_set_ncaps(nxi, data);
23092 + case VCMD_get_ncaps:
23093 + return vc_get_ncaps(nxi, data);
23095 + case VCMD_set_prio_bias:
23096 + return vc_set_prio_bias(vxi, data);
23097 + case VCMD_get_prio_bias:
23098 + return vc_get_prio_bias(vxi, data);
23099 + case VCMD_add_dlimit:
23100 + return __COMPAT(vc_add_dlimit, id, data, compat);
23101 + case VCMD_rem_dlimit:
23102 + return __COMPAT(vc_rem_dlimit, id, data, compat);
23103 + case VCMD_set_dlimit:
23104 + return __COMPAT(vc_set_dlimit, id, data, compat);
23105 + case VCMD_get_dlimit:
23106 + return __COMPAT(vc_get_dlimit, id, data, compat);
23108 + case VCMD_ctx_kill:
23109 + return vc_ctx_kill(vxi, data);
23111 + case VCMD_wait_exit:
23112 + return vc_wait_exit(vxi, data);
23114 + case VCMD_get_iattr:
23115 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
23116 + case VCMD_set_iattr:
23117 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
23119 + case VCMD_fget_iattr:
23120 + return vc_fget_iattr(id, data);
23121 + case VCMD_fset_iattr:
23122 + return vc_fset_iattr(id, data);
23124 + case VCMD_enter_space_v0:
23125 + return vc_enter_space_v1(vxi, NULL);
23126 + case VCMD_enter_space_v1:
23127 + return vc_enter_space_v1(vxi, data);
23128 + /* this is version 2 */
23129 + case VCMD_enter_space:
23130 + return vc_enter_space(vxi, data);
23132 + case VCMD_ctx_create_v0:
23133 + return vc_ctx_create(id, NULL);
23134 + case VCMD_ctx_create:
23135 + return vc_ctx_create(id, data);
23136 + case VCMD_ctx_migrate_v0:
23137 + return vc_ctx_migrate(vxi, NULL);
23138 + case VCMD_ctx_migrate:
23139 + return vc_ctx_migrate(vxi, data);
23141 + case VCMD_net_create_v0:
23142 + return vc_net_create(id, NULL);
23143 + case VCMD_net_create:
23144 + return vc_net_create(id, data);
23145 + case VCMD_net_migrate:
23146 + return vc_net_migrate(nxi, data);
23148 + case VCMD_tag_migrate:
23149 + return vc_tag_migrate(id);
23151 + case VCMD_net_add:
23152 + return vc_net_add(nxi, data);
23153 + case VCMD_net_remove:
23154 + return vc_net_remove(nxi, data);
23156 + case VCMD_net_add_ipv4_v1:
23157 + return vc_net_add_ipv4_v1(nxi, data);
23158 + /* this is version 2 */
23159 + case VCMD_net_add_ipv4:
23160 + return vc_net_add_ipv4(nxi, data);
23162 + case VCMD_net_rem_ipv4_v1:
23163 + return vc_net_rem_ipv4_v1(nxi, data);
23164 + /* this is version 2 */
23165 + case VCMD_net_rem_ipv4:
23166 + return vc_net_rem_ipv4(nxi, data);
23167 +#ifdef CONFIG_IPV6
23168 + case VCMD_net_add_ipv6:
23169 + return vc_net_add_ipv6(nxi, data);
23170 + case VCMD_net_remove_ipv6:
23171 + return vc_net_remove_ipv6(nxi, data);
23173 +/* case VCMD_add_match_ipv4:
23174 + return vc_add_match_ipv4(nxi, data);
23175 + case VCMD_get_match_ipv4:
23176 + return vc_get_match_ipv4(nxi, data);
23177 +#ifdef CONFIG_IPV6
23178 + case VCMD_add_match_ipv6:
23179 + return vc_add_match_ipv6(nxi, data);
23180 + case VCMD_get_match_ipv6:
23181 + return vc_get_match_ipv6(nxi, data);
23184 +#ifdef CONFIG_VSERVER_DEVICE
23185 + case VCMD_set_mapping:
23186 + return __COMPAT(vc_set_mapping, vxi, data, compat);
23187 + case VCMD_unset_mapping:
23188 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
23190 +#ifdef CONFIG_VSERVER_HISTORY
23191 + case VCMD_dump_history:
23192 + return vc_dump_history(id);
23193 + case VCMD_read_history:
23194 + return __COMPAT(vc_read_history, id, data, compat);
23197 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
23198 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
23204 +#define __VCMD(vcmd, _perm, _args, _flags) \
23205 + case VCMD_ ## vcmd: perm = _perm; \
23206 + args = _args; flags = _flags; break
23209 +#define VCA_NONE 0x00
23210 +#define VCA_VXI 0x01
23211 +#define VCA_NXI 0x02
23213 +#define VCF_NONE 0x00
23214 +#define VCF_INFO 0x01
23215 +#define VCF_ADMIN 0x02
23216 +#define VCF_ARES 0x06 /* includes admin */
23217 +#define VCF_SETUP 0x08
23219 +#define VCF_ZIDOK 0x10 /* zero id okay */
23223 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
23226 + int permit = -1, state = 0;
23227 + int perm = -1, args = 0, flags = 0;
23228 + struct vx_info *vxi = NULL;
23229 + struct nx_info *nxi = NULL;
23232 + /* unpriviledged commands */
23233 + __VCMD(get_version, 0, VCA_NONE, 0);
23234 + __VCMD(get_vci, 0, VCA_NONE, 0);
23235 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
23236 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
23237 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
23238 + __VCMD(get_space_default,0, VCA_NONE, 0);
23240 + /* info commands */
23241 + __VCMD(task_xid, 2, VCA_NONE, 0);
23242 + __VCMD(reset_hits, 2, VCA_VXI, 0);
23243 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
23244 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
23245 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
23246 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
23247 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
23248 + __VCMD(get_umask, 3, VCA_VXI, VCF_INFO);
23249 + __VCMD(get_wmask, 3, VCA_VXI, VCF_INFO);
23250 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
23251 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
23252 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
23254 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
23255 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
23256 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
23257 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
23259 + __VCMD(task_nid, 2, VCA_NONE, 0);
23260 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
23261 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
23262 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
23264 + __VCMD(task_tag, 2, VCA_NONE, 0);
23266 + __VCMD(get_iattr, 2, VCA_NONE, 0);
23267 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
23268 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
23269 + __VCMD(get_prio_bias, 3, VCA_VXI, VCF_INFO);
23271 + /* lower admin commands */
23272 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
23273 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
23274 + __VCMD(ctx_create, 5, VCA_NONE, 0);
23275 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
23276 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
23277 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
23278 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
23279 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
23281 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
23282 + __VCMD(net_create, 5, VCA_NONE, 0);
23283 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
23285 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
23287 + /* higher admin commands */
23288 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
23289 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23290 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23292 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23293 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23294 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23295 + __VCMD(set_umask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23296 + __VCMD(set_wmask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23297 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23299 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23300 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23301 + __VCMD(set_prio_bias, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23303 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23304 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23305 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23306 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23307 + __VCMD(net_add_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23308 + __VCMD(net_rem_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23309 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23310 + __VCMD(net_rem_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23311 +#ifdef CONFIG_IPV6
23312 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23313 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23315 + __VCMD(set_iattr, 7, VCA_NONE, 0);
23316 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
23317 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
23318 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
23319 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
23321 +#ifdef CONFIG_VSERVER_DEVICE
23322 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23323 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23325 + /* debug level admin commands */
23326 +#ifdef CONFIG_VSERVER_HISTORY
23327 + __VCMD(dump_history, 9, VCA_NONE, 0);
23328 + __VCMD(read_history, 9, VCA_NONE, 0);
23335 + vxdprintk(VXD_CBIT(switch, 0),
23336 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
23337 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23338 + VC_VERSION(cmd), id, data, compat,
23339 + perm, args, flags);
23346 + if (!capable(CAP_CONTEXT))
23350 + /* moved here from the individual commands */
23352 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
23356 + /* vcmd involves resource management */
23358 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
23362 + /* various legacy exceptions */
23364 + /* will go away when spectator is a cap */
23365 + case VCMD_ctx_migrate_v0:
23366 + case VCMD_ctx_migrate:
23368 + current->xid = 1;
23374 + /* will go away when spectator is a cap */
23375 + case VCMD_net_migrate:
23377 + current->nid = 1;
23384 + /* vcmds are fine by default */
23387 + /* admin type vcmds require admin ... */
23388 + if (flags & VCF_ADMIN)
23389 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
23391 + /* ... but setup type vcmds override that */
23392 + if (!permit && (flags & VCF_SETUP))
23393 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
23401 + if (!id && (flags & VCF_ZIDOK))
23405 + if (args & VCA_VXI) {
23406 + vxi = lookup_vx_info(id);
23410 + if ((flags & VCF_ADMIN) &&
23411 + /* special case kill for shutdown */
23412 + (cmd != VCMD_ctx_kill) &&
23413 + /* can context be administrated? */
23414 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
23420 + if (args & VCA_NXI) {
23421 + nxi = lookup_nx_info(id);
23425 + if ((flags & VCF_ADMIN) &&
23426 + /* can context be administrated? */
23427 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
23434 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
23437 + if ((args & VCA_NXI) && nxi)
23438 + put_nx_info(nxi);
23440 + if ((args & VCA_VXI) && vxi)
23441 + put_vx_info(vxi);
23443 + vxdprintk(VXD_CBIT(switch, 1),
23444 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
23445 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23446 + VC_VERSION(cmd), ret, ret, state, permit);
23451 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
23453 + return do_vserver(cmd, id, data, 0);
23456 +#ifdef CONFIG_COMPAT
23459 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
23461 + return do_vserver(cmd, id, data, 1);
23464 +#endif /* CONFIG_COMPAT */
23465 diff -NurpP --minimal linux-3.1.6/kernel/vserver/sysctl.c linux-3.1.6-vs2.3.2.5/kernel/vserver/sysctl.c
23466 --- linux-3.1.6/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
23467 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/sysctl.c 2011-11-18 00:40:25.000000000 +0100
23470 + * kernel/vserver/sysctl.c
23472 + * Virtual Context Support
23474 + * Copyright (C) 2004-2007 Herbert Pötzl
23476 + * V0.01 basic structure
23480 +#include <linux/module.h>
23481 +#include <linux/ctype.h>
23482 +#include <linux/sysctl.h>
23483 +#include <linux/parser.h>
23484 +#include <asm/uaccess.h>
23487 + CTL_DEBUG_ERROR = 0,
23488 + CTL_DEBUG_SWITCH = 1,
23504 +unsigned int vs_debug_switch = 0;
23505 +unsigned int vs_debug_xid = 0;
23506 +unsigned int vs_debug_nid = 0;
23507 +unsigned int vs_debug_tag = 0;
23508 +unsigned int vs_debug_net = 0;
23509 +unsigned int vs_debug_limit = 0;
23510 +unsigned int vs_debug_cres = 0;
23511 +unsigned int vs_debug_dlim = 0;
23512 +unsigned int vs_debug_quota = 0;
23513 +unsigned int vs_debug_cvirt = 0;
23514 +unsigned int vs_debug_space = 0;
23515 +unsigned int vs_debug_perm = 0;
23516 +unsigned int vs_debug_misc = 0;
23519 +static struct ctl_table_header *vserver_table_header;
23520 +static ctl_table vserver_root_table[];
23523 +void vserver_register_sysctl(void)
23525 + if (!vserver_table_header) {
23526 + vserver_table_header = register_sysctl_table(vserver_root_table);
23531 +void vserver_unregister_sysctl(void)
23533 + if (vserver_table_header) {
23534 + unregister_sysctl_table(vserver_table_header);
23535 + vserver_table_header = NULL;
23540 +static int proc_dodebug(ctl_table *table, int write,
23541 + void __user *buffer, size_t *lenp, loff_t *ppos)
23543 + char tmpbuf[20], *p, c;
23544 + unsigned int value;
23545 + size_t left, len;
23547 + if ((*ppos && !write) || !*lenp) {
23555 + if (!access_ok(VERIFY_READ, buffer, left))
23557 + p = (char *)buffer;
23558 + while (left && __get_user(c, p) >= 0 && isspace(c))
23563 + if (left > sizeof(tmpbuf) - 1)
23565 + if (copy_from_user(tmpbuf, p, left))
23567 + tmpbuf[left] = '\0';
23569 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
23570 + value = 10 * value + (*p - '0');
23571 + if (*p && !isspace(*p))
23573 + while (left && isspace(*p))
23575 + *(unsigned int *)table->data = value;
23577 + if (!access_ok(VERIFY_WRITE, buffer, left))
23579 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
23582 + if (__copy_to_user(buffer, tmpbuf, len))
23584 + if ((left -= len) > 0) {
23585 + if (put_user('\n', (char *)buffer + len))
23599 +#define CTL_ENTRY(ctl, name) \
23601 + .procname = #name, \
23602 + .data = &vs_ ## name, \
23603 + .maxlen = sizeof(int), \
23605 + .proc_handler = &proc_dodebug, \
23606 + .extra1 = &zero, \
23607 + .extra2 = &zero, \
23610 +static ctl_table vserver_debug_table[] = {
23611 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
23612 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
23613 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
23614 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
23615 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
23616 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
23617 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
23618 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
23619 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
23620 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
23621 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
23622 + CTL_ENTRY(CTL_DEBUG_PERM, debug_perm),
23623 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
23627 +static ctl_table vserver_root_table[] = {
23629 + .procname = "vserver",
23631 + .child = vserver_debug_table
23637 +static match_table_t tokens = {
23638 + { CTL_DEBUG_SWITCH, "switch=%x" },
23639 + { CTL_DEBUG_XID, "xid=%x" },
23640 + { CTL_DEBUG_NID, "nid=%x" },
23641 + { CTL_DEBUG_TAG, "tag=%x" },
23642 + { CTL_DEBUG_NET, "net=%x" },
23643 + { CTL_DEBUG_LIMIT, "limit=%x" },
23644 + { CTL_DEBUG_CRES, "cres=%x" },
23645 + { CTL_DEBUG_DLIM, "dlim=%x" },
23646 + { CTL_DEBUG_QUOTA, "quota=%x" },
23647 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
23648 + { CTL_DEBUG_SPACE, "space=%x" },
23649 + { CTL_DEBUG_PERM, "perm=%x" },
23650 + { CTL_DEBUG_MISC, "misc=%x" },
23651 + { CTL_DEBUG_ERROR, NULL }
23654 +#define HANDLE_CASE(id, name, val) \
23655 + case CTL_DEBUG_ ## id: \
23656 + vs_debug_ ## name = val; \
23657 + printk("vs_debug_" #name "=0x%x\n", val); \
23661 +static int __init vs_debug_setup(char *str)
23666 + printk("vs_debug_setup(%s)\n", str);
23667 + while ((p = strsep(&str, ",")) != NULL) {
23668 + substring_t args[MAX_OPT_ARGS];
23669 + unsigned int value;
23674 + token = match_token(p, tokens, args);
23675 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
23678 + HANDLE_CASE(SWITCH, switch, value);
23679 + HANDLE_CASE(XID, xid, value);
23680 + HANDLE_CASE(NID, nid, value);
23681 + HANDLE_CASE(TAG, tag, value);
23682 + HANDLE_CASE(NET, net, value);
23683 + HANDLE_CASE(LIMIT, limit, value);
23684 + HANDLE_CASE(CRES, cres, value);
23685 + HANDLE_CASE(DLIM, dlim, value);
23686 + HANDLE_CASE(QUOTA, quota, value);
23687 + HANDLE_CASE(CVIRT, cvirt, value);
23688 + HANDLE_CASE(SPACE, space, value);
23689 + HANDLE_CASE(PERM, perm, value);
23690 + HANDLE_CASE(MISC, misc, value);
23699 +__setup("vsdebug=", vs_debug_setup);
23703 +EXPORT_SYMBOL_GPL(vs_debug_switch);
23704 +EXPORT_SYMBOL_GPL(vs_debug_xid);
23705 +EXPORT_SYMBOL_GPL(vs_debug_nid);
23706 +EXPORT_SYMBOL_GPL(vs_debug_net);
23707 +EXPORT_SYMBOL_GPL(vs_debug_limit);
23708 +EXPORT_SYMBOL_GPL(vs_debug_cres);
23709 +EXPORT_SYMBOL_GPL(vs_debug_dlim);
23710 +EXPORT_SYMBOL_GPL(vs_debug_quota);
23711 +EXPORT_SYMBOL_GPL(vs_debug_cvirt);
23712 +EXPORT_SYMBOL_GPL(vs_debug_space);
23713 +EXPORT_SYMBOL_GPL(vs_debug_perm);
23714 +EXPORT_SYMBOL_GPL(vs_debug_misc);
23716 diff -NurpP --minimal linux-3.1.6/kernel/vserver/tag.c linux-3.1.6-vs2.3.2.5/kernel/vserver/tag.c
23717 --- linux-3.1.6/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
23718 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/tag.c 2011-10-24 18:53:33.000000000 +0200
23721 + * linux/kernel/vserver/tag.c
23723 + * Virtual Server: Shallow Tag Space
23725 + * Copyright (C) 2007 Herbert Pötzl
23727 + * V0.01 basic implementation
23731 +#include <linux/sched.h>
23732 +#include <linux/vserver/debug.h>
23733 +#include <linux/vs_pid.h>
23734 +#include <linux/vs_tag.h>
23736 +#include <linux/vserver/tag_cmd.h>
23739 +int dx_migrate_task(struct task_struct *p, tag_t tag)
23744 + vxdprintk(VXD_CBIT(tag, 5),
23745 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
23751 + vxdprintk(VXD_CBIT(tag, 5),
23752 + "moved task %p into [#%d]", p, tag);
23756 +/* vserver syscall commands below here */
23758 +/* taks xid and vx_info functions */
23761 +int vc_task_tag(uint32_t id)
23766 + struct task_struct *tsk;
23768 + tsk = find_task_by_real_pid(id);
23769 + tag = (tsk) ? tsk->tag : -ESRCH;
23770 + rcu_read_unlock();
23772 + tag = dx_current_tag();
23777 +int vc_tag_migrate(uint32_t tag)
23779 + return dx_migrate_task(current, tag & 0xFFFF);
23783 diff -NurpP --minimal linux-3.1.6/kernel/vserver/vci_config.h linux-3.1.6-vs2.3.2.5/kernel/vserver/vci_config.h
23784 --- linux-3.1.6/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
23785 +++ linux-3.1.6-vs2.3.2.5/kernel/vserver/vci_config.h 2011-10-24 18:53:33.000000000 +0200
23788 +/* interface version */
23790 +#define VCI_VERSION 0x00020308
23794 + VCI_KCBIT_NO_DYNAMIC = 0,
23796 + VCI_KCBIT_PROC_SECURE = 4,
23797 + /* VCI_KCBIT_HARDCPU = 5, */
23798 + /* VCI_KCBIT_IDLELIMIT = 6, */
23799 + /* VCI_KCBIT_IDLETIME = 7, */
23801 + VCI_KCBIT_COWBL = 8,
23802 + VCI_KCBIT_FULLCOWBL = 9,
23803 + VCI_KCBIT_SPACES = 10,
23804 + VCI_KCBIT_NETV2 = 11,
23805 + VCI_KCBIT_MEMCG = 12,
23807 + VCI_KCBIT_DEBUG = 16,
23808 + VCI_KCBIT_HISTORY = 20,
23809 + VCI_KCBIT_TAGGED = 24,
23810 + VCI_KCBIT_PPTAG = 28,
23812 + VCI_KCBIT_MORE = 31,
23816 +static inline uint32_t vci_kernel_config(void)
23819 + (1 << VCI_KCBIT_NO_DYNAMIC) |
23821 + /* configured features */
23822 +#ifdef CONFIG_VSERVER_PROC_SECURE
23823 + (1 << VCI_KCBIT_PROC_SECURE) |
23825 +#ifdef CONFIG_VSERVER_COWBL
23826 + (1 << VCI_KCBIT_COWBL) |
23827 + (1 << VCI_KCBIT_FULLCOWBL) |
23829 + (1 << VCI_KCBIT_SPACES) |
23830 + (1 << VCI_KCBIT_NETV2) |
23831 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
23832 + (1 << VCI_KCBIT_MEMCG) |
23835 + /* debug options */
23836 +#ifdef CONFIG_VSERVER_DEBUG
23837 + (1 << VCI_KCBIT_DEBUG) |
23839 +#ifdef CONFIG_VSERVER_HISTORY
23840 + (1 << VCI_KCBIT_HISTORY) |
23843 + /* inode context tagging */
23844 +#if defined(CONFIG_TAGGING_NONE)
23845 + (0 << VCI_KCBIT_TAGGED) |
23846 +#elif defined(CONFIG_TAGGING_UID16)
23847 + (1 << VCI_KCBIT_TAGGED) |
23848 +#elif defined(CONFIG_TAGGING_GID16)
23849 + (2 << VCI_KCBIT_TAGGED) |
23850 +#elif defined(CONFIG_TAGGING_ID24)
23851 + (3 << VCI_KCBIT_TAGGED) |
23852 +#elif defined(CONFIG_TAGGING_INTERN)
23853 + (4 << VCI_KCBIT_TAGGED) |
23854 +#elif defined(CONFIG_TAGGING_RUNTIME)
23855 + (5 << VCI_KCBIT_TAGGED) |
23857 + (7 << VCI_KCBIT_TAGGED) |
23859 + (1 << VCI_KCBIT_PPTAG) |
23863 diff -NurpP --minimal linux-3.1.6/mm/memcontrol.c linux-3.1.6-vs2.3.2.5/mm/memcontrol.c
23864 --- linux-3.1.6/mm/memcontrol.c 2011-10-24 18:45:33.000000000 +0200
23865 +++ linux-3.1.6-vs2.3.2.5/mm/memcontrol.c 2011-10-24 18:53:33.000000000 +0200
23866 @@ -760,6 +760,31 @@ struct mem_cgroup *mem_cgroup_from_task(
23867 struct mem_cgroup, css);
23870 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
23872 + return res_counter_read_u64(&mem->res, member);
23875 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
23877 + return res_counter_read_u64(&mem->memsw, member);
23880 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
23882 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE);
23885 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
23887 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS);
23890 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
23892 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_FILE_MAPPED);
23895 struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
23897 struct mem_cgroup *mem = NULL;
23898 diff -NurpP --minimal linux-3.1.6/mm/oom_kill.c linux-3.1.6-vs2.3.2.5/mm/oom_kill.c
23899 --- linux-3.1.6/mm/oom_kill.c 2011-10-24 18:45:33.000000000 +0200
23900 +++ linux-3.1.6-vs2.3.2.5/mm/oom_kill.c 2011-12-07 04:20:11.000000000 +0100
23902 #include <linux/mempolicy.h>
23903 #include <linux/security.h>
23904 #include <linux/ptrace.h>
23905 +#include <linux/reboot.h>
23906 +#include <linux/vs_context.h>
23908 int sysctl_panic_on_oom;
23909 int sysctl_oom_kill_allocating_task;
23910 @@ -134,11 +136,18 @@ struct task_struct *find_lock_task_mm(st
23911 static bool oom_unkillable_task(struct task_struct *p,
23912 const struct mem_cgroup *mem, const nodemask_t *nodemask)
23914 - if (is_global_init(p))
23915 + unsigned xid = vx_current_xid();
23917 + /* skip the init task, global and per guest */
23918 + if (task_is_init(p))
23920 if (p->flags & PF_KTHREAD)
23923 + /* skip other guest and host processes if oom in guest */
23924 + if (xid && vx_task_xid(p) != xid)
23927 /* When mem_cgroup_out_of_memory() and p is not member of the group */
23928 if (mem && !task_in_mem_cgroup(p, mem))
23930 @@ -428,8 +437,8 @@ static int oom_kill_task(struct task_str
23931 /* mm cannot be safely dereferenced after task_unlock(p) */
23934 - pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
23935 - task_pid_nr(p), p->comm, K(p->mm->total_vm),
23936 + pr_err("Killed process %d:#%u (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
23937 + task_pid_nr(p), p->xid, p->comm, K(p->mm->total_vm),
23938 K(get_mm_counter(p->mm, MM_ANONPAGES)),
23939 K(get_mm_counter(p->mm, MM_FILEPAGES)));
23941 @@ -483,8 +492,8 @@ static int oom_kill_process(struct task_
23945 - pr_err("%s: Kill process %d (%s) score %d or sacrifice child\n",
23946 - message, task_pid_nr(p), p->comm, points);
23947 + pr_err("%s: Kill process %d:#%u (%s) score %d or sacrifice child\n",
23948 + message, task_pid_nr(p), p->xid, p->comm, points);
23952 @@ -585,6 +594,8 @@ int unregister_oom_notifier(struct notif
23954 EXPORT_SYMBOL_GPL(unregister_oom_notifier);
23956 +long vs_oom_action(unsigned int);
23959 * Try to acquire the OOM killer lock for the zones in zonelist. Returns zero
23960 * if a parallel OOM killing is already taking place that includes a zone in
23961 @@ -743,7 +754,12 @@ retry:
23963 dump_header(NULL, gfp_mask, order, NULL, mpol_mask);
23964 read_unlock(&tasklist_lock);
23965 - panic("Out of memory and no killable processes...\n");
23967 + /* avoid panic for guest OOM */
23968 + if (current->xid)
23969 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
23971 + panic("Out of memory and no killable processes...\n");
23974 if (oom_kill_process(p, gfp_mask, order, points, totalpages, NULL,
23975 diff -NurpP --minimal linux-3.1.6/mm/page_alloc.c linux-3.1.6-vs2.3.2.5/mm/page_alloc.c
23976 --- linux-3.1.6/mm/page_alloc.c 2011-12-23 16:04:07.000000000 +0100
23977 +++ linux-3.1.6-vs2.3.2.5/mm/page_alloc.c 2011-12-23 16:11:57.000000000 +0100
23979 #include <linux/ftrace_event.h>
23980 #include <linux/memcontrol.h>
23981 #include <linux/prefetch.h>
23982 +#include <linux/vs_base.h>
23983 +#include <linux/vs_limit.h>
23985 #include <asm/tlbflush.h>
23986 #include <asm/div64.h>
23987 @@ -2484,6 +2486,9 @@ void si_meminfo(struct sysinfo *val)
23988 val->totalhigh = totalhigh_pages;
23989 val->freehigh = nr_free_highpages();
23990 val->mem_unit = PAGE_SIZE;
23992 + if (vx_flags(VXF_VIRT_MEM, 0))
23993 + vx_vsi_meminfo(val);
23996 EXPORT_SYMBOL(si_meminfo);
23997 @@ -2504,6 +2509,9 @@ void si_meminfo_node(struct sysinfo *val
24000 val->mem_unit = PAGE_SIZE;
24002 + if (vx_flags(VXF_VIRT_MEM, 0))
24003 + vx_vsi_meminfo(val);
24007 diff -NurpP --minimal linux-3.1.6/mm/pgtable-generic.c linux-3.1.6-vs2.3.2.5/mm/pgtable-generic.c
24008 --- linux-3.1.6/mm/pgtable-generic.c 2011-03-15 18:07:42.000000000 +0100
24009 +++ linux-3.1.6-vs2.3.2.5/mm/pgtable-generic.c 2011-10-24 18:53:33.000000000 +0200
24011 * Copyright (C) 2010 Linus Torvalds
24014 +#include <linux/mm.h>
24016 #include <linux/pagemap.h>
24017 #include <asm/tlb.h>
24018 #include <asm-generic/pgtable.h>
24019 diff -NurpP --minimal linux-3.1.6/mm/shmem.c linux-3.1.6-vs2.3.2.5/mm/shmem.c
24020 --- linux-3.1.6/mm/shmem.c 2011-10-24 18:45:33.000000000 +0200
24021 +++ linux-3.1.6-vs2.3.2.5/mm/shmem.c 2011-10-24 18:53:33.000000000 +0200
24022 @@ -1429,7 +1429,7 @@ static int shmem_statfs(struct dentry *d
24024 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
24026 - buf->f_type = TMPFS_MAGIC;
24027 + buf->f_type = TMPFS_SUPER_MAGIC;
24028 buf->f_bsize = PAGE_CACHE_SIZE;
24029 buf->f_namelen = NAME_MAX;
24030 if (sbinfo->max_blocks) {
24031 @@ -2186,7 +2186,7 @@ int shmem_fill_super(struct super_block
24032 sb->s_maxbytes = MAX_LFS_FILESIZE;
24033 sb->s_blocksize = PAGE_CACHE_SIZE;
24034 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
24035 - sb->s_magic = TMPFS_MAGIC;
24036 + sb->s_magic = TMPFS_SUPER_MAGIC;
24037 sb->s_op = &shmem_ops;
24038 sb->s_time_gran = 1;
24039 #ifdef CONFIG_TMPFS_XATTR
24040 diff -NurpP --minimal linux-3.1.6/mm/slab.c linux-3.1.6-vs2.3.2.5/mm/slab.c
24041 --- linux-3.1.6/mm/slab.c 2011-12-23 16:04:07.000000000 +0100
24042 +++ linux-3.1.6-vs2.3.2.5/mm/slab.c 2011-12-15 01:07:58.000000000 +0100
24043 @@ -411,6 +411,8 @@ static void kmem_list3_init(struct kmem_
24044 #define STATS_INC_FREEMISS(x) do { } while (0)
24047 +#include "slab_vs.h"
24052 @@ -3402,6 +3404,7 @@ retry:
24054 obj = slab_get_obj(cachep, slabp, nodeid);
24055 check_slabp(cachep, slabp);
24056 + vx_slab_alloc(cachep, flags);
24057 l3->free_objects--;
24058 /* move slabp to correct slabp list: */
24059 list_del(&slabp->list);
24060 @@ -3479,6 +3482,7 @@ __cache_alloc_node(struct kmem_cache *ca
24061 /* ___cache_alloc_node can fall back to other nodes */
24062 ptr = ____cache_alloc_node(cachep, flags, nodeid);
24064 + vx_slab_alloc(cachep, flags);
24065 local_irq_restore(save_flags);
24066 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
24067 kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
24068 @@ -3666,6 +3670,7 @@ static inline void __cache_free(struct k
24070 kmemleak_free_recursive(objp, cachep->flags);
24071 objp = cache_free_debugcheck(cachep, objp, caller);
24072 + vx_slab_free(cachep);
24074 kmemcheck_slab_free(cachep, objp, obj_size(cachep));
24076 diff -NurpP --minimal linux-3.1.6/mm/slab_vs.h linux-3.1.6-vs2.3.2.5/mm/slab_vs.h
24077 --- linux-3.1.6/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
24078 +++ linux-3.1.6-vs2.3.2.5/mm/slab_vs.h 2011-10-24 18:53:33.000000000 +0200
24081 +#include <linux/vserver/context.h>
24083 +#include <linux/vs_context.h>
24086 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
24088 + int what = gfp_zone(cachep->gfpflags);
24089 + struct vx_info *vxi = current_vx_info();
24094 + atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
24098 +void vx_slab_free(struct kmem_cache *cachep)
24100 + int what = gfp_zone(cachep->gfpflags);
24101 + struct vx_info *vxi = current_vx_info();
24106 + atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
24109 diff -NurpP --minimal linux-3.1.6/mm/swapfile.c linux-3.1.6-vs2.3.2.5/mm/swapfile.c
24110 --- linux-3.1.6/mm/swapfile.c 2011-10-24 18:45:33.000000000 +0200
24111 +++ linux-3.1.6-vs2.3.2.5/mm/swapfile.c 2011-12-07 04:20:21.000000000 +0100
24113 #include <asm/tlbflush.h>
24114 #include <linux/swapops.h>
24115 #include <linux/page_cgroup.h>
24116 +#include <linux/vs_base.h>
24118 static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
24120 @@ -1754,6 +1755,16 @@ static int swap_show(struct seq_file *sw
24122 if (si == SEQ_START_TOKEN) {
24123 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
24124 + if (vx_flags(VXF_VIRT_MEM, 0)) {
24125 + struct sysinfo si;
24127 + vx_vsi_swapinfo(&si);
24128 + if (si.totalswap < (1 << 10))
24130 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
24131 + "hdv0", "partition", si.totalswap >> 10,
24132 + (si.totalswap - si.freeswap) >> 10, -1);
24137 @@ -2177,6 +2188,8 @@ void si_swapinfo(struct sysinfo *val)
24138 val->freeswap = nr_swap_pages + nr_to_be_unused;
24139 val->totalswap = total_swap_pages + nr_to_be_unused;
24140 spin_unlock(&swap_lock);
24141 + if (vx_flags(VXF_VIRT_MEM, 0))
24142 + vx_vsi_swapinfo(val);
24146 diff -NurpP --minimal linux-3.1.6/net/bridge/br_multicast.c linux-3.1.6-vs2.3.2.5/net/bridge/br_multicast.c
24147 --- linux-3.1.6/net/bridge/br_multicast.c 2011-12-23 16:04:07.000000000 +0100
24148 +++ linux-3.1.6-vs2.3.2.5/net/bridge/br_multicast.c 2011-12-15 01:07:58.000000000 +0100
24149 @@ -447,7 +447,7 @@ static struct sk_buff *br_ip6_multicast_
24150 ip6h->hop_limit = 1;
24151 ipv6_addr_set(&ip6h->daddr, htonl(0xff020000), 0, 0, htonl(1));
24152 ipv6_dev_get_saddr(dev_net(br->dev), br->dev, &ip6h->daddr, 0,
24154 + &ip6h->saddr, NULL);
24155 ipv6_eth_mc_map(&ip6h->daddr, eth->h_dest);
24157 hopopt = (u8 *)(ip6h + 1);
24158 diff -NurpP --minimal linux-3.1.6/net/core/dev.c linux-3.1.6-vs2.3.2.5/net/core/dev.c
24159 --- linux-3.1.6/net/core/dev.c 2011-12-23 16:04:07.000000000 +0100
24160 +++ linux-3.1.6-vs2.3.2.5/net/core/dev.c 2011-11-15 17:08:44.000000000 +0100
24161 @@ -127,6 +127,7 @@
24162 #include <linux/in.h>
24163 #include <linux/jhash.h>
24164 #include <linux/random.h>
24165 +#include <linux/vs_inet.h>
24166 #include <trace/events/napi.h>
24167 #include <trace/events/net.h>
24168 #include <trace/events/skb.h>
24169 @@ -619,7 +620,8 @@ struct net_device *__dev_get_by_name(str
24170 struct hlist_head *head = dev_name_hash(net, name);
24172 hlist_for_each_entry(dev, p, head, name_hlist)
24173 - if (!strncmp(dev->name, name, IFNAMSIZ))
24174 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24175 + nx_dev_visible(current_nx_info(), dev))
24179 @@ -645,7 +647,8 @@ struct net_device *dev_get_by_name_rcu(s
24180 struct hlist_head *head = dev_name_hash(net, name);
24182 hlist_for_each_entry_rcu(dev, p, head, name_hlist)
24183 - if (!strncmp(dev->name, name, IFNAMSIZ))
24184 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24185 + nx_dev_visible(current_nx_info(), dev))
24189 @@ -696,7 +699,8 @@ struct net_device *__dev_get_by_index(st
24190 struct hlist_head *head = dev_index_hash(net, ifindex);
24192 hlist_for_each_entry(dev, p, head, index_hlist)
24193 - if (dev->ifindex == ifindex)
24194 + if ((dev->ifindex == ifindex) &&
24195 + nx_dev_visible(current_nx_info(), dev))
24199 @@ -714,7 +718,7 @@ EXPORT_SYMBOL(__dev_get_by_index);
24200 * about locking. The caller must hold RCU lock.
24203 -struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
24204 +struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex)
24206 struct hlist_node *p;
24207 struct net_device *dev;
24208 @@ -726,6 +730,16 @@ struct net_device *dev_get_by_index_rcu(
24212 +EXPORT_SYMBOL(dev_get_by_index_real_rcu);
24214 +struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
24216 + struct net_device *dev = dev_get_by_index_real_rcu(net, ifindex);
24218 + if (nx_dev_visible(current_nx_info(), dev))
24222 EXPORT_SYMBOL(dev_get_by_index_rcu);
24225 @@ -774,7 +788,8 @@ struct net_device *dev_getbyhwaddr_rcu(s
24227 for_each_netdev_rcu(net, dev)
24228 if (dev->type == type &&
24229 - !memcmp(dev->dev_addr, ha, dev->addr_len))
24230 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
24231 + nx_dev_visible(current_nx_info(), dev))
24235 @@ -786,9 +801,11 @@ struct net_device *__dev_getfirstbyhwtyp
24236 struct net_device *dev;
24239 - for_each_netdev(net, dev)
24240 - if (dev->type == type)
24241 + for_each_netdev(net, dev) {
24242 + if ((dev->type == type) &&
24243 + nx_dev_visible(current_nx_info(), dev))
24249 @@ -906,6 +923,8 @@ static int __dev_alloc_name(struct net *
24251 if (i < 0 || i >= max_netdevices)
24253 + if (!nx_dev_visible(current_nx_info(), d))
24256 /* avoid cases where sscanf is not exact inverse of printf */
24257 snprintf(buf, IFNAMSIZ, name, i);
24258 @@ -3955,6 +3974,8 @@ static int dev_ifconf(struct net *net, c
24261 for_each_netdev(net, dev) {
24262 + if (!nx_dev_visible(current_nx_info(), dev))
24264 for (i = 0; i < NPROTO; i++) {
24265 if (gifconf_list[i]) {
24267 @@ -4029,6 +4050,10 @@ static void dev_seq_printf_stats(struct
24268 struct rtnl_link_stats64 temp;
24269 const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
24271 + /* device visible inside network context? */
24272 + if (!nx_dev_visible(current_nx_info(), dev))
24275 seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
24276 "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
24277 dev->name, stats->rx_bytes, stats->rx_packets,
24278 diff -NurpP --minimal linux-3.1.6/net/core/rtnetlink.c linux-3.1.6-vs2.3.2.5/net/core/rtnetlink.c
24279 --- linux-3.1.6/net/core/rtnetlink.c 2011-10-24 18:45:34.000000000 +0200
24280 +++ linux-3.1.6-vs2.3.2.5/net/core/rtnetlink.c 2011-10-24 18:53:33.000000000 +0200
24281 @@ -1040,6 +1040,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
24282 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
24285 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
24287 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
24288 NETLINK_CB(cb->skb).pid,
24289 cb->nlh->nlmsg_seq, 0,
24290 @@ -1881,6 +1883,9 @@ void rtmsg_ifinfo(int type, struct net_d
24291 int err = -ENOBUFS;
24292 size_t if_info_size;
24294 + if (!nx_dev_visible(current_nx_info(), dev))
24297 skb = nlmsg_new((if_info_size = if_nlmsg_size(dev)), GFP_KERNEL);
24300 diff -NurpP --minimal linux-3.1.6/net/core/sock.c linux-3.1.6-vs2.3.2.5/net/core/sock.c
24301 --- linux-3.1.6/net/core/sock.c 2011-12-23 16:04:07.000000000 +0100
24302 +++ linux-3.1.6-vs2.3.2.5/net/core/sock.c 2011-11-15 17:08:44.000000000 +0100
24303 @@ -127,6 +127,10 @@
24304 #include <net/cls_cgroup.h>
24306 #include <linux/filter.h>
24307 +#include <linux/vs_socket.h>
24308 +#include <linux/vs_limit.h>
24309 +#include <linux/vs_context.h>
24310 +#include <linux/vs_network.h>
24312 #include <trace/events/sock.h>
24314 @@ -1073,6 +1077,8 @@ static struct sock *sk_prot_alloc(struct
24316 sk_tx_queue_clear(sk);
24318 + sock_vx_init(sk);
24319 + sock_nx_init(sk);
24323 @@ -1172,6 +1178,11 @@ static void __sk_free(struct sock *sk)
24324 put_cred(sk->sk_peer_cred);
24325 put_pid(sk->sk_peer_pid);
24326 put_net(sock_net(sk));
24328 + clr_vx_info(&sk->sk_vx_info);
24330 + clr_nx_info(&sk->sk_nx_info);
24332 sk_prot_free(sk->sk_prot_creator, sk);
24335 @@ -1219,6 +1230,8 @@ struct sock *sk_clone(const struct sock
24338 get_net(sock_net(newsk));
24339 + sock_vx_init(newsk);
24340 + sock_nx_init(newsk);
24341 sk_node_init(&newsk->sk_node);
24342 sock_lock_init(newsk);
24343 bh_lock_sock(newsk);
24344 @@ -1275,6 +1288,12 @@ struct sock *sk_clone(const struct sock
24346 atomic_set(&newsk->sk_refcnt, 2);
24348 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
24349 + newsk->sk_xid = sk->sk_xid;
24350 + vx_sock_inc(newsk);
24351 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
24352 + newsk->sk_nid = sk->sk_nid;
24355 * Increment the counter in the same struct proto as the master
24356 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
24357 @@ -2023,6 +2042,12 @@ void sock_init_data(struct socket *sock,
24359 sk->sk_stamp = ktime_set(-1L, 0);
24361 + set_vx_info(&sk->sk_vx_info, current_vx_info());
24362 + sk->sk_xid = vx_current_xid();
24364 + set_nx_info(&sk->sk_nx_info, current_nx_info());
24365 + sk->sk_nid = nx_current_nid();
24368 * Before updating sk_refcnt, we must commit prior changes to memory
24369 * (Documentation/RCU/rculist_nulls.txt for details)
24370 diff -NurpP --minimal linux-3.1.6/net/ipv4/af_inet.c linux-3.1.6-vs2.3.2.5/net/ipv4/af_inet.c
24371 --- linux-3.1.6/net/ipv4/af_inet.c 2011-10-24 18:45:34.000000000 +0200
24372 +++ linux-3.1.6-vs2.3.2.5/net/ipv4/af_inet.c 2011-10-24 18:53:33.000000000 +0200
24373 @@ -117,6 +117,7 @@
24374 #ifdef CONFIG_IP_MROUTE
24375 #include <linux/mroute.h>
24377 +#include <linux/vs_limit.h>
24380 /* The inetsw table contains everything that inet_create needs to
24381 @@ -326,9 +327,13 @@ lookup_protocol:
24385 + if ((protocol == IPPROTO_ICMP) &&
24386 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
24389 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
24390 goto out_rcu_unlock;
24393 err = -EAFNOSUPPORT;
24394 if (!inet_netns_ok(net, protocol))
24395 goto out_rcu_unlock;
24396 @@ -452,6 +457,7 @@ int inet_bind(struct socket *sock, struc
24397 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
24398 struct sock *sk = sock->sk;
24399 struct inet_sock *inet = inet_sk(sk);
24400 + struct nx_v4_sock_addr nsa;
24401 unsigned short snum;
24404 @@ -475,7 +481,11 @@ int inet_bind(struct socket *sock, struc
24408 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
24409 + err = v4_map_sock_addr(inet, addr, &nsa);
24413 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
24415 /* Not specified by any standard per-se, however it breaks too
24416 * many applications when removed. It is unfortunate since
24417 @@ -487,7 +497,7 @@ int inet_bind(struct socket *sock, struc
24418 err = -EADDRNOTAVAIL;
24419 if (!sysctl_ip_nonlocal_bind &&
24420 !(inet->freebind || inet->transparent) &&
24421 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
24422 + nsa.saddr != htonl(INADDR_ANY) &&
24423 chk_addr_ret != RTN_LOCAL &&
24424 chk_addr_ret != RTN_MULTICAST &&
24425 chk_addr_ret != RTN_BROADCAST)
24426 @@ -512,7 +522,7 @@ int inet_bind(struct socket *sock, struc
24427 if (sk->sk_state != TCP_CLOSE || inet->inet_num)
24428 goto out_release_sock;
24430 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24431 + v4_set_sock_addr(inet, &nsa);
24432 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24433 inet->inet_saddr = 0; /* Use device */
24435 @@ -715,11 +725,13 @@ int inet_getname(struct socket *sock, st
24438 sin->sin_port = inet->inet_dport;
24439 - sin->sin_addr.s_addr = inet->inet_daddr;
24440 + sin->sin_addr.s_addr =
24441 + nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
24443 __be32 addr = inet->inet_rcv_saddr;
24445 addr = inet->inet_saddr;
24446 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
24447 sin->sin_port = inet->inet_sport;
24448 sin->sin_addr.s_addr = addr;
24450 diff -NurpP --minimal linux-3.1.6/net/ipv4/arp.c linux-3.1.6-vs2.3.2.5/net/ipv4/arp.c
24451 --- linux-3.1.6/net/ipv4/arp.c 2011-10-24 18:45:34.000000000 +0200
24452 +++ linux-3.1.6-vs2.3.2.5/net/ipv4/arp.c 2011-10-24 18:53:33.000000000 +0200
24453 @@ -1332,6 +1332,7 @@ static void arp_format_neigh_entry(struc
24454 struct net_device *dev = n->dev;
24455 int hatype = dev->type;
24457 + /* FIXME: check for network context */
24458 read_lock(&n->lock);
24459 /* Convert hardware address to XX:XX:XX:XX ... form. */
24460 #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
24461 @@ -1363,6 +1364,7 @@ static void arp_format_pneigh_entry(stru
24462 int hatype = dev ? dev->type : 0;
24465 + /* FIXME: check for network context */
24466 sprintf(tbuf, "%pI4", n->key);
24467 seq_printf(seq, "%-16s 0x%-10x0x%-10x%s * %s\n",
24468 tbuf, hatype, ATF_PUBL | ATF_PERM, "00:00:00:00:00:00",
24469 diff -NurpP --minimal linux-3.1.6/net/ipv4/devinet.c linux-3.1.6-vs2.3.2.5/net/ipv4/devinet.c
24470 --- linux-3.1.6/net/ipv4/devinet.c 2011-10-24 18:45:34.000000000 +0200
24471 +++ linux-3.1.6-vs2.3.2.5/net/ipv4/devinet.c 2011-10-24 18:53:33.000000000 +0200
24472 @@ -518,6 +518,7 @@ struct in_device *inetdev_by_index(struc
24474 EXPORT_SYMBOL(inetdev_by_index);
24477 /* Called only from RTNL semaphored context. No locks. */
24479 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
24480 @@ -759,6 +760,8 @@ int devinet_ioctl(struct net *net, unsig
24482 in_dev = __in_dev_get_rtnl(dev);
24484 + struct nx_info *nxi = current_nx_info();
24486 if (tryaddrmatch) {
24487 /* Matthias Andree */
24488 /* compare label and address (4.4BSD style) */
24489 @@ -767,6 +770,8 @@ int devinet_ioctl(struct net *net, unsig
24490 This is checked above. */
24491 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24492 ifap = &ifa->ifa_next) {
24493 + if (!nx_v4_ifa_visible(nxi, ifa))
24495 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
24496 sin_orig.sin_addr.s_addr ==
24498 @@ -779,9 +784,12 @@ int devinet_ioctl(struct net *net, unsig
24499 comparing just the label */
24501 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24502 - ifap = &ifa->ifa_next)
24503 + ifap = &ifa->ifa_next) {
24504 + if (!nx_v4_ifa_visible(nxi, ifa))
24506 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
24512 @@ -934,6 +942,8 @@ static int inet_gifconf(struct net_devic
24515 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
24516 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
24519 done += sizeof(ifr);
24521 @@ -1294,6 +1304,7 @@ static int inet_dump_ifaddr(struct sk_bu
24522 struct net_device *dev;
24523 struct in_device *in_dev;
24524 struct in_ifaddr *ifa;
24525 + struct sock *sk = skb->sk;
24526 struct hlist_head *head;
24527 struct hlist_node *node;
24529 @@ -1316,6 +1327,8 @@ static int inet_dump_ifaddr(struct sk_bu
24531 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
24532 ifa = ifa->ifa_next, ip_idx++) {
24533 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
24535 if (ip_idx < s_ip_idx)
24537 if (inet_fill_ifaddr(skb, ifa,
24538 diff -NurpP --minimal linux-3.1.6/net/ipv4/fib_trie.c linux-3.1.6-vs2.3.2.5/net/ipv4/fib_trie.c
24539 --- linux-3.1.6/net/ipv4/fib_trie.c 2011-10-24 18:45:34.000000000 +0200
24540 +++ linux-3.1.6-vs2.3.2.5/net/ipv4/fib_trie.c 2011-10-24 18:53:33.000000000 +0200
24541 @@ -2554,6 +2554,7 @@ static int fib_route_seq_show(struct seq
24542 || fa->fa_type == RTN_MULTICAST)
24545 + /* FIXME: check for network context? */
24548 "%s\t%08X\t%08X\t%04X\t%d\t%u\t"
24549 diff -NurpP --minimal linux-3.1.6/net/ipv4/inet_connection_sock.c linux-3.1.6-vs2.3.2.5/net/ipv4/inet_connection_sock.c
24550 --- linux-3.1.6/net/ipv4/inet_connection_sock.c 2011-07-22 11:18:13.000000000 +0200
24551 +++ linux-3.1.6-vs2.3.2.5/net/ipv4/inet_connection_sock.c 2011-10-24 18:53:33.000000000 +0200
24552 @@ -52,6 +52,37 @@ void inet_get_local_port_range(int *low,
24554 EXPORT_SYMBOL(inet_get_local_port_range);
24556 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
24558 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1),
24559 + sk2_rcv_saddr = sk_rcv_saddr(sk2);
24561 + if (inet_v6_ipv6only(sk2))
24564 + if (sk1_rcv_saddr &&
24566 + sk1_rcv_saddr == sk2_rcv_saddr)
24569 + if (sk1_rcv_saddr &&
24570 + !sk2_rcv_saddr &&
24571 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
24574 + if (sk2_rcv_saddr &&
24575 + !sk1_rcv_saddr &&
24576 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
24579 + if (!sk1_rcv_saddr &&
24580 + !sk2_rcv_saddr &&
24581 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
24587 int inet_csk_bind_conflict(const struct sock *sk,
24588 const struct inet_bind_bucket *tb)
24590 @@ -74,9 +105,7 @@ int inet_csk_bind_conflict(const struct
24591 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
24592 if (!reuse || !sk2->sk_reuse ||
24593 sk2->sk_state == TCP_LISTEN) {
24594 - const __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
24595 - if (!sk2_rcv_saddr || !sk_rcv_saddr(sk) ||
24596 - sk2_rcv_saddr == sk_rcv_saddr(sk))
24597 + if (ipv4_rcv_saddr_equal(sk, sk2))
24601 diff -NurpP --minimal linux-3.1.6/net/ipv4/inet_diag.c linux-3.1.6-vs2.3.2.5/net/ipv4/inet_diag.c
24602 --- linux-3.1.6/net/ipv4/inet_diag.c 2011-10-24 18:45:34.000000000 +0200
24603 +++ linux-3.1.6-vs2.3.2.5/net/ipv4/inet_diag.c 2011-10-24 18:53:33.000000000 +0200
24605 #include <linux/stddef.h>
24607 #include <linux/inet_diag.h>
24608 +#include <linux/vs_network.h>
24609 +#include <linux/vs_inet.h>
24611 static const struct inet_diag_handler **inet_diag_table;
24613 @@ -119,8 +121,10 @@ static int inet_csk_diag_fill(struct soc
24615 r->id.idiag_sport = inet->inet_sport;
24616 r->id.idiag_dport = inet->inet_dport;
24617 - r->id.idiag_src[0] = inet->inet_rcv_saddr;
24618 - r->id.idiag_dst[0] = inet->inet_daddr;
24619 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
24620 + inet->inet_rcv_saddr);
24621 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
24622 + inet->inet_daddr);
24624 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
24625 if (r->idiag_family == AF_INET6) {
24626 @@ -205,8 +209,8 @@ static int inet_twsk_diag_fill(struct in
24627 r->id.idiag_cookie[1] = (u32)(((unsigned long)tw >> 31) >> 1);
24628 r->id.idiag_sport = tw->tw_sport;
24629 r->id.idiag_dport = tw->tw_dport;
24630 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
24631 - r->id.idiag_dst[0] = tw->tw_daddr;
24632 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
24633 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
24634 r->idiag_state = tw->tw_substate;
24635 r->idiag_timer = 3;
24636 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
24637 @@ -263,6 +267,7 @@ static int inet_diag_get_exact(struct sk
24640 if (req->idiag_family == AF_INET) {
24641 + /* TODO: lback */
24642 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
24643 req->id.idiag_dport, req->id.idiag_src[0],
24644 req->id.idiag_sport, req->id.idiag_if);
24645 @@ -505,6 +510,7 @@ static int inet_csk_diag_dump(struct soc
24649 + /* TODO: lback */
24650 entry.saddr = &inet->inet_rcv_saddr;
24651 entry.daddr = &inet->inet_daddr;
24653 @@ -543,6 +549,7 @@ static int inet_twsk_diag_dump(struct in
24657 + /* TODO: lback */
24658 entry.saddr = &tw->tw_rcv_saddr;
24659 entry.daddr = &tw->tw_daddr;
24661 @@ -589,8 +596,8 @@ static int inet_diag_fill_req(struct sk_
24663 r->id.idiag_sport = inet->inet_sport;
24664 r->id.idiag_dport = ireq->rmt_port;
24665 - r->id.idiag_src[0] = ireq->loc_addr;
24666 - r->id.idiag_dst[0] = ireq->rmt_addr;
24667 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
24668 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
24669 r->idiag_expires = jiffies_to_msecs(tmo);
24670 r->idiag_rqueue = 0;
24671 r->idiag_wqueue = 0;
24672 @@ -661,6 +668,7 @@ static int inet_diag_dump_reqs(struct sk
24676 + /* TODO: lback */
24678 #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
24679 (entry.family == AF_INET6) ?
24680 @@ -731,6 +739,8 @@ static int inet_diag_dump(struct sk_buff
24681 sk_nulls_for_each(sk, node, &ilb->head) {
24682 struct inet_sock *inet = inet_sk(sk);
24684 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24689 @@ -797,6 +807,8 @@ skip_listen_ht:
24690 sk_nulls_for_each(sk, node, &head->chain) {
24691 struct inet_sock *inet = inet_sk(sk);
24693 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24697 if (!(r->idiag_states & (1 << sk->sk_state)))
24698 @@ -821,6 +833,8 @@ next_normal:
24699 inet_twsk_for_each(tw, node,
24702 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
24706 if (r->id.idiag_sport != tw->tw_sport &&
24707 diff -NurpP --minimal linux-3.1.6/net/ipv4/inet_hashtables.c linux-3.1.6-vs2.3.2.5/net/ipv4/inet_hashtables.c
24708 --- linux-3.1.6/net/ipv4/inet_hashtables.c 2011-10-24 18:45:34.000000000 +0200
24709 +++ linux-3.1.6-vs2.3.2.5/net/ipv4/inet_hashtables.c 2011-10-24 18:53:33.000000000 +0200
24711 #include <net/inet_connection_sock.h>
24712 #include <net/inet_hashtables.h>
24713 #include <net/secure_seq.h>
24714 +#include <net/route.h>
24715 #include <net/ip.h>
24718 @@ -156,6 +157,11 @@ static inline int compute_score(struct s
24719 if (rcv_saddr != daddr)
24723 + /* block non nx_info ips */
24724 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
24725 + daddr, NXA_MASK_BIND))
24728 if (sk->sk_bound_dev_if) {
24729 if (sk->sk_bound_dev_if != dif)
24730 @@ -173,7 +179,6 @@ static inline int compute_score(struct s
24731 * wildcarded during the search since they can never be otherwise.
24735 struct sock *__inet_lookup_listener(struct net *net,
24736 struct inet_hashinfo *hashinfo,
24737 const __be32 daddr, const unsigned short hnum,
24738 @@ -196,6 +201,7 @@ begin:
24744 * if the nulls value we got at the end of this lookup is
24745 * not the expected one, we must restart lookup.
24746 diff -NurpP --minimal linux-3.1.6/net/ipv4/netfilter/nf_nat_helper.c linux-3.1.6-vs2.3.2.5/net/ipv4/netfilter/nf_nat_helper.c
24747 --- linux-3.1.6/net/ipv4/netfilter/nf_nat_helper.c 2011-07-22 11:18:13.000000000 +0200
24748 +++ linux-3.1.6-vs2.3.2.5/net/ipv4/netfilter/nf_nat_helper.c 2011-10-24 18:53:33.000000000 +0200
24750 #include <net/route.h>
24752 #include <linux/netfilter_ipv4.h>
24753 +#include <net/route.h>
24754 #include <net/netfilter/nf_conntrack.h>
24755 #include <net/netfilter/nf_conntrack_helper.h>
24756 #include <net/netfilter/nf_conntrack_ecache.h>
24757 diff -NurpP --minimal linux-3.1.6/net/ipv4/netfilter.c linux-3.1.6-vs2.3.2.5/net/ipv4/netfilter.c
24758 --- linux-3.1.6/net/ipv4/netfilter.c 2011-10-24 18:45:34.000000000 +0200
24759 +++ linux-3.1.6-vs2.3.2.5/net/ipv4/netfilter.c 2011-10-24 18:53:33.000000000 +0200
24761 #include <linux/ip.h>
24762 #include <linux/skbuff.h>
24763 #include <linux/gfp.h>
24764 -#include <net/route.h>
24765 +// #include <net/route.h>
24766 #include <net/xfrm.h>
24767 #include <net/ip.h>
24768 #include <net/netfilter/nf_queue.h>
24769 diff -NurpP --minimal linux-3.1.6/net/ipv4/raw.c linux-3.1.6-vs2.3.2.5/net/ipv4/raw.c
24770 --- linux-3.1.6/net/ipv4/raw.c 2011-10-24 18:45:34.000000000 +0200
24771 +++ linux-3.1.6-vs2.3.2.5/net/ipv4/raw.c 2011-10-24 18:53:33.000000000 +0200
24772 @@ -117,7 +117,7 @@ static struct sock *__raw_v4_lookup(stru
24774 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
24775 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
24776 - !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
24777 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
24778 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
24779 goto found; /* gotcha */
24781 @@ -385,6 +385,12 @@ static int raw_send_hdrinc(struct sock *
24782 icmp_out_count(net, ((struct icmphdr *)
24783 skb_transport_header(skb))->type);
24786 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
24787 + sk->sk_nx_info &&
24788 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
24791 err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL,
24792 rt->dst.dev, dst_output);
24794 @@ -572,6 +578,16 @@ static int raw_sendmsg(struct kiocb *ioc
24798 + if (sk->sk_nx_info) {
24799 + rt = ip_v4_find_src(sock_net(sk), sk->sk_nx_info, &fl4);
24800 + if (IS_ERR(rt)) {
24801 + err = PTR_ERR(rt);
24808 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4));
24809 rt = ip_route_output_flow(sock_net(sk), &fl4, sk);
24811 @@ -648,17 +664,19 @@ static int raw_bind(struct sock *sk, str
24813 struct inet_sock *inet = inet_sk(sk);
24814 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
24815 + struct nx_v4_sock_addr nsa = { 0 };
24819 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
24821 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
24822 + v4_map_sock_addr(inet, addr, &nsa);
24823 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
24824 ret = -EADDRNOTAVAIL;
24825 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
24826 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
24827 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
24829 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24830 + v4_set_sock_addr(inet, &nsa);
24831 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24832 inet->inet_saddr = 0; /* Use device */
24834 @@ -710,7 +728,8 @@ static int raw_recvmsg(struct kiocb *ioc
24835 /* Copy the address. */
24837 sin->sin_family = AF_INET;
24838 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
24839 + sin->sin_addr.s_addr =
24840 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
24842 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
24844 @@ -906,7 +925,8 @@ static struct sock *raw_get_first(struct
24845 struct hlist_node *node;
24847 sk_for_each(sk, node, &state->h->ht[state->bucket])
24848 - if (sock_net(sk) == seq_file_net(seq))
24849 + if ((sock_net(sk) == seq_file_net(seq)) &&
24850 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24854 @@ -922,7 +942,8 @@ static struct sock *raw_get_next(struct
24858 - } while (sk && sock_net(sk) != seq_file_net(seq));
24859 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
24860 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
24862 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
24863 sk = sk_head(&state->h->ht[state->bucket]);
24864 diff -NurpP --minimal linux-3.1.6/net/ipv4/route.c linux-3.1.6-vs2.3.2.5/net/ipv4/route.c
24865 --- linux-3.1.6/net/ipv4/route.c 2011-12-23 16:04:07.000000000 +0100
24866 +++ linux-3.1.6-vs2.3.2.5/net/ipv4/route.c 2011-12-15 01:07:58.000000000 +0100
24867 @@ -2609,7 +2609,7 @@ static struct rtable *ip_route_output_sl
24870 if (fl4->flowi4_oif) {
24871 - dev_out = dev_get_by_index_rcu(net, fl4->flowi4_oif);
24872 + dev_out = dev_get_by_index_real_rcu(net, fl4->flowi4_oif);
24873 rth = ERR_PTR(-ENODEV);
24874 if (dev_out == NULL)
24876 diff -NurpP --minimal linux-3.1.6/net/ipv4/tcp.c linux-3.1.6-vs2.3.2.5/net/ipv4/tcp.c
24877 --- linux-3.1.6/net/ipv4/tcp.c 2011-07-22 11:18:13.000000000 +0200
24878 +++ linux-3.1.6-vs2.3.2.5/net/ipv4/tcp.c 2011-10-24 18:53:33.000000000 +0200
24879 @@ -266,6 +266,7 @@
24880 #include <linux/crypto.h>
24881 #include <linux/time.h>
24882 #include <linux/slab.h>
24883 +#include <linux/in.h>
24885 #include <net/icmp.h>
24886 #include <net/tcp.h>
24887 diff -NurpP --minimal linux-3.1.6/net/ipv4/tcp_ipv4.c linux-3.1.6-vs2.3.2.5/net/ipv4/tcp_ipv4.c
24888 --- linux-3.1.6/net/ipv4/tcp_ipv4.c 2011-10-24 18:45:34.000000000 +0200
24889 +++ linux-3.1.6-vs2.3.2.5/net/ipv4/tcp_ipv4.c 2011-10-24 18:53:33.000000000 +0200
24890 @@ -2018,6 +2018,12 @@ static void *listening_get_next(struct s
24891 req = req->dl_next;
24894 + vxdprintk(VXD_CBIT(net, 6),
24895 + "sk,req: %p [#%d] (from %d)", req->sk,
24896 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
24898 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
24900 if (req->rsk_ops->family == st->family) {
24903 @@ -2042,6 +2048,10 @@ get_req:
24906 sk_nulls_for_each_from(sk, node) {
24907 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
24908 + sk, sk->sk_nid, nx_current_nid());
24909 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24911 if (!net_eq(sock_net(sk), net))
24913 if (sk->sk_family == st->family) {
24914 @@ -2118,6 +2128,11 @@ static void *established_get_first(struc
24916 spin_lock_bh(lock);
24917 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
24918 + vxdprintk(VXD_CBIT(net, 6),
24919 + "sk,egf: %p [#%d] (from %d)",
24920 + sk, sk->sk_nid, nx_current_nid());
24921 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24923 if (sk->sk_family != st->family ||
24924 !net_eq(sock_net(sk), net)) {
24926 @@ -2128,6 +2143,11 @@ static void *established_get_first(struc
24927 st->state = TCP_SEQ_STATE_TIME_WAIT;
24928 inet_twsk_for_each(tw, node,
24929 &tcp_hashinfo.ehash[st->bucket].twchain) {
24930 + vxdprintk(VXD_CBIT(net, 6),
24931 + "tw: %p [#%d] (from %d)",
24932 + tw, tw->tw_nid, nx_current_nid());
24933 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
24935 if (tw->tw_family != st->family ||
24936 !net_eq(twsk_net(tw), net)) {
24938 @@ -2157,7 +2177,9 @@ static void *established_get_next(struct
24942 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
24943 + while (tw && (tw->tw_family != st->family ||
24944 + !net_eq(twsk_net(tw), net) ||
24945 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
24949 @@ -2181,6 +2203,11 @@ get_tw:
24950 sk = sk_nulls_next(sk);
24952 sk_nulls_for_each_from(sk, node) {
24953 + vxdprintk(VXD_CBIT(net, 6),
24954 + "sk,egn: %p [#%d] (from %d)",
24955 + sk, sk->sk_nid, nx_current_nid());
24956 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24958 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
24961 @@ -2390,9 +2417,9 @@ static void get_openreq4(struct sock *sk
24962 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
24963 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %pK%n",
24966 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
24967 ntohs(inet_sk(sk)->inet_sport),
24969 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
24970 ntohs(ireq->rmt_port),
24972 0, 0, /* could print option size, but that is af dependent. */
24973 @@ -2414,8 +2441,8 @@ static void get_tcp4_sock(struct sock *s
24974 struct tcp_sock *tp = tcp_sk(sk);
24975 const struct inet_connection_sock *icsk = inet_csk(sk);
24976 struct inet_sock *inet = inet_sk(sk);
24977 - __be32 dest = inet->inet_daddr;
24978 - __be32 src = inet->inet_rcv_saddr;
24979 + __be32 dest = nx_map_sock_lback(current_nx_info(), inet->inet_daddr);
24980 + __be32 src = nx_map_sock_lback(current_nx_info(), inet->inet_rcv_saddr);
24981 __u16 destp = ntohs(inet->inet_dport);
24982 __u16 srcp = ntohs(inet->inet_sport);
24984 @@ -2472,8 +2499,8 @@ static void get_timewait4_sock(struct in
24988 - dest = tw->tw_daddr;
24989 - src = tw->tw_rcv_saddr;
24990 + dest = nx_map_sock_lback(current_nx_info(), tw->tw_daddr);
24991 + src = nx_map_sock_lback(current_nx_info(), tw->tw_rcv_saddr);
24992 destp = ntohs(tw->tw_dport);
24993 srcp = ntohs(tw->tw_sport);
24995 diff -NurpP --minimal linux-3.1.6/net/ipv4/tcp_minisocks.c linux-3.1.6-vs2.3.2.5/net/ipv4/tcp_minisocks.c
24996 --- linux-3.1.6/net/ipv4/tcp_minisocks.c 2011-10-24 18:45:34.000000000 +0200
24997 +++ linux-3.1.6-vs2.3.2.5/net/ipv4/tcp_minisocks.c 2011-10-24 18:53:33.000000000 +0200
24999 #include <linux/slab.h>
25000 #include <linux/sysctl.h>
25001 #include <linux/workqueue.h>
25002 +#include <linux/vs_limit.h>
25003 +#include <linux/vs_socket.h>
25004 +#include <linux/vs_context.h>
25005 #include <net/tcp.h>
25006 #include <net/inet_common.h>
25007 #include <net/xfrm.h>
25008 @@ -336,6 +339,11 @@ void tcp_time_wait(struct sock *sk, int
25009 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
25010 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
25012 + tw->tw_xid = sk->sk_xid;
25013 + tw->tw_vx_info = NULL;
25014 + tw->tw_nid = sk->sk_nid;
25015 + tw->tw_nx_info = NULL;
25017 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
25018 if (tw->tw_family == PF_INET6) {
25019 struct ipv6_pinfo *np = inet6_sk(sk);
25020 diff -NurpP --minimal linux-3.1.6/net/ipv4/udp.c linux-3.1.6-vs2.3.2.5/net/ipv4/udp.c
25021 --- linux-3.1.6/net/ipv4/udp.c 2011-10-24 18:45:34.000000000 +0200
25022 +++ linux-3.1.6-vs2.3.2.5/net/ipv4/udp.c 2011-10-24 18:53:33.000000000 +0200
25023 @@ -297,14 +297,7 @@ fail:
25025 EXPORT_SYMBOL(udp_lib_get_port);
25027 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25029 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
25031 - return (!ipv6_only_sock(sk2) &&
25032 - (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
25033 - inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
25035 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
25037 static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
25039 @@ -339,6 +332,11 @@ static inline int compute_score(struct s
25040 if (inet->inet_rcv_saddr != daddr)
25044 + /* block non nx_info ips */
25045 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
25046 + daddr, NXA_MASK_BIND))
25049 if (inet->inet_daddr) {
25050 if (inet->inet_daddr != saddr)
25051 @@ -442,6 +440,7 @@ exact_match:
25056 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
25057 * harder than this. -DaveM
25059 @@ -487,6 +486,11 @@ begin:
25060 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
25061 score = compute_score(sk, net, saddr, hnum, sport,
25062 daddr, dport, dif);
25063 + /* FIXME: disabled?
25064 + if (score == 9) {
25068 if (score > badness) {
25071 @@ -500,6 +504,7 @@ begin:
25072 if (get_nulls_value(node) != slot)
25077 if (unlikely(!atomic_inc_not_zero_hint(&result->sk_refcnt, 2)))
25079 @@ -509,6 +514,7 @@ begin:
25087 @@ -551,8 +557,7 @@ static inline struct sock *udp_v4_mcast_
25088 udp_sk(s)->udp_port_hash != hnum ||
25089 (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
25090 (inet->inet_dport != rmt_port && inet->inet_dport) ||
25091 - (inet->inet_rcv_saddr &&
25092 - inet->inet_rcv_saddr != loc_addr) ||
25093 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
25094 ipv6_only_sock(s) ||
25095 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
25097 @@ -930,6 +935,16 @@ int udp_sendmsg(struct kiocb *iocb, stru
25098 inet_sk_flowi_flags(sk)|FLOWI_FLAG_CAN_SLEEP,
25099 faddr, saddr, dport, inet->inet_sport);
25101 + if (sk->sk_nx_info) {
25102 + rt = ip_v4_find_src(net, sk->sk_nx_info, fl4);
25103 + if (IS_ERR(rt)) {
25104 + err = PTR_ERR(rt);
25111 security_sk_classify_flow(sk, flowi4_to_flowi(fl4));
25112 rt = ip_route_output_flow(net, fl4, sk);
25114 @@ -1227,7 +1242,8 @@ try_again:
25116 sin->sin_family = AF_INET;
25117 sin->sin_port = udp_hdr(skb)->source;
25118 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25119 + sin->sin_addr.s_addr = nx_map_sock_lback(
25120 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
25121 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
25123 if (inet->cmsg_flags)
25124 @@ -1972,6 +1988,8 @@ static struct sock *udp_get_first(struct
25125 sk_nulls_for_each(sk, node, &hslot->head) {
25126 if (!net_eq(sock_net(sk), net))
25128 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25130 if (sk->sk_family == state->family)
25133 @@ -1989,7 +2007,9 @@ static struct sock *udp_get_next(struct
25136 sk = sk_nulls_next(sk);
25137 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
25138 + } while (sk && (!net_eq(sock_net(sk), net) ||
25139 + sk->sk_family != state->family ||
25140 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25143 if (state->bucket <= state->udp_table->mask)
25144 diff -NurpP --minimal linux-3.1.6/net/ipv6/Kconfig linux-3.1.6-vs2.3.2.5/net/ipv6/Kconfig
25145 --- linux-3.1.6/net/ipv6/Kconfig 2010-08-02 16:52:59.000000000 +0200
25146 +++ linux-3.1.6-vs2.3.2.5/net/ipv6/Kconfig 2011-10-24 18:53:33.000000000 +0200
25149 # IPv6 as module will cause a CRASH if you try to unload it
25151 - tristate "The IPv6 protocol"
25153 + bool "The IPv6 protocol"
25156 This is complemental support for the IP version 6.
25157 You will still be able to do traditional IPv4 networking as well.
25158 diff -NurpP --minimal linux-3.1.6/net/ipv6/addrconf.c linux-3.1.6-vs2.3.2.5/net/ipv6/addrconf.c
25159 --- linux-3.1.6/net/ipv6/addrconf.c 2011-10-24 18:45:34.000000000 +0200
25160 +++ linux-3.1.6-vs2.3.2.5/net/ipv6/addrconf.c 2011-10-24 18:53:33.000000000 +0200
25163 #include <linux/proc_fs.h>
25164 #include <linux/seq_file.h>
25165 +#include <linux/vs_network.h>
25166 +#include <linux/vs_inet6.h>
25168 /* Set to 3 to get tracing... */
25169 #define ACONF_DEBUG 2
25170 @@ -1108,7 +1110,7 @@ out:
25172 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
25173 const struct in6_addr *daddr, unsigned int prefs,
25174 - struct in6_addr *saddr)
25175 + struct in6_addr *saddr, struct nx_info *nxi)
25177 struct ipv6_saddr_score scores[2],
25178 *score = &scores[0], *hiscore = &scores[1];
25179 @@ -1180,6 +1182,8 @@ int ipv6_dev_get_saddr(struct net *net,
25183 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
25187 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
25188 @@ -3087,7 +3091,10 @@ static void if6_seq_stop(struct seq_file
25189 static int if6_seq_show(struct seq_file *seq, void *v)
25191 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
25192 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25194 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
25195 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
25196 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25198 ifp->idev->dev->ifindex,
25200 @@ -3593,6 +3600,11 @@ static int in6_dump_addrs(struct inet6_d
25201 struct ifacaddr6 *ifaca;
25203 int ip_idx = *p_ip_idx;
25204 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25206 + /* disable ipv6 on non v6 guests */
25207 + if (nxi && !nx_info_has_v6(nxi))
25210 read_lock_bh(&idev->lock);
25212 @@ -3603,6 +3615,8 @@ static int in6_dump_addrs(struct inet6_d
25213 list_for_each_entry(ifa, &idev->addr_list, if_list) {
25214 if (++ip_idx < s_ip_idx)
25216 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
25218 err = inet6_fill_ifaddr(skb, ifa,
25219 NETLINK_CB(cb->skb).pid,
25220 cb->nlh->nlmsg_seq,
25221 @@ -3619,6 +3633,8 @@ static int in6_dump_addrs(struct inet6_d
25222 ifmca = ifmca->next, ip_idx++) {
25223 if (ip_idx < s_ip_idx)
25225 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
25227 err = inet6_fill_ifmcaddr(skb, ifmca,
25228 NETLINK_CB(cb->skb).pid,
25229 cb->nlh->nlmsg_seq,
25230 @@ -3634,6 +3650,8 @@ static int in6_dump_addrs(struct inet6_d
25231 ifaca = ifaca->aca_next, ip_idx++) {
25232 if (ip_idx < s_ip_idx)
25234 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
25236 err = inet6_fill_ifacaddr(skb, ifaca,
25237 NETLINK_CB(cb->skb).pid,
25238 cb->nlh->nlmsg_seq,
25239 @@ -4019,6 +4037,11 @@ static int inet6_dump_ifinfo(struct sk_b
25240 struct inet6_dev *idev;
25241 struct hlist_head *head;
25242 struct hlist_node *node;
25243 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25245 + /* FIXME: maybe disable ipv6 on non v6 guests?
25246 + if (skb->sk && skb->sk->sk_vx_info)
25247 + return skb->len; */
25250 s_idx = cb->args[1];
25251 @@ -4030,6 +4053,8 @@ static int inet6_dump_ifinfo(struct sk_b
25252 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
25255 + if (!v6_dev_in_nx_info(dev, nxi))
25257 idev = __in6_dev_get(dev);
25260 diff -NurpP --minimal linux-3.1.6/net/ipv6/af_inet6.c linux-3.1.6-vs2.3.2.5/net/ipv6/af_inet6.c
25261 --- linux-3.1.6/net/ipv6/af_inet6.c 2011-10-24 18:45:34.000000000 +0200
25262 +++ linux-3.1.6-vs2.3.2.5/net/ipv6/af_inet6.c 2011-10-24 18:53:33.000000000 +0200
25264 #include <linux/netdevice.h>
25265 #include <linux/icmpv6.h>
25266 #include <linux/netfilter_ipv6.h>
25267 +#include <linux/vs_inet.h>
25268 +#include <linux/vs_inet6.h>
25270 #include <net/ip.h>
25271 #include <net/ipv6.h>
25272 @@ -160,9 +162,12 @@ lookup_protocol:
25276 + if ((protocol == IPPROTO_ICMPV6) &&
25277 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
25279 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
25280 goto out_rcu_unlock;
25283 sock->ops = answer->ops;
25284 answer_prot = answer->prot;
25285 answer_no_check = answer->no_check;
25286 @@ -261,6 +266,7 @@ int inet6_bind(struct socket *sock, stru
25287 struct inet_sock *inet = inet_sk(sk);
25288 struct ipv6_pinfo *np = inet6_sk(sk);
25289 struct net *net = sock_net(sk);
25290 + struct nx_v6_sock_addr nsa;
25292 unsigned short snum;
25294 @@ -276,6 +282,10 @@ int inet6_bind(struct socket *sock, stru
25295 if (addr->sin6_family != AF_INET6)
25296 return -EAFNOSUPPORT;
25298 + err = v6_map_sock_addr(inet, addr, &nsa);
25302 addr_type = ipv6_addr_type(&addr->sin6_addr);
25303 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
25305 @@ -307,6 +317,7 @@ int inet6_bind(struct socket *sock, stru
25306 /* Reproduce AF_INET checks to make the bindings consistent */
25307 v4addr = addr->sin6_addr.s6_addr32[3];
25308 chk_addr_ret = inet_addr_type(net, v4addr);
25310 if (!sysctl_ip_nonlocal_bind &&
25311 !(inet->freebind || inet->transparent) &&
25312 v4addr != htonl(INADDR_ANY) &&
25313 @@ -316,6 +327,10 @@ int inet6_bind(struct socket *sock, stru
25314 err = -EADDRNOTAVAIL;
25317 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
25318 + err = -EADDRNOTAVAIL;
25322 if (addr_type != IPV6_ADDR_ANY) {
25323 struct net_device *dev = NULL;
25324 @@ -342,6 +357,11 @@ int inet6_bind(struct socket *sock, stru
25328 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25329 + err = -EADDRNOTAVAIL;
25333 /* ipv4 addr of the socket is invalid. Only the
25334 * unspecified and mapped address have a v4 equivalent.
25336 @@ -358,6 +378,9 @@ int inet6_bind(struct socket *sock, stru
25340 + /* what's that for? */
25341 + v6_set_sock_addr(inet, &nsa);
25343 inet->inet_rcv_saddr = v4addr;
25344 inet->inet_saddr = v4addr;
25346 @@ -459,9 +482,11 @@ int inet6_getname(struct socket *sock, s
25348 sin->sin6_port = inet->inet_dport;
25349 ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
25350 + /* FIXME: remap lback? */
25352 sin->sin6_flowinfo = np->flow_label;
25354 + /* FIXME: remap lback? */
25355 if (ipv6_addr_any(&np->rcv_saddr))
25356 ipv6_addr_copy(&sin->sin6_addr, &np->saddr);
25358 diff -NurpP --minimal linux-3.1.6/net/ipv6/datagram.c linux-3.1.6-vs2.3.2.5/net/ipv6/datagram.c
25359 --- linux-3.1.6/net/ipv6/datagram.c 2011-10-24 18:45:34.000000000 +0200
25360 +++ linux-3.1.6-vs2.3.2.5/net/ipv6/datagram.c 2011-10-24 18:53:33.000000000 +0200
25361 @@ -646,7 +646,7 @@ int datagram_send_ctl(struct net *net, s
25364 if (fl6->flowi6_oif) {
25365 - dev = dev_get_by_index_rcu(net, fl6->flowi6_oif);
25366 + dev = dev_get_by_index_real_rcu(net, fl6->flowi6_oif);
25370 diff -NurpP --minimal linux-3.1.6/net/ipv6/fib6_rules.c linux-3.1.6-vs2.3.2.5/net/ipv6/fib6_rules.c
25371 --- linux-3.1.6/net/ipv6/fib6_rules.c 2011-05-22 16:18:00.000000000 +0200
25372 +++ linux-3.1.6-vs2.3.2.5/net/ipv6/fib6_rules.c 2011-10-24 18:53:33.000000000 +0200
25373 @@ -90,7 +90,7 @@ static int fib6_rule_action(struct fib_r
25374 ip6_dst_idev(&rt->dst)->dev,
25376 rt6_flags2srcprefs(flags),
25380 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
25382 diff -NurpP --minimal linux-3.1.6/net/ipv6/inet6_hashtables.c linux-3.1.6-vs2.3.2.5/net/ipv6/inet6_hashtables.c
25383 --- linux-3.1.6/net/ipv6/inet6_hashtables.c 2011-10-24 18:45:34.000000000 +0200
25384 +++ linux-3.1.6-vs2.3.2.5/net/ipv6/inet6_hashtables.c 2011-10-24 18:53:33.000000000 +0200
25387 #include <linux/module.h>
25388 #include <linux/random.h>
25389 +#include <linux/vs_inet6.h>
25391 #include <net/inet_connection_sock.h>
25392 #include <net/inet_hashtables.h>
25393 @@ -83,7 +84,6 @@ struct sock *__inet6_lookup_established(
25394 unsigned int slot = hash & hashinfo->ehash_mask;
25395 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
25400 sk_nulls_for_each_rcu(sk, node, &head->chain) {
25401 @@ -95,7 +95,7 @@ begin:
25409 if (get_nulls_value(node) != slot)
25410 @@ -141,6 +141,9 @@ static inline int compute_score(struct s
25411 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25415 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25418 if (sk->sk_bound_dev_if) {
25419 if (sk->sk_bound_dev_if != dif)
25420 diff -NurpP --minimal linux-3.1.6/net/ipv6/ip6_output.c linux-3.1.6-vs2.3.2.5/net/ipv6/ip6_output.c
25421 --- linux-3.1.6/net/ipv6/ip6_output.c 2011-10-24 18:45:34.000000000 +0200
25422 +++ linux-3.1.6-vs2.3.2.5/net/ipv6/ip6_output.c 2011-10-24 18:53:33.000000000 +0200
25423 @@ -966,7 +966,8 @@ static int ip6_dst_lookup_tail(struct so
25424 struct rt6_info *rt = (struct rt6_info *) *dst;
25425 err = ip6_route_get_saddr(net, rt, &fl6->daddr,
25426 sk ? inet6_sk(sk)->srcprefs : 0,
25429 + sk ? sk->sk_nx_info : NULL);
25431 goto out_err_release;
25433 diff -NurpP --minimal linux-3.1.6/net/ipv6/ndisc.c linux-3.1.6-vs2.3.2.5/net/ipv6/ndisc.c
25434 --- linux-3.1.6/net/ipv6/ndisc.c 2011-10-24 18:45:34.000000000 +0200
25435 +++ linux-3.1.6-vs2.3.2.5/net/ipv6/ndisc.c 2011-10-24 18:53:33.000000000 +0200
25436 @@ -591,7 +591,7 @@ static void ndisc_send_na(struct net_dev
25438 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
25439 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
25443 src_addr = &tmpaddr;
25445 diff -NurpP --minimal linux-3.1.6/net/ipv6/raw.c linux-3.1.6-vs2.3.2.5/net/ipv6/raw.c
25446 --- linux-3.1.6/net/ipv6/raw.c 2011-10-24 18:45:34.000000000 +0200
25447 +++ linux-3.1.6-vs2.3.2.5/net/ipv6/raw.c 2011-10-24 18:53:33.000000000 +0200
25449 #include <linux/icmpv6.h>
25450 #include <linux/netfilter.h>
25451 #include <linux/netfilter_ipv6.h>
25452 +#include <linux/vs_inet6.h>
25453 #include <linux/skbuff.h>
25454 #include <linux/compat.h>
25455 #include <asm/uaccess.h>
25456 @@ -284,6 +285,13 @@ static int rawv6_bind(struct sock *sk, s
25460 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25461 + err = -EADDRNOTAVAIL;
25467 /* ipv4 addr of the socket is invalid. Only the
25468 * unspecified and mapped address have a v4 equivalent.
25470 diff -NurpP --minimal linux-3.1.6/net/ipv6/route.c linux-3.1.6-vs2.3.2.5/net/ipv6/route.c
25471 --- linux-3.1.6/net/ipv6/route.c 2011-12-23 16:04:07.000000000 +0100
25472 +++ linux-3.1.6-vs2.3.2.5/net/ipv6/route.c 2011-11-15 17:08:44.000000000 +0100
25474 #include <net/xfrm.h>
25475 #include <net/netevent.h>
25476 #include <net/netlink.h>
25477 +#include <linux/vs_inet6.h>
25479 #include <asm/uaccess.h>
25481 @@ -2085,15 +2086,17 @@ int ip6_route_get_saddr(struct net *net,
25482 struct rt6_info *rt,
25483 const struct in6_addr *daddr,
25484 unsigned int prefs,
25485 - struct in6_addr *saddr)
25486 + struct in6_addr *saddr,
25487 + struct nx_info *nxi)
25489 struct inet6_dev *idev = ip6_dst_idev((struct dst_entry*)rt);
25491 - if (rt->rt6i_prefsrc.plen)
25492 + if (rt->rt6i_prefsrc.plen && (!nxi ||
25493 + v6_addr_in_nx_info(nxi, &rt->rt6i_prefsrc.addr, NXA_TYPE_ADDR)))
25494 ipv6_addr_copy(saddr, &rt->rt6i_prefsrc.addr);
25496 err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
25497 - daddr, prefs, saddr);
25498 + daddr, prefs, saddr, nxi);
25502 @@ -2423,7 +2426,8 @@ static int rt6_fill_node(struct net *net
25503 NLA_PUT_U32(skb, RTA_IIF, iif);
25505 struct in6_addr saddr_buf;
25506 - if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf) == 0)
25507 + if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf,
25508 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
25509 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
25512 @@ -2626,6 +2630,7 @@ static int rt6_info_route(struct rt6_inf
25513 struct seq_file *m = p_arg;
25514 struct neighbour *n;
25516 + /* FIXME: check for network context? */
25517 seq_printf(m, "%pi6 %02x ", &rt->rt6i_dst.addr, rt->rt6i_dst.plen);
25519 #ifdef CONFIG_IPV6_SUBTREES
25520 diff -NurpP --minimal linux-3.1.6/net/ipv6/tcp_ipv6.c linux-3.1.6-vs2.3.2.5/net/ipv6/tcp_ipv6.c
25521 --- linux-3.1.6/net/ipv6/tcp_ipv6.c 2011-10-24 18:45:34.000000000 +0200
25522 +++ linux-3.1.6-vs2.3.2.5/net/ipv6/tcp_ipv6.c 2011-10-24 18:53:33.000000000 +0200
25525 #include <linux/crypto.h>
25526 #include <linux/scatterlist.h>
25527 +#include <linux/vs_inet6.h>
25529 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
25530 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
25531 @@ -162,8 +163,15 @@ static int tcp_v6_connect(struct sock *s
25532 * connect() to INADDR_ANY means loopback (BSD'ism).
25535 - if(ipv6_addr_any(&usin->sin6_addr))
25536 - usin->sin6_addr.s6_addr[15] = 0x1;
25537 + if(ipv6_addr_any(&usin->sin6_addr)) {
25538 + struct nx_info *nxi = sk->sk_nx_info;
25540 + if (nxi && nx_info_has_v6(nxi))
25541 + /* FIXME: remap lback? */
25542 + usin->sin6_addr = nxi->v6.ip;
25544 + usin->sin6_addr.s6_addr[15] = 0x1;
25547 addr_type = ipv6_addr_type(&usin->sin6_addr);
25549 diff -NurpP --minimal linux-3.1.6/net/ipv6/udp.c linux-3.1.6-vs2.3.2.5/net/ipv6/udp.c
25550 --- linux-3.1.6/net/ipv6/udp.c 2011-10-24 18:45:34.000000000 +0200
25551 +++ linux-3.1.6-vs2.3.2.5/net/ipv6/udp.c 2011-10-24 18:53:33.000000000 +0200
25552 @@ -45,41 +45,67 @@
25553 #include <net/tcp_states.h>
25554 #include <net/ip6_checksum.h>
25555 #include <net/xfrm.h>
25556 +#include <linux/vs_inet6.h>
25558 #include <linux/proc_fs.h>
25559 #include <linux/seq_file.h>
25560 #include "udp_impl.h"
25562 -int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
25563 +int ipv6_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25565 - const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
25566 + const struct in6_addr *sk1_rcv_saddr6 = &inet6_sk(sk1)->rcv_saddr;
25567 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
25568 - __be32 sk1_rcv_saddr = sk_rcv_saddr(sk);
25569 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1);
25570 __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
25571 - int sk_ipv6only = ipv6_only_sock(sk);
25572 + int sk1_ipv6only = ipv6_only_sock(sk1);
25573 int sk2_ipv6only = inet_v6_ipv6only(sk2);
25574 - int addr_type = ipv6_addr_type(sk_rcv_saddr6);
25575 + int addr_type = ipv6_addr_type(sk1_rcv_saddr6);
25576 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
25578 /* if both are mapped, treat as IPv4 */
25579 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
25580 - return (!sk2_ipv6only &&
25581 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
25582 + if (!sk2_ipv6only &&
25583 (!sk1_rcv_saddr || !sk2_rcv_saddr ||
25584 - sk1_rcv_saddr == sk2_rcv_saddr));
25585 + sk1_rcv_saddr == sk2_rcv_saddr))
25591 if (addr_type2 == IPV6_ADDR_ANY &&
25592 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
25596 if (addr_type == IPV6_ADDR_ANY &&
25597 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
25599 + !(sk1_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
25602 if (sk2_rcv_saddr6 &&
25603 - ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
25605 + ipv6_addr_equal(sk1_rcv_saddr6, sk2_rcv_saddr6))
25611 + if (!sk1_rcv_saddr && !sk2_rcv_saddr)
25612 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25613 + if (!sk2_rcv_saddr)
25614 + return v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, -1);
25615 + if (!sk1_rcv_saddr)
25616 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, -1);
25619 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
25620 + return nx_v6_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25621 + else if (addr_type2 == IPV6_ADDR_ANY)
25622 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr6, -1);
25623 + else if (addr_type == IPV6_ADDR_ANY) {
25624 + if (addr_type2 == IPV6_ADDR_MAPPED)
25625 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25627 + return v6_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr6, -1);
25632 static unsigned int udp6_portaddr_hash(struct net *net,
25633 @@ -143,6 +169,10 @@ static inline int compute_score(struct s
25634 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25638 + /* block non nx_info ips */
25639 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25642 if (!ipv6_addr_any(&np->daddr)) {
25643 if (!ipv6_addr_equal(&np->daddr, saddr))
25644 diff -NurpP --minimal linux-3.1.6/net/ipv6/xfrm6_policy.c linux-3.1.6-vs2.3.2.5/net/ipv6/xfrm6_policy.c
25645 --- linux-3.1.6/net/ipv6/xfrm6_policy.c 2011-07-22 11:18:13.000000000 +0200
25646 +++ linux-3.1.6-vs2.3.2.5/net/ipv6/xfrm6_policy.c 2011-10-24 18:53:33.000000000 +0200
25647 @@ -63,7 +63,7 @@ static int xfrm6_get_saddr(struct net *n
25648 dev = ip6_dst_idev(dst)->dev;
25649 ipv6_dev_get_saddr(dev_net(dev), dev,
25650 (struct in6_addr *)&daddr->a6, 0,
25651 - (struct in6_addr *)&saddr->a6);
25652 + (struct in6_addr *)&saddr->a6, NULL);
25656 diff -NurpP --minimal linux-3.1.6/net/netfilter/ipvs/ip_vs_xmit.c linux-3.1.6-vs2.3.2.5/net/netfilter/ipvs/ip_vs_xmit.c
25657 --- linux-3.1.6/net/netfilter/ipvs/ip_vs_xmit.c 2011-07-22 11:18:13.000000000 +0200
25658 +++ linux-3.1.6-vs2.3.2.5/net/netfilter/ipvs/ip_vs_xmit.c 2011-10-24 18:53:33.000000000 +0200
25659 @@ -226,7 +226,7 @@ __ip_vs_route_output_v6(struct net *net,
25661 if (ipv6_addr_any(&fl6.saddr) &&
25662 ipv6_dev_get_saddr(net, ip6_dst_idev(dst)->dev,
25663 - &fl6.daddr, 0, &fl6.saddr) < 0)
25664 + &fl6.daddr, 0, &fl6.saddr, NULL) < 0)
25667 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
25668 diff -NurpP --minimal linux-3.1.6/net/netlink/af_netlink.c linux-3.1.6-vs2.3.2.5/net/netlink/af_netlink.c
25669 --- linux-3.1.6/net/netlink/af_netlink.c 2011-10-24 18:45:34.000000000 +0200
25670 +++ linux-3.1.6-vs2.3.2.5/net/netlink/af_netlink.c 2011-10-24 18:53:33.000000000 +0200
25672 #include <linux/types.h>
25673 #include <linux/audit.h>
25674 #include <linux/mutex.h>
25675 +#include <linux/vs_context.h>
25676 +#include <linux/vs_network.h>
25677 +#include <linux/vs_limit.h>
25679 #include <net/net_namespace.h>
25680 #include <net/sock.h>
25681 @@ -1913,6 +1916,8 @@ static struct sock *netlink_seq_socket_i
25682 sk_for_each(s, node, &hash->table[j]) {
25683 if (sock_net(s) != seq_file_net(seq))
25685 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
25689 iter->hash_idx = j;
25690 @@ -1947,7 +1952,8 @@ static void *netlink_seq_next(struct seq
25694 - } while (s && sock_net(s) != seq_file_net(seq));
25695 + } while (s && (sock_net(s) != seq_file_net(seq) ||
25696 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
25700 @@ -1959,7 +1965,8 @@ static void *netlink_seq_next(struct seq
25702 for (; j <= hash->mask; j++) {
25703 s = sk_head(&hash->table[j]);
25704 - while (s && sock_net(s) != seq_file_net(seq))
25705 + while (s && (sock_net(s) != seq_file_net(seq) ||
25706 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
25710 diff -NurpP --minimal linux-3.1.6/net/socket.c linux-3.1.6-vs2.3.2.5/net/socket.c
25711 --- linux-3.1.6/net/socket.c 2011-10-24 18:45:34.000000000 +0200
25712 +++ linux-3.1.6-vs2.3.2.5/net/socket.c 2011-10-24 18:53:33.000000000 +0200
25715 #include <net/sock.h>
25716 #include <linux/netfilter.h>
25717 +#include <linux/vs_base.h>
25718 +#include <linux/vs_socket.h>
25719 +#include <linux/vs_inet.h>
25720 +#include <linux/vs_inet6.h>
25722 #include <linux/if_tun.h>
25723 #include <linux/ipv6_route.h>
25724 @@ -546,6 +550,7 @@ static inline int __sock_sendmsg_nosec(s
25725 struct msghdr *msg, size_t size)
25727 struct sock_iocb *si = kiocb_to_siocb(iocb);
25730 sock_update_classid(sock->sk);
25732 @@ -554,7 +559,22 @@ static inline int __sock_sendmsg_nosec(s
25736 - return sock->ops->sendmsg(iocb, sock, msg, size);
25737 + len = sock->ops->sendmsg(iocb, sock, msg, size);
25740 + vx_sock_send(sock->sk, size);
25742 + vx_sock_fail(sock->sk, size);
25744 + vxdprintk(VXD_CBIT(net, 7),
25745 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%zu",
25747 + (sock->sk)?sock->sk->sk_nx_info:0,
25748 + (sock->sk)?sock->sk->sk_vx_info:0,
25749 + (sock->sk)?sock->sk->sk_xid:0,
25750 + (sock->sk)?sock->sk->sk_nid:0,
25751 + (unsigned int)size, len);
25755 static inline int __sock_sendmsg(struct kiocb *iocb, struct socket *sock,
25756 @@ -694,6 +714,7 @@ static inline int __sock_recvmsg_nosec(s
25757 struct msghdr *msg, size_t size, int flags)
25759 struct sock_iocb *si = kiocb_to_siocb(iocb);
25762 sock_update_classid(sock->sk);
25764 @@ -703,7 +724,18 @@ static inline int __sock_recvmsg_nosec(s
25768 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
25769 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
25770 + if ((len >= 0) && sock->sk)
25771 + vx_sock_recv(sock->sk, len);
25772 + vxdprintk(VXD_CBIT(net, 7),
25773 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
25775 + (sock->sk)?sock->sk->sk_nx_info:0,
25776 + (sock->sk)?sock->sk->sk_vx_info:0,
25777 + (sock->sk)?sock->sk->sk_xid:0,
25778 + (sock->sk)?sock->sk->sk_nid:0,
25779 + (unsigned int)size, len);
25783 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
25784 @@ -1188,6 +1220,13 @@ int __sock_create(struct net *net, int f
25785 if (type < 0 || type >= SOCK_MAX)
25788 + if (!nx_check(0, VS_ADMIN)) {
25789 + if (family == PF_INET && !current_nx_info_has_v4())
25790 + return -EAFNOSUPPORT;
25791 + if (family == PF_INET6 && !current_nx_info_has_v6())
25792 + return -EAFNOSUPPORT;
25797 This uglymoron is moved from INET layer to here to avoid
25798 @@ -1323,6 +1362,7 @@ SYSCALL_DEFINE3(socket, int, family, int
25802 + set_bit(SOCK_USER_SOCKET, &sock->flags);
25803 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
25806 @@ -1364,10 +1404,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
25807 err = sock_create(family, type, protocol, &sock1);
25810 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
25812 err = sock_create(family, type, protocol, &sock2);
25814 goto out_release_1;
25815 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
25817 err = sock1->ops->socketpair(sock1, sock2);
25819 diff -NurpP --minimal linux-3.1.6/net/sunrpc/auth.c linux-3.1.6-vs2.3.2.5/net/sunrpc/auth.c
25820 --- linux-3.1.6/net/sunrpc/auth.c 2011-10-24 18:45:34.000000000 +0200
25821 +++ linux-3.1.6-vs2.3.2.5/net/sunrpc/auth.c 2011-10-24 18:53:33.000000000 +0200
25823 #include <linux/hash.h>
25824 #include <linux/sunrpc/clnt.h>
25825 #include <linux/spinlock.h>
25826 +#include <linux/vs_tag.h>
25829 # define RPCDBG_FACILITY RPCDBG_AUTH
25830 @@ -427,6 +428,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
25831 memset(&acred, 0, sizeof(acred));
25832 acred.uid = cred->fsuid;
25833 acred.gid = cred->fsgid;
25834 + acred.tag = dx_current_tag();
25835 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
25837 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
25838 @@ -467,6 +469,7 @@ rpcauth_bind_root_cred(struct rpc_task *
25839 struct auth_cred acred = {
25842 + .tag = dx_current_tag(),
25845 dprintk("RPC: %5u looking up %s cred\n",
25846 diff -NurpP --minimal linux-3.1.6/net/sunrpc/auth_unix.c linux-3.1.6-vs2.3.2.5/net/sunrpc/auth_unix.c
25847 --- linux-3.1.6/net/sunrpc/auth_unix.c 2011-12-23 16:04:07.000000000 +0100
25848 +++ linux-3.1.6-vs2.3.2.5/net/sunrpc/auth_unix.c 2011-11-15 17:08:44.000000000 +0100
25849 @@ -12,12 +12,14 @@
25850 #include <linux/module.h>
25851 #include <linux/sunrpc/clnt.h>
25852 #include <linux/sunrpc/auth.h>
25853 +#include <linux/vs_tag.h>
25855 #define NFS_NGROUPS 16
25858 struct rpc_cred uc_base;
25861 gid_t uc_gids[NFS_NGROUPS];
25863 #define uc_uid uc_base.cr_uid
25864 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
25865 groups = NFS_NGROUPS;
25867 cred->uc_gid = acred->gid;
25868 + cred->uc_tag = acred->tag;
25869 for (i = 0; i < groups; i++)
25870 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
25871 if (i < NFS_NGROUPS)
25872 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
25876 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
25877 + if (cred->uc_uid != acred->uid ||
25878 + cred->uc_gid != acred->gid ||
25879 + cred->uc_tag != acred->tag)
25882 if (acred->group_info != NULL)
25883 @@ -145,7 +150,7 @@ unx_marshal(struct rpc_task *task, __be3
25884 struct rpc_clnt *clnt = task->tk_client;
25885 struct unx_cred *cred = container_of(task->tk_rqstp->rq_cred, struct unx_cred, uc_base);
25886 __be32 *base, *hold;
25890 *p++ = htonl(RPC_AUTH_UNIX);
25892 @@ -155,9 +160,12 @@ unx_marshal(struct rpc_task *task, __be3
25893 * Copy the UTS nodename captured when the client was created.
25895 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
25896 + tag = task->tk_client->cl_tag;
25898 - *p++ = htonl((u32) cred->uc_uid);
25899 - *p++ = htonl((u32) cred->uc_gid);
25900 + *p++ = htonl((u32) TAGINO_UID(tag,
25901 + cred->uc_uid, cred->uc_tag));
25902 + *p++ = htonl((u32) TAGINO_GID(tag,
25903 + cred->uc_gid, cred->uc_tag));
25905 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
25906 *p++ = htonl((u32) cred->uc_gids[i]);
25907 diff -NurpP --minimal linux-3.1.6/net/sunrpc/clnt.c linux-3.1.6-vs2.3.2.5/net/sunrpc/clnt.c
25908 --- linux-3.1.6/net/sunrpc/clnt.c 2011-10-24 18:45:34.000000000 +0200
25909 +++ linux-3.1.6-vs2.3.2.5/net/sunrpc/clnt.c 2011-10-24 18:53:33.000000000 +0200
25911 #include <linux/in.h>
25912 #include <linux/in6.h>
25913 #include <linux/un.h>
25914 +#include <linux/vs_cvirt.h>
25916 #include <linux/sunrpc/clnt.h>
25917 #include <linux/sunrpc/rpc_pipe_fs.h>
25918 @@ -361,6 +362,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
25919 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
25920 clnt->cl_chatty = 1;
25922 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
25923 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
25924 + clnt->cl_tag = 1; */
25927 EXPORT_SYMBOL_GPL(rpc_create);
25928 diff -NurpP --minimal linux-3.1.6/net/unix/af_unix.c linux-3.1.6-vs2.3.2.5/net/unix/af_unix.c
25929 --- linux-3.1.6/net/unix/af_unix.c 2011-10-24 18:45:34.000000000 +0200
25930 +++ linux-3.1.6-vs2.3.2.5/net/unix/af_unix.c 2011-10-24 18:53:33.000000000 +0200
25931 @@ -114,6 +114,8 @@
25932 #include <linux/mount.h>
25933 #include <net/checksum.h>
25934 #include <linux/security.h>
25935 +#include <linux/vs_context.h>
25936 +#include <linux/vs_limit.h>
25938 static struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
25939 static DEFINE_SPINLOCK(unix_table_lock);
25940 @@ -258,6 +260,8 @@ static struct sock *__unix_find_socket_b
25941 if (!net_eq(sock_net(s), net))
25944 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
25946 if (u->addr->len == len &&
25947 !memcmp(u->addr->name, sunname, len))
25949 @@ -2204,6 +2208,8 @@ static struct sock *unix_seq_idx(struct
25950 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
25951 if (sock_net(s) != seq_file_net(seq))
25953 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
25958 @@ -2228,7 +2234,8 @@ static void *unix_seq_next(struct seq_fi
25959 sk = first_unix_socket(&iter->i);
25961 sk = next_unix_socket(&iter->i, sk);
25962 - while (sk && (sock_net(sk) != seq_file_net(seq)))
25963 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
25964 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
25965 sk = next_unix_socket(&iter->i, sk);
25968 diff -NurpP --minimal linux-3.1.6/scripts/checksyscalls.sh linux-3.1.6-vs2.3.2.5/scripts/checksyscalls.sh
25969 --- linux-3.1.6/scripts/checksyscalls.sh 2011-03-15 18:07:46.000000000 +0100
25970 +++ linux-3.1.6-vs2.3.2.5/scripts/checksyscalls.sh 2011-10-24 18:53:33.000000000 +0200
25971 @@ -193,7 +193,6 @@ cat << EOF
25972 #define __IGNORE_afs_syscall
25973 #define __IGNORE_getpmsg
25974 #define __IGNORE_putpmsg
25975 -#define __IGNORE_vserver
25979 diff -NurpP --minimal linux-3.1.6/security/commoncap.c linux-3.1.6-vs2.3.2.5/security/commoncap.c
25980 --- linux-3.1.6/security/commoncap.c 2011-07-22 11:18:14.000000000 +0200
25981 +++ linux-3.1.6-vs2.3.2.5/security/commoncap.c 2011-10-24 18:53:33.000000000 +0200
25982 @@ -62,6 +62,7 @@ int cap_netlink_recv(struct sk_buff *skb
25987 EXPORT_SYMBOL(cap_netlink_recv);
25990 @@ -83,14 +84,20 @@ EXPORT_SYMBOL(cap_netlink_recv);
25991 int cap_capable(struct task_struct *tsk, const struct cred *cred,
25992 struct user_namespace *targ_ns, int cap, int audit)
25994 + struct vx_info *vxi = tsk->vx_info;
25997 /* The creator of the user namespace has all caps. */
25998 if (targ_ns != &init_user_ns && targ_ns->creator == cred->user)
26001 /* Do we have the necessary capabilities? */
26002 - if (targ_ns == cred->user->user_ns)
26003 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
26004 + if (targ_ns == cred->user->user_ns) {
26005 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
26006 + cap_raised(cred->cap_effective, cap))
26008 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
26011 /* Have we tried all of the parent namespaces? */
26012 if (targ_ns == &init_user_ns)
26013 @@ -611,7 +618,7 @@ int cap_inode_setxattr(struct dentry *de
26015 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26016 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26017 - !capable(CAP_SYS_ADMIN))
26018 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26022 @@ -637,7 +644,7 @@ int cap_inode_removexattr(struct dentry
26024 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26025 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26026 - !capable(CAP_SYS_ADMIN))
26027 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26031 diff -NurpP --minimal linux-3.1.6/security/selinux/hooks.c linux-3.1.6-vs2.3.2.5/security/selinux/hooks.c
26032 --- linux-3.1.6/security/selinux/hooks.c 2011-10-24 18:45:35.000000000 +0200
26033 +++ linux-3.1.6-vs2.3.2.5/security/selinux/hooks.c 2011-10-24 18:53:33.000000000 +0200
26035 #include <linux/dccp.h>
26036 #include <linux/quota.h>
26037 #include <linux/un.h> /* for Unix socket types */
26038 -#include <net/af_unix.h> /* for Unix socket types */
26039 #include <linux/parser.h>
26040 #include <linux/nfs_mount.h>
26041 #include <net/ipv6.h>