1 diff -NurpP --minimal linux-3.6.9/Documentation/vserver/debug.txt linux-3.6.9-vs2.3.4.4/Documentation/vserver/debug.txt
2 --- linux-3.6.9/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-3.6.9-vs2.3.4.4/Documentation/vserver/debug.txt 2012-10-04 18:46:59.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.6.9/arch/alpha/Kconfig linux-3.6.9-vs2.3.4.4/arch/alpha/Kconfig
160 --- linux-3.6.9/arch/alpha/Kconfig 2012-10-04 15:26:43.000000000 +0200
161 +++ linux-3.6.9-vs2.3.4.4/arch/alpha/Kconfig 2012-10-04 18:46:59.000000000 +0200
162 @@ -664,6 +664,8 @@ config DUMMY_CONSOLE
166 +source "kernel/vserver/Kconfig"
168 source "security/Kconfig"
170 source "crypto/Kconfig"
171 diff -NurpP --minimal linux-3.6.9/arch/alpha/kernel/ptrace.c linux-3.6.9-vs2.3.4.4/arch/alpha/kernel/ptrace.c
172 --- linux-3.6.9/arch/alpha/kernel/ptrace.c 2012-05-21 18:06:12.000000000 +0200
173 +++ linux-3.6.9-vs2.3.4.4/arch/alpha/kernel/ptrace.c 2012-10-04 18:46:59.000000000 +0200
175 #include <linux/user.h>
176 #include <linux/security.h>
177 #include <linux/signal.h>
178 +#include <linux/vs_base.h>
180 #include <asm/uaccess.h>
181 #include <asm/pgtable.h>
182 diff -NurpP --minimal linux-3.6.9/arch/alpha/kernel/systbls.S linux-3.6.9-vs2.3.4.4/arch/alpha/kernel/systbls.S
183 --- linux-3.6.9/arch/alpha/kernel/systbls.S 2012-10-04 15:26:43.000000000 +0200
184 +++ linux-3.6.9-vs2.3.4.4/arch/alpha/kernel/systbls.S 2012-10-04 18:46:59.000000000 +0200
185 @@ -446,7 +446,7 @@ sys_call_table:
186 .quad sys_stat64 /* 425 */
189 - .quad sys_ni_syscall /* sys_vserver */
190 + .quad sys_vserver /* sys_vserver */
191 .quad sys_ni_syscall /* sys_mbind */
192 .quad sys_ni_syscall /* sys_get_mempolicy */
193 .quad sys_ni_syscall /* sys_set_mempolicy */
194 diff -NurpP --minimal linux-3.6.9/arch/alpha/kernel/traps.c linux-3.6.9-vs2.3.4.4/arch/alpha/kernel/traps.c
195 --- linux-3.6.9/arch/alpha/kernel/traps.c 2012-05-21 18:06:12.000000000 +0200
196 +++ linux-3.6.9-vs2.3.4.4/arch/alpha/kernel/traps.c 2012-10-04 18:46:59.000000000 +0200
197 @@ -184,7 +184,8 @@ die_if_kernel(char * str, struct pt_regs
199 printk("CPU %d ", hard_smp_processor_id());
201 - printk("%s(%d): %s %ld\n", current->comm, task_pid_nr(current), str, err);
202 + printk("%s(%d[#%u]): %s %ld\n", current->comm,
203 + task_pid_nr(current), current->xid, str, err);
204 dik_show_regs(regs, r9_15);
205 add_taint(TAINT_DIE);
206 dik_show_trace((unsigned long *)(regs+1));
207 diff -NurpP --minimal linux-3.6.9/arch/arm/Kconfig linux-3.6.9-vs2.3.4.4/arch/arm/Kconfig
208 --- linux-3.6.9/arch/arm/Kconfig 2012-12-08 01:34:06.000000000 +0100
209 +++ linux-3.6.9-vs2.3.4.4/arch/arm/Kconfig 2012-11-06 18:43:40.000000000 +0100
210 @@ -2341,6 +2341,8 @@ source "fs/Kconfig"
212 source "arch/arm/Kconfig.debug"
214 +source "kernel/vserver/Kconfig"
216 source "security/Kconfig"
218 source "crypto/Kconfig"
219 diff -NurpP --minimal linux-3.6.9/arch/arm/kernel/calls.S linux-3.6.9-vs2.3.4.4/arch/arm/kernel/calls.S
220 --- linux-3.6.9/arch/arm/kernel/calls.S 2012-10-04 15:26:43.000000000 +0200
221 +++ linux-3.6.9-vs2.3.4.4/arch/arm/kernel/calls.S 2012-10-04 18:46:59.000000000 +0200
223 /* 310 */ CALL(sys_request_key)
225 CALL(ABI(sys_semtimedop, sys_oabi_semtimedop))
226 -/* vserver */ CALL(sys_ni_syscall)
229 /* 315 */ CALL(sys_ioprio_get)
230 CALL(sys_inotify_init)
231 diff -NurpP --minimal linux-3.6.9/arch/arm/kernel/process.c linux-3.6.9-vs2.3.4.4/arch/arm/kernel/process.c
232 --- linux-3.6.9/arch/arm/kernel/process.c 2012-10-04 15:26:43.000000000 +0200
233 +++ linux-3.6.9-vs2.3.4.4/arch/arm/kernel/process.c 2012-10-04 18:46:59.000000000 +0200
234 @@ -337,7 +337,8 @@ void __show_regs(struct pt_regs *regs)
235 void show_regs(struct pt_regs * regs)
238 - printk("Pid: %d, comm: %20s\n", task_pid_nr(current), current->comm);
239 + printk("Pid: %d[#%u], comm: %20s\n",
240 + task_pid_nr(current), current->xid, current->comm);
244 diff -NurpP --minimal linux-3.6.9/arch/arm/kernel/traps.c linux-3.6.9-vs2.3.4.4/arch/arm/kernel/traps.c
245 --- linux-3.6.9/arch/arm/kernel/traps.c 2012-10-04 15:26:44.000000000 +0200
246 +++ linux-3.6.9-vs2.3.4.4/arch/arm/kernel/traps.c 2012-10-04 19:03:56.000000000 +0200
247 @@ -249,8 +249,8 @@ static int __die(const char *str, int er
251 - printk(KERN_EMERG "Process %.*s (pid: %d, stack limit = 0x%p)\n",
252 - TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), end_of_stack(tsk));
253 + printk(KERN_EMERG "Process %.*s (pid: %d:#%u, stack limit = 0x%p)\n",
254 + TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), tsk->xid, end_of_stack(tsk));
256 if (!user_mode(regs) || in_interrupt()) {
257 dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp,
258 diff -NurpP --minimal linux-3.6.9/arch/cris/Kconfig linux-3.6.9-vs2.3.4.4/arch/cris/Kconfig
259 --- linux-3.6.9/arch/cris/Kconfig 2012-10-04 15:26:51.000000000 +0200
260 +++ linux-3.6.9-vs2.3.4.4/arch/cris/Kconfig 2012-10-04 18:46:59.000000000 +0200
261 @@ -673,6 +673,8 @@ source "drivers/staging/Kconfig"
263 source "arch/cris/Kconfig.debug"
265 +source "kernel/vserver/Kconfig"
267 source "security/Kconfig"
269 source "crypto/Kconfig"
270 diff -NurpP --minimal linux-3.6.9/arch/frv/kernel/kernel_thread.S linux-3.6.9-vs2.3.4.4/arch/frv/kernel/kernel_thread.S
271 --- linux-3.6.9/arch/frv/kernel/kernel_thread.S 2012-10-04 15:26:51.000000000 +0200
272 +++ linux-3.6.9-vs2.3.4.4/arch/frv/kernel/kernel_thread.S 2012-10-04 18:46:59.000000000 +0200
273 @@ -37,7 +37,7 @@ kernel_thread:
275 # start by forking the current process, but with shared VM
276 setlos.p #__NR_clone,gr7 ; syscall number
277 - ori gr10,#CLONE_VM,gr8 ; first syscall arg [clone_flags]
278 + ori gr10,#CLONE_KT,gr8 ; first syscall arg [clone_flags]
279 sethi.p #0xe4e4,gr9 ; second syscall arg [newsp]
281 setlos.p #0,gr10 ; third syscall arg [parent_tidptr]
282 diff -NurpP --minimal linux-3.6.9/arch/h8300/Kconfig linux-3.6.9-vs2.3.4.4/arch/h8300/Kconfig
283 --- linux-3.6.9/arch/h8300/Kconfig 2012-10-04 15:26:51.000000000 +0200
284 +++ linux-3.6.9-vs2.3.4.4/arch/h8300/Kconfig 2012-10-04 18:46:59.000000000 +0200
285 @@ -215,6 +215,8 @@ source "fs/Kconfig"
287 source "arch/h8300/Kconfig.debug"
289 +source "kernel/vserver/Kconfig"
291 source "security/Kconfig"
293 source "crypto/Kconfig"
294 diff -NurpP --minimal linux-3.6.9/arch/ia64/Kconfig linux-3.6.9-vs2.3.4.4/arch/ia64/Kconfig
295 --- linux-3.6.9/arch/ia64/Kconfig 2012-10-04 15:26:51.000000000 +0200
296 +++ linux-3.6.9-vs2.3.4.4/arch/ia64/Kconfig 2012-10-04 18:46:59.000000000 +0200
297 @@ -652,6 +652,8 @@ source "fs/Kconfig"
299 source "arch/ia64/Kconfig.debug"
301 +source "kernel/vserver/Kconfig"
303 source "security/Kconfig"
305 source "crypto/Kconfig"
306 diff -NurpP --minimal linux-3.6.9/arch/ia64/kernel/entry.S linux-3.6.9-vs2.3.4.4/arch/ia64/kernel/entry.S
307 --- linux-3.6.9/arch/ia64/kernel/entry.S 2012-03-19 19:46:40.000000000 +0100
308 +++ linux-3.6.9-vs2.3.4.4/arch/ia64/kernel/entry.S 2012-10-04 18:46:59.000000000 +0200
309 @@ -1714,7 +1714,7 @@ sys_call_table:
311 data8 sys_mq_getsetattr
313 - data8 sys_ni_syscall // reserved for vserver
315 data8 sys_waitid // 1270
317 data8 sys_request_key
318 diff -NurpP --minimal linux-3.6.9/arch/ia64/kernel/process.c linux-3.6.9-vs2.3.4.4/arch/ia64/kernel/process.c
319 --- linux-3.6.9/arch/ia64/kernel/process.c 2012-12-08 01:34:06.000000000 +0100
320 +++ linux-3.6.9-vs2.3.4.4/arch/ia64/kernel/process.c 2012-11-06 18:43:40.000000000 +0100
321 @@ -111,8 +111,8 @@ show_regs (struct pt_regs *regs)
322 unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
325 - printk("\nPid: %d, CPU %d, comm: %20s\n", task_pid_nr(current),
326 - smp_processor_id(), current->comm);
327 + printk("\nPid: %d[#%u], CPU %d, comm: %20s\n", task_pid_nr(current),
328 + current->xid, smp_processor_id(), current->comm);
329 printk("psr : %016lx ifs : %016lx ip : [<%016lx>] %s (%s)\n",
330 regs->cr_ipsr, regs->cr_ifs, ip, print_tainted(),
331 init_utsname()->release);
332 diff -NurpP --minimal linux-3.6.9/arch/ia64/kernel/ptrace.c linux-3.6.9-vs2.3.4.4/arch/ia64/kernel/ptrace.c
333 --- linux-3.6.9/arch/ia64/kernel/ptrace.c 2012-05-21 18:06:26.000000000 +0200
334 +++ linux-3.6.9-vs2.3.4.4/arch/ia64/kernel/ptrace.c 2012-10-04 18:46:59.000000000 +0200
336 #include <linux/regset.h>
337 #include <linux/elf.h>
338 #include <linux/tracehook.h>
339 +#include <linux/vs_base.h>
341 #include <asm/pgtable.h>
342 #include <asm/processor.h>
343 diff -NurpP --minimal linux-3.6.9/arch/ia64/kernel/traps.c linux-3.6.9-vs2.3.4.4/arch/ia64/kernel/traps.c
344 --- linux-3.6.9/arch/ia64/kernel/traps.c 2012-05-21 18:06:26.000000000 +0200
345 +++ linux-3.6.9-vs2.3.4.4/arch/ia64/kernel/traps.c 2012-10-04 18:47:00.000000000 +0200
346 @@ -60,8 +60,9 @@ die (const char *str, struct pt_regs *re
349 if (++die.lock_owner_depth < 3) {
350 - printk("%s[%d]: %s %ld [%d]\n",
351 - current->comm, task_pid_nr(current), str, err, ++die_counter);
352 + printk("%s[%d[#%u]]: %s %ld [%d]\n",
353 + current->comm, task_pid_nr(current), current->xid,
354 + str, err, ++die_counter);
355 if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV)
358 @@ -324,8 +325,9 @@ handle_fpu_swa (int fp_fault, struct pt_
359 if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
360 last.time = current_jiffies + 5 * HZ;
362 - "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
363 - current->comm, task_pid_nr(current), regs->cr_iip + ia64_psr(regs)->ri, isr);
364 + "%s(%d[#%u]): floating-point assist fault at ip %016lx, isr %016lx\n",
365 + current->comm, task_pid_nr(current), current->xid,
366 + regs->cr_iip + ia64_psr(regs)->ri, isr);
370 diff -NurpP --minimal linux-3.6.9/arch/m32r/kernel/traps.c linux-3.6.9-vs2.3.4.4/arch/m32r/kernel/traps.c
371 --- linux-3.6.9/arch/m32r/kernel/traps.c 2012-05-21 18:06:26.000000000 +0200
372 +++ linux-3.6.9-vs2.3.4.4/arch/m32r/kernel/traps.c 2012-10-04 18:47:00.000000000 +0200
373 @@ -195,8 +195,9 @@ static void show_registers(struct pt_reg
375 printk("SPI: %08lx\n", sp);
377 - printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
378 - current->comm, task_pid_nr(current), 0xffff & i, 4096+(unsigned long)current);
379 + printk("Process %s (pid: %d[#%u], process nr: %d, stackpage=%08lx)",
380 + current->comm, task_pid_nr(current), current->xid,
381 + 0xffff & i, 4096+(unsigned long)current);
384 * When in-kernel, we also print out the stack and code at the
385 diff -NurpP --minimal linux-3.6.9/arch/m68k/Kconfig linux-3.6.9-vs2.3.4.4/arch/m68k/Kconfig
386 --- linux-3.6.9/arch/m68k/Kconfig 2012-10-04 15:26:51.000000000 +0200
387 +++ linux-3.6.9-vs2.3.4.4/arch/m68k/Kconfig 2012-10-04 18:47:00.000000000 +0200
388 @@ -129,6 +129,8 @@ source "fs/Kconfig"
390 source "arch/m68k/Kconfig.debug"
392 +source "kernel/vserver/Kconfig"
394 source "security/Kconfig"
396 source "crypto/Kconfig"
397 diff -NurpP --minimal linux-3.6.9/arch/mips/Kconfig linux-3.6.9-vs2.3.4.4/arch/mips/Kconfig
398 --- linux-3.6.9/arch/mips/Kconfig 2012-10-04 15:26:52.000000000 +0200
399 +++ linux-3.6.9-vs2.3.4.4/arch/mips/Kconfig 2012-10-04 18:47:00.000000000 +0200
400 @@ -2554,6 +2554,8 @@ source "fs/Kconfig"
402 source "arch/mips/Kconfig.debug"
404 +source "kernel/vserver/Kconfig"
406 source "security/Kconfig"
408 source "crypto/Kconfig"
409 diff -NurpP --minimal linux-3.6.9/arch/mips/kernel/ptrace.c linux-3.6.9-vs2.3.4.4/arch/mips/kernel/ptrace.c
410 --- linux-3.6.9/arch/mips/kernel/ptrace.c 2012-07-22 23:38:52.000000000 +0200
411 +++ linux-3.6.9-vs2.3.4.4/arch/mips/kernel/ptrace.c 2012-10-04 18:47:00.000000000 +0200
413 #include <linux/security.h>
414 #include <linux/audit.h>
415 #include <linux/seccomp.h>
416 +#include <linux/vs_base.h>
418 #include <asm/byteorder.h>
420 @@ -262,6 +263,9 @@ long arch_ptrace(struct task_struct *chi
421 void __user *datavp = (void __user *) data;
422 unsigned long __user *datalp = (void __user *) data;
424 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
428 /* when I and D space are separate, these will need to be fixed. */
429 case PTRACE_PEEKTEXT: /* read word at location addr. */
430 diff -NurpP --minimal linux-3.6.9/arch/mips/kernel/scall32-o32.S linux-3.6.9-vs2.3.4.4/arch/mips/kernel/scall32-o32.S
431 --- linux-3.6.9/arch/mips/kernel/scall32-o32.S 2012-01-09 16:14:05.000000000 +0100
432 +++ linux-3.6.9-vs2.3.4.4/arch/mips/kernel/scall32-o32.S 2012-10-04 18:47:00.000000000 +0200
433 @@ -523,7 +523,7 @@ einval: li v0, -ENOSYS
434 sys sys_mq_timedreceive 5
435 sys sys_mq_notify 2 /* 4275 */
436 sys sys_mq_getsetattr 3
437 - sys sys_ni_syscall 0 /* sys_vserver */
440 sys sys_ni_syscall 0 /* available, was setaltroot */
441 sys sys_add_key 5 /* 4280 */
442 diff -NurpP --minimal linux-3.6.9/arch/mips/kernel/scall64-64.S linux-3.6.9-vs2.3.4.4/arch/mips/kernel/scall64-64.S
443 --- linux-3.6.9/arch/mips/kernel/scall64-64.S 2012-01-09 16:14:05.000000000 +0100
444 +++ linux-3.6.9-vs2.3.4.4/arch/mips/kernel/scall64-64.S 2012-10-04 18:47:00.000000000 +0200
445 @@ -362,7 +362,7 @@ sys_call_table:
446 PTR sys_mq_timedreceive
448 PTR sys_mq_getsetattr /* 5235 */
449 - PTR sys_ni_syscall /* sys_vserver */
452 PTR sys_ni_syscall /* available, was setaltroot */
454 diff -NurpP --minimal linux-3.6.9/arch/mips/kernel/scall64-n32.S linux-3.6.9-vs2.3.4.4/arch/mips/kernel/scall64-n32.S
455 --- linux-3.6.9/arch/mips/kernel/scall64-n32.S 2012-01-09 16:14:05.000000000 +0100
456 +++ linux-3.6.9-vs2.3.4.4/arch/mips/kernel/scall64-n32.S 2012-10-04 18:47:00.000000000 +0200
457 @@ -361,7 +361,7 @@ EXPORT(sysn32_call_table)
458 PTR compat_sys_mq_timedreceive
459 PTR compat_sys_mq_notify
460 PTR compat_sys_mq_getsetattr
461 - PTR sys_ni_syscall /* 6240, sys_vserver */
462 + PTR sys32_vserver /* 6240 */
463 PTR compat_sys_waitid
464 PTR sys_ni_syscall /* available, was setaltroot */
466 diff -NurpP --minimal linux-3.6.9/arch/mips/kernel/scall64-o32.S linux-3.6.9-vs2.3.4.4/arch/mips/kernel/scall64-o32.S
467 --- linux-3.6.9/arch/mips/kernel/scall64-o32.S 2012-01-09 16:14:05.000000000 +0100
468 +++ linux-3.6.9-vs2.3.4.4/arch/mips/kernel/scall64-o32.S 2012-10-04 18:47:00.000000000 +0200
469 @@ -480,7 +480,7 @@ sys_call_table:
470 PTR compat_sys_mq_timedreceive
471 PTR compat_sys_mq_notify /* 4275 */
472 PTR compat_sys_mq_getsetattr
473 - PTR sys_ni_syscall /* sys_vserver */
476 PTR sys_ni_syscall /* available, was setaltroot */
477 PTR sys_add_key /* 4280 */
478 diff -NurpP --minimal linux-3.6.9/arch/mips/kernel/traps.c linux-3.6.9-vs2.3.4.4/arch/mips/kernel/traps.c
479 --- linux-3.6.9/arch/mips/kernel/traps.c 2012-10-04 15:26:53.000000000 +0200
480 +++ linux-3.6.9-vs2.3.4.4/arch/mips/kernel/traps.c 2012-10-04 18:47:00.000000000 +0200
481 @@ -347,9 +347,10 @@ void show_registers(struct pt_regs *regs
485 - printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
486 - current->comm, current->pid, current_thread_info(), current,
487 - field, current_thread_info()->tp_value);
488 + printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p, tls=%0*lx)\n",
489 + current->comm, task_pid_nr(current), current->xid,
490 + current_thread_info(), current,
491 + field, current_thread_info()->tp_value);
492 if (cpu_has_userlocal) {
495 diff -NurpP --minimal linux-3.6.9/arch/parisc/Kconfig linux-3.6.9-vs2.3.4.4/arch/parisc/Kconfig
496 --- linux-3.6.9/arch/parisc/Kconfig 2012-07-22 23:38:52.000000000 +0200
497 +++ linux-3.6.9-vs2.3.4.4/arch/parisc/Kconfig 2012-10-04 18:47:00.000000000 +0200
498 @@ -281,6 +281,8 @@ source "fs/Kconfig"
500 source "arch/parisc/Kconfig.debug"
502 +source "kernel/vserver/Kconfig"
504 source "security/Kconfig"
506 source "crypto/Kconfig"
507 diff -NurpP --minimal linux-3.6.9/arch/parisc/kernel/syscall_table.S linux-3.6.9-vs2.3.4.4/arch/parisc/kernel/syscall_table.S
508 --- linux-3.6.9/arch/parisc/kernel/syscall_table.S 2011-10-24 18:45:00.000000000 +0200
509 +++ linux-3.6.9-vs2.3.4.4/arch/parisc/kernel/syscall_table.S 2012-10-04 18:47:00.000000000 +0200
511 ENTRY_COMP(mbind) /* 260 */
512 ENTRY_COMP(get_mempolicy)
513 ENTRY_COMP(set_mempolicy)
514 - ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */
515 + ENTRY_DIFF(vserver)
517 ENTRY_SAME(request_key) /* 265 */
519 diff -NurpP --minimal linux-3.6.9/arch/parisc/kernel/traps.c linux-3.6.9-vs2.3.4.4/arch/parisc/kernel/traps.c
520 --- linux-3.6.9/arch/parisc/kernel/traps.c 2012-05-21 18:06:28.000000000 +0200
521 +++ linux-3.6.9-vs2.3.4.4/arch/parisc/kernel/traps.c 2012-10-04 18:47:00.000000000 +0200
522 @@ -235,8 +235,9 @@ void die_if_kernel(char *str, struct pt_
526 - printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
527 - current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
528 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
529 + current->comm, task_pid_nr(current), current->xid,
530 + str, err, regs->iaoq[0]);
531 #ifdef PRINT_USER_FAULTS
532 /* XXX for debugging only */
534 @@ -269,8 +270,8 @@ void die_if_kernel(char *str, struct pt_
535 pdc_console_restart();
538 - printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
539 - current->comm, task_pid_nr(current), str, err);
540 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
541 + current->comm, task_pid_nr(current), current->xid, str, err);
543 /* Wot's wrong wif bein' racy? */
544 if (current->thread.flags & PARISC_KERNEL_DEATH) {
545 diff -NurpP --minimal linux-3.6.9/arch/parisc/mm/fault.c linux-3.6.9-vs2.3.4.4/arch/parisc/mm/fault.c
546 --- linux-3.6.9/arch/parisc/mm/fault.c 2010-08-02 16:52:06.000000000 +0200
547 +++ linux-3.6.9-vs2.3.4.4/arch/parisc/mm/fault.c 2012-10-04 18:47:00.000000000 +0200
548 @@ -237,8 +237,9 @@ bad_area:
550 #ifdef PRINT_USER_FAULTS
551 printk(KERN_DEBUG "\n");
552 - printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
553 - task_pid_nr(tsk), tsk->comm, code, address);
554 + printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
555 + "command='%s' type=%lu address=0x%08lx\n",
556 + task_pid_nr(tsk), tsk->xid, tsk->comm, code, address);
558 printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
559 vma->vm_start, vma->vm_end);
560 diff -NurpP --minimal linux-3.6.9/arch/powerpc/Kconfig linux-3.6.9-vs2.3.4.4/arch/powerpc/Kconfig
561 --- linux-3.6.9/arch/powerpc/Kconfig 2012-10-04 15:26:53.000000000 +0200
562 +++ linux-3.6.9-vs2.3.4.4/arch/powerpc/Kconfig 2012-10-04 18:47:00.000000000 +0200
563 @@ -996,6 +996,8 @@ source "lib/Kconfig"
565 source "arch/powerpc/Kconfig.debug"
567 +source "kernel/vserver/Kconfig"
569 source "security/Kconfig"
572 diff -NurpP --minimal linux-3.6.9/arch/powerpc/include/asm/unistd.h linux-3.6.9-vs2.3.4.4/arch/powerpc/include/asm/unistd.h
573 --- linux-3.6.9/arch/powerpc/include/asm/unistd.h 2012-10-04 15:26:53.000000000 +0200
574 +++ linux-3.6.9-vs2.3.4.4/arch/powerpc/include/asm/unistd.h 2012-10-04 18:47:00.000000000 +0200
577 #define __NR_rtas 255
578 #define __NR_sys_debug_setcontext 256
579 -/* Number 257 is reserved for vserver */
580 +#define __NR_vserver 257
581 #define __NR_migrate_pages 258
582 #define __NR_mbind 259
583 #define __NR_get_mempolicy 260
584 diff -NurpP --minimal linux-3.6.9/arch/powerpc/kernel/process.c linux-3.6.9-vs2.3.4.4/arch/powerpc/kernel/process.c
585 --- linux-3.6.9/arch/powerpc/kernel/process.c 2012-10-04 15:26:54.000000000 +0200
586 +++ linux-3.6.9-vs2.3.4.4/arch/powerpc/kernel/process.c 2012-10-04 18:47:00.000000000 +0200
587 @@ -661,8 +661,9 @@ void show_regs(struct pt_regs * regs)
589 printk("DAR: "REG", DSISR: %08lx\n", regs->dar, regs->dsisr);
591 - printk("TASK = %p[%d] '%s' THREAD: %p",
592 - current, task_pid_nr(current), current->comm, task_thread_info(current));
593 + printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
594 + current, task_pid_nr(current), current->xid,
595 + current->comm, task_thread_info(current));
598 printk(" CPU: %d", raw_smp_processor_id());
599 diff -NurpP --minimal linux-3.6.9/arch/powerpc/kernel/traps.c linux-3.6.9-vs2.3.4.4/arch/powerpc/kernel/traps.c
600 --- linux-3.6.9/arch/powerpc/kernel/traps.c 2012-10-04 15:26:54.000000000 +0200
601 +++ linux-3.6.9-vs2.3.4.4/arch/powerpc/kernel/traps.c 2012-10-04 18:47:00.000000000 +0200
602 @@ -1119,8 +1119,9 @@ void nonrecoverable_exception(struct pt_
604 void trace_syscall(struct pt_regs *regs)
606 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
607 - current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
608 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
609 + current, task_pid_nr(current), current->xid,
610 + regs->nip, regs->link, regs->gpr[0],
611 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
614 diff -NurpP --minimal linux-3.6.9/arch/s390/Kconfig linux-3.6.9-vs2.3.4.4/arch/s390/Kconfig
615 --- linux-3.6.9/arch/s390/Kconfig 2012-10-04 15:26:54.000000000 +0200
616 +++ linux-3.6.9-vs2.3.4.4/arch/s390/Kconfig 2012-10-04 18:47:00.000000000 +0200
617 @@ -634,6 +634,8 @@ source "fs/Kconfig"
619 source "arch/s390/Kconfig.debug"
621 +source "kernel/vserver/Kconfig"
623 source "security/Kconfig"
625 source "crypto/Kconfig"
626 diff -NurpP --minimal linux-3.6.9/arch/s390/include/asm/tlb.h linux-3.6.9-vs2.3.4.4/arch/s390/include/asm/tlb.h
627 --- linux-3.6.9/arch/s390/include/asm/tlb.h 2012-07-22 23:38:59.000000000 +0200
628 +++ linux-3.6.9-vs2.3.4.4/arch/s390/include/asm/tlb.h 2012-10-04 18:47:00.000000000 +0200
630 #include <linux/mm.h>
631 #include <linux/pagemap.h>
632 #include <linux/swap.h>
634 #include <asm/processor.h>
635 #include <asm/pgalloc.h>
636 #include <asm/tlbflush.h>
637 diff -NurpP --minimal linux-3.6.9/arch/s390/include/asm/unistd.h linux-3.6.9-vs2.3.4.4/arch/s390/include/asm/unistd.h
638 --- linux-3.6.9/arch/s390/include/asm/unistd.h 2012-10-04 15:26:55.000000000 +0200
639 +++ linux-3.6.9-vs2.3.4.4/arch/s390/include/asm/unistd.h 2012-10-04 18:47:00.000000000 +0200
641 #define __NR_clock_gettime (__NR_timer_create+6)
642 #define __NR_clock_getres (__NR_timer_create+7)
643 #define __NR_clock_nanosleep (__NR_timer_create+8)
644 -/* Number 263 is reserved for vserver */
645 +#define __NR_vserver 263
646 #define __NR_statfs64 265
647 #define __NR_fstatfs64 266
648 #define __NR_remap_file_pages 267
649 diff -NurpP --minimal linux-3.6.9/arch/s390/kernel/ptrace.c linux-3.6.9-vs2.3.4.4/arch/s390/kernel/ptrace.c
650 --- linux-3.6.9/arch/s390/kernel/ptrace.c 2012-10-04 15:26:55.000000000 +0200
651 +++ linux-3.6.9-vs2.3.4.4/arch/s390/kernel/ptrace.c 2012-10-04 18:47:00.000000000 +0200
653 #include <linux/tracehook.h>
654 #include <linux/seccomp.h>
655 #include <linux/compat.h>
656 +#include <linux/vs_base.h>
657 #include <trace/syscall.h>
658 #include <asm/segment.h>
659 #include <asm/page.h>
660 diff -NurpP --minimal linux-3.6.9/arch/s390/kernel/syscalls.S linux-3.6.9-vs2.3.4.4/arch/s390/kernel/syscalls.S
661 --- linux-3.6.9/arch/s390/kernel/syscalls.S 2012-01-09 16:14:06.000000000 +0100
662 +++ linux-3.6.9-vs2.3.4.4/arch/s390/kernel/syscalls.S 2012-10-04 18:47:00.000000000 +0200
663 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
664 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
665 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
666 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
667 -NI_SYSCALL /* reserved for vserver */
668 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
669 SYSCALL(sys_s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
670 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
671 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
672 diff -NurpP --minimal linux-3.6.9/arch/sh/Kconfig linux-3.6.9-vs2.3.4.4/arch/sh/Kconfig
673 --- linux-3.6.9/arch/sh/Kconfig 2012-10-04 15:26:55.000000000 +0200
674 +++ linux-3.6.9-vs2.3.4.4/arch/sh/Kconfig 2012-10-04 18:47:00.000000000 +0200
675 @@ -940,6 +940,8 @@ source "fs/Kconfig"
677 source "arch/sh/Kconfig.debug"
679 +source "kernel/vserver/Kconfig"
681 source "security/Kconfig"
683 source "crypto/Kconfig"
684 diff -NurpP --minimal linux-3.6.9/arch/sh/kernel/irq.c linux-3.6.9-vs2.3.4.4/arch/sh/kernel/irq.c
685 --- linux-3.6.9/arch/sh/kernel/irq.c 2012-10-04 15:26:56.000000000 +0200
686 +++ linux-3.6.9-vs2.3.4.4/arch/sh/kernel/irq.c 2012-10-04 18:47:00.000000000 +0200
688 #include <linux/ftrace.h>
689 #include <linux/delay.h>
690 #include <linux/ratelimit.h>
691 +// #include <linux/vs_context.h>
692 #include <asm/processor.h>
693 #include <asm/machvec.h>
694 #include <asm/uaccess.h>
695 diff -NurpP --minimal linux-3.6.9/arch/sparc/Kconfig linux-3.6.9-vs2.3.4.4/arch/sparc/Kconfig
696 --- linux-3.6.9/arch/sparc/Kconfig 2012-10-04 15:26:58.000000000 +0200
697 +++ linux-3.6.9-vs2.3.4.4/arch/sparc/Kconfig 2012-10-04 18:47:00.000000000 +0200
698 @@ -593,6 +593,8 @@ source "fs/Kconfig"
700 source "arch/sparc/Kconfig.debug"
702 +source "kernel/vserver/Kconfig"
704 source "security/Kconfig"
706 source "crypto/Kconfig"
707 diff -NurpP --minimal linux-3.6.9/arch/sparc/include/asm/unistd.h linux-3.6.9-vs2.3.4.4/arch/sparc/include/asm/unistd.h
708 --- linux-3.6.9/arch/sparc/include/asm/unistd.h 2012-10-04 15:26:59.000000000 +0200
709 +++ linux-3.6.9-vs2.3.4.4/arch/sparc/include/asm/unistd.h 2012-10-04 18:47:00.000000000 +0200
711 #define __NR_timer_getoverrun 264
712 #define __NR_timer_delete 265
713 #define __NR_timer_create 266
714 -/* #define __NR_vserver 267 Reserved for VSERVER */
715 +#define __NR_vserver 267
716 #define __NR_io_setup 268
717 #define __NR_io_destroy 269
718 #define __NR_io_submit 270
719 diff -NurpP --minimal linux-3.6.9/arch/sparc/kernel/systbls_32.S linux-3.6.9-vs2.3.4.4/arch/sparc/kernel/systbls_32.S
720 --- linux-3.6.9/arch/sparc/kernel/systbls_32.S 2012-01-09 16:14:09.000000000 +0100
721 +++ linux-3.6.9-vs2.3.4.4/arch/sparc/kernel/systbls_32.S 2012-10-04 18:47:00.000000000 +0200
722 @@ -70,7 +70,7 @@ sys_call_table:
723 /*250*/ .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_ni_syscall
724 /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
725 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
726 -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
727 +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
728 /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
729 /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
730 /*280*/ .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
731 diff -NurpP --minimal linux-3.6.9/arch/sparc/kernel/systbls_64.S linux-3.6.9-vs2.3.4.4/arch/sparc/kernel/systbls_64.S
732 --- linux-3.6.9/arch/sparc/kernel/systbls_64.S 2012-07-22 23:39:00.000000000 +0200
733 +++ linux-3.6.9-vs2.3.4.4/arch/sparc/kernel/systbls_64.S 2012-10-04 18:47:00.000000000 +0200
734 @@ -71,7 +71,7 @@ sys_call_table32:
735 /*250*/ .word sys_mremap, compat_sys_sysctl, sys32_getsid, sys_fdatasync, sys_nis_syscall
736 .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
737 /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
738 - .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
739 + .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
740 /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
741 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
742 /*280*/ .word sys32_tee, sys_add_key, sys_request_key, compat_sys_keyctl, compat_sys_openat
743 @@ -148,7 +148,7 @@ sys_call_table:
744 /*250*/ .word sys_64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nis_syscall
745 .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
746 /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
747 - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
748 + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
749 /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
750 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
751 /*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
752 diff -NurpP --minimal linux-3.6.9/arch/um/Kconfig.rest linux-3.6.9-vs2.3.4.4/arch/um/Kconfig.rest
753 --- linux-3.6.9/arch/um/Kconfig.rest 2012-01-09 16:14:09.000000000 +0100
754 +++ linux-3.6.9-vs2.3.4.4/arch/um/Kconfig.rest 2012-10-04 18:47:00.000000000 +0200
755 @@ -12,6 +12,8 @@ source "arch/um/Kconfig.net"
759 +source "kernel/vserver/Kconfig"
761 source "security/Kconfig"
763 source "crypto/Kconfig"
764 diff -NurpP --minimal linux-3.6.9/arch/um/include/shared/kern_constants.h linux-3.6.9-vs2.3.4.4/arch/um/include/shared/kern_constants.h
765 --- linux-3.6.9/arch/um/include/shared/kern_constants.h 1970-01-01 01:00:00.000000000 +0100
766 +++ linux-3.6.9-vs2.3.4.4/arch/um/include/shared/kern_constants.h 2012-10-04 18:47:00.000000000 +0200
768 +#include "../../../../include/generated/asm-offsets.h"
769 diff -NurpP --minimal linux-3.6.9/arch/um/include/shared/user_constants.h linux-3.6.9-vs2.3.4.4/arch/um/include/shared/user_constants.h
770 --- linux-3.6.9/arch/um/include/shared/user_constants.h 1970-01-01 01:00:00.000000000 +0100
771 +++ linux-3.6.9-vs2.3.4.4/arch/um/include/shared/user_constants.h 2012-10-04 18:47:00.000000000 +0200
776 + * This file was generated by arch/um/Makefile
780 +#define HOST_SC_CR2 176 /* offsetof(struct sigcontext, cr2) # */
781 +#define HOST_SC_ERR 152 /* offsetof(struct sigcontext, err) # */
782 +#define HOST_SC_TRAPNO 160 /* offsetof(struct sigcontext, trapno) # */
783 +#define HOST_FP_SIZE 64 /* sizeof(struct _fpstate) / sizeof(unsigned long) # */
784 +#define HOST_RBX 5 /* RBX # */
785 +#define HOST_RCX 11 /* RCX # */
786 +#define HOST_RDI 14 /* RDI # */
787 +#define HOST_RSI 13 /* RSI # */
788 +#define HOST_RDX 12 /* RDX # */
789 +#define HOST_RBP 4 /* RBP # */
790 +#define HOST_RAX 10 /* RAX # */
791 +#define HOST_R8 9 /* R8 # */
792 +#define HOST_R9 8 /* R9 # */
793 +#define HOST_R10 7 /* R10 # */
794 +#define HOST_R11 6 /* R11 # */
795 +#define HOST_R12 3 /* R12 # */
796 +#define HOST_R13 2 /* R13 # */
797 +#define HOST_R14 1 /* R14 # */
798 +#define HOST_R15 0 /* R15 # */
799 +#define HOST_ORIG_RAX 15 /* ORIG_RAX # */
800 +#define HOST_CS 17 /* CS # */
801 +#define HOST_SS 20 /* SS # */
802 +#define HOST_EFLAGS 18 /* EFLAGS # */
803 +#define HOST_IP 16 /* RIP # */
804 +#define HOST_SP 19 /* RSP # */
805 +#define UM_FRAME_SIZE 216 /* sizeof(struct user_regs_struct) # */
806 +#define UM_POLLIN 1 /* POLLIN # */
807 +#define UM_POLLPRI 2 /* POLLPRI # */
808 +#define UM_POLLOUT 4 /* POLLOUT # */
809 +#define UM_PROT_READ 1 /* PROT_READ # */
810 +#define UM_PROT_WRITE 2 /* PROT_WRITE # */
811 +#define UM_PROT_EXEC 4 /* PROT_EXEC # */
813 diff -NurpP --minimal linux-3.6.9/arch/x86/Kconfig linux-3.6.9-vs2.3.4.4/arch/x86/Kconfig
814 --- linux-3.6.9/arch/x86/Kconfig 2012-10-04 15:27:00.000000000 +0200
815 +++ linux-3.6.9-vs2.3.4.4/arch/x86/Kconfig 2012-10-04 18:47:00.000000000 +0200
816 @@ -2228,6 +2228,8 @@ source "fs/Kconfig"
818 source "arch/x86/Kconfig.debug"
820 +source "kernel/vserver/Kconfig"
822 source "security/Kconfig"
824 source "crypto/Kconfig"
825 diff -NurpP --minimal linux-3.6.9/arch/x86/syscalls/syscall_32.tbl linux-3.6.9-vs2.3.4.4/arch/x86/syscalls/syscall_32.tbl
826 --- linux-3.6.9/arch/x86/syscalls/syscall_32.tbl 2012-07-22 23:39:02.000000000 +0200
827 +++ linux-3.6.9-vs2.3.4.4/arch/x86/syscalls/syscall_32.tbl 2012-10-04 18:47:00.000000000 +0200
829 270 i386 tgkill sys_tgkill
830 271 i386 utimes sys_utimes compat_sys_utimes
831 272 i386 fadvise64_64 sys_fadvise64_64 sys32_fadvise64_64
833 +273 i386 vserver sys_vserver sys32_vserver
834 274 i386 mbind sys_mbind
835 275 i386 get_mempolicy sys_get_mempolicy compat_sys_get_mempolicy
836 276 i386 set_mempolicy sys_set_mempolicy
837 diff -NurpP --minimal linux-3.6.9/arch/x86/syscalls/syscall_64.tbl linux-3.6.9-vs2.3.4.4/arch/x86/syscalls/syscall_64.tbl
838 --- linux-3.6.9/arch/x86/syscalls/syscall_64.tbl 2012-10-04 15:27:01.000000000 +0200
839 +++ linux-3.6.9-vs2.3.4.4/arch/x86/syscalls/syscall_64.tbl 2012-10-04 18:47:00.000000000 +0200
841 233 common epoll_ctl sys_epoll_ctl
842 234 common tgkill sys_tgkill
843 235 common utimes sys_utimes
845 +236 64 vserver sys_vserver
846 237 common mbind sys_mbind
847 238 common set_mempolicy sys_set_mempolicy
848 239 common get_mempolicy sys_get_mempolicy
849 diff -NurpP --minimal linux-3.6.9/drivers/block/Kconfig linux-3.6.9-vs2.3.4.4/drivers/block/Kconfig
850 --- linux-3.6.9/drivers/block/Kconfig 2012-05-21 18:06:43.000000000 +0200
851 +++ linux-3.6.9-vs2.3.4.4/drivers/block/Kconfig 2012-10-04 18:47:00.000000000 +0200
852 @@ -290,6 +290,13 @@ config BLK_DEV_CRYPTOLOOP
854 source "drivers/block/drbd/Kconfig"
856 +config BLK_DEV_VROOT
857 + tristate "Virtual Root device support"
858 + depends on QUOTACTL
860 + Saying Y here will allow you to use quota/fs ioctls on a shared
861 + partition within a virtual server without compromising security.
864 tristate "Network block device support"
866 diff -NurpP --minimal linux-3.6.9/drivers/block/Makefile linux-3.6.9-vs2.3.4.4/drivers/block/Makefile
867 --- linux-3.6.9/drivers/block/Makefile 2012-03-19 19:46:52.000000000 +0100
868 +++ linux-3.6.9-vs2.3.4.4/drivers/block/Makefile 2012-10-04 18:47:00.000000000 +0200
869 @@ -35,6 +35,7 @@ obj-$(CONFIG_VIODASD) += viodasd.o
870 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
871 obj-$(CONFIG_BLK_DEV_UB) += ub.o
872 obj-$(CONFIG_BLK_DEV_HD) += hd.o
873 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
875 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
876 obj-$(CONFIG_XEN_BLKDEV_BACKEND) += xen-blkback/
877 diff -NurpP --minimal linux-3.6.9/drivers/block/loop.c linux-3.6.9-vs2.3.4.4/drivers/block/loop.c
878 --- linux-3.6.9/drivers/block/loop.c 2012-07-22 23:39:02.000000000 +0200
879 +++ linux-3.6.9-vs2.3.4.4/drivers/block/loop.c 2012-10-04 18:47:00.000000000 +0200
881 #include <linux/sysfs.h>
882 #include <linux/miscdevice.h>
883 #include <linux/falloc.h>
884 +#include <linux/vs_context.h>
886 #include <asm/uaccess.h>
888 @@ -869,6 +870,7 @@ static int loop_set_fd(struct loop_devic
889 lo->lo_blocksize = lo_blocksize;
890 lo->lo_device = bdev;
891 lo->lo_flags = lo_flags;
892 + lo->lo_xid = vx_current_xid();
893 lo->lo_backing_file = file;
894 lo->transfer = transfer_none;
896 @@ -1001,6 +1003,7 @@ static int loop_clr_fd(struct loop_devic
897 lo->lo_sizelimit = 0;
898 lo->lo_encrypt_key_size = 0;
899 lo->lo_thread = NULL;
901 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
902 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
903 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
904 @@ -1042,7 +1045,7 @@ loop_set_status(struct loop_device *lo,
906 if (lo->lo_encrypt_key_size &&
907 lo->lo_key_owner != uid &&
908 - !capable(CAP_SYS_ADMIN))
909 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
911 if (lo->lo_state != Lo_bound)
913 @@ -1132,7 +1135,8 @@ loop_get_status(struct loop_device *lo,
914 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
915 info->lo_encrypt_type =
916 lo->lo_encryption ? lo->lo_encryption->number : 0;
917 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
918 + if (lo->lo_encrypt_key_size &&
919 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
920 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
921 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
922 lo->lo_encrypt_key_size);
923 @@ -1492,6 +1496,11 @@ static int lo_open(struct block_device *
927 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P)) {
932 mutex_lock(&lo->lo_ctl_mutex);
934 mutex_unlock(&lo->lo_ctl_mutex);
935 diff -NurpP --minimal linux-3.6.9/drivers/block/vroot.c linux-3.6.9-vs2.3.4.4/drivers/block/vroot.c
936 --- linux-3.6.9/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
937 +++ linux-3.6.9-vs2.3.4.4/drivers/block/vroot.c 2012-10-04 18:47:00.000000000 +0200
940 + * linux/drivers/block/vroot.c
942 + * written by Herbert Pötzl, 9/11/2002
943 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
945 + * based on the loop.c code by Theodore Ts'o.
947 + * Copyright (C) 2002-2007 by Herbert Pötzl.
948 + * Redistribution of this file is permitted under the
949 + * GNU General Public License.
953 +#include <linux/module.h>
954 +#include <linux/moduleparam.h>
955 +#include <linux/file.h>
956 +#include <linux/major.h>
957 +#include <linux/blkdev.h>
958 +#include <linux/slab.h>
960 +#include <linux/vroot.h>
961 +#include <linux/vs_context.h>
964 +static int max_vroot = 8;
966 +static struct vroot_device *vroot_dev;
967 +static struct gendisk **disks;
970 +static int vroot_set_dev(
971 + struct vroot_device *vr,
972 + struct block_device *bdev,
975 + struct block_device *real_bdev;
977 + struct inode *inode;
981 + if (vr->vr_state != Vr_unbound)
990 + inode = file->f_dentry->d_inode;
993 + if (S_ISBLK(inode->i_mode)) {
994 + real_bdev = inode->i_bdev;
995 + vr->vr_device = real_bdev;
996 + __iget(real_bdev->bd_inode);
1000 + vxdprintk(VXD_CBIT(misc, 0),
1001 + "vroot[%d]_set_dev: dev=" VXF_DEV,
1002 + vr->vr_number, VXD_DEV(real_bdev));
1004 + vr->vr_state = Vr_bound;
1013 +static int vroot_clr_dev(
1014 + struct vroot_device *vr,
1015 + struct block_device *bdev)
1017 + struct block_device *real_bdev;
1019 + if (vr->vr_state != Vr_bound)
1021 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
1024 + real_bdev = vr->vr_device;
1026 + vxdprintk(VXD_CBIT(misc, 0),
1027 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
1028 + vr->vr_number, VXD_DEV(real_bdev));
1031 + vr->vr_state = Vr_unbound;
1032 + vr->vr_device = NULL;
1037 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
1038 + unsigned int cmd, unsigned long arg)
1040 + struct vroot_device *vr = bdev->bd_disk->private_data;
1043 + down(&vr->vr_ctl_mutex);
1045 + case VROOT_SET_DEV:
1046 + err = vroot_set_dev(vr, bdev, arg);
1048 + case VROOT_CLR_DEV:
1049 + err = vroot_clr_dev(vr, bdev);
1055 + up(&vr->vr_ctl_mutex);
1059 +static int vr_open(struct block_device *bdev, fmode_t mode)
1061 + struct vroot_device *vr = bdev->bd_disk->private_data;
1063 + down(&vr->vr_ctl_mutex);
1065 + up(&vr->vr_ctl_mutex);
1069 +static int vr_release(struct gendisk *disk, fmode_t mode)
1071 + struct vroot_device *vr = disk->private_data;
1073 + down(&vr->vr_ctl_mutex);
1075 + up(&vr->vr_ctl_mutex);
1079 +static struct block_device_operations vr_fops = {
1080 + .owner = THIS_MODULE,
1082 + .release = vr_release,
1083 + .ioctl = vr_ioctl,
1086 +static void vroot_make_request(struct request_queue *q, struct bio *bio)
1088 + printk("vroot_make_request %p, %p\n", q, bio);
1089 + bio_io_error(bio);
1092 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
1094 + struct inode *inode = bdev->bd_inode;
1095 + struct vroot_device *vr;
1096 + struct block_device *real_bdev;
1097 + int minor = iminor(inode);
1099 + vr = &vroot_dev[minor];
1100 + real_bdev = vr->vr_device;
1102 + vxdprintk(VXD_CBIT(misc, 0),
1103 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
1104 + vr->vr_number, VXD_DEV(real_bdev));
1106 + if (vr->vr_state != Vr_bound)
1107 + return ERR_PTR(-ENXIO);
1109 + __iget(real_bdev->bd_inode);
1116 + * And now the modules code and kernel interface.
1119 +module_param(max_vroot, int, 0);
1121 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
1122 +MODULE_LICENSE("GPL");
1123 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
1125 +MODULE_AUTHOR ("Herbert Pötzl");
1126 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
1129 +int __init vroot_init(void)
1133 + if (max_vroot < 1 || max_vroot > 256) {
1134 + max_vroot = MAX_VROOT_DEFAULT;
1135 + printk(KERN_WARNING "vroot: invalid max_vroot "
1136 + "(must be between 1 and 256), "
1137 + "using default (%d)\n", max_vroot);
1140 + if (register_blkdev(VROOT_MAJOR, "vroot"))
1144 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
1147 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
1149 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
1153 + for (i = 0; i < max_vroot; i++) {
1154 + disks[i] = alloc_disk(1);
1157 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
1158 + if (!disks[i]->queue)
1160 + blk_queue_make_request(disks[i]->queue, vroot_make_request);
1163 + for (i = 0; i < max_vroot; i++) {
1164 + struct vroot_device *vr = &vroot_dev[i];
1165 + struct gendisk *disk = disks[i];
1167 + memset(vr, 0, sizeof(*vr));
1168 + sema_init(&vr->vr_ctl_mutex, 1);
1169 + vr->vr_number = i;
1170 + disk->major = VROOT_MAJOR;
1171 + disk->first_minor = i;
1172 + disk->fops = &vr_fops;
1173 + sprintf(disk->disk_name, "vroot%d", i);
1174 + disk->private_data = vr;
1177 + err = register_vroot_grb(&__vroot_get_real_bdev);
1181 + for (i = 0; i < max_vroot; i++)
1182 + add_disk(disks[i]);
1183 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
1188 + put_disk(disks[i]);
1193 + unregister_blkdev(VROOT_MAJOR, "vroot");
1194 + printk(KERN_ERR "vroot: ran out of memory\n");
1198 +void vroot_exit(void)
1202 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
1203 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
1205 + for (i = 0; i < max_vroot; i++) {
1206 + del_gendisk(disks[i]);
1207 + put_disk(disks[i]);
1209 + unregister_blkdev(VROOT_MAJOR, "vroot");
1215 +module_init(vroot_init);
1216 +module_exit(vroot_exit);
1220 +static int __init max_vroot_setup(char *str)
1222 + max_vroot = simple_strtol(str, NULL, 0);
1226 +__setup("max_vroot=", max_vroot_setup);
1230 diff -NurpP --minimal linux-3.6.9/drivers/infiniband/Kconfig linux-3.6.9-vs2.3.4.4/drivers/infiniband/Kconfig
1231 --- linux-3.6.9/drivers/infiniband/Kconfig 2012-07-22 23:39:06.000000000 +0200
1232 +++ linux-3.6.9-vs2.3.4.4/drivers/infiniband/Kconfig 2012-10-04 18:47:00.000000000 +0200
1233 @@ -39,7 +39,7 @@ config INFINIBAND_USER_MEM
1234 config INFINIBAND_ADDR_TRANS
1237 - depends on !(INFINIBAND = y && IPV6 = m)
1238 + depends on !(INFINIBAND = y && IPV6 = y)
1241 source "drivers/infiniband/hw/mthca/Kconfig"
1242 diff -NurpP --minimal linux-3.6.9/drivers/infiniband/core/addr.c linux-3.6.9-vs2.3.4.4/drivers/infiniband/core/addr.c
1243 --- linux-3.6.9/drivers/infiniband/core/addr.c 2012-10-04 15:27:10.000000000 +0200
1244 +++ linux-3.6.9-vs2.3.4.4/drivers/infiniband/core/addr.c 2012-10-04 18:47:00.000000000 +0200
1245 @@ -263,7 +263,7 @@ static int addr6_resolve(struct sockaddr
1247 if (ipv6_addr_any(&fl6.saddr)) {
1248 ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
1249 - &fl6.daddr, 0, &fl6.saddr);
1250 + &fl6.daddr, 0, &fl6.saddr, NULL);
1254 diff -NurpP --minimal linux-3.6.9/drivers/md/dm-ioctl.c linux-3.6.9-vs2.3.4.4/drivers/md/dm-ioctl.c
1255 --- linux-3.6.9/drivers/md/dm-ioctl.c 2012-10-04 15:27:11.000000000 +0200
1256 +++ linux-3.6.9-vs2.3.4.4/drivers/md/dm-ioctl.c 2012-10-04 18:47:00.000000000 +0200
1258 #include <linux/dm-ioctl.h>
1259 #include <linux/hdreg.h>
1260 #include <linux/compat.h>
1261 +#include <linux/vs_context.h>
1263 #include <asm/uaccess.h>
1265 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
1266 unsigned int h = hash_str(str);
1268 list_for_each_entry (hc, _name_buckets + h, name_list)
1269 - if (!strcmp(hc->name, str)) {
1270 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1271 + !strcmp(hc->name, str)) {
1275 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
1276 unsigned int h = hash_str(str);
1278 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
1279 - if (!strcmp(hc->uuid, str)) {
1280 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1281 + !strcmp(hc->uuid, str)) {
1285 @@ -131,13 +134,15 @@ static struct hash_cell *__get_uuid_cell
1286 static struct hash_cell *__get_dev_cell(uint64_t dev)
1288 struct mapped_device *md;
1289 - struct hash_cell *hc;
1290 + struct hash_cell *hc = NULL;
1292 md = dm_get_md(huge_decode_dev(dev));
1296 - hc = dm_get_mdptr(md);
1297 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
1298 + hc = dm_get_mdptr(md);
1303 @@ -445,6 +450,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
1305 static int remove_all(struct dm_ioctl *param, size_t param_size)
1307 + if (!vx_check(0, VS_ADMIN))
1310 dm_hash_remove_all(1);
1311 param->data_size = 0;
1313 @@ -492,6 +500,8 @@ static int list_devices(struct dm_ioctl
1315 for (i = 0; i < NUM_BUCKETS; i++) {
1316 list_for_each_entry (hc, _name_buckets + i, name_list) {
1317 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1319 needed += sizeof(struct dm_name_list);
1320 needed += strlen(hc->name) + 1;
1321 needed += ALIGN_MASK;
1322 @@ -515,6 +525,8 @@ static int list_devices(struct dm_ioctl
1324 for (i = 0; i < NUM_BUCKETS; i++) {
1325 list_for_each_entry (hc, _name_buckets + i, name_list) {
1326 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1329 old_nl->next = (uint32_t) ((void *) nl -
1331 @@ -1619,8 +1631,8 @@ static int ctl_ioctl(uint command, struc
1333 size_t input_param_size;
1335 - /* only root can play with this */
1336 - if (!capable(CAP_SYS_ADMIN))
1337 + /* only root and certain contexts can play with this */
1338 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
1341 if (_IOC_TYPE(command) != DM_IOCTL)
1342 diff -NurpP --minimal linux-3.6.9/drivers/md/dm.c linux-3.6.9-vs2.3.4.4/drivers/md/dm.c
1343 --- linux-3.6.9/drivers/md/dm.c 2012-12-08 01:34:09.000000000 +0100
1344 +++ linux-3.6.9-vs2.3.4.4/drivers/md/dm.c 2012-12-08 01:36:32.000000000 +0100
1346 #include <linux/idr.h>
1347 #include <linux/hdreg.h>
1348 #include <linux/delay.h>
1349 +#include <linux/vs_base.h>
1351 #include <trace/events/block.h>
1353 @@ -131,6 +132,7 @@ struct mapped_device {
1356 atomic_t open_count;
1359 unsigned long flags;
1361 @@ -343,6 +345,7 @@ int dm_deleting_md(struct mapped_device
1362 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
1364 struct mapped_device *md;
1367 spin_lock(&_minor_lock);
1369 @@ -351,18 +354,19 @@ static int dm_blk_open(struct block_devi
1372 if (test_bit(DMF_FREEING, &md->flags) ||
1373 - dm_deleting_md(md)) {
1375 + dm_deleting_md(md))
1379 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
1384 atomic_inc(&md->open_count);
1388 spin_unlock(&_minor_lock);
1390 - return md ? 0 : -ENXIO;
1394 static int dm_blk_close(struct gendisk *disk, fmode_t mode)
1395 @@ -583,6 +587,14 @@ int dm_set_geometry(struct mapped_device
1400 + * Get the xid associated with a dm device
1402 +xid_t dm_get_xid(struct mapped_device *md)
1407 /*-----------------------------------------------------------------
1409 * A more elegant soln is in the works that uses the queue
1410 @@ -1898,6 +1910,7 @@ static struct mapped_device *alloc_dev(i
1411 INIT_LIST_HEAD(&md->uevent_list);
1412 spin_lock_init(&md->uevent_lock);
1414 + md->xid = vx_current_xid();
1415 md->queue = blk_alloc_queue(GFP_KERNEL);
1418 diff -NurpP --minimal linux-3.6.9/drivers/md/dm.h linux-3.6.9-vs2.3.4.4/drivers/md/dm.h
1419 --- linux-3.6.9/drivers/md/dm.h 2012-10-04 15:27:11.000000000 +0200
1420 +++ linux-3.6.9-vs2.3.4.4/drivers/md/dm.h 2012-10-04 18:47:00.000000000 +0200
1421 @@ -46,6 +46,8 @@ struct dm_dev_internal {
1423 struct dm_md_mempools;
1425 +xid_t dm_get_xid(struct mapped_device *md);
1427 /*-----------------------------------------------------------------
1428 * Internal table functions.
1429 *---------------------------------------------------------------*/
1430 diff -NurpP --minimal linux-3.6.9/drivers/net/tun.c linux-3.6.9-vs2.3.4.4/drivers/net/tun.c
1431 --- linux-3.6.9/drivers/net/tun.c 2012-10-04 15:27:20.000000000 +0200
1432 +++ linux-3.6.9-vs2.3.4.4/drivers/net/tun.c 2012-10-04 18:47:00.000000000 +0200
1434 #include <linux/nsproxy.h>
1435 #include <linux/virtio_net.h>
1436 #include <linux/rcupdate.h>
1437 +#include <linux/vs_network.h>
1438 #include <net/net_namespace.h>
1439 #include <net/netns/generic.h>
1440 #include <net/rtnetlink.h>
1441 @@ -122,6 +123,7 @@ struct tun_struct {
1447 struct net_device *dev;
1448 netdev_features_t set_features;
1449 @@ -1033,6 +1035,7 @@ static void tun_setup(struct net_device
1453 + tun->nid = current->nid;
1455 dev->ethtool_ops = &tun_ethtool_ops;
1456 dev->destructor = tun_free_netdev;
1457 @@ -1191,7 +1194,7 @@ static int tun_set_iff(struct net *net,
1459 if (((tun->owner != -1 && cred->euid != tun->owner) ||
1460 (tun->group != -1 && !in_egroup_p(tun->group))) &&
1461 - !capable(CAP_NET_ADMIN))
1462 + !cap_raised(current_cap(), CAP_NET_ADMIN))
1464 err = security_tun_dev_attach(tun->socket.sk);
1466 @@ -1205,7 +1208,7 @@ static int tun_set_iff(struct net *net,
1468 unsigned long flags = 0;
1470 - if (!capable(CAP_NET_ADMIN))
1471 + if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
1473 err = security_tun_dev_create();
1475 @@ -1276,6 +1279,9 @@ static int tun_set_iff(struct net *net,
1477 sk->sk_destruct = tun_sock_destruct;
1479 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
1482 err = tun_attach(tun, file);
1485 @@ -1459,6 +1465,16 @@ static long __tun_chr_ioctl(struct file
1486 tun_debug(KERN_INFO, tun, "group set to %d\n", tun->group);
1490 + if (!capable(CAP_CONTEXT))
1493 + /* Set nid owner of the device */
1494 + tun->nid = (nid_t) arg;
1496 + tun_debug(KERN_INFO, tun, "nid owner set to %u\n", tun->nid);
1500 /* Only allow setting the type when the interface is down */
1501 if (tun->dev->flags & IFF_UP) {
1502 diff -NurpP --minimal linux-3.6.9/drivers/tty/sysrq.c linux-3.6.9-vs2.3.4.4/drivers/tty/sysrq.c
1503 --- linux-3.6.9/drivers/tty/sysrq.c 2012-05-21 18:07:16.000000000 +0200
1504 +++ linux-3.6.9-vs2.3.4.4/drivers/tty/sysrq.c 2012-10-04 18:47:00.000000000 +0200
1506 #include <linux/slab.h>
1507 #include <linux/input.h>
1508 #include <linux/uaccess.h>
1509 +#include <linux/vserver/debug.h>
1511 #include <asm/ptrace.h>
1512 #include <asm/irq_regs.h>
1513 @@ -398,6 +399,21 @@ static struct sysrq_key_op sysrq_unrt_op
1514 .enable_mask = SYSRQ_ENABLE_RTNICE,
1518 +#ifdef CONFIG_VSERVER_DEBUG
1519 +static void sysrq_handle_vxinfo(int key)
1521 + dump_vx_info_inactive((key == 'x') ? 0 : 1);
1524 +static struct sysrq_key_op sysrq_showvxinfo_op = {
1525 + .handler = sysrq_handle_vxinfo,
1526 + .help_msg = "conteXt",
1527 + .action_msg = "Show Context Info",
1528 + .enable_mask = SYSRQ_ENABLE_DUMP,
1532 /* Key Operations table and lock */
1533 static DEFINE_SPINLOCK(sysrq_key_table_lock);
1535 @@ -452,7 +468,11 @@ static struct sysrq_key_op *sysrq_key_ta
1537 &sysrq_showstate_blocked_op, /* w */
1538 /* x: May be registered on ppc/powerpc for xmon */
1539 +#ifdef CONFIG_VSERVER_DEBUG
1540 + &sysrq_showvxinfo_op, /* x */
1544 /* y: May be registered on sparc64 for global register dump */
1546 &sysrq_ftrace_dump_op, /* z */
1547 @@ -467,6 +487,8 @@ static int sysrq_key_table_key2index(int
1549 else if ((key >= 'a') && (key <= 'z'))
1550 retval = key + 10 - 'a';
1551 + else if ((key >= 'A') && (key <= 'Z'))
1552 + retval = key + 10 - 'A';
1556 diff -NurpP --minimal linux-3.6.9/drivers/tty/tty_io.c linux-3.6.9-vs2.3.4.4/drivers/tty/tty_io.c
1557 --- linux-3.6.9/drivers/tty/tty_io.c 2012-07-22 23:39:32.000000000 +0200
1558 +++ linux-3.6.9-vs2.3.4.4/drivers/tty/tty_io.c 2012-10-04 18:47:00.000000000 +0200
1561 #include <linux/kmod.h>
1562 #include <linux/nsproxy.h>
1563 +#include <linux/vs_pid.h>
1565 #undef TTY_DEBUG_HANGUP
1567 @@ -2123,7 +2124,8 @@ static int tiocsti(struct tty_struct *tt
1569 struct tty_ldisc *ld;
1571 - if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
1572 + if (((current->signal->tty != tty) &&
1573 + !vx_capable(CAP_SYS_ADMIN, VXC_TIOCSTI)))
1575 if (get_user(ch, p))
1577 @@ -2411,6 +2413,7 @@ static int tiocspgrp(struct tty_struct *
1579 if (get_user(pgrp_nr, p))
1581 + pgrp_nr = vx_rmap_pid(pgrp_nr);
1585 diff -NurpP --minimal linux-3.6.9/fs/attr.c linux-3.6.9-vs2.3.4.4/fs/attr.c
1586 --- linux-3.6.9/fs/attr.c 2012-10-04 15:27:39.000000000 +0200
1587 +++ linux-3.6.9-vs2.3.4.4/fs/attr.c 2012-10-04 18:47:00.000000000 +0200
1589 #include <linux/fcntl.h>
1590 #include <linux/security.h>
1591 #include <linux/evm.h>
1592 +#include <linux/proc_fs.h>
1593 +#include <linux/devpts_fs.h>
1594 +#include <linux/vs_tag.h>
1597 * inode_change_ok - check if attribute changes to an inode are allowed
1598 @@ -74,6 +77,10 @@ int inode_change_ok(const struct inode *
1602 + /* check for inode tag permission */
1603 + if (dx_permission(inode, MAY_WRITE))
1608 EXPORT_SYMBOL(inode_change_ok);
1609 @@ -144,6 +151,8 @@ void setattr_copy(struct inode *inode, c
1610 inode->i_uid = attr->ia_uid;
1611 if (ia_valid & ATTR_GID)
1612 inode->i_gid = attr->ia_gid;
1613 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
1614 + inode->i_tag = attr->ia_tag;
1615 if (ia_valid & ATTR_ATIME)
1616 inode->i_atime = timespec_trunc(attr->ia_atime,
1617 inode->i_sb->s_time_gran);
1618 @@ -173,7 +182,8 @@ int notify_change(struct dentry * dentry
1620 WARN_ON_ONCE(!mutex_is_locked(&inode->i_mutex));
1622 - if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
1623 + if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
1624 + ATTR_TAG | ATTR_TIMES_SET)) {
1625 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1628 diff -NurpP --minimal linux-3.6.9/fs/block_dev.c linux-3.6.9-vs2.3.4.4/fs/block_dev.c
1629 --- linux-3.6.9/fs/block_dev.c 2012-10-04 15:27:39.000000000 +0200
1630 +++ linux-3.6.9-vs2.3.4.4/fs/block_dev.c 2012-10-04 18:47:00.000000000 +0200
1632 #include <linux/namei.h>
1633 #include <linux/log2.h>
1634 #include <linux/cleancache.h>
1635 +#include <linux/vs_device.h>
1636 #include <asm/uaccess.h>
1637 #include "internal.h"
1639 @@ -581,6 +582,7 @@ struct block_device *bdget(dev_t dev)
1640 bdev->bd_invalidated = 0;
1641 inode->i_mode = S_IFBLK;
1642 inode->i_rdev = dev;
1643 + inode->i_mdev = dev;
1644 inode->i_bdev = bdev;
1645 inode->i_data.a_ops = &def_blk_aops;
1646 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
1647 @@ -627,6 +629,11 @@ EXPORT_SYMBOL(bdput);
1648 static struct block_device *bd_acquire(struct inode *inode)
1650 struct block_device *bdev;
1653 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
1655 + inode->i_mdev = mdev;
1657 spin_lock(&bdev_lock);
1658 bdev = inode->i_bdev;
1659 @@ -637,7 +644,7 @@ static struct block_device *bd_acquire(s
1661 spin_unlock(&bdev_lock);
1663 - bdev = bdget(inode->i_rdev);
1664 + bdev = bdget(mdev);
1666 spin_lock(&bdev_lock);
1667 if (!inode->i_bdev) {
1668 diff -NurpP --minimal linux-3.6.9/fs/btrfs/ctree.h linux-3.6.9-vs2.3.4.4/fs/btrfs/ctree.h
1669 --- linux-3.6.9/fs/btrfs/ctree.h 2012-10-04 15:27:39.000000000 +0200
1670 +++ linux-3.6.9-vs2.3.4.4/fs/btrfs/ctree.h 2012-10-04 18:47:00.000000000 +0200
1671 @@ -674,11 +674,14 @@ struct btrfs_inode_item {
1672 /* modification sequence number for NFS */
1677 * a little future expansion, for more than this we can
1678 * just grow the inode item and version it
1680 - __le64 reserved[4];
1681 + __le16 reserved16;
1682 + __le32 reserved32;
1683 + __le64 reserved[3];
1684 struct btrfs_timespec atime;
1685 struct btrfs_timespec ctime;
1686 struct btrfs_timespec mtime;
1687 @@ -1727,6 +1730,8 @@ struct btrfs_ioctl_defrag_range_args {
1688 #define BTRFS_MOUNT_CHECK_INTEGRITY_INCLUDING_EXTENT_DATA (1 << 21)
1689 #define BTRFS_MOUNT_PANIC_ON_FATAL_ERROR (1 << 22)
1691 +#define BTRFS_MOUNT_TAGGED (1 << 24)
1693 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
1694 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
1695 #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \
1696 @@ -1988,6 +1993,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
1697 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
1698 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
1699 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
1700 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
1701 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
1702 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
1703 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
1704 @@ -2041,6 +2047,10 @@ BTRFS_SETGET_FUNCS(extent_flags, struct
1706 BTRFS_SETGET_FUNCS(extent_refs_v0, struct btrfs_extent_item_v0, refs, 32);
1708 +#define BTRFS_INODE_IXUNLINK (1 << 24)
1709 +#define BTRFS_INODE_BARRIER (1 << 25)
1710 +#define BTRFS_INODE_COW (1 << 26)
1713 BTRFS_SETGET_FUNCS(tree_block_level, struct btrfs_tree_block_info, level, 8);
1715 @@ -3305,6 +3315,7 @@ extern const struct dentry_operations bt
1716 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1717 void btrfs_update_iflags(struct inode *inode);
1718 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
1719 +int btrfs_sync_flags(struct inode *inode, int, int);
1720 int btrfs_defrag_file(struct inode *inode, struct file *file,
1721 struct btrfs_ioctl_defrag_range_args *range,
1722 u64 newer_than, unsigned long max_pages);
1723 diff -NurpP --minimal linux-3.6.9/fs/btrfs/disk-io.c linux-3.6.9-vs2.3.4.4/fs/btrfs/disk-io.c
1724 --- linux-3.6.9/fs/btrfs/disk-io.c 2012-10-04 15:27:39.000000000 +0200
1725 +++ linux-3.6.9-vs2.3.4.4/fs/btrfs/disk-io.c 2012-10-04 18:47:00.000000000 +0200
1726 @@ -2187,6 +2187,9 @@ int open_ctree(struct super_block *sb,
1730 + if (btrfs_test_opt(tree_root, TAGGED))
1731 + sb->s_flags |= MS_TAGGED;
1733 features = btrfs_super_incompat_flags(disk_super) &
1734 ~BTRFS_FEATURE_INCOMPAT_SUPP;
1736 diff -NurpP --minimal linux-3.6.9/fs/btrfs/inode.c linux-3.6.9-vs2.3.4.4/fs/btrfs/inode.c
1737 --- linux-3.6.9/fs/btrfs/inode.c 2012-10-04 15:27:39.000000000 +0200
1738 +++ linux-3.6.9-vs2.3.4.4/fs/btrfs/inode.c 2012-10-04 18:47:00.000000000 +0200
1740 #include <linux/slab.h>
1741 #include <linux/ratelimit.h>
1742 #include <linux/mount.h>
1743 +#include <linux/vs_tag.h>
1746 #include "disk-io.h"
1747 @@ -2545,6 +2546,8 @@ static void btrfs_read_locked_inode(stru
1748 struct btrfs_key location;
1754 bool filled = false;
1756 @@ -2572,8 +2575,13 @@ static void btrfs_read_locked_inode(stru
1757 struct btrfs_inode_item);
1758 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
1759 set_nlink(inode, btrfs_inode_nlink(leaf, inode_item));
1760 - inode->i_uid = btrfs_inode_uid(leaf, inode_item);
1761 - inode->i_gid = btrfs_inode_gid(leaf, inode_item);
1763 + uid = btrfs_inode_uid(leaf, inode_item);
1764 + gid = btrfs_inode_gid(leaf, inode_item);
1765 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
1766 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
1767 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
1768 + btrfs_inode_tag(leaf, inode_item));
1769 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
1771 tspec = btrfs_inode_atime(inode_item);
1772 @@ -2651,8 +2659,14 @@ static void fill_inode_item(struct btrfs
1773 struct btrfs_inode_item *item,
1774 struct inode *inode)
1776 - btrfs_set_inode_uid(leaf, item, inode->i_uid);
1777 - btrfs_set_inode_gid(leaf, item, inode->i_gid);
1778 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
1779 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
1781 + btrfs_set_inode_uid(leaf, item, uid);
1782 + btrfs_set_inode_gid(leaf, item, gid);
1783 +#ifdef CONFIG_TAGGING_INTERN
1784 + btrfs_set_inode_tag(leaf, item, inode->i_tag);
1786 btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
1787 btrfs_set_inode_mode(leaf, item, inode->i_mode);
1788 btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
1789 @@ -7636,11 +7650,13 @@ static const struct inode_operations btr
1790 .listxattr = btrfs_listxattr,
1791 .removexattr = btrfs_removexattr,
1792 .permission = btrfs_permission,
1793 + .sync_flags = btrfs_sync_flags,
1794 .get_acl = btrfs_get_acl,
1796 static const struct inode_operations btrfs_dir_ro_inode_operations = {
1797 .lookup = btrfs_lookup,
1798 .permission = btrfs_permission,
1799 + .sync_flags = btrfs_sync_flags,
1800 .get_acl = btrfs_get_acl,
1803 diff -NurpP --minimal linux-3.6.9/fs/btrfs/ioctl.c linux-3.6.9-vs2.3.4.4/fs/btrfs/ioctl.c
1804 --- linux-3.6.9/fs/btrfs/ioctl.c 2012-10-04 15:27:39.000000000 +0200
1805 +++ linux-3.6.9-vs2.3.4.4/fs/btrfs/ioctl.c 2012-10-04 18:47:00.000000000 +0200
1806 @@ -74,10 +74,13 @@ static unsigned int btrfs_flags_to_ioctl
1808 unsigned int iflags = 0;
1810 - if (flags & BTRFS_INODE_SYNC)
1811 - iflags |= FS_SYNC_FL;
1812 if (flags & BTRFS_INODE_IMMUTABLE)
1813 iflags |= FS_IMMUTABLE_FL;
1814 + if (flags & BTRFS_INODE_IXUNLINK)
1815 + iflags |= FS_IXUNLINK_FL;
1817 + if (flags & BTRFS_INODE_SYNC)
1818 + iflags |= FS_SYNC_FL;
1819 if (flags & BTRFS_INODE_APPEND)
1820 iflags |= FS_APPEND_FL;
1821 if (flags & BTRFS_INODE_NODUMP)
1822 @@ -94,28 +97,78 @@ static unsigned int btrfs_flags_to_ioctl
1823 else if (flags & BTRFS_INODE_NOCOMPRESS)
1824 iflags |= FS_NOCOMP_FL;
1826 + if (flags & BTRFS_INODE_BARRIER)
1827 + iflags |= FS_BARRIER_FL;
1828 + if (flags & BTRFS_INODE_COW)
1829 + iflags |= FS_COW_FL;
1834 - * Update inode->i_flags based on the btrfs internal flags.
1835 + * Update inode->i_(v)flags based on the btrfs internal flags.
1837 void btrfs_update_iflags(struct inode *inode)
1839 struct btrfs_inode *ip = BTRFS_I(inode);
1841 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
1842 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
1843 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
1845 - if (ip->flags & BTRFS_INODE_SYNC)
1846 - inode->i_flags |= S_SYNC;
1847 if (ip->flags & BTRFS_INODE_IMMUTABLE)
1848 inode->i_flags |= S_IMMUTABLE;
1849 + if (ip->flags & BTRFS_INODE_IXUNLINK)
1850 + inode->i_flags |= S_IXUNLINK;
1852 + if (ip->flags & BTRFS_INODE_SYNC)
1853 + inode->i_flags |= S_SYNC;
1854 if (ip->flags & BTRFS_INODE_APPEND)
1855 inode->i_flags |= S_APPEND;
1856 if (ip->flags & BTRFS_INODE_NOATIME)
1857 inode->i_flags |= S_NOATIME;
1858 if (ip->flags & BTRFS_INODE_DIRSYNC)
1859 inode->i_flags |= S_DIRSYNC;
1861 + inode->i_vflags &= ~(V_BARRIER | V_COW);
1863 + if (ip->flags & BTRFS_INODE_BARRIER)
1864 + inode->i_vflags |= V_BARRIER;
1865 + if (ip->flags & BTRFS_INODE_COW)
1866 + inode->i_vflags |= V_COW;
1870 + * Update btrfs internal flags from inode->i_(v)flags.
1872 +void btrfs_update_flags(struct inode *inode)
1874 + struct btrfs_inode *ip = BTRFS_I(inode);
1876 + unsigned int flags = inode->i_flags;
1877 + unsigned int vflags = inode->i_vflags;
1879 + ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
1880 + BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
1881 + BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
1882 + BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
1884 + if (flags & S_IMMUTABLE)
1885 + ip->flags |= BTRFS_INODE_IMMUTABLE;
1886 + if (flags & S_IXUNLINK)
1887 + ip->flags |= BTRFS_INODE_IXUNLINK;
1889 + if (flags & S_SYNC)
1890 + ip->flags |= BTRFS_INODE_SYNC;
1891 + if (flags & S_APPEND)
1892 + ip->flags |= BTRFS_INODE_APPEND;
1893 + if (flags & S_NOATIME)
1894 + ip->flags |= BTRFS_INODE_NOATIME;
1895 + if (flags & S_DIRSYNC)
1896 + ip->flags |= BTRFS_INODE_DIRSYNC;
1898 + if (vflags & V_BARRIER)
1899 + ip->flags |= BTRFS_INODE_BARRIER;
1900 + if (vflags & V_COW)
1901 + ip->flags |= BTRFS_INODE_COW;
1905 @@ -131,6 +184,7 @@ void btrfs_inherit_iflags(struct inode *
1908 flags = BTRFS_I(dir)->flags;
1909 + flags &= ~BTRFS_INODE_BARRIER;
1911 if (flags & BTRFS_INODE_NOCOMPRESS) {
1912 BTRFS_I(inode)->flags &= ~BTRFS_INODE_COMPRESS;
1913 @@ -146,6 +200,30 @@ void btrfs_inherit_iflags(struct inode *
1914 btrfs_update_iflags(inode);
1917 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
1919 + struct btrfs_inode *ip = BTRFS_I(inode);
1920 + struct btrfs_root *root = ip->root;
1921 + struct btrfs_trans_handle *trans;
1924 + trans = btrfs_join_transaction(root);
1927 + inode->i_flags = flags;
1928 + inode->i_vflags = vflags;
1929 + btrfs_update_flags(inode);
1931 + ret = btrfs_update_inode(trans, root, inode);
1934 + btrfs_update_iflags(inode);
1935 + inode->i_ctime = CURRENT_TIME;
1936 + btrfs_end_transaction(trans, root);
1941 static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
1943 struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
1944 @@ -206,21 +284,27 @@ static int btrfs_ioctl_setflags(struct f
1946 flags = btrfs_mask_flags(inode->i_mode, flags);
1947 oldflags = btrfs_flags_to_ioctl(ip->flags);
1948 - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
1949 + if ((flags ^ oldflags) & (FS_APPEND_FL |
1950 + FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
1951 if (!capable(CAP_LINUX_IMMUTABLE)) {
1957 - if (flags & FS_SYNC_FL)
1958 - ip->flags |= BTRFS_INODE_SYNC;
1960 - ip->flags &= ~BTRFS_INODE_SYNC;
1961 if (flags & FS_IMMUTABLE_FL)
1962 ip->flags |= BTRFS_INODE_IMMUTABLE;
1964 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
1965 + if (flags & FS_IXUNLINK_FL)
1966 + ip->flags |= BTRFS_INODE_IXUNLINK;
1968 + ip->flags &= ~BTRFS_INODE_IXUNLINK;
1970 + if (flags & FS_SYNC_FL)
1971 + ip->flags |= BTRFS_INODE_SYNC;
1973 + ip->flags &= ~BTRFS_INODE_SYNC;
1974 if (flags & FS_APPEND_FL)
1975 ip->flags |= BTRFS_INODE_APPEND;
1977 diff -NurpP --minimal linux-3.6.9/fs/btrfs/super.c linux-3.6.9-vs2.3.4.4/fs/btrfs/super.c
1978 --- linux-3.6.9/fs/btrfs/super.c 2012-10-04 15:27:39.000000000 +0200
1979 +++ linux-3.6.9-vs2.3.4.4/fs/btrfs/super.c 2012-10-04 18:47:00.000000000 +0200
1980 @@ -306,7 +306,7 @@ enum {
1981 Opt_no_space_cache, Opt_recovery, Opt_skip_balance,
1982 Opt_check_integrity, Opt_check_integrity_including_extent_data,
1983 Opt_check_integrity_print_mask, Opt_fatal_errors,
1985 + Opt_tag, Opt_notag, Opt_tagid, Opt_err,
1988 static match_table_t tokens = {
1989 @@ -346,6 +346,9 @@ static match_table_t tokens = {
1990 {Opt_check_integrity_including_extent_data, "check_int_data"},
1991 {Opt_check_integrity_print_mask, "check_int_print_mask=%d"},
1992 {Opt_fatal_errors, "fatal_errors=%s"},
1994 + {Opt_notag, "notag"},
1995 + {Opt_tagid, "tagid=%u"},
1999 @@ -596,6 +599,22 @@ int btrfs_parse_options(struct btrfs_roo
2003 +#ifndef CONFIG_TAGGING_NONE
2005 + printk(KERN_INFO "btrfs: use tagging\n");
2006 + btrfs_set_opt(info->mount_opt, TAGGED);
2009 + printk(KERN_INFO "btrfs: disabled tagging\n");
2010 + btrfs_clear_opt(info->mount_opt, TAGGED);
2013 +#ifdef CONFIG_PROPAGATE
2016 + btrfs_set_opt(info->mount_opt, TAGGED);
2020 printk(KERN_INFO "btrfs: unrecognized mount option "
2022 @@ -1196,6 +1215,12 @@ static int btrfs_remount(struct super_bl
2023 btrfs_resize_thread_pool(fs_info,
2024 fs_info->thread_pool_size, old_thread_pool_size);
2026 + if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
2027 + printk("btrfs: %s: tagging not permitted on remount.\n",
2032 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
2035 diff -NurpP --minimal linux-3.6.9/fs/char_dev.c linux-3.6.9-vs2.3.4.4/fs/char_dev.c
2036 --- linux-3.6.9/fs/char_dev.c 2012-03-19 19:47:25.000000000 +0100
2037 +++ linux-3.6.9-vs2.3.4.4/fs/char_dev.c 2012-10-04 18:47:00.000000000 +0200
2039 #include <linux/mutex.h>
2040 #include <linux/backing-dev.h>
2041 #include <linux/tty.h>
2042 +#include <linux/vs_context.h>
2043 +#include <linux/vs_device.h>
2045 #include "internal.h"
2047 @@ -371,14 +373,21 @@ static int chrdev_open(struct inode *ino
2049 struct cdev *new = NULL;
2053 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2055 + inode->i_mdev = mdev;
2057 spin_lock(&cdev_lock);
2060 struct kobject *kobj;
2063 spin_unlock(&cdev_lock);
2064 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2066 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2069 new = container_of(kobj, struct cdev, kobj);
2070 diff -NurpP --minimal linux-3.6.9/fs/dcache.c linux-3.6.9-vs2.3.4.4/fs/dcache.c
2071 --- linux-3.6.9/fs/dcache.c 2012-10-04 15:27:39.000000000 +0200
2072 +++ linux-3.6.9-vs2.3.4.4/fs/dcache.c 2012-12-07 22:49:54.000000000 +0100
2074 #include <linux/rculist_bl.h>
2075 #include <linux/prefetch.h>
2076 #include <linux/ratelimit.h>
2077 +#include <linux/vs_limit.h>
2078 #include "internal.h"
2081 @@ -617,6 +618,8 @@ int d_invalidate(struct dentry * dentry)
2082 spin_lock(&dentry->d_lock);
2085 + vx_dentry_dec(dentry);
2088 * Somebody else still using it?
2090 @@ -646,6 +649,7 @@ EXPORT_SYMBOL(d_invalidate);
2091 static inline void __dget_dlock(struct dentry *dentry)
2094 + vx_dentry_inc(dentry);
2097 static inline void __dget(struct dentry *dentry)
2098 @@ -1276,6 +1280,9 @@ struct dentry *__d_alloc(struct super_bl
2099 struct dentry *dentry;
2102 + if (!vx_dentry_avail(1))
2105 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
2108 @@ -1308,6 +1315,7 @@ struct dentry *__d_alloc(struct super_bl
2110 dentry->d_count = 1;
2111 dentry->d_flags = 0;
2112 + vx_dentry_inc(dentry);
2113 spin_lock_init(&dentry->d_lock);
2114 seqcount_init(&dentry->d_seq);
2115 dentry->d_inode = NULL;
2116 @@ -2012,6 +2020,7 @@ struct dentry *__d_lookup(struct dentry
2120 + vx_dentry_inc(dentry);
2122 spin_unlock(&dentry->d_lock);
2124 diff -NurpP --minimal linux-3.6.9/fs/devpts/inode.c linux-3.6.9-vs2.3.4.4/fs/devpts/inode.c
2125 --- linux-3.6.9/fs/devpts/inode.c 2012-10-04 15:27:39.000000000 +0200
2126 +++ linux-3.6.9-vs2.3.4.4/fs/devpts/inode.c 2012-10-04 18:47:00.000000000 +0200
2128 #include <linux/parser.h>
2129 #include <linux/fsnotify.h>
2130 #include <linux/seq_file.h>
2131 +#include <linux/vs_base.h>
2133 #define DEVPTS_DEFAULT_MODE 0600
2136 #define DEVPTS_DEFAULT_PTMX_MODE 0000
2137 #define PTMX_MINOR 2
2139 +static int devpts_permission(struct inode *inode, int mask)
2141 + int ret = -EACCES;
2143 + /* devpts is xid tagged */
2144 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
2145 + ret = generic_permission(inode, mask);
2149 +static struct inode_operations devpts_file_inode_operations = {
2150 + .permission = devpts_permission,
2155 * sysctl support for setting limits on the number of Unix98 ptys allocated.
2156 * Otherwise one can eat up all kernel memory by opening /dev/ptmx repeatedly.
2157 @@ -336,6 +352,34 @@ static int devpts_show_options(struct se
2161 +static int devpts_filter(struct dentry *de)
2165 + /* devpts is xid tagged */
2166 + if (de && de->d_inode)
2167 + xid = (xid_t)de->d_inode->i_tag;
2168 +#ifdef CONFIG_VSERVER_WARN_DEVPTS
2170 + vxwprintk_task(1, "devpts " VS_Q("%.*s") " without inode.",
2171 + de->d_name.len, de->d_name.name);
2173 + return vx_check(xid, VS_WATCH_P | VS_IDENT);
2176 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2178 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2181 +static struct file_operations devpts_dir_operations = {
2182 + .open = dcache_dir_open,
2183 + .release = dcache_dir_close,
2184 + .llseek = dcache_dir_lseek,
2185 + .read = generic_read_dir,
2186 + .readdir = devpts_readdir,
2189 static const struct super_operations devpts_sops = {
2190 .statfs = simple_statfs,
2191 .remount_fs = devpts_remount,
2192 @@ -379,8 +423,10 @@ devpts_fill_super(struct super_block *s,
2193 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2194 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2195 inode->i_op = &simple_dir_inode_operations;
2196 - inode->i_fop = &simple_dir_operations;
2197 + inode->i_fop = &devpts_dir_operations;
2198 set_nlink(inode, 2);
2199 + /* devpts is xid tagged */
2200 + inode->i_tag = (vs_tag_t)vx_current_xid();
2202 s->s_root = d_make_root(inode);
2204 @@ -572,6 +618,9 @@ int devpts_pty_new(struct inode *ptmx_in
2205 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
2206 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2207 init_special_inode(inode, S_IFCHR|opts->mode, device);
2208 + /* devpts is xid tagged */
2209 + inode->i_tag = (vs_tag_t)vx_current_xid();
2210 + inode->i_op = &devpts_file_inode_operations;
2211 inode->i_private = tty;
2212 tty->driver_data = inode;
2214 diff -NurpP --minimal linux-3.6.9/fs/ext2/balloc.c linux-3.6.9-vs2.3.4.4/fs/ext2/balloc.c
2215 --- linux-3.6.9/fs/ext2/balloc.c 2012-10-04 15:27:39.000000000 +0200
2216 +++ linux-3.6.9-vs2.3.4.4/fs/ext2/balloc.c 2012-10-04 18:47:00.000000000 +0200
2217 @@ -699,7 +699,6 @@ ext2_try_to_allocate(struct super_block
2219 end = EXT2_BLOCKS_PER_GROUP(sb);
2222 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2225 diff -NurpP --minimal linux-3.6.9/fs/ext2/ext2.h linux-3.6.9-vs2.3.4.4/fs/ext2/ext2.h
2226 --- linux-3.6.9/fs/ext2/ext2.h 2012-07-22 23:39:39.000000000 +0200
2227 +++ linux-3.6.9-vs2.3.4.4/fs/ext2/ext2.h 2012-10-04 18:47:00.000000000 +0200
2228 @@ -244,8 +244,12 @@ struct ext2_group_desc
2229 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
2230 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
2231 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
2232 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
2233 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
2235 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
2236 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
2238 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
2239 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
2241 @@ -329,7 +333,8 @@ struct ext2_inode {
2243 __le16 l_i_uid_high; /* these 2 fields */
2244 __le16 l_i_gid_high; /* were reserved2[0] */
2245 - __u32 l_i_reserved2;
2246 + __le16 l_i_tag; /* Context Tag */
2247 + __u16 l_i_reserved2;
2250 __u8 h_i_frag; /* Fragment number */
2251 @@ -357,6 +362,7 @@ struct ext2_inode {
2252 #define i_gid_low i_gid
2253 #define i_uid_high osd2.linux2.l_i_uid_high
2254 #define i_gid_high osd2.linux2.l_i_gid_high
2255 +#define i_raw_tag osd2.linux2.l_i_tag
2256 #define i_reserved2 osd2.linux2.l_i_reserved2
2259 @@ -384,6 +390,7 @@ struct ext2_inode {
2260 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
2261 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
2262 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
2263 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
2266 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
2267 @@ -757,6 +764,7 @@ extern void ext2_set_inode_flags(struct
2268 extern void ext2_get_inode_flags(struct ext2_inode_info *);
2269 extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2270 u64 start, u64 len);
2271 +extern int ext2_sync_flags(struct inode *, int, int);
2274 extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
2275 diff -NurpP --minimal linux-3.6.9/fs/ext2/file.c linux-3.6.9-vs2.3.4.4/fs/ext2/file.c
2276 --- linux-3.6.9/fs/ext2/file.c 2011-10-24 18:45:27.000000000 +0200
2277 +++ linux-3.6.9-vs2.3.4.4/fs/ext2/file.c 2012-10-04 18:47:00.000000000 +0200
2278 @@ -104,4 +104,5 @@ const struct inode_operations ext2_file_
2279 .setattr = ext2_setattr,
2280 .get_acl = ext2_get_acl,
2281 .fiemap = ext2_fiemap,
2282 + .sync_flags = ext2_sync_flags,
2284 diff -NurpP --minimal linux-3.6.9/fs/ext2/ialloc.c linux-3.6.9-vs2.3.4.4/fs/ext2/ialloc.c
2285 --- linux-3.6.9/fs/ext2/ialloc.c 2012-10-04 15:27:39.000000000 +0200
2286 +++ linux-3.6.9-vs2.3.4.4/fs/ext2/ialloc.c 2012-10-04 18:47:00.000000000 +0200
2288 #include <linux/backing-dev.h>
2289 #include <linux/buffer_head.h>
2290 #include <linux/random.h>
2291 +#include <linux/vs_tag.h>
2295 @@ -547,6 +548,7 @@ got:
2296 inode->i_mode = mode;
2297 inode->i_uid = current_fsuid();
2298 inode->i_gid = dir->i_gid;
2299 + inode->i_tag = dx_current_fstag(sb);
2301 inode_init_owner(inode, dir, mode);
2303 diff -NurpP --minimal linux-3.6.9/fs/ext2/inode.c linux-3.6.9-vs2.3.4.4/fs/ext2/inode.c
2304 --- linux-3.6.9/fs/ext2/inode.c 2012-10-04 15:27:39.000000000 +0200
2305 +++ linux-3.6.9-vs2.3.4.4/fs/ext2/inode.c 2012-10-04 18:47:00.000000000 +0200
2307 #include <linux/mpage.h>
2308 #include <linux/fiemap.h>
2309 #include <linux/namei.h>
2310 +#include <linux/vs_tag.h>
2314 @@ -1165,7 +1166,7 @@ static void ext2_truncate_blocks(struct
2316 if (ext2_inode_is_fast_symlink(inode))
2318 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2319 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2321 __ext2_truncate_blocks(inode, offset);
2323 @@ -1256,36 +1257,61 @@ void ext2_set_inode_flags(struct inode *
2325 unsigned int flags = EXT2_I(inode)->i_flags;
2327 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2328 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2329 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2332 + if (flags & EXT2_IMMUTABLE_FL)
2333 + inode->i_flags |= S_IMMUTABLE;
2334 + if (flags & EXT2_IXUNLINK_FL)
2335 + inode->i_flags |= S_IXUNLINK;
2337 if (flags & EXT2_SYNC_FL)
2338 inode->i_flags |= S_SYNC;
2339 if (flags & EXT2_APPEND_FL)
2340 inode->i_flags |= S_APPEND;
2341 - if (flags & EXT2_IMMUTABLE_FL)
2342 - inode->i_flags |= S_IMMUTABLE;
2343 if (flags & EXT2_NOATIME_FL)
2344 inode->i_flags |= S_NOATIME;
2345 if (flags & EXT2_DIRSYNC_FL)
2346 inode->i_flags |= S_DIRSYNC;
2348 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2350 + if (flags & EXT2_BARRIER_FL)
2351 + inode->i_vflags |= V_BARRIER;
2352 + if (flags & EXT2_COW_FL)
2353 + inode->i_vflags |= V_COW;
2356 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
2357 void ext2_get_inode_flags(struct ext2_inode_info *ei)
2359 unsigned int flags = ei->vfs_inode.i_flags;
2360 + unsigned int vflags = ei->vfs_inode.i_vflags;
2362 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
2363 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
2364 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
2365 + EXT2_BARRIER_FL | EXT2_COW_FL);
2367 + if (flags & S_IMMUTABLE)
2368 + ei->i_flags |= EXT2_IMMUTABLE_FL;
2369 + if (flags & S_IXUNLINK)
2370 + ei->i_flags |= EXT2_IXUNLINK_FL;
2372 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
2373 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
2375 ei->i_flags |= EXT2_SYNC_FL;
2376 if (flags & S_APPEND)
2377 ei->i_flags |= EXT2_APPEND_FL;
2378 - if (flags & S_IMMUTABLE)
2379 - ei->i_flags |= EXT2_IMMUTABLE_FL;
2380 if (flags & S_NOATIME)
2381 ei->i_flags |= EXT2_NOATIME_FL;
2382 if (flags & S_DIRSYNC)
2383 ei->i_flags |= EXT2_DIRSYNC_FL;
2385 + if (vflags & V_BARRIER)
2386 + ei->i_flags |= EXT2_BARRIER_FL;
2387 + if (vflags & V_COW)
2388 + ei->i_flags |= EXT2_COW_FL;
2391 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
2392 @@ -1321,8 +1347,10 @@ struct inode *ext2_iget (struct super_bl
2393 i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2394 i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2396 - i_uid_write(inode, i_uid);
2397 - i_gid_write(inode, i_gid);
2398 + i_uid_write(inode, INOTAG_UID(DX_TAG(inode), i_uid, i_gid));
2399 + i_gid_write(inode, INOTAG_GID(DX_TAG(inode), i_uid, i_gid));
2400 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), i_uid, i_gid,
2401 + le16_to_cpu(raw_inode->i_raw_tag));
2402 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
2403 inode->i_size = le32_to_cpu(raw_inode->i_size);
2404 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2405 @@ -1420,8 +1448,8 @@ static int __ext2_write_inode(struct ino
2406 struct ext2_inode_info *ei = EXT2_I(inode);
2407 struct super_block *sb = inode->i_sb;
2408 ino_t ino = inode->i_ino;
2409 - uid_t uid = i_uid_read(inode);
2410 - gid_t gid = i_gid_read(inode);
2411 + uid_t uid = TAGINO_UID(DX_TAG(inode), i_uid_read(inode), inode->i_tag);
2412 + gid_t gid = TAGINO_GID(DX_TAG(inode), i_gid_read(inode), inode->i_tag);
2413 struct buffer_head * bh;
2414 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2416 @@ -1457,6 +1485,9 @@ static int __ext2_write_inode(struct ino
2417 raw_inode->i_uid_high = 0;
2418 raw_inode->i_gid_high = 0;
2420 +#ifdef CONFIG_TAGGING_INTERN
2421 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2423 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2424 raw_inode->i_size = cpu_to_le32(inode->i_size);
2425 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2426 @@ -1537,7 +1568,8 @@ int ext2_setattr(struct dentry *dentry,
2427 if (is_quota_modification(inode, iattr))
2428 dquot_initialize(inode);
2429 if ((iattr->ia_valid & ATTR_UID && !uid_eq(iattr->ia_uid, inode->i_uid)) ||
2430 - (iattr->ia_valid & ATTR_GID && !gid_eq(iattr->ia_gid, inode->i_gid))) {
2431 + (iattr->ia_valid & ATTR_GID && !gid_eq(iattr->ia_gid, inode->i_gid)) ||
2432 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
2433 error = dquot_transfer(inode, iattr);
2436 diff -NurpP --minimal linux-3.6.9/fs/ext2/ioctl.c linux-3.6.9-vs2.3.4.4/fs/ext2/ioctl.c
2437 --- linux-3.6.9/fs/ext2/ioctl.c 2012-03-19 19:47:25.000000000 +0100
2438 +++ linux-3.6.9-vs2.3.4.4/fs/ext2/ioctl.c 2012-10-04 18:47:00.000000000 +0200
2440 #include <asm/uaccess.h>
2443 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
2445 + inode->i_flags = flags;
2446 + inode->i_vflags = vflags;
2447 + ext2_get_inode_flags(EXT2_I(inode));
2448 + inode->i_ctime = CURRENT_TIME_SEC;
2449 + mark_inode_dirty(inode);
2453 long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2455 struct inode *inode = filp->f_dentry->d_inode;
2456 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
2458 flags = ext2_mask_flags(inode->i_mode, flags);
2460 + if (IS_BARRIER(inode)) {
2461 + vxwprintk_task(1, "messing with the barrier.");
2465 mutex_lock(&inode->i_mutex);
2466 /* Is it quota file? Do not allow user to mess with it */
2467 if (IS_NOQUOTA(inode)) {
2468 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
2470 * This test looks nicer. Thanks to Pauline Middelink
2472 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
2473 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
2474 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
2475 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
2476 if (!capable(CAP_LINUX_IMMUTABLE)) {
2477 mutex_unlock(&inode->i_mutex);
2479 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
2483 - flags = flags & EXT2_FL_USER_MODIFIABLE;
2484 + flags &= EXT2_FL_USER_MODIFIABLE;
2485 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
2486 ei->i_flags = flags;
2488 diff -NurpP --minimal linux-3.6.9/fs/ext2/namei.c linux-3.6.9-vs2.3.4.4/fs/ext2/namei.c
2489 --- linux-3.6.9/fs/ext2/namei.c 2012-10-04 15:27:39.000000000 +0200
2490 +++ linux-3.6.9-vs2.3.4.4/fs/ext2/namei.c 2012-10-04 18:47:00.000000000 +0200
2493 #include <linux/pagemap.h>
2494 #include <linux/quotaops.h>
2495 +#include <linux/vs_tag.h>
2499 @@ -73,6 +74,7 @@ static struct dentry *ext2_lookup(struct
2500 (unsigned long) ino);
2501 return ERR_PTR(-EIO);
2503 + dx_propagate_tag(nd, inode);
2505 return d_splice_alias(inode, dentry);
2507 @@ -397,6 +399,7 @@ const struct inode_operations ext2_dir_i
2508 .removexattr = generic_removexattr,
2510 .setattr = ext2_setattr,
2511 + .sync_flags = ext2_sync_flags,
2512 .get_acl = ext2_get_acl,
2515 diff -NurpP --minimal linux-3.6.9/fs/ext2/super.c linux-3.6.9-vs2.3.4.4/fs/ext2/super.c
2516 --- linux-3.6.9/fs/ext2/super.c 2012-10-04 15:27:39.000000000 +0200
2517 +++ linux-3.6.9-vs2.3.4.4/fs/ext2/super.c 2012-10-04 18:47:00.000000000 +0200
2518 @@ -390,7 +390,8 @@ enum {
2519 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
2520 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
2521 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
2522 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
2523 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
2524 + Opt_tag, Opt_notag, Opt_tagid
2527 static const match_table_t tokens = {
2528 @@ -418,6 +419,9 @@ static const match_table_t tokens = {
2530 {Opt_noacl, "noacl"},
2533 + {Opt_notag, "notag"},
2534 + {Opt_tagid, "tagid=%u"},
2535 {Opt_grpquota, "grpquota"},
2536 {Opt_ignore, "noquota"},
2537 {Opt_quota, "quota"},
2538 @@ -501,6 +505,20 @@ static int parse_options(char *options,
2540 set_opt (sbi->s_mount_opt, NO_UID32);
2542 +#ifndef CONFIG_TAGGING_NONE
2544 + set_opt (sbi->s_mount_opt, TAGGED);
2547 + clear_opt (sbi->s_mount_opt, TAGGED);
2550 +#ifdef CONFIG_PROPAGATE
2553 + set_opt (sbi->s_mount_opt, TAGGED);
2557 clear_opt (sbi->s_mount_opt, CHECK);
2559 @@ -859,6 +877,8 @@ static int ext2_fill_super(struct super_
2560 if (!parse_options((char *) data, sb))
2563 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
2564 + sb->s_flags |= MS_TAGGED;
2565 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2566 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
2568 @@ -1265,6 +1285,14 @@ static int ext2_remount (struct super_bl
2572 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
2573 + !(sb->s_flags & MS_TAGGED)) {
2574 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
2577 + goto restore_opts;
2580 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2581 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
2583 diff -NurpP --minimal linux-3.6.9/fs/ext3/ext3.h linux-3.6.9-vs2.3.4.4/fs/ext3/ext3.h
2584 --- linux-3.6.9/fs/ext3/ext3.h 2012-07-22 23:39:39.000000000 +0200
2585 +++ linux-3.6.9-vs2.3.4.4/fs/ext3/ext3.h 2012-10-04 18:47:00.000000000 +0200
2586 @@ -151,10 +151,14 @@ struct ext3_group_desc
2587 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
2588 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
2589 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
2590 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
2591 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
2593 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
2594 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
2595 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
2596 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
2598 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
2599 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
2601 /* Flags that should be inherited by new inodes from their parent. */
2602 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
2603 @@ -290,7 +294,8 @@ struct ext3_inode {
2605 __le16 l_i_uid_high; /* these 2 fields */
2606 __le16 l_i_gid_high; /* were reserved2[0] */
2607 - __u32 l_i_reserved2;
2608 + __le16 l_i_tag; /* Context Tag */
2609 + __u16 l_i_reserved2;
2612 __u8 h_i_frag; /* Fragment number */
2613 @@ -320,6 +325,7 @@ struct ext3_inode {
2614 #define i_gid_low i_gid
2615 #define i_uid_high osd2.linux2.l_i_uid_high
2616 #define i_gid_high osd2.linux2.l_i_gid_high
2617 +#define i_raw_tag osd2.linux2.l_i_tag
2618 #define i_reserved2 osd2.linux2.l_i_reserved2
2621 @@ -364,6 +370,7 @@ struct ext3_inode {
2622 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
2623 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
2624 * error in ordered mode */
2625 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
2627 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
2628 #ifndef _LINUX_EXT2_FS_H
2629 @@ -1061,6 +1068,7 @@ extern void ext3_get_inode_flags(struct
2630 extern void ext3_set_aops(struct inode *inode);
2631 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2632 u64 start, u64 len);
2633 +extern int ext3_sync_flags(struct inode *, int, int);
2636 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
2637 diff -NurpP --minimal linux-3.6.9/fs/ext3/file.c linux-3.6.9-vs2.3.4.4/fs/ext3/file.c
2638 --- linux-3.6.9/fs/ext3/file.c 2012-05-21 18:07:20.000000000 +0200
2639 +++ linux-3.6.9-vs2.3.4.4/fs/ext3/file.c 2012-10-04 18:47:00.000000000 +0200
2640 @@ -76,5 +76,6 @@ const struct inode_operations ext3_file_
2642 .get_acl = ext3_get_acl,
2643 .fiemap = ext3_fiemap,
2644 + .sync_flags = ext3_sync_flags,
2647 diff -NurpP --minimal linux-3.6.9/fs/ext3/ialloc.c linux-3.6.9-vs2.3.4.4/fs/ext3/ialloc.c
2648 --- linux-3.6.9/fs/ext3/ialloc.c 2012-07-22 23:39:39.000000000 +0200
2649 +++ linux-3.6.9-vs2.3.4.4/fs/ext3/ialloc.c 2012-10-04 18:47:00.000000000 +0200
2652 #include <linux/quotaops.h>
2653 #include <linux/random.h>
2654 +#include <linux/vs_tag.h>
2658 @@ -469,6 +470,7 @@ got:
2659 inode->i_mode = mode;
2660 inode->i_uid = current_fsuid();
2661 inode->i_gid = dir->i_gid;
2662 + inode->i_tag = dx_current_fstag(sb);
2664 inode_init_owner(inode, dir, mode);
2666 diff -NurpP --minimal linux-3.6.9/fs/ext3/inode.c linux-3.6.9-vs2.3.4.4/fs/ext3/inode.c
2667 --- linux-3.6.9/fs/ext3/inode.c 2012-10-04 15:27:39.000000000 +0200
2668 +++ linux-3.6.9-vs2.3.4.4/fs/ext3/inode.c 2012-10-04 18:47:00.000000000 +0200
2670 #include <linux/writeback.h>
2671 #include <linux/mpage.h>
2672 #include <linux/namei.h>
2673 +#include <linux/vs_tag.h>
2678 @@ -2848,36 +2850,60 @@ void ext3_set_inode_flags(struct inode *
2680 unsigned int flags = EXT3_I(inode)->i_flags;
2682 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2683 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2684 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2686 + if (flags & EXT3_IMMUTABLE_FL)
2687 + inode->i_flags |= S_IMMUTABLE;
2688 + if (flags & EXT3_IXUNLINK_FL)
2689 + inode->i_flags |= S_IXUNLINK;
2691 if (flags & EXT3_SYNC_FL)
2692 inode->i_flags |= S_SYNC;
2693 if (flags & EXT3_APPEND_FL)
2694 inode->i_flags |= S_APPEND;
2695 - if (flags & EXT3_IMMUTABLE_FL)
2696 - inode->i_flags |= S_IMMUTABLE;
2697 if (flags & EXT3_NOATIME_FL)
2698 inode->i_flags |= S_NOATIME;
2699 if (flags & EXT3_DIRSYNC_FL)
2700 inode->i_flags |= S_DIRSYNC;
2702 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2704 + if (flags & EXT3_BARRIER_FL)
2705 + inode->i_vflags |= V_BARRIER;
2706 + if (flags & EXT3_COW_FL)
2707 + inode->i_vflags |= V_COW;
2710 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
2711 void ext3_get_inode_flags(struct ext3_inode_info *ei)
2713 unsigned int flags = ei->vfs_inode.i_flags;
2714 + unsigned int vflags = ei->vfs_inode.i_vflags;
2716 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
2717 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
2718 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
2719 + EXT3_BARRIER_FL | EXT3_COW_FL);
2721 + if (flags & S_IMMUTABLE)
2722 + ei->i_flags |= EXT3_IMMUTABLE_FL;
2723 + if (flags & S_IXUNLINK)
2724 + ei->i_flags |= EXT3_IXUNLINK_FL;
2726 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
2727 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
2729 ei->i_flags |= EXT3_SYNC_FL;
2730 if (flags & S_APPEND)
2731 ei->i_flags |= EXT3_APPEND_FL;
2732 - if (flags & S_IMMUTABLE)
2733 - ei->i_flags |= EXT3_IMMUTABLE_FL;
2734 if (flags & S_NOATIME)
2735 ei->i_flags |= EXT3_NOATIME_FL;
2736 if (flags & S_DIRSYNC)
2737 ei->i_flags |= EXT3_DIRSYNC_FL;
2739 + if (vflags & V_BARRIER)
2740 + ei->i_flags |= EXT3_BARRIER_FL;
2741 + if (vflags & V_COW)
2742 + ei->i_flags |= EXT3_COW_FL;
2745 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
2746 @@ -2915,8 +2941,10 @@ struct inode *ext3_iget(struct super_blo
2747 i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2748 i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2750 - i_uid_write(inode, i_uid);
2751 - i_gid_write(inode, i_gid);
2752 + i_uid_write(inode, INOTAG_UID(DX_TAG(inode), i_uid, i_gid));
2753 + i_gid_write(inode, INOTAG_GID(DX_TAG(inode), i_uid, i_gid));
2754 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), i_uid, i_gid,
2755 + le16_to_cpu(raw_inode->i_raw_tag));
2756 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
2757 inode->i_size = le32_to_cpu(raw_inode->i_size);
2758 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2759 @@ -3088,8 +3116,8 @@ again:
2761 ext3_get_inode_flags(ei);
2762 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
2763 - i_uid = i_uid_read(inode);
2764 - i_gid = i_gid_read(inode);
2765 + i_uid = TAGINO_UID(DX_TAG(inode), i_uid_read(inode), inode->i_tag);
2766 + i_gid = TAGINO_GID(DX_TAG(inode), i_gid_read(inode), inode->i_tag);
2767 if(!(test_opt(inode->i_sb, NO_UID32))) {
2768 raw_inode->i_uid_low = cpu_to_le16(low_16_bits(i_uid));
2769 raw_inode->i_gid_low = cpu_to_le16(low_16_bits(i_gid));
2770 @@ -3114,6 +3142,9 @@ again:
2771 raw_inode->i_uid_high = 0;
2772 raw_inode->i_gid_high = 0;
2774 +#ifdef CONFIG_TAGGING_INTERN
2775 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2777 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2778 disksize = cpu_to_le32(ei->i_disksize);
2779 if (disksize != raw_inode->i_size) {
2780 @@ -3282,7 +3313,8 @@ int ext3_setattr(struct dentry *dentry,
2781 if (is_quota_modification(inode, attr))
2782 dquot_initialize(inode);
2783 if ((ia_valid & ATTR_UID && !uid_eq(attr->ia_uid, inode->i_uid)) ||
2784 - (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid))) {
2785 + (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid)) ||
2786 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
2789 /* (user+group)*(old+new) structure, inode write (sb,
2790 @@ -3304,6 +3336,8 @@ int ext3_setattr(struct dentry *dentry,
2791 inode->i_uid = attr->ia_uid;
2792 if (attr->ia_valid & ATTR_GID)
2793 inode->i_gid = attr->ia_gid;
2794 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2795 + inode->i_tag = attr->ia_tag;
2796 error = ext3_mark_inode_dirty(handle, inode);
2797 ext3_journal_stop(handle);
2799 diff -NurpP --minimal linux-3.6.9/fs/ext3/ioctl.c linux-3.6.9-vs2.3.4.4/fs/ext3/ioctl.c
2800 --- linux-3.6.9/fs/ext3/ioctl.c 2012-05-21 18:07:20.000000000 +0200
2801 +++ linux-3.6.9-vs2.3.4.4/fs/ext3/ioctl.c 2012-10-04 18:47:00.000000000 +0200
2803 #include <asm/uaccess.h>
2807 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
2809 + handle_t *handle = NULL;
2810 + struct ext3_iloc iloc;
2813 + handle = ext3_journal_start(inode, 1);
2814 + if (IS_ERR(handle))
2815 + return PTR_ERR(handle);
2817 + if (IS_SYNC(inode))
2818 + handle->h_sync = 1;
2819 + err = ext3_reserve_inode_write(handle, inode, &iloc);
2823 + inode->i_flags = flags;
2824 + inode->i_vflags = vflags;
2825 + ext3_get_inode_flags(EXT3_I(inode));
2826 + inode->i_ctime = CURRENT_TIME_SEC;
2828 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
2830 + ext3_journal_stop(handle);
2834 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2836 struct inode *inode = filp->f_dentry->d_inode;
2837 @@ -45,6 +73,11 @@ long ext3_ioctl(struct file *filp, unsig
2839 flags = ext3_mask_flags(inode->i_mode, flags);
2841 + if (IS_BARRIER(inode)) {
2842 + vxwprintk_task(1, "messing with the barrier.");
2846 mutex_lock(&inode->i_mutex);
2848 /* Is it quota file? Do not allow user to mess with it */
2849 @@ -63,7 +96,9 @@ long ext3_ioctl(struct file *filp, unsig
2851 * This test looks nicer. Thanks to Pauline Middelink
2853 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
2854 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
2855 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
2856 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
2857 if (!capable(CAP_LINUX_IMMUTABLE))
2860 @@ -88,7 +123,7 @@ long ext3_ioctl(struct file *filp, unsig
2864 - flags = flags & EXT3_FL_USER_MODIFIABLE;
2865 + flags &= EXT3_FL_USER_MODIFIABLE;
2866 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
2867 ei->i_flags = flags;
2869 diff -NurpP --minimal linux-3.6.9/fs/ext3/namei.c linux-3.6.9-vs2.3.4.4/fs/ext3/namei.c
2870 --- linux-3.6.9/fs/ext3/namei.c 2012-10-04 15:27:39.000000000 +0200
2871 +++ linux-3.6.9-vs2.3.4.4/fs/ext3/namei.c 2012-10-04 18:47:00.000000000 +0200
2875 #include <linux/quotaops.h>
2876 +#include <linux/vs_tag.h>
2881 @@ -915,6 +917,7 @@ restart:
2882 submit_bh(READ | REQ_META | REQ_PRIO,
2885 + dx_propagate_tag(nd, inode);
2888 if ((bh = bh_use[ra_ptr++]) == NULL)
2889 @@ -2526,6 +2529,7 @@ const struct inode_operations ext3_dir_i
2890 .listxattr = ext3_listxattr,
2891 .removexattr = generic_removexattr,
2893 + .sync_flags = ext3_sync_flags,
2894 .get_acl = ext3_get_acl,
2897 diff -NurpP --minimal linux-3.6.9/fs/ext3/super.c linux-3.6.9-vs2.3.4.4/fs/ext3/super.c
2898 --- linux-3.6.9/fs/ext3/super.c 2012-10-04 15:27:39.000000000 +0200
2899 +++ linux-3.6.9-vs2.3.4.4/fs/ext3/super.c 2012-10-04 18:47:00.000000000 +0200
2900 @@ -811,7 +811,8 @@ enum {
2901 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
2902 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
2903 Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
2904 - Opt_resize, Opt_usrquota, Opt_grpquota
2905 + Opt_resize, Opt_usrquota, Opt_grpquota,
2906 + Opt_tag, Opt_notag, Opt_tagid
2909 static const match_table_t tokens = {
2910 @@ -868,6 +869,9 @@ static const match_table_t tokens = {
2911 {Opt_barrier, "barrier"},
2912 {Opt_nobarrier, "nobarrier"},
2913 {Opt_resize, "resize"},
2915 + {Opt_notag, "notag"},
2916 + {Opt_tagid, "tagid=%u"},
2920 @@ -1033,6 +1037,20 @@ static int parse_options (char *options,
2922 set_opt (sbi->s_mount_opt, NO_UID32);
2924 +#ifndef CONFIG_TAGGING_NONE
2926 + set_opt (sbi->s_mount_opt, TAGGED);
2929 + clear_opt (sbi->s_mount_opt, TAGGED);
2932 +#ifdef CONFIG_PROPAGATE
2935 + set_opt (sbi->s_mount_opt, TAGGED);
2939 clear_opt (sbi->s_mount_opt, CHECK);
2941 @@ -1731,6 +1749,9 @@ static int ext3_fill_super (struct super
2945 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
2946 + sb->s_flags |= MS_TAGGED;
2948 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2949 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
2951 @@ -2618,6 +2639,14 @@ static int ext3_remount (struct super_bl
2952 if (test_opt(sb, ABORT))
2953 ext3_abort(sb, __func__, "Abort forced by user");
2955 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
2956 + !(sb->s_flags & MS_TAGGED)) {
2957 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
2960 + goto restore_opts;
2963 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2964 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
2966 diff -NurpP --minimal linux-3.6.9/fs/ext4/ext4.h linux-3.6.9-vs2.3.4.4/fs/ext4/ext4.h
2967 --- linux-3.6.9/fs/ext4/ext4.h 2012-12-08 01:34:13.000000000 +0100
2968 +++ linux-3.6.9-vs2.3.4.4/fs/ext4/ext4.h 2012-12-08 01:36:33.000000000 +0100
2969 @@ -393,8 +393,12 @@ struct flex_groups {
2970 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
2971 #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
2972 #define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
2973 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
2974 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
2976 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
2977 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
2979 #define EXT4_FL_USER_VISIBLE 0x004BDFFF /* User visible flags */
2980 #define EXT4_FL_USER_MODIFIABLE 0x004B80FF /* User modifiable flags */
2982 @@ -666,7 +670,7 @@ struct ext4_inode {
2983 __le16 l_i_uid_high; /* these 2 fields */
2984 __le16 l_i_gid_high; /* were reserved2[0] */
2985 __le16 l_i_checksum_lo;/* crc32c(uuid+inum+inode) LE */
2986 - __le16 l_i_reserved;
2987 + __le16 l_i_tag; /* Context Tag */
2990 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
2991 @@ -784,6 +788,7 @@ do { \
2992 #define i_gid_low i_gid
2993 #define i_uid_high osd2.linux2.l_i_uid_high
2994 #define i_gid_high osd2.linux2.l_i_gid_high
2995 +#define i_raw_tag osd2.linux2.l_i_tag
2996 #define i_checksum_lo osd2.linux2.l_i_checksum_lo
2998 #elif defined(__GNU__)
2999 @@ -964,6 +969,7 @@ struct ext4_inode_info {
3000 #define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
3001 #define EXT4_MOUNT_NO_AUTO_DA_ALLOC 0x10000 /* No auto delalloc mapping */
3002 #define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */
3003 +#define EXT4_MOUNT_TAGGED 0x40000 /* Enable Context Tags */
3004 #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
3005 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
3006 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
3007 @@ -2392,6 +2398,7 @@ extern int ext4_map_blocks(handle_t *han
3008 struct ext4_map_blocks *map, int flags);
3009 extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
3010 __u64 start, __u64 len);
3011 +extern int ext4_sync_flags(struct inode *, int, int);
3013 extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
3014 __u64 start_orig, __u64 start_donor,
3015 diff -NurpP --minimal linux-3.6.9/fs/ext4/file.c linux-3.6.9-vs2.3.4.4/fs/ext4/file.c
3016 --- linux-3.6.9/fs/ext4/file.c 2012-10-04 15:27:39.000000000 +0200
3017 +++ linux-3.6.9-vs2.3.4.4/fs/ext4/file.c 2012-10-04 18:47:00.000000000 +0200
3018 @@ -334,5 +334,6 @@ const struct inode_operations ext4_file_
3020 .get_acl = ext4_get_acl,
3021 .fiemap = ext4_fiemap,
3022 + .sync_flags = ext4_sync_flags,
3025 diff -NurpP --minimal linux-3.6.9/fs/ext4/ialloc.c linux-3.6.9-vs2.3.4.4/fs/ext4/ialloc.c
3026 --- linux-3.6.9/fs/ext4/ialloc.c 2012-12-08 01:34:13.000000000 +0100
3027 +++ linux-3.6.9-vs2.3.4.4/fs/ext4/ialloc.c 2012-11-06 18:43:41.000000000 +0100
3029 #include <linux/random.h>
3030 #include <linux/bitops.h>
3031 #include <linux/blkdev.h>
3032 +#include <linux/vs_tag.h>
3033 #include <asm/byteorder.h>
3036 @@ -839,6 +840,7 @@ got:
3037 inode->i_mode = mode;
3038 inode->i_uid = current_fsuid();
3039 inode->i_gid = dir->i_gid;
3040 + inode->i_tag = dx_current_fstag(sb);
3042 inode_init_owner(inode, dir, mode);
3044 diff -NurpP --minimal linux-3.6.9/fs/ext4/inode.c linux-3.6.9-vs2.3.4.4/fs/ext4/inode.c
3045 --- linux-3.6.9/fs/ext4/inode.c 2012-12-08 01:34:13.000000000 +0100
3046 +++ linux-3.6.9-vs2.3.4.4/fs/ext4/inode.c 2012-11-06 18:43:41.000000000 +0100
3048 #include <linux/printk.h>
3049 #include <linux/slab.h>
3050 #include <linux/ratelimit.h>
3051 +#include <linux/vs_tag.h>
3053 #include "ext4_jbd2.h"
3055 @@ -3715,41 +3716,64 @@ void ext4_set_inode_flags(struct inode *
3057 unsigned int flags = EXT4_I(inode)->i_flags;
3059 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3060 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3061 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3063 + if (flags & EXT4_IMMUTABLE_FL)
3064 + inode->i_flags |= S_IMMUTABLE;
3065 + if (flags & EXT4_IXUNLINK_FL)
3066 + inode->i_flags |= S_IXUNLINK;
3068 if (flags & EXT4_SYNC_FL)
3069 inode->i_flags |= S_SYNC;
3070 if (flags & EXT4_APPEND_FL)
3071 inode->i_flags |= S_APPEND;
3072 - if (flags & EXT4_IMMUTABLE_FL)
3073 - inode->i_flags |= S_IMMUTABLE;
3074 if (flags & EXT4_NOATIME_FL)
3075 inode->i_flags |= S_NOATIME;
3076 if (flags & EXT4_DIRSYNC_FL)
3077 inode->i_flags |= S_DIRSYNC;
3079 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3081 + if (flags & EXT4_BARRIER_FL)
3082 + inode->i_vflags |= V_BARRIER;
3083 + if (flags & EXT4_COW_FL)
3084 + inode->i_vflags |= V_COW;
3087 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3088 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3090 - unsigned int vfs_fl;
3091 + unsigned int vfs_fl, vfs_vf;
3092 unsigned long old_fl, new_fl;
3095 vfs_fl = ei->vfs_inode.i_flags;
3096 + vfs_vf = ei->vfs_inode.i_vflags;
3097 old_fl = ei->i_flags;
3098 new_fl = old_fl & ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3099 EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|
3101 + EXT4_DIRSYNC_FL|EXT4_BARRIER_FL|
3104 + if (vfs_fl & S_IMMUTABLE)
3105 + new_fl |= EXT4_IMMUTABLE_FL;
3106 + if (vfs_fl & S_IXUNLINK)
3107 + new_fl |= EXT4_IXUNLINK_FL;
3109 if (vfs_fl & S_SYNC)
3110 new_fl |= EXT4_SYNC_FL;
3111 if (vfs_fl & S_APPEND)
3112 new_fl |= EXT4_APPEND_FL;
3113 - if (vfs_fl & S_IMMUTABLE)
3114 - new_fl |= EXT4_IMMUTABLE_FL;
3115 if (vfs_fl & S_NOATIME)
3116 new_fl |= EXT4_NOATIME_FL;
3117 if (vfs_fl & S_DIRSYNC)
3118 new_fl |= EXT4_DIRSYNC_FL;
3120 + if (vfs_vf & V_BARRIER)
3121 + new_fl |= EXT4_BARRIER_FL;
3122 + if (vfs_vf & V_COW)
3123 + new_fl |= EXT4_COW_FL;
3124 } while (cmpxchg(&ei->i_flags, old_fl, new_fl) != old_fl);
3127 @@ -3841,8 +3865,10 @@ struct inode *ext4_iget(struct super_blo
3128 i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3129 i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3131 - i_uid_write(inode, i_uid);
3132 - i_gid_write(inode, i_gid);
3133 + i_uid_write(inode, INOTAG_UID(DX_TAG(inode), i_uid, i_gid));
3134 + i_gid_write(inode, INOTAG_GID(DX_TAG(inode), i_uid, i_gid));
3135 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), i_uid, i_gid,
3136 + le16_to_cpu(raw_inode->i_raw_tag));
3137 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
3139 ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */
3140 @@ -4066,8 +4092,8 @@ static int ext4_do_update_inode(handle_t
3142 ext4_get_inode_flags(ei);
3143 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3144 - i_uid = i_uid_read(inode);
3145 - i_gid = i_gid_read(inode);
3146 + i_uid = TAGINO_UID(DX_TAG(inode), i_uid_read(inode), inode->i_tag);
3147 + i_gid = TAGINO_GID(DX_TAG(inode), i_gid_read(inode), inode->i_tag);
3148 if (!(test_opt(inode->i_sb, NO_UID32))) {
3149 raw_inode->i_uid_low = cpu_to_le16(low_16_bits(i_uid));
3150 raw_inode->i_gid_low = cpu_to_le16(low_16_bits(i_gid));
3151 @@ -4090,6 +4116,9 @@ static int ext4_do_update_inode(handle_t
3152 raw_inode->i_uid_high = 0;
3153 raw_inode->i_gid_high = 0;
3155 +#ifdef CONFIG_TAGGING_INTERN
3156 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3158 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3160 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3161 @@ -4278,7 +4307,8 @@ int ext4_setattr(struct dentry *dentry,
3162 if (is_quota_modification(inode, attr))
3163 dquot_initialize(inode);
3164 if ((ia_valid & ATTR_UID && !uid_eq(attr->ia_uid, inode->i_uid)) ||
3165 - (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid))) {
3166 + (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid)) ||
3167 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3170 /* (user+group)*(old+new) structure, inode write (sb,
3171 @@ -4300,6 +4330,8 @@ int ext4_setattr(struct dentry *dentry,
3172 inode->i_uid = attr->ia_uid;
3173 if (attr->ia_valid & ATTR_GID)
3174 inode->i_gid = attr->ia_gid;
3175 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3176 + inode->i_tag = attr->ia_tag;
3177 error = ext4_mark_inode_dirty(handle, inode);
3178 ext4_journal_stop(handle);
3180 diff -NurpP --minimal linux-3.6.9/fs/ext4/ioctl.c linux-3.6.9-vs2.3.4.4/fs/ext4/ioctl.c
3181 --- linux-3.6.9/fs/ext4/ioctl.c 2012-10-04 15:27:39.000000000 +0200
3182 +++ linux-3.6.9-vs2.3.4.4/fs/ext4/ioctl.c 2012-10-04 18:47:00.000000000 +0200
3184 #include <linux/compat.h>
3185 #include <linux/mount.h>
3186 #include <linux/file.h>
3187 +#include <linux/vs_tag.h>
3188 #include <asm/uaccess.h>
3189 #include "ext4_jbd2.h"
3192 #define MAX_32_NUM ((((unsigned long long) 1) << 32) - 1)
3194 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
3196 + handle_t *handle = NULL;
3197 + struct ext4_iloc iloc;
3200 + handle = ext4_journal_start(inode, 1);
3201 + if (IS_ERR(handle))
3202 + return PTR_ERR(handle);
3204 + if (IS_SYNC(inode))
3205 + ext4_handle_sync(handle);
3206 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3210 + inode->i_flags = flags;
3211 + inode->i_vflags = vflags;
3212 + ext4_get_inode_flags(EXT4_I(inode));
3213 + inode->i_ctime = ext4_current_time(inode);
3215 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3217 + ext4_journal_stop(handle);
3221 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3223 struct inode *inode = filp->f_dentry->d_inode;
3224 @@ -53,6 +81,11 @@ long ext4_ioctl(struct file *filp, unsig
3226 flags = ext4_mask_flags(inode->i_mode, flags);
3228 + if (IS_BARRIER(inode)) {
3229 + vxwprintk_task(1, "messing with the barrier.");
3234 mutex_lock(&inode->i_mutex);
3235 /* Is it quota file? Do not allow user to mess with it */
3236 @@ -70,7 +103,9 @@ long ext4_ioctl(struct file *filp, unsig
3238 * This test looks nicer. Thanks to Pauline Middelink
3240 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3241 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3242 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3243 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3244 if (!capable(CAP_LINUX_IMMUTABLE))
3247 diff -NurpP --minimal linux-3.6.9/fs/ext4/namei.c linux-3.6.9-vs2.3.4.4/fs/ext4/namei.c
3248 --- linux-3.6.9/fs/ext4/namei.c 2012-12-08 01:34:13.000000000 +0100
3249 +++ linux-3.6.9-vs2.3.4.4/fs/ext4/namei.c 2012-11-06 18:43:41.000000000 +0100
3251 #include <linux/quotaops.h>
3252 #include <linux/buffer_head.h>
3253 #include <linux/bio.h>
3254 +#include <linux/vs_tag.h>
3256 #include "ext4_jbd2.h"
3258 @@ -1199,6 +1200,7 @@ restart:
3259 ll_rw_block(READ | REQ_META | REQ_PRIO,
3262 + dx_propagate_tag(nd, inode);
3264 if ((bh = bh_use[ra_ptr++]) == NULL)
3266 @@ -2982,6 +2984,7 @@ const struct inode_operations ext4_dir_i
3268 .get_acl = ext4_get_acl,
3269 .fiemap = ext4_fiemap,
3270 + .sync_flags = ext4_sync_flags,
3273 const struct inode_operations ext4_special_inode_operations = {
3274 diff -NurpP --minimal linux-3.6.9/fs/ext4/super.c linux-3.6.9-vs2.3.4.4/fs/ext4/super.c
3275 --- linux-3.6.9/fs/ext4/super.c 2012-12-08 01:34:13.000000000 +0100
3276 +++ linux-3.6.9-vs2.3.4.4/fs/ext4/super.c 2012-12-08 01:36:33.000000000 +0100
3277 @@ -1220,6 +1220,7 @@ enum {
3278 Opt_inode_readahead_blks, Opt_journal_ioprio,
3279 Opt_dioread_nolock, Opt_dioread_lock,
3280 Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable,
3281 + Opt_tag, Opt_notag, Opt_tagid
3284 static const match_table_t tokens = {
3285 @@ -1298,6 +1299,9 @@ static const match_table_t tokens = {
3286 {Opt_removed, "reservation"}, /* mount option from ext2/3 */
3287 {Opt_removed, "noreservation"}, /* mount option from ext2/3 */
3288 {Opt_removed, "journal=%u"}, /* mount option from ext2/3 */
3290 + {Opt_notag, "notag"},
3291 + {Opt_tagid, "tagid=%u"},
3295 @@ -1544,6 +1548,20 @@ static int handle_mount_opt(struct super
3297 *journal_ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, arg);
3299 +#ifndef CONFIG_TAGGING_NONE
3301 + set_opt(sb, TAGGED);
3304 + clear_opt(sb, TAGGED);
3307 +#ifdef CONFIG_PROPAGATE
3310 + set_opt(sb, TAGGED);
3315 for (m = ext4_mount_opts; m->token != Opt_err; m++) {
3316 @@ -3418,6 +3436,9 @@ static int ext4_fill_super(struct super_
3320 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3321 + sb->s_flags |= MS_TAGGED;
3323 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3324 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3326 @@ -4583,6 +4604,14 @@ static int ext4_remount(struct super_blo
3327 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
3328 ext4_abort(sb, "Abort forced by user");
3330 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3331 + !(sb->s_flags & MS_TAGGED)) {
3332 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3335 + goto restore_opts;
3338 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3339 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3341 diff -NurpP --minimal linux-3.6.9/fs/fcntl.c linux-3.6.9-vs2.3.4.4/fs/fcntl.c
3342 --- linux-3.6.9/fs/fcntl.c 2012-10-04 15:27:39.000000000 +0200
3343 +++ linux-3.6.9-vs2.3.4.4/fs/fcntl.c 2012-10-04 19:05:02.000000000 +0200
3345 #include <linux/rcupdate.h>
3346 #include <linux/pid_namespace.h>
3347 #include <linux/user_namespace.h>
3348 +#include <linux/vs_limit.h>
3350 #include <asm/poll.h>
3351 #include <asm/siginfo.h>
3352 @@ -104,6 +105,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
3355 filp_close(tofree, files);
3357 + vx_openfd_inc(newfd); /* fd was unused */
3361 @@ -477,6 +480,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
3362 filp = fget_raw_light(fd, &fput_needed);
3365 + if (!vx_files_avail(1))
3368 if (unlikely(filp->f_mode & FMODE_PATH)) {
3369 if (!check_fcntl_cmd(cmd))
3370 diff -NurpP --minimal linux-3.6.9/fs/file.c linux-3.6.9-vs2.3.4.4/fs/file.c
3371 --- linux-3.6.9/fs/file.c 2012-05-21 18:07:20.000000000 +0200
3372 +++ linux-3.6.9-vs2.3.4.4/fs/file.c 2012-10-04 18:47:00.000000000 +0200
3374 #include <linux/spinlock.h>
3375 #include <linux/rcupdate.h>
3376 #include <linux/workqueue.h>
3377 +#include <linux/vs_limit.h>
3379 struct fdtable_defer {
3381 @@ -358,6 +359,8 @@ struct files_struct *dup_fd(struct files
3382 struct file *f = *old_fds++;
3385 + /* TODO: sum it first for check and performance */
3386 + vx_openfd_inc(open_files - i);
3389 * The fd may be claimed in the fd bitmap but not yet
3390 @@ -464,6 +467,7 @@ repeat:
3392 __clear_close_on_exec(fd, fdt);
3394 + vx_openfd_inc(fd);
3397 if (rcu_dereference_raw(fdt->fd[fd]) != NULL) {
3398 diff -NurpP --minimal linux-3.6.9/fs/file_table.c linux-3.6.9-vs2.3.4.4/fs/file_table.c
3399 --- linux-3.6.9/fs/file_table.c 2012-10-04 15:27:39.000000000 +0200
3400 +++ linux-3.6.9-vs2.3.4.4/fs/file_table.c 2012-11-17 14:36:19.000000000 +0100
3402 #include <linux/hardirq.h>
3403 #include <linux/task_work.h>
3404 #include <linux/ima.h>
3405 +#include <linux/vs_limit.h>
3406 +#include <linux/vs_context.h>
3408 #include <linux/atomic.h>
3410 @@ -136,6 +138,8 @@ struct file *get_empty_filp(void)
3411 spin_lock_init(&f->f_lock);
3412 eventpoll_init_file(f);
3413 /* f->f_version: 0 */
3414 + f->f_xid = vx_current_xid();
3419 @@ -257,6 +261,8 @@ static void __fput(struct file *file)
3420 i_readcount_dec(inode);
3421 if (file->f_mode & FMODE_WRITE)
3422 drop_file_write_access(file);
3423 + vx_files_dec(file);
3425 file->f_path.dentry = NULL;
3426 file->f_path.mnt = NULL;
3428 @@ -449,6 +455,8 @@ void put_filp(struct file *file)
3430 if (atomic_long_dec_and_test(&file->f_count)) {
3431 security_file_free(file);
3432 + vx_files_dec(file);
3434 file_sb_list_del(file);
3437 diff -NurpP --minimal linux-3.6.9/fs/fs_struct.c linux-3.6.9-vs2.3.4.4/fs/fs_struct.c
3438 --- linux-3.6.9/fs/fs_struct.c 2012-10-04 15:27:39.000000000 +0200
3439 +++ linux-3.6.9-vs2.3.4.4/fs/fs_struct.c 2012-10-04 19:08:56.000000000 +0200
3441 #include <linux/path.h>
3442 #include <linux/slab.h>
3443 #include <linux/fs_struct.h>
3444 +#include <linux/vserver/global.h>
3445 #include "internal.h"
3448 @@ -87,6 +88,7 @@ void free_fs_struct(struct fs_struct *fs
3450 path_put(&fs->root);
3452 + atomic_dec(&vs_global_fs);
3453 kmem_cache_free(fs_cachep, fs);
3456 @@ -124,6 +126,7 @@ struct fs_struct *copy_fs_struct(struct
3459 spin_unlock(&old->lock);
3460 + atomic_inc(&vs_global_fs);
3464 diff -NurpP --minimal linux-3.6.9/fs/gfs2/file.c linux-3.6.9-vs2.3.4.4/fs/gfs2/file.c
3465 --- linux-3.6.9/fs/gfs2/file.c 2012-12-08 01:34:13.000000000 +0100
3466 +++ linux-3.6.9-vs2.3.4.4/fs/gfs2/file.c 2012-12-08 01:36:33.000000000 +0100
3467 @@ -143,6 +143,9 @@ static const u32 fsflags_to_gfs2[32] = {
3468 [12] = GFS2_DIF_EXHASH,
3469 [14] = GFS2_DIF_INHERIT_JDATA,
3470 [17] = GFS2_DIF_TOPDIR,
3471 + [27] = GFS2_DIF_IXUNLINK,
3472 + [26] = GFS2_DIF_BARRIER,
3473 + [29] = GFS2_DIF_COW,
3476 static const u32 gfs2_to_fsflags[32] = {
3477 @@ -153,6 +156,9 @@ static const u32 gfs2_to_fsflags[32] = {
3478 [gfs2fl_ExHash] = FS_INDEX_FL,
3479 [gfs2fl_TopLevel] = FS_TOPDIR_FL,
3480 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
3481 + [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
3482 + [gfs2fl_Barrier] = FS_BARRIER_FL,
3483 + [gfs2fl_Cow] = FS_COW_FL,
3486 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
3487 @@ -183,12 +189,18 @@ void gfs2_set_inode_flags(struct inode *
3489 struct gfs2_inode *ip = GFS2_I(inode);
3490 unsigned int flags = inode->i_flags;
3491 + unsigned int vflags = inode->i_vflags;
3493 + flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3494 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC | S_NOSEC);
3496 - flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|S_NOSEC);
3497 if ((ip->i_eattr == 0) && !is_sxid(inode->i_mode))
3498 inode->i_flags |= S_NOSEC;
3499 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
3500 flags |= S_IMMUTABLE;
3501 + if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
3502 + flags |= S_IXUNLINK;
3504 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
3506 if (ip->i_diskflags & GFS2_DIF_NOATIME)
3507 @@ -196,6 +208,43 @@ void gfs2_set_inode_flags(struct inode *
3508 if (ip->i_diskflags & GFS2_DIF_SYNC)
3510 inode->i_flags = flags;
3512 + vflags &= ~(V_BARRIER | V_COW);
3514 + if (ip->i_diskflags & GFS2_DIF_BARRIER)
3515 + vflags |= V_BARRIER;
3516 + if (ip->i_diskflags & GFS2_DIF_COW)
3518 + inode->i_vflags = vflags;
3521 +void gfs2_get_inode_flags(struct inode *inode)
3523 + struct gfs2_inode *ip = GFS2_I(inode);
3524 + unsigned int flags = inode->i_flags;
3525 + unsigned int vflags = inode->i_vflags;
3527 + ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
3528 + GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
3529 + GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
3530 + GFS2_DIF_BARRIER | GFS2_DIF_COW);
3532 + if (flags & S_IMMUTABLE)
3533 + ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
3534 + if (flags & S_IXUNLINK)
3535 + ip->i_diskflags |= GFS2_DIF_IXUNLINK;
3537 + if (flags & S_APPEND)
3538 + ip->i_diskflags |= GFS2_DIF_APPENDONLY;
3539 + if (flags & S_NOATIME)
3540 + ip->i_diskflags |= GFS2_DIF_NOATIME;
3541 + if (flags & S_SYNC)
3542 + ip->i_diskflags |= GFS2_DIF_SYNC;
3544 + if (vflags & V_BARRIER)
3545 + ip->i_diskflags |= GFS2_DIF_BARRIER;
3546 + if (vflags & V_COW)
3547 + ip->i_diskflags |= GFS2_DIF_COW;
3550 /* Flags that can be set by user space */
3551 @@ -309,6 +358,37 @@ static int gfs2_set_flags(struct file *f
3552 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
3555 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
3557 + struct gfs2_inode *ip = GFS2_I(inode);
3558 + struct gfs2_sbd *sdp = GFS2_SB(inode);
3559 + struct buffer_head *bh;
3560 + struct gfs2_holder gh;
3563 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
3566 + error = gfs2_trans_begin(sdp, RES_DINODE, 0);
3569 + error = gfs2_meta_inode_buffer(ip, &bh);
3571 + goto out_trans_end;
3572 + gfs2_trans_add_bh(ip->i_gl, bh, 1);
3573 + inode->i_flags = flags;
3574 + inode->i_vflags = vflags;
3575 + gfs2_get_inode_flags(inode);
3576 + gfs2_dinode_out(ip, bh->b_data);
3578 + gfs2_set_aops(inode);
3580 + gfs2_trans_end(sdp);
3582 + gfs2_glock_dq_uninit(&gh);
3586 static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3589 diff -NurpP --minimal linux-3.6.9/fs/gfs2/inode.h linux-3.6.9-vs2.3.4.4/fs/gfs2/inode.h
3590 --- linux-3.6.9/fs/gfs2/inode.h 2012-07-22 23:39:40.000000000 +0200
3591 +++ linux-3.6.9-vs2.3.4.4/fs/gfs2/inode.h 2012-10-04 18:47:00.000000000 +0200
3592 @@ -117,6 +117,7 @@ extern const struct file_operations gfs2
3593 extern const struct file_operations gfs2_dir_fops_nolock;
3595 extern void gfs2_set_inode_flags(struct inode *inode);
3596 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
3598 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
3599 extern const struct file_operations gfs2_file_fops;
3600 diff -NurpP --minimal linux-3.6.9/fs/inode.c linux-3.6.9-vs2.3.4.4/fs/inode.c
3601 --- linux-3.6.9/fs/inode.c 2012-12-08 01:34:13.000000000 +0100
3602 +++ linux-3.6.9-vs2.3.4.4/fs/inode.c 2012-12-08 01:36:33.000000000 +0100
3604 #include <linux/prefetch.h>
3605 #include <linux/buffer_head.h> /* for inode_has_buffers */
3606 #include <linux/ratelimit.h>
3607 +#include <linux/vs_tag.h>
3608 #include "internal.h"
3611 @@ -128,6 +129,9 @@ int inode_init_always(struct super_block
3612 struct address_space *const mapping = &inode->i_data;
3616 + /* essential because of inode slab reuse */
3618 inode->i_blkbits = sb->s_blocksize_bits;
3620 atomic_set(&inode->i_count, 1);
3621 @@ -149,6 +153,7 @@ int inode_init_always(struct super_block
3622 inode->i_bdev = NULL;
3623 inode->i_cdev = NULL;
3625 + inode->i_mdev = 0;
3626 inode->dirtied_when = 0;
3628 if (security_inode_alloc(inode))
3629 @@ -483,6 +488,8 @@ void __insert_inode_hash(struct inode *i
3631 EXPORT_SYMBOL(__insert_inode_hash);
3633 +EXPORT_SYMBOL_GPL(__iget);
3636 * __remove_inode_hash - remove an inode from the hash
3637 * @inode: inode to unhash
3638 @@ -1804,9 +1811,11 @@ void init_special_inode(struct inode *in
3639 if (S_ISCHR(mode)) {
3640 inode->i_fop = &def_chr_fops;
3641 inode->i_rdev = rdev;
3642 + inode->i_mdev = rdev;
3643 } else if (S_ISBLK(mode)) {
3644 inode->i_fop = &def_blk_fops;
3645 inode->i_rdev = rdev;
3646 + inode->i_mdev = rdev;
3647 } else if (S_ISFIFO(mode))
3648 inode->i_fop = &def_fifo_fops;
3649 else if (S_ISSOCK(mode))
3650 @@ -1835,6 +1844,7 @@ void inode_init_owner(struct inode *inod
3652 inode->i_gid = current_fsgid();
3653 inode->i_mode = mode;
3654 + inode->i_tag = dx_current_fstag(inode->i_sb);
3656 EXPORT_SYMBOL(inode_init_owner);
3658 diff -NurpP --minimal linux-3.6.9/fs/ioctl.c linux-3.6.9-vs2.3.4.4/fs/ioctl.c
3659 --- linux-3.6.9/fs/ioctl.c 2012-05-21 18:07:24.000000000 +0200
3660 +++ linux-3.6.9-vs2.3.4.4/fs/ioctl.c 2012-10-04 18:47:00.000000000 +0200
3662 #include <linux/writeback.h>
3663 #include <linux/buffer_head.h>
3664 #include <linux/falloc.h>
3665 +#include <linux/proc_fs.h>
3666 +#include <linux/vserver/inode.h>
3667 +#include <linux/vs_tag.h>
3669 #include <asm/ioctls.h>
3671 diff -NurpP --minimal linux-3.6.9/fs/ioprio.c linux-3.6.9-vs2.3.4.4/fs/ioprio.c
3672 --- linux-3.6.9/fs/ioprio.c 2012-07-22 23:39:40.000000000 +0200
3673 +++ linux-3.6.9-vs2.3.4.4/fs/ioprio.c 2012-10-04 18:47:00.000000000 +0200
3675 #include <linux/syscalls.h>
3676 #include <linux/security.h>
3677 #include <linux/pid_namespace.h>
3678 +#include <linux/vs_base.h>
3680 int set_task_ioprio(struct task_struct *task, int ioprio)
3682 @@ -105,6 +106,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
3684 pgrp = find_vpid(who);
3685 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3686 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3688 ret = set_task_ioprio(p, ioprio);
3691 @@ -198,6 +201,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
3693 pgrp = find_vpid(who);
3694 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3695 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3697 tmpio = get_task_ioprio(p);
3700 diff -NurpP --minimal linux-3.6.9/fs/jfs/file.c linux-3.6.9-vs2.3.4.4/fs/jfs/file.c
3701 --- linux-3.6.9/fs/jfs/file.c 2011-10-24 18:45:27.000000000 +0200
3702 +++ linux-3.6.9-vs2.3.4.4/fs/jfs/file.c 2012-10-04 18:47:00.000000000 +0200
3703 @@ -109,7 +109,8 @@ int jfs_setattr(struct dentry *dentry, s
3704 if (is_quota_modification(inode, iattr))
3705 dquot_initialize(inode);
3706 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
3707 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
3708 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
3709 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
3710 rc = dquot_transfer(inode, iattr);
3713 @@ -142,6 +143,7 @@ const struct inode_operations jfs_file_i
3714 #ifdef CONFIG_JFS_POSIX_ACL
3715 .get_acl = jfs_get_acl,
3717 + .sync_flags = jfs_sync_flags,
3720 const struct file_operations jfs_file_operations = {
3721 diff -NurpP --minimal linux-3.6.9/fs/jfs/ioctl.c linux-3.6.9-vs2.3.4.4/fs/jfs/ioctl.c
3722 --- linux-3.6.9/fs/jfs/ioctl.c 2012-03-19 19:47:25.000000000 +0100
3723 +++ linux-3.6.9-vs2.3.4.4/fs/jfs/ioctl.c 2012-10-04 18:47:00.000000000 +0200
3725 #include <linux/mount.h>
3726 #include <linux/time.h>
3727 #include <linux/sched.h>
3728 +#include <linux/mount.h>
3729 #include <asm/current.h>
3730 #include <asm/uaccess.h>
3732 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
3736 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
3738 + inode->i_flags = flags;
3739 + inode->i_vflags = vflags;
3740 + jfs_get_inode_flags(JFS_IP(inode));
3741 + inode->i_ctime = CURRENT_TIME_SEC;
3742 + mark_inode_dirty(inode);
3746 long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3748 struct inode *inode = filp->f_dentry->d_inode;
3749 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
3750 if (!S_ISDIR(inode->i_mode))
3751 flags &= ~JFS_DIRSYNC_FL;
3753 + if (IS_BARRIER(inode)) {
3754 + vxwprintk_task(1, "messing with the barrier.");
3758 /* Is it quota file? Do not allow user to mess with it */
3759 if (IS_NOQUOTA(inode)) {
3761 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
3762 * the relevant capability.
3764 if ((oldflags & JFS_IMMUTABLE_FL) ||
3765 - ((flags ^ oldflags) &
3766 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
3767 + ((flags ^ oldflags) & (JFS_APPEND_FL |
3768 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
3769 if (!capable(CAP_LINUX_IMMUTABLE)) {
3770 mutex_unlock(&inode->i_mutex);
3772 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
3776 - flags = flags & JFS_FL_USER_MODIFIABLE;
3777 + flags &= JFS_FL_USER_MODIFIABLE;
3778 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
3779 jfs_inode->mode2 = flags;
3781 diff -NurpP --minimal linux-3.6.9/fs/jfs/jfs_dinode.h linux-3.6.9-vs2.3.4.4/fs/jfs/jfs_dinode.h
3782 --- linux-3.6.9/fs/jfs/jfs_dinode.h 2008-12-25 00:26:37.000000000 +0100
3783 +++ linux-3.6.9-vs2.3.4.4/fs/jfs/jfs_dinode.h 2012-10-04 18:47:00.000000000 +0200
3784 @@ -161,9 +161,13 @@ struct dinode {
3786 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
3787 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
3788 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3790 -#define JFS_FL_USER_VISIBLE 0x03F80000
3791 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
3792 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3793 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
3795 +#define JFS_FL_USER_VISIBLE 0x07F80000
3796 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
3797 #define JFS_FL_INHERIT 0x03C80000
3799 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
3800 diff -NurpP --minimal linux-3.6.9/fs/jfs/jfs_filsys.h linux-3.6.9-vs2.3.4.4/fs/jfs/jfs_filsys.h
3801 --- linux-3.6.9/fs/jfs/jfs_filsys.h 2008-12-25 00:26:37.000000000 +0100
3802 +++ linux-3.6.9-vs2.3.4.4/fs/jfs/jfs_filsys.h 2012-10-04 18:47:00.000000000 +0200
3804 #define JFS_NAME_MAX 255
3805 #define JFS_PATH_MAX BPSIZE
3807 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
3810 * file system state (superblock state)
3811 diff -NurpP --minimal linux-3.6.9/fs/jfs/jfs_imap.c linux-3.6.9-vs2.3.4.4/fs/jfs/jfs_imap.c
3812 --- linux-3.6.9/fs/jfs/jfs_imap.c 2012-01-09 16:14:54.000000000 +0100
3813 +++ linux-3.6.9-vs2.3.4.4/fs/jfs/jfs_imap.c 2012-10-04 18:47:00.000000000 +0200
3815 #include <linux/pagemap.h>
3816 #include <linux/quotaops.h>
3817 #include <linux/slab.h>
3818 +#include <linux/vs_tag.h>
3820 #include "jfs_incore.h"
3821 #include "jfs_inode.h"
3822 @@ -3058,6 +3059,8 @@ static int copy_from_dinode(struct dinod
3824 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
3825 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
3829 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
3830 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
3831 @@ -3078,14 +3081,18 @@ static int copy_from_dinode(struct dinod
3833 set_nlink(ip, le32_to_cpu(dip->di_nlink));
3835 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
3836 + uid = le32_to_cpu(dip->di_uid);
3837 + gid = le32_to_cpu(dip->di_gid);
3838 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
3840 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
3842 ip->i_uid = jfs_ip->saved_uid;
3844 ip->i_uid = sbi->uid;
3847 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
3848 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
3850 ip->i_gid = jfs_ip->saved_gid;
3852 @@ -3150,14 +3157,12 @@ static void copy_to_dinode(struct dinode
3853 dip->di_size = cpu_to_le64(ip->i_size);
3854 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
3855 dip->di_nlink = cpu_to_le32(ip->i_nlink);
3856 - if (sbi->uid == -1)
3857 - dip->di_uid = cpu_to_le32(ip->i_uid);
3859 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
3860 - if (sbi->gid == -1)
3861 - dip->di_gid = cpu_to_le32(ip->i_gid);
3863 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
3865 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
3866 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
3867 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
3868 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
3870 jfs_get_inode_flags(jfs_ip);
3872 * mode2 is only needed for storing the higher order bits.
3873 diff -NurpP --minimal linux-3.6.9/fs/jfs/jfs_inode.c linux-3.6.9-vs2.3.4.4/fs/jfs/jfs_inode.c
3874 --- linux-3.6.9/fs/jfs/jfs_inode.c 2012-01-09 16:14:54.000000000 +0100
3875 +++ linux-3.6.9-vs2.3.4.4/fs/jfs/jfs_inode.c 2012-10-04 18:47:00.000000000 +0200
3878 #include <linux/fs.h>
3879 #include <linux/quotaops.h>
3880 +#include <linux/vs_tag.h>
3881 #include "jfs_incore.h"
3882 #include "jfs_inode.h"
3883 #include "jfs_filsys.h"
3884 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
3886 unsigned int flags = JFS_IP(inode)->mode2;
3888 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
3889 - S_NOATIME | S_DIRSYNC | S_SYNC);
3890 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3891 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3893 if (flags & JFS_IMMUTABLE_FL)
3894 inode->i_flags |= S_IMMUTABLE;
3895 + if (flags & JFS_IXUNLINK_FL)
3896 + inode->i_flags |= S_IXUNLINK;
3898 + if (flags & JFS_SYNC_FL)
3899 + inode->i_flags |= S_SYNC;
3900 if (flags & JFS_APPEND_FL)
3901 inode->i_flags |= S_APPEND;
3902 if (flags & JFS_NOATIME_FL)
3903 inode->i_flags |= S_NOATIME;
3904 if (flags & JFS_DIRSYNC_FL)
3905 inode->i_flags |= S_DIRSYNC;
3906 - if (flags & JFS_SYNC_FL)
3907 - inode->i_flags |= S_SYNC;
3909 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3911 + if (flags & JFS_BARRIER_FL)
3912 + inode->i_vflags |= V_BARRIER;
3913 + if (flags & JFS_COW_FL)
3914 + inode->i_vflags |= V_COW;
3917 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
3919 unsigned int flags = jfs_ip->vfs_inode.i_flags;
3920 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
3922 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
3923 + JFS_APPEND_FL | JFS_NOATIME_FL |
3924 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
3925 + JFS_BARRIER_FL | JFS_COW_FL);
3927 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
3928 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
3929 if (flags & S_IMMUTABLE)
3930 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
3931 + if (flags & S_IXUNLINK)
3932 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
3934 if (flags & S_APPEND)
3935 jfs_ip->mode2 |= JFS_APPEND_FL;
3936 if (flags & S_NOATIME)
3937 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
3938 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
3940 jfs_ip->mode2 |= JFS_SYNC_FL;
3942 + if (vflags & V_BARRIER)
3943 + jfs_ip->mode2 |= JFS_BARRIER_FL;
3944 + if (vflags & V_COW)
3945 + jfs_ip->mode2 |= JFS_COW_FL;
3949 diff -NurpP --minimal linux-3.6.9/fs/jfs/jfs_inode.h linux-3.6.9-vs2.3.4.4/fs/jfs/jfs_inode.h
3950 --- linux-3.6.9/fs/jfs/jfs_inode.h 2011-10-24 18:45:27.000000000 +0200
3951 +++ linux-3.6.9-vs2.3.4.4/fs/jfs/jfs_inode.h 2012-10-04 18:47:00.000000000 +0200
3952 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
3953 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
3954 int fh_len, int fh_type);
3955 extern void jfs_set_inode_flags(struct inode *);
3956 +extern int jfs_sync_flags(struct inode *, int, int);
3957 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
3958 extern int jfs_setattr(struct dentry *, struct iattr *);
3960 diff -NurpP --minimal linux-3.6.9/fs/jfs/namei.c linux-3.6.9-vs2.3.4.4/fs/jfs/namei.c
3961 --- linux-3.6.9/fs/jfs/namei.c 2012-10-04 15:27:40.000000000 +0200
3962 +++ linux-3.6.9-vs2.3.4.4/fs/jfs/namei.c 2012-10-04 18:47:00.000000000 +0200
3964 #include <linux/ctype.h>
3965 #include <linux/quotaops.h>
3966 #include <linux/exportfs.h>
3967 +#include <linux/vs_tag.h>
3968 #include "jfs_incore.h"
3969 #include "jfs_superblock.h"
3970 #include "jfs_inode.h"
3971 @@ -1461,6 +1462,7 @@ static struct dentry *jfs_lookup(struct
3972 jfs_err("jfs_lookup: iget failed on inum %d", (uint)inum);
3975 + dx_propagate_tag(nd, ip);
3976 return d_splice_alias(ip, dentry);
3979 @@ -1525,6 +1527,7 @@ const struct inode_operations jfs_dir_in
3980 #ifdef CONFIG_JFS_POSIX_ACL
3981 .get_acl = jfs_get_acl,
3983 + .sync_flags = jfs_sync_flags,
3986 const struct file_operations jfs_dir_operations = {
3987 diff -NurpP --minimal linux-3.6.9/fs/jfs/super.c linux-3.6.9-vs2.3.4.4/fs/jfs/super.c
3988 --- linux-3.6.9/fs/jfs/super.c 2012-10-04 15:27:40.000000000 +0200
3989 +++ linux-3.6.9-vs2.3.4.4/fs/jfs/super.c 2012-10-04 18:47:00.000000000 +0200
3990 @@ -197,7 +197,8 @@ static void jfs_put_super(struct super_b
3992 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
3993 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
3994 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
3995 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
3996 + Opt_tag, Opt_notag, Opt_tagid
3999 static const match_table_t tokens = {
4000 @@ -207,6 +208,10 @@ static const match_table_t tokens = {
4001 {Opt_resize, "resize=%u"},
4002 {Opt_resize_nosize, "resize"},
4003 {Opt_errors, "errors=%s"},
4005 + {Opt_notag, "notag"},
4006 + {Opt_tagid, "tagid=%u"},
4007 + {Opt_tag, "tagxid"},
4008 {Opt_ignore, "noquota"},
4009 {Opt_ignore, "quota"},
4010 {Opt_usrquota, "usrquota"},
4011 @@ -341,6 +346,20 @@ static int parse_options(char *options,
4015 +#ifndef CONFIG_TAGGING_NONE
4017 + *flag |= JFS_TAGGED;
4020 + *flag &= JFS_TAGGED;
4023 +#ifdef CONFIG_PROPAGATE
4026 + *flag |= JFS_TAGGED;
4030 printk("jfs: Unrecognized mount option \"%s\" "
4031 " or missing value\n", p);
4032 @@ -372,6 +391,12 @@ static int jfs_remount(struct super_bloc
4036 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4037 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4043 if (sb->s_flags & MS_RDONLY) {
4045 @@ -455,6 +480,9 @@ static int jfs_fill_super(struct super_b
4046 #ifdef CONFIG_JFS_POSIX_ACL
4047 sb->s_flags |= MS_POSIXACL;
4049 + /* map mount option tagxid */
4050 + if (sbi->flag & JFS_TAGGED)
4051 + sb->s_flags |= MS_TAGGED;
4054 printk(KERN_ERR "resize option for remount only\n");
4055 diff -NurpP --minimal linux-3.6.9/fs/libfs.c linux-3.6.9-vs2.3.4.4/fs/libfs.c
4056 --- linux-3.6.9/fs/libfs.c 2012-10-04 15:27:40.000000000 +0200
4057 +++ linux-3.6.9-vs2.3.4.4/fs/libfs.c 2012-10-04 18:47:00.000000000 +0200
4058 @@ -135,7 +135,8 @@ static inline unsigned char dt_type(stru
4059 * both impossible due to the lock on directory.
4062 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4063 +static inline int do_dcache_readdir_filter(struct file *filp,
4064 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4066 struct dentry *dentry = filp->f_path.dentry;
4067 struct dentry *cursor = filp->private_data;
4068 @@ -166,6 +167,8 @@ int dcache_readdir(struct file * filp, v
4069 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
4070 struct dentry *next;
4071 next = list_entry(p, struct dentry, d_u.d_child);
4072 + if (filter && !filter(next))
4074 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
4075 if (!simple_positive(next)) {
4076 spin_unlock(&next->d_lock);
4077 @@ -192,6 +195,17 @@ int dcache_readdir(struct file * filp, v
4081 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4083 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4086 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4087 + int (*filter)(struct dentry *))
4089 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4092 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4095 @@ -983,6 +997,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4096 EXPORT_SYMBOL(dcache_dir_lseek);
4097 EXPORT_SYMBOL(dcache_dir_open);
4098 EXPORT_SYMBOL(dcache_readdir);
4099 +EXPORT_SYMBOL(dcache_readdir_filter);
4100 EXPORT_SYMBOL(generic_read_dir);
4101 EXPORT_SYMBOL(mount_pseudo);
4102 EXPORT_SYMBOL(simple_write_begin);
4103 diff -NurpP --minimal linux-3.6.9/fs/locks.c linux-3.6.9-vs2.3.4.4/fs/locks.c
4104 --- linux-3.6.9/fs/locks.c 2012-10-04 15:27:40.000000000 +0200
4105 +++ linux-3.6.9-vs2.3.4.4/fs/locks.c 2012-10-04 18:47:00.000000000 +0200
4107 #include <linux/time.h>
4108 #include <linux/rcupdate.h>
4109 #include <linux/pid_namespace.h>
4110 +#include <linux/vs_base.h>
4111 +#include <linux/vs_limit.h>
4113 #include <asm/uaccess.h>
4115 @@ -184,11 +186,17 @@ static void locks_init_lock_heads(struct
4116 /* Allocate an empty lock structure. */
4117 struct file_lock *locks_alloc_lock(void)
4119 - struct file_lock *fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL);
4120 + struct file_lock *fl;
4123 - locks_init_lock_heads(fl);
4124 + if (!vx_locks_avail(1))
4127 + fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL);
4130 + locks_init_lock_heads(fl);
4135 EXPORT_SYMBOL_GPL(locks_alloc_lock);
4136 @@ -212,6 +220,7 @@ void locks_free_lock(struct file_lock *f
4137 BUG_ON(!list_empty(&fl->fl_block));
4138 BUG_ON(!list_empty(&fl->fl_link));
4141 locks_release_private(fl);
4142 kmem_cache_free(filelock_cache, fl);
4144 @@ -221,6 +230,7 @@ void locks_init_lock(struct file_lock *f
4146 memset(fl, 0, sizeof(struct file_lock));
4147 locks_init_lock_heads(fl);
4151 EXPORT_SYMBOL(locks_init_lock);
4152 @@ -261,6 +271,7 @@ void locks_copy_lock(struct file_lock *n
4153 new->fl_file = fl->fl_file;
4154 new->fl_ops = fl->fl_ops;
4155 new->fl_lmops = fl->fl_lmops;
4156 + new->fl_xid = fl->fl_xid;
4158 locks_copy_private(new, fl);
4160 @@ -299,6 +310,11 @@ static int flock_make_lock(struct file *
4161 fl->fl_flags = FL_FLOCK;
4163 fl->fl_end = OFFSET_MAX;
4165 + vxd_assert(filp->f_xid == vx_current_xid(),
4166 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4167 + fl->fl_xid = filp->f_xid;
4172 @@ -438,6 +454,7 @@ static int lease_init(struct file *filp,
4174 fl->fl_owner = current->files;
4175 fl->fl_pid = current->tgid;
4176 + fl->fl_xid = vx_current_xid();
4179 fl->fl_flags = FL_LEASE;
4180 @@ -457,6 +474,11 @@ static struct file_lock *lease_alloc(str
4182 return ERR_PTR(error);
4184 + fl->fl_xid = vx_current_xid();
4186 + vxd_assert(filp->f_xid == fl->fl_xid,
4187 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4189 error = lease_init(filp, type, fl);
4191 locks_free_lock(fl);
4192 @@ -753,6 +775,7 @@ static int flock_lock_file(struct file *
4196 + new_fl->fl_xid = -1;
4198 for_each_lock(inode, before) {
4199 struct file_lock *fl = *before;
4200 @@ -773,6 +796,7 @@ find_conflict:
4202 locks_copy_lock(new_fl, request);
4203 locks_insert_lock(before, new_fl);
4204 + vx_locks_inc(new_fl);
4208 @@ -783,7 +807,8 @@ out:
4212 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4213 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4214 + struct file_lock *conflock, xid_t xid)
4216 struct file_lock *fl;
4217 struct file_lock *new_fl = NULL;
4218 @@ -793,6 +818,8 @@ static int __posix_lock_file(struct inod
4219 struct file_lock **before;
4220 int error, added = 0;
4222 + vxd_assert(xid == vx_current_xid(),
4223 + "xid(%d) == current(%d)", xid, vx_current_xid());
4225 * We may need two file_lock structures for this operation,
4226 * so we get them in advance to avoid races.
4227 @@ -803,7 +830,11 @@ static int __posix_lock_file(struct inod
4228 (request->fl_type != F_UNLCK ||
4229 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4230 new_fl = locks_alloc_lock();
4231 + new_fl->fl_xid = xid;
4232 + vx_locks_inc(new_fl);
4233 new_fl2 = locks_alloc_lock();
4234 + new_fl2->fl_xid = xid;
4235 + vx_locks_inc(new_fl2);
4239 @@ -1002,7 +1033,8 @@ static int __posix_lock_file(struct inod
4240 int posix_lock_file(struct file *filp, struct file_lock *fl,
4241 struct file_lock *conflock)
4243 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
4244 + return __posix_lock_file(filp->f_path.dentry->d_inode,
4245 + fl, conflock, filp->f_xid);
4247 EXPORT_SYMBOL(posix_lock_file);
4249 @@ -1092,7 +1124,7 @@ int locks_mandatory_area(int read_write,
4250 fl.fl_end = offset + count - 1;
4253 - error = __posix_lock_file(inode, &fl, NULL);
4254 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
4255 if (error != FILE_LOCK_DEFERRED)
4257 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
4258 @@ -1397,6 +1429,7 @@ int generic_add_lease(struct file *filp,
4261 locks_insert_lock(before, lease);
4262 + vx_locks_inc(lease);
4266 @@ -1838,6 +1871,11 @@ int fcntl_setlk(unsigned int fd, struct
4267 if (file_lock == NULL)
4270 + vxd_assert(filp->f_xid == vx_current_xid(),
4271 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4272 + file_lock->fl_xid = filp->f_xid;
4273 + vx_locks_inc(file_lock);
4276 * This might block, so we do it before checking the inode.
4278 @@ -1956,6 +1994,11 @@ int fcntl_setlk64(unsigned int fd, struc
4279 if (file_lock == NULL)
4282 + vxd_assert(filp->f_xid == vx_current_xid(),
4283 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4284 + file_lock->fl_xid = filp->f_xid;
4285 + vx_locks_inc(file_lock);
4288 * This might block, so we do it before checking the inode.
4290 @@ -2221,8 +2264,11 @@ static int locks_show(struct seq_file *f
4292 lock_get_status(f, fl, *((loff_t *)f->private), "");
4294 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
4295 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
4296 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
4298 lock_get_status(f, bfl, *((loff_t *)f->private), " ->");
4303 diff -NurpP --minimal linux-3.6.9/fs/mount.h linux-3.6.9-vs2.3.4.4/fs/mount.h
4304 --- linux-3.6.9/fs/mount.h 2012-10-04 15:27:40.000000000 +0200
4305 +++ linux-3.6.9-vs2.3.4.4/fs/mount.h 2012-10-04 18:47:00.000000000 +0200
4306 @@ -46,6 +46,7 @@ struct mount {
4307 int mnt_expiry_mark; /* true if marked for expiry */
4310 + vs_tag_t mnt_tag; /* tagging used for vfsmount */
4313 #define MNT_NS_INTERNAL ERR_PTR(-EINVAL) /* distinct from any mnt_namespace */
4314 diff -NurpP --minimal linux-3.6.9/fs/namei.c linux-3.6.9-vs2.3.4.4/fs/namei.c
4315 --- linux-3.6.9/fs/namei.c 2012-12-08 01:34:14.000000000 +0100
4316 +++ linux-3.6.9-vs2.3.4.4/fs/namei.c 2012-12-08 01:08:53.000000000 +0100
4318 #include <linux/device_cgroup.h>
4319 #include <linux/fs_struct.h>
4320 #include <linux/posix_acl.h>
4321 +#include <linux/proc_fs.h>
4322 +#include <linux/vserver/inode.h>
4323 +#include <linux/vs_base.h>
4324 +#include <linux/vs_tag.h>
4325 +#include <linux/vs_cowbl.h>
4326 +#include <linux/vs_device.h>
4327 +#include <linux/vs_context.h>
4328 +#include <linux/pid_namespace.h>
4329 #include <asm/uaccess.h>
4331 #include "internal.h"
4332 @@ -212,6 +220,89 @@ static int check_acl(struct inode *inode
4336 +static inline int dx_barrier(const struct inode *inode)
4338 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
4339 + vxwprintk_task(1, "did hit the barrier.");
4345 +static int __dx_permission(const struct inode *inode, int mask)
4347 + if (dx_barrier(inode))
4350 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
4351 + /* devpts is xid tagged */
4352 + if (S_ISDIR(inode->i_mode) ||
4353 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
4356 + /* just pretend we didn't find anything */
4359 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
4360 + struct proc_dir_entry *de = PDE(inode);
4362 + if (de && !vx_hide_check(0, de->vx_flags))
4365 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
4367 + struct task_struct *tsk;
4369 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
4370 + vx_flags(VXF_STATE_SETUP, 0))
4373 + pid = PROC_I(inode)->pid;
4378 + tsk = pid_task(pid, PIDTYPE_PID);
4379 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
4380 + tsk, (tsk ? vx_task_xid(tsk) : 0));
4382 + vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P)) {
4383 + rcu_read_unlock();
4386 + rcu_read_unlock();
4389 + /* FIXME: Should we block some entries here? */
4394 + if (dx_notagcheck(inode->i_sb) ||
4395 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
4404 +int dx_permission(const struct inode *inode, int mask)
4406 + int ret = __dx_permission(inode, mask);
4407 + if (unlikely(ret)) {
4408 +#ifndef CONFIG_VSERVER_WARN_DEVPTS
4409 + if (inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC)
4412 + "denied [0x%x] access to inode %s:%p[#%d,%lu]",
4413 + mask, inode->i_sb->s_id, inode, inode->i_tag,
4420 * This does the basic permission checking
4422 @@ -334,10 +425,14 @@ int __inode_permission(struct inode *ino
4424 * Nobody gets write access to an immutable file.
4426 - if (IS_IMMUTABLE(inode))
4427 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
4431 + retval = dx_permission(inode, mask);
4435 retval = do_inode_permission(inode, mask);
4438 @@ -1189,7 +1284,8 @@ static void follow_dotdot(struct nameida
4440 if (nd->path.dentry == nd->root.dentry &&
4441 nd->path.mnt == nd->root.mnt) {
4443 + /* for sane '/' avoid follow_mount() */
4446 if (nd->path.dentry != nd->path.mnt->mnt_root) {
4447 /* rare case of legitimate dget_parent()... */
4448 @@ -1338,6 +1434,9 @@ static int lookup_fast(struct nameidata
4453 + /* FIXME: check dx permission */
4456 path->dentry = dentry;
4457 if (unlikely(!__follow_mount_rcu(nd, path, inode)))
4458 @@ -1373,6 +1472,8 @@ unlazy:
4462 + /* FIXME: check dx permission */
4465 path->dentry = dentry;
4466 err = follow_managed(path, nd->flags);
4467 @@ -2192,7 +2293,7 @@ static int may_delete(struct inode *dir,
4470 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
4471 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4472 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4475 if (!S_ISDIR(victim->d_inode->i_mode))
4476 @@ -2271,19 +2372,25 @@ int vfs_create(struct inode *dir, struct
4479 int error = may_create(dir, dentry);
4483 + vxdprintk(VXD_CBIT(misc, 3), "may_create failed with %d", error);
4487 if (!dir->i_op->create)
4488 return -EACCES; /* shouldn't it be ENOSYS? */
4491 error = security_inode_create(dir, dentry, mode);
4495 + vxdprintk(VXD_CBIT(misc, 3), "security_inode_create failed with %d", error);
4498 error = dir->i_op->create(dir, dentry, mode, want_excl);
4500 fsnotify_create(dir, dentry);
4502 + vxdprintk(VXD_CBIT(misc, 3), "i_op->create failed with %d", error);
4506 @@ -2318,6 +2425,15 @@ static int may_open(struct path *path, i
4510 +#ifdef CONFIG_VSERVER_COWBL
4511 + if (IS_COW(inode) &&
4512 + ((flag & O_ACCMODE) != O_RDONLY)) {
4513 + if (IS_COW_LINK(inode))
4515 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
4516 + mark_inode_dirty(inode);
4519 error = inode_permission(inode, acc_mode);
4522 @@ -2820,6 +2936,16 @@ finish_open:
4524 finish_open_created:
4525 error = may_open(&nd->path, acc_mode, open_flag);
4526 +#ifdef CONFIG_VSERVER_COWBL
4527 + if (error == -EMLINK) {
4528 + struct dentry *dentry;
4529 + dentry = cow_break_link(pathname);
4530 + if (IS_ERR(dentry))
4531 + error = PTR_ERR(dentry);
4538 file->f_path.mnt = nd->path.mnt;
4539 @@ -2884,6 +3010,7 @@ static struct file *path_openat(int dfd,
4544 file = get_empty_filp();
4546 return ERR_PTR(-ENFILE);
4547 @@ -2920,6 +3047,16 @@ static struct file *path_openat(int dfd,
4548 error = do_last(nd, &path, file, op, &opened, pathname);
4549 put_link(nd, &link, cookie);
4552 +#ifdef CONFIG_VSERVER_COWBL
4553 + if (error == -EMLINK) {
4554 + if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
4555 + path_put(&nd->root);
4562 if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
4563 path_put(&nd->root);
4564 @@ -3023,6 +3160,11 @@ struct dentry *kern_path_create(int dfd,
4568 + vxdprintk(VXD_CBIT(misc, 3), "kern_path_create path.dentry = %p (%.*s), dentry = %p (%.*s), d_inode = %p",
4569 + path->dentry, path->dentry->d_name.len,
4570 + path->dentry->d_name.name, dentry,
4571 + dentry->d_name.len, dentry->d_name.name,
4572 + path->dentry->d_inode);
4576 @@ -3489,7 +3631,7 @@ int vfs_link(struct dentry *old_dentry,
4578 * A link to an append-only or immutable file cannot be created.
4580 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4581 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4583 if (!dir->i_op->link)
4585 @@ -3874,6 +4016,275 @@ int vfs_follow_link(struct nameidata *nd
4586 return __vfs_follow_link(nd, link);
4590 +#ifdef CONFIG_VSERVER_COWBL
4593 +long do_cow_splice(struct file *in, struct file *out, size_t len)
4597 + return do_splice_direct(in, &ppos, out, len, 0);
4600 +struct dentry *cow_break_link(const char *pathname)
4602 + int ret, mode, pathlen, redo = 0;
4603 + struct nameidata old_nd, dir_nd;
4604 + struct path dir_path, *old_path, *new_path;
4605 + struct dentry *dir, *old_dentry, *new_dentry = NULL;
4606 + struct file *old_file;
4607 + struct file *new_file;
4608 + char *to, *path, pad='\251';
4611 + vxdprintk(VXD_CBIT(misc, 1),
4612 + "cow_break_link(" VS_Q("%s") ")", pathname);
4614 + path = kmalloc(PATH_MAX, GFP_KERNEL);
4619 + /* old_nd.path will have refs to dentry and mnt */
4620 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
4621 + vxdprintk(VXD_CBIT(misc, 2),
4622 + "do_path_lookup(old): %d", ret);
4624 + goto out_free_path;
4626 + /* dentry/mnt refs handed over to old_path */
4627 + old_path = &old_nd.path;
4628 + /* no explicit reference for old_dentry here */
4629 + old_dentry = old_path->dentry;
4631 + mode = old_dentry->d_inode->i_mode;
4632 + to = d_path(old_path, path, PATH_MAX-2);
4633 + pathlen = strlen(to);
4634 + vxdprintk(VXD_CBIT(misc, 2),
4635 + "old path " VS_Q("%s") " [%p:" VS_Q("%.*s") ":%d]", to,
4637 + old_dentry->d_name.len, old_dentry->d_name.name,
4638 + old_dentry->d_name.len);
4640 + to[pathlen + 1] = 0;
4642 + new_dentry = NULL;
4643 + to[pathlen] = pad--;
4645 + if (pad <= '\240')
4648 + vxdprintk(VXD_CBIT(misc, 1), "temp copy " VS_Q("%s"), to);
4650 + /* dir_nd.path will have refs to dentry and mnt */
4651 + ret = do_path_lookup(AT_FDCWD, to,
4652 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
4653 + vxdprintk(VXD_CBIT(misc, 2), "do_path_lookup(new): %d", ret);
4657 + /* this puppy downs the dir inode mutex if successful.
4658 + dir_path will hold refs to dentry and mnt and
4659 + we'll have get write access to the mnt */
4660 + new_dentry = kern_path_create(AT_FDCWD, to, &dir_path, 0);
4661 + if (!new_dentry || IS_ERR(new_dentry)) {
4662 + path_put(&dir_nd.path);
4663 + vxdprintk(VXD_CBIT(misc, 2),
4664 + "kern_path_create(new) failed with %ld",
4665 + PTR_ERR(new_dentry));
4668 + vxdprintk(VXD_CBIT(misc, 2),
4669 + "kern_path_create(new): %p [" VS_Q("%.*s") ":%d]",
4671 + new_dentry->d_name.len, new_dentry->d_name.name,
4672 + new_dentry->d_name.len);
4674 + /* take a reference on new_dentry */
4677 + /* dentry/mnt refs handed over to new_path */
4678 + new_path = &dir_path;
4680 + /* dentry for old/new dir */
4681 + dir = dir_nd.path.dentry;
4683 + /* give up reference on dir */
4684 + dput(new_path->dentry);
4686 + /* new_dentry already has a reference */
4687 + new_path->dentry = new_dentry;
4689 + ret = vfs_create(dir->d_inode, new_dentry, mode, 1);
4690 + vxdprintk(VXD_CBIT(misc, 2),
4691 + "vfs_create(new): %d", ret);
4692 + if (ret == -EEXIST) {
4693 + mutex_unlock(&dir->d_inode->i_mutex);
4694 + path_put(&dir_nd.path);
4695 + mnt_drop_write(new_path->mnt);
4696 + path_put(new_path);
4697 + new_dentry = NULL;
4701 + goto out_unlock_new;
4703 + /* drop out early, ret passes ENOENT */
4705 + if ((redo = d_unhashed(old_dentry)))
4706 + goto out_unlock_new;
4708 + /* doesn't change refs for old_path */
4709 + old_file = dentry_open(old_path, O_RDONLY, current_cred());
4710 + vxdprintk(VXD_CBIT(misc, 2),
4711 + "dentry_open(old): %p", old_file);
4712 + if (IS_ERR(old_file)) {
4713 + ret = PTR_ERR(old_file);
4714 + goto out_unlock_new;
4717 + /* doesn't change refs for new_path */
4718 + new_file = dentry_open(new_path, O_WRONLY, current_cred());
4719 + vxdprintk(VXD_CBIT(misc, 2),
4720 + "dentry_open(new): %p", new_file);
4721 + if (IS_ERR(new_file)) {
4722 + ret = PTR_ERR(new_file);
4723 + goto out_fput_old;
4726 + size = i_size_read(old_file->f_dentry->d_inode);
4727 + ret = do_cow_splice(old_file, new_file, size);
4728 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
4730 + goto out_fput_both;
4731 + } else if (ret < size) {
4733 + goto out_fput_both;
4735 + struct inode *old_inode = old_dentry->d_inode;
4736 + struct inode *new_inode = new_dentry->d_inode;
4737 + struct iattr attr = {
4738 + .ia_uid = old_inode->i_uid,
4739 + .ia_gid = old_inode->i_gid,
4740 + .ia_valid = ATTR_UID | ATTR_GID
4743 + setattr_copy(new_inode, &attr);
4744 + mark_inode_dirty(new_inode);
4747 + /* lock rename mutex */
4748 + mutex_lock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
4750 + /* drop out late */
4752 + if ((redo = d_unhashed(old_dentry)))
4755 + vxdprintk(VXD_CBIT(misc, 2),
4756 + "vfs_rename: [" VS_Q("%*s") ":%d] -> [" VS_Q("%*s") ":%d]",
4757 + new_dentry->d_name.len, new_dentry->d_name.name,
4758 + new_dentry->d_name.len,
4759 + old_dentry->d_name.len, old_dentry->d_name.name,
4760 + old_dentry->d_name.len);
4761 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_dentry,
4762 + old_dentry->d_parent->d_inode, old_dentry);
4763 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
4766 + mutex_unlock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
4769 + vxdprintk(VXD_CBIT(misc, 3),
4770 + "fput(new_file=%p[#%ld])", new_file,
4771 + atomic_long_read(&new_file->f_count));
4775 + vxdprintk(VXD_CBIT(misc, 3),
4776 + "fput(old_file=%p[#%ld])", old_file,
4777 + atomic_long_read(&old_file->f_count));
4781 + /* drop references from dir_nd.path */
4782 + path_put(&dir_nd.path);
4784 + /* drop write access to mnt */
4785 + mnt_drop_write(new_path->mnt);
4787 + /* unlock the inode mutex from kern_path_create() */
4788 + mutex_unlock(&dir->d_inode->i_mutex);
4792 + /* error path cleanup */
4793 + vfs_unlink(dir->d_inode, new_dentry);
4797 + goto out_rel_both;
4799 + /* lookup dentry once again
4800 + old_nd.path will be freed as old_path in out_rel_old */
4801 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
4803 + goto out_rel_both;
4805 + /* drop reference on new_dentry */
4807 + new_dentry = old_path->dentry;
4809 + vxdprintk(VXD_CBIT(misc, 2),
4810 + "do_path_lookup(redo): %p [" VS_Q("%.*s") ":%d]",
4812 + new_dentry->d_name.len, new_dentry->d_name.name,
4813 + new_dentry->d_name.len);
4817 + path_put(new_path);
4819 + path_put(old_path);
4825 + new_dentry = ERR_PTR(ret);
4827 + vxdprintk(VXD_CBIT(misc, 3),
4828 + "cow_break_link returning with %p", new_dentry);
4829 + return new_dentry;
4834 +int vx_info_mnt_namespace(struct mnt_namespace *ns, char *buffer)
4837 + struct vfsmount *vmnt;
4838 + char *pstr, *root;
4841 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
4845 + vmnt = &ns->root->mnt;
4847 + path.dentry = vmnt->mnt_root;
4848 + root = d_path(&path, pstr, PATH_MAX - 2);
4849 + length = sprintf(buffer + length,
4850 + "Namespace:\t%p [#%u]\n"
4851 + "RootPath:\t%s\n",
4852 + ns, atomic_read(&ns->count),
4858 /* get the link contents into pagecache */
4859 static char *page_getlink(struct dentry * dentry, struct page **ppage)
4861 @@ -3998,3 +4409,4 @@ EXPORT_SYMBOL(vfs_symlink);
4862 EXPORT_SYMBOL(vfs_unlink);
4863 EXPORT_SYMBOL(dentry_unhash);
4864 EXPORT_SYMBOL(generic_readlink);
4865 +EXPORT_SYMBOL(vx_info_mnt_namespace);
4866 diff -NurpP --minimal linux-3.6.9/fs/namespace.c linux-3.6.9-vs2.3.4.4/fs/namespace.c
4867 --- linux-3.6.9/fs/namespace.c 2012-10-04 15:27:40.000000000 +0200
4868 +++ linux-3.6.9-vs2.3.4.4/fs/namespace.c 2012-12-08 01:10:23.000000000 +0100
4870 #include <linux/fs_struct.h> /* get_fs_root et.al. */
4871 #include <linux/fsnotify.h> /* fsnotify_vfsmount_delete */
4872 #include <linux/uaccess.h>
4873 +#include <linux/vs_base.h>
4874 +#include <linux/vs_context.h>
4875 +#include <linux/vs_tag.h>
4876 +#include <linux/vserver/space.h>
4877 +#include <linux/vserver/global.h>
4879 #include "internal.h"
4881 @@ -749,6 +754,10 @@ vfs_kern_mount(struct file_system_type *
4883 return ERR_PTR(-ENODEV);
4885 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
4886 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
4887 + return ERR_PTR(-EPERM);
4889 mnt = alloc_vfsmnt(name);
4891 return ERR_PTR(-ENOMEM);
4892 @@ -801,6 +810,7 @@ static struct mount *clone_mnt(struct mo
4893 mnt->mnt.mnt_root = dget(root);
4894 mnt->mnt_mountpoint = mnt->mnt.mnt_root;
4895 mnt->mnt_parent = mnt;
4896 + mnt->mnt_tag = old->mnt_tag;
4897 br_write_lock(&vfsmount_lock);
4898 list_add_tail(&mnt->mnt_instance, &sb->s_mounts);
4899 br_write_unlock(&vfsmount_lock);
4900 @@ -1266,7 +1276,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
4904 - if (!capable(CAP_SYS_ADMIN))
4905 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
4908 retval = do_umount(mnt, flags);
4909 @@ -1292,7 +1302,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
4911 static int mount_is_safe(struct path *path)
4913 - if (capable(CAP_SYS_ADMIN))
4914 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
4918 @@ -1610,7 +1620,7 @@ static int do_change_type(struct path *p
4922 - if (!capable(CAP_SYS_ADMIN))
4923 + if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
4926 if (path->dentry != path->mnt->mnt_root)
4927 @@ -1626,6 +1636,7 @@ static int do_change_type(struct path *p
4931 + // mnt->mnt_flags = mnt_flags;
4933 br_write_lock(&vfsmount_lock);
4934 for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL))
4935 @@ -1641,12 +1652,14 @@ static int do_change_type(struct path *p
4936 * do loopback mount.
4938 static int do_loopback(struct path *path, char *old_name,
4940 + vs_tag_t tag, unsigned long flags, int mnt_flags)
4942 LIST_HEAD(umount_list);
4943 struct path old_path;
4944 struct mount *mnt = NULL, *old;
4945 int err = mount_is_safe(path);
4946 + int recurse = flags & MS_REC;
4950 if (!old_name || !*old_name)
4951 @@ -1715,13 +1728,13 @@ static int change_mount_flags(struct vfs
4952 * on it - tough luck.
4954 static int do_remount(struct path *path, int flags, int mnt_flags,
4956 + void *data, xid_t xid)
4959 struct super_block *sb = path->mnt->mnt_sb;
4960 struct mount *mnt = real_mount(path->mnt);
4962 - if (!capable(CAP_SYS_ADMIN))
4963 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
4966 if (!check_mnt(mnt))
4967 @@ -1770,7 +1783,7 @@ static int do_move_mount(struct path *pa
4971 - if (!capable(CAP_SYS_ADMIN))
4972 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
4974 if (!old_name || !*old_name)
4976 @@ -1927,7 +1940,7 @@ static int do_new_mount(struct path *pat
4979 /* we need capabilities... */
4980 - if (!capable(CAP_SYS_ADMIN))
4981 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
4984 mnt = do_kern_mount(type, flags, name, data);
4985 @@ -2197,6 +2210,7 @@ long do_mount(char *dev_name, char *dir_
4992 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
4993 @@ -2224,6 +2238,12 @@ long do_mount(char *dev_name, char *dir_
4994 if (!(flags & MS_NOATIME))
4995 mnt_flags |= MNT_RELATIME;
4997 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
4998 + /* FIXME: bind and re-mounts get the tag flag? */
4999 + if (flags & (MS_BIND|MS_REMOUNT))
5000 + flags |= MS_TAGID;
5003 /* Separate the per-mountpoint flags */
5004 if (flags & MS_NOSUID)
5005 mnt_flags |= MNT_NOSUID;
5006 @@ -2240,15 +2260,17 @@ long do_mount(char *dev_name, char *dir_
5007 if (flags & MS_RDONLY)
5008 mnt_flags |= MNT_READONLY;
5010 + if (!capable(CAP_SYS_ADMIN))
5011 + mnt_flags |= MNT_NODEV;
5012 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN |
5013 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
5016 if (flags & MS_REMOUNT)
5017 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
5020 else if (flags & MS_BIND)
5021 - retval = do_loopback(&path, dev_name, flags & MS_REC);
5022 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
5023 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
5024 retval = do_change_type(&path, flags);
5025 else if (flags & MS_MOVE)
5026 @@ -2329,6 +2351,7 @@ static struct mnt_namespace *dup_mnt_ns(
5027 q = next_mnt(q, new);
5029 up_write(&namespace_sem);
5030 + atomic_inc(&vs_global_mnt_ns);
5034 @@ -2524,9 +2547,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
5036 new_mnt = real_mount(new.mnt);
5037 root_mnt = real_mount(root.mnt);
5038 - if (IS_MNT_SHARED(real_mount(old.mnt)) ||
5039 + if ((IS_MNT_SHARED(real_mount(old.mnt)) ||
5040 IS_MNT_SHARED(new_mnt->mnt_parent) ||
5041 - IS_MNT_SHARED(root_mnt->mnt_parent))
5042 + IS_MNT_SHARED(root_mnt->mnt_parent)) &&
5043 + !vx_flags(VXF_STATE_SETUP, 0))
5045 if (!check_mnt(root_mnt) || !check_mnt(new_mnt))
5047 @@ -2647,6 +2671,7 @@ void put_mnt_ns(struct mnt_namespace *ns
5048 br_write_unlock(&vfsmount_lock);
5049 up_write(&namespace_sem);
5050 release_mounts(&umount_list);
5051 + atomic_dec(&vs_global_mnt_ns);
5055 diff -NurpP --minimal linux-3.6.9/fs/nfs/client.c linux-3.6.9-vs2.3.4.4/fs/nfs/client.c
5056 --- linux-3.6.9/fs/nfs/client.c 2012-12-08 01:34:14.000000000 +0100
5057 +++ linux-3.6.9-vs2.3.4.4/fs/nfs/client.c 2012-11-06 18:43:41.000000000 +0100
5058 @@ -692,6 +692,9 @@ int nfs_init_server_rpcclient(struct nfs
5059 if (server->flags & NFS_MOUNT_SOFT)
5060 server->client->cl_softrtry = 1;
5062 + server->client->cl_tag = 0;
5063 + if (server->flags & NFS_MOUNT_TAGGED)
5064 + server->client->cl_tag = 1;
5067 EXPORT_SYMBOL_GPL(nfs_init_server_rpcclient);
5068 @@ -869,6 +872,10 @@ static void nfs_server_set_fsinfo(struct
5069 server->acdirmin = server->acdirmax = 0;
5072 + /* FIXME: needs fsinfo
5073 + if (server->flags & NFS_MOUNT_TAGGED)
5074 + sb->s_flags |= MS_TAGGED; */
5076 server->maxfilesize = fsinfo->maxfilesize;
5078 server->time_delta = fsinfo->time_delta;
5079 diff -NurpP --minimal linux-3.6.9/fs/nfs/dir.c linux-3.6.9-vs2.3.4.4/fs/nfs/dir.c
5080 --- linux-3.6.9/fs/nfs/dir.c 2012-10-04 15:27:40.000000000 +0200
5081 +++ linux-3.6.9-vs2.3.4.4/fs/nfs/dir.c 2012-10-04 18:47:00.000000000 +0200
5083 #include <linux/sched.h>
5084 #include <linux/kmemleak.h>
5085 #include <linux/xattr.h>
5086 +#include <linux/vs_tag.h>
5088 #include "delegation.h"
5090 @@ -1251,6 +1252,7 @@ struct dentry *nfs_lookup(struct inode *
5091 /* Success: notify readdir to use READDIRPLUS */
5092 nfs_advise_use_readdirplus(dir);
5094 + dx_propagate_tag(nd, inode);
5096 res = d_materialise_unique(dentry, inode);
5098 diff -NurpP --minimal linux-3.6.9/fs/nfs/inode.c linux-3.6.9-vs2.3.4.4/fs/nfs/inode.c
5099 --- linux-3.6.9/fs/nfs/inode.c 2012-10-04 15:27:40.000000000 +0200
5100 +++ linux-3.6.9-vs2.3.4.4/fs/nfs/inode.c 2012-10-04 18:47:00.000000000 +0200
5102 #include <linux/compat.h>
5103 #include <linux/freezer.h>
5104 #include <linux/crc32.h>
5105 +#include <linux/vs_tag.h>
5107 #include <asm/uaccess.h>
5109 @@ -279,6 +280,8 @@ nfs_fhget(struct super_block *sb, struct
5110 if (inode->i_state & I_NEW) {
5111 struct nfs_inode *nfsi = NFS_I(inode);
5112 unsigned long now = jiffies;
5116 /* We set i_ino for the few things that still rely on it,
5117 * such as stat(2) */
5118 @@ -323,8 +326,8 @@ nfs_fhget(struct super_block *sb, struct
5119 inode->i_version = 0;
5122 - inode->i_uid = -2;
5123 - inode->i_gid = -2;
5126 inode->i_blocks = 0;
5127 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
5129 @@ -358,11 +361,11 @@ nfs_fhget(struct super_block *sb, struct
5130 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
5131 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5132 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
5133 - inode->i_uid = fattr->uid;
5135 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
5136 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5137 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
5138 - inode->i_gid = fattr->gid;
5140 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
5141 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5142 if (fattr->valid & NFS_ATTR_FATTR_BLOCKS_USED)
5143 @@ -373,6 +376,11 @@ nfs_fhget(struct super_block *sb, struct
5145 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
5147 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5148 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5149 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
5150 + /* maybe fattr->xid someday */
5152 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
5153 nfsi->attrtimeo_timestamp = now;
5154 nfsi->access_cache = RB_ROOT;
5155 @@ -494,6 +502,8 @@ void nfs_setattr_update_inode(struct ino
5156 inode->i_uid = attr->ia_uid;
5157 if ((attr->ia_valid & ATTR_GID) != 0)
5158 inode->i_gid = attr->ia_gid;
5159 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5160 + inode->i_tag = attr->ia_tag;
5161 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5162 spin_unlock(&inode->i_lock);
5164 @@ -965,6 +975,9 @@ static int nfs_check_inode_attributes(st
5165 struct nfs_inode *nfsi = NFS_I(inode);
5166 loff_t cur_size, new_isize;
5167 unsigned long invalid = 0;
5173 if (nfs_have_delegated_attributes(inode))
5174 @@ -990,13 +1003,18 @@ static int nfs_check_inode_attributes(st
5175 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5178 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5179 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5180 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5182 /* Have any file permissions changed? */
5183 if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
5184 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5185 - if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
5186 + if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
5187 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5188 - if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
5189 + if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
5190 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5191 + /* maybe check for tag too? */
5193 /* Has the link count changed? */
5194 if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
5195 @@ -1300,6 +1318,9 @@ static int nfs_update_inode(struct inode
5196 unsigned long invalid = 0;
5197 unsigned long now = jiffies;
5198 unsigned long save_cache_validity;
5203 dfprintk(VFS, "NFS: %s(%s/%ld fh_crc=0x%08x ct=%d info=0x%x)\n",
5204 __func__, inode->i_sb->s_id, inode->i_ino,
5205 @@ -1401,6 +1422,9 @@ static int nfs_update_inode(struct inode
5206 | NFS_INO_REVAL_PAGECACHE
5207 | NFS_INO_REVAL_FORCED);
5209 + uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
5210 + gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
5211 + tag = inode->i_tag;
5213 if (fattr->valid & NFS_ATTR_FATTR_ATIME)
5214 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5215 @@ -1422,9 +1446,9 @@ static int nfs_update_inode(struct inode
5216 | NFS_INO_REVAL_FORCED);
5218 if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
5219 - if (inode->i_uid != fattr->uid) {
5220 + if (uid != fattr->uid) {
5221 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5222 - inode->i_uid = fattr->uid;
5225 } else if (server->caps & NFS_CAP_OWNER)
5226 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5227 @@ -1433,9 +1457,9 @@ static int nfs_update_inode(struct inode
5228 | NFS_INO_REVAL_FORCED);
5230 if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
5231 - if (inode->i_gid != fattr->gid) {
5232 + if (gid != fattr->gid) {
5233 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5234 - inode->i_gid = fattr->gid;
5237 } else if (server->caps & NFS_CAP_OWNER_GROUP)
5238 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5239 @@ -1443,6 +1467,10 @@ static int nfs_update_inode(struct inode
5240 | NFS_INO_INVALID_ACL
5241 | NFS_INO_REVAL_FORCED);
5243 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5244 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5245 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, tag);
5247 if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
5248 if (inode->i_nlink != fattr->nlink) {
5249 invalid |= NFS_INO_INVALID_ATTR;
5250 diff -NurpP --minimal linux-3.6.9/fs/nfs/nfs3xdr.c linux-3.6.9-vs2.3.4.4/fs/nfs/nfs3xdr.c
5251 --- linux-3.6.9/fs/nfs/nfs3xdr.c 2012-10-04 15:27:40.000000000 +0200
5252 +++ linux-3.6.9-vs2.3.4.4/fs/nfs/nfs3xdr.c 2012-10-04 18:47:00.000000000 +0200
5254 #include <linux/nfs3.h>
5255 #include <linux/nfs_fs.h>
5256 #include <linux/nfsacl.h>
5257 +#include <linux/vs_tag.h>
5258 #include "internal.h"
5260 #define NFSDBG_FACILITY NFSDBG_XDR
5261 @@ -560,7 +561,8 @@ static __be32 *xdr_decode_nfstime3(__be3
5265 -static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr)
5266 +static void encode_sattr3(struct xdr_stream *xdr,
5267 + const struct iattr *attr, int tag)
5271 @@ -592,15 +594,19 @@ static void encode_sattr3(struct xdr_str
5275 - if (attr->ia_valid & ATTR_UID) {
5276 + if (attr->ia_valid & ATTR_UID ||
5277 + (tag && (attr->ia_valid & ATTR_TAG))) {
5279 - *p++ = cpu_to_be32(attr->ia_uid);
5280 + *p++ = cpu_to_be32(TAGINO_UID(tag,
5281 + attr->ia_uid, attr->ia_tag));
5285 - if (attr->ia_valid & ATTR_GID) {
5286 + if (attr->ia_valid & ATTR_GID ||
5287 + (tag && (attr->ia_valid & ATTR_TAG))) {
5289 - *p++ = cpu_to_be32(attr->ia_gid);
5290 + *p++ = cpu_to_be32(TAGINO_GID(tag,
5291 + attr->ia_gid, attr->ia_tag));
5295 @@ -879,7 +885,7 @@ static void nfs3_xdr_enc_setattr3args(st
5296 const struct nfs3_sattrargs *args)
5298 encode_nfs_fh3(xdr, args->fh);
5299 - encode_sattr3(xdr, args->sattr);
5300 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5301 encode_sattrguard3(xdr, args);
5304 @@ -1029,13 +1035,13 @@ static void nfs3_xdr_enc_write3args(stru
5307 static void encode_createhow3(struct xdr_stream *xdr,
5308 - const struct nfs3_createargs *args)
5309 + const struct nfs3_createargs *args, int tag)
5311 encode_uint32(xdr, args->createmode);
5312 switch (args->createmode) {
5313 case NFS3_CREATE_UNCHECKED:
5314 case NFS3_CREATE_GUARDED:
5315 - encode_sattr3(xdr, args->sattr);
5316 + encode_sattr3(xdr, args->sattr, tag);
5318 case NFS3_CREATE_EXCLUSIVE:
5319 encode_createverf3(xdr, args->verifier);
5320 @@ -1050,7 +1056,7 @@ static void nfs3_xdr_enc_create3args(str
5321 const struct nfs3_createargs *args)
5323 encode_diropargs3(xdr, args->fh, args->name, args->len);
5324 - encode_createhow3(xdr, args);
5325 + encode_createhow3(xdr, args, req->rq_task->tk_client->cl_tag);
5329 @@ -1066,7 +1072,7 @@ static void nfs3_xdr_enc_mkdir3args(stru
5330 const struct nfs3_mkdirargs *args)
5332 encode_diropargs3(xdr, args->fh, args->name, args->len);
5333 - encode_sattr3(xdr, args->sattr);
5334 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5338 @@ -1083,9 +1089,9 @@ static void nfs3_xdr_enc_mkdir3args(stru
5341 static void encode_symlinkdata3(struct xdr_stream *xdr,
5342 - const struct nfs3_symlinkargs *args)
5343 + const struct nfs3_symlinkargs *args, int tag)
5345 - encode_sattr3(xdr, args->sattr);
5346 + encode_sattr3(xdr, args->sattr, tag);
5347 encode_nfspath3(xdr, args->pages, args->pathlen);
5350 @@ -1094,7 +1100,7 @@ static void nfs3_xdr_enc_symlink3args(st
5351 const struct nfs3_symlinkargs *args)
5353 encode_diropargs3(xdr, args->fromfh, args->fromname, args->fromlen);
5354 - encode_symlinkdata3(xdr, args);
5355 + encode_symlinkdata3(xdr, args, req->rq_task->tk_client->cl_tag);
5359 @@ -1122,24 +1128,24 @@ static void nfs3_xdr_enc_symlink3args(st
5362 static void encode_devicedata3(struct xdr_stream *xdr,
5363 - const struct nfs3_mknodargs *args)
5364 + const struct nfs3_mknodargs *args, int tag)
5366 - encode_sattr3(xdr, args->sattr);
5367 + encode_sattr3(xdr, args->sattr, tag);
5368 encode_specdata3(xdr, args->rdev);
5371 static void encode_mknoddata3(struct xdr_stream *xdr,
5372 - const struct nfs3_mknodargs *args)
5373 + const struct nfs3_mknodargs *args, int tag)
5375 encode_ftype3(xdr, args->type);
5376 switch (args->type) {
5379 - encode_devicedata3(xdr, args);
5380 + encode_devicedata3(xdr, args, tag);
5384 - encode_sattr3(xdr, args->sattr);
5385 + encode_sattr3(xdr, args->sattr, tag);
5389 @@ -1154,7 +1160,7 @@ static void nfs3_xdr_enc_mknod3args(stru
5390 const struct nfs3_mknodargs *args)
5392 encode_diropargs3(xdr, args->fh, args->name, args->len);
5393 - encode_mknoddata3(xdr, args);
5394 + encode_mknoddata3(xdr, args, req->rq_task->tk_client->cl_tag);
5398 diff -NurpP --minimal linux-3.6.9/fs/nfs/super.c linux-3.6.9-vs2.3.4.4/fs/nfs/super.c
5399 --- linux-3.6.9/fs/nfs/super.c 2012-12-08 01:34:14.000000000 +0100
5400 +++ linux-3.6.9-vs2.3.4.4/fs/nfs/super.c 2012-12-08 01:36:33.000000000 +0100
5402 #include <linux/parser.h>
5403 #include <linux/nsproxy.h>
5404 #include <linux/rcupdate.h>
5405 +#include <linux/vs_tag.h>
5407 #include <asm/uaccess.h>
5409 @@ -88,6 +89,7 @@ enum {
5410 Opt_sharecache, Opt_nosharecache,
5411 Opt_resvport, Opt_noresvport,
5412 Opt_fscache, Opt_nofscache,
5413 + Opt_tag, Opt_notag,
5415 /* Mount options that take integer arguments */
5417 @@ -100,6 +102,7 @@ enum {
5423 /* Mount options that take string arguments */
5425 @@ -182,6 +185,10 @@ static const match_table_t nfs_mount_opt
5426 /* The following needs to be listed after all other options */
5427 { Opt_nfsvers, "v%s" },
5429 + { Opt_tag, "tag" },
5430 + { Opt_notag, "notag" },
5431 + { Opt_tagid, "tagid=%u" },
5436 @@ -626,6 +633,7 @@ static void nfs_show_mount_options(struc
5437 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
5438 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
5439 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
5440 + { NFS_MOUNT_TAGGED, ",tag", "" },
5443 const struct proc_nfs_info *nfs_infop;
5444 @@ -1243,6 +1251,14 @@ static int nfs_parse_mount_options(char
5445 kfree(mnt->fscache_uniq);
5446 mnt->fscache_uniq = NULL;
5448 +#ifndef CONFIG_TAGGING_NONE
5450 + mnt->flags |= NFS_MOUNT_TAGGED;
5453 + mnt->flags &= ~NFS_MOUNT_TAGGED;
5458 * options that take numeric values
5459 @@ -1329,6 +1345,12 @@ static int nfs_parse_mount_options(char
5460 goto out_invalid_value;
5461 mnt->minorversion = option;
5463 +#ifdef CONFIG_PROPAGATE
5466 + nfs_data.flags |= NFS_MOUNT_TAGGED;
5471 * options that take text values
5472 diff -NurpP --minimal linux-3.6.9/fs/nfsd/auth.c linux-3.6.9-vs2.3.4.4/fs/nfsd/auth.c
5473 --- linux-3.6.9/fs/nfsd/auth.c 2012-07-22 23:39:41.000000000 +0200
5474 +++ linux-3.6.9-vs2.3.4.4/fs/nfsd/auth.c 2012-10-04 18:47:00.000000000 +0200
5477 #include <linux/sched.h>
5478 #include <linux/user_namespace.h>
5479 +#include <linux/vs_tag.h>
5483 @@ -37,6 +38,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
5485 new->fsuid = rqstp->rq_cred.cr_uid;
5486 new->fsgid = rqstp->rq_cred.cr_gid;
5487 + /* FIXME: this desperately needs a tag :)
5488 + new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
5491 rqgi = rqstp->rq_cred.cr_group_info;
5493 diff -NurpP --minimal linux-3.6.9/fs/nfsd/nfs3xdr.c linux-3.6.9-vs2.3.4.4/fs/nfsd/nfs3xdr.c
5494 --- linux-3.6.9/fs/nfsd/nfs3xdr.c 2012-05-21 18:07:26.000000000 +0200
5495 +++ linux-3.6.9-vs2.3.4.4/fs/nfsd/nfs3xdr.c 2012-10-04 18:47:00.000000000 +0200
5499 #include <linux/namei.h>
5500 +#include <linux/vs_tag.h>
5504 @@ -95,6 +96,8 @@ static __be32 *
5505 decode_sattr3(__be32 *p, struct iattr *iap)
5513 @@ -104,12 +107,15 @@ decode_sattr3(__be32 *p, struct iattr *i
5516 iap->ia_valid |= ATTR_UID;
5517 - iap->ia_uid = ntohl(*p++);
5518 + uid = ntohl(*p++);
5521 iap->ia_valid |= ATTR_GID;
5522 - iap->ia_gid = ntohl(*p++);
5523 + gid = ntohl(*p++);
5525 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
5526 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
5527 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
5531 @@ -165,8 +171,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
5532 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
5533 *p++ = htonl((u32) stat->mode);
5534 *p++ = htonl((u32) stat->nlink);
5535 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
5536 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
5537 + *p++ = htonl((u32) nfsd_ruid(rqstp,
5538 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5539 + stat->uid, stat->tag)));
5540 + *p++ = htonl((u32) nfsd_rgid(rqstp,
5541 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5542 + stat->gid, stat->tag)));
5543 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
5544 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
5546 diff -NurpP --minimal linux-3.6.9/fs/nfsd/nfs4xdr.c linux-3.6.9-vs2.3.4.4/fs/nfsd/nfs4xdr.c
5547 --- linux-3.6.9/fs/nfsd/nfs4xdr.c 2012-10-04 15:27:40.000000000 +0200
5548 +++ linux-3.6.9-vs2.3.4.4/fs/nfsd/nfs4xdr.c 2012-10-04 18:47:00.000000000 +0200
5550 #include <linux/utsname.h>
5551 #include <linux/pagemap.h>
5552 #include <linux/sunrpc/svcauth_gss.h>
5553 +#include <linux/vs_tag.h>
5557 @@ -2351,14 +2352,18 @@ out_acl:
5558 WRITE32(stat.nlink);
5560 if (bmval1 & FATTR4_WORD1_OWNER) {
5561 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
5562 + status = nfsd4_encode_user(rqstp,
5563 + TAGINO_UID(DX_TAG(dentry->d_inode),
5564 + stat.uid, stat.tag), &p, &buflen);
5565 if (status == nfserr_resource)
5570 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
5571 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
5572 + status = nfsd4_encode_group(rqstp,
5573 + TAGINO_GID(DX_TAG(dentry->d_inode),
5574 + stat.gid, stat.tag), &p, &buflen);
5575 if (status == nfserr_resource)
5578 diff -NurpP --minimal linux-3.6.9/fs/nfsd/nfsxdr.c linux-3.6.9-vs2.3.4.4/fs/nfsd/nfsxdr.c
5579 --- linux-3.6.9/fs/nfsd/nfsxdr.c 2011-05-22 16:17:53.000000000 +0200
5580 +++ linux-3.6.9-vs2.3.4.4/fs/nfsd/nfsxdr.c 2012-10-04 18:47:00.000000000 +0200
5585 +#include <linux/vs_tag.h>
5587 #define NFSDDBG_FACILITY NFSDDBG_XDR
5589 @@ -88,6 +89,8 @@ static __be32 *
5590 decode_sattr(__be32 *p, struct iattr *iap)
5598 @@ -101,12 +104,15 @@ decode_sattr(__be32 *p, struct iattr *ia
5600 if ((tmp = ntohl(*p++)) != (u32)-1) {
5601 iap->ia_valid |= ATTR_UID;
5602 - iap->ia_uid = tmp;
5605 if ((tmp = ntohl(*p++)) != (u32)-1) {
5606 iap->ia_valid |= ATTR_GID;
5607 - iap->ia_gid = tmp;
5610 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
5611 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
5612 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
5613 if ((tmp = ntohl(*p++)) != (u32)-1) {
5614 iap->ia_valid |= ATTR_SIZE;
5616 @@ -151,8 +157,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
5617 *p++ = htonl(nfs_ftypes[type >> 12]);
5618 *p++ = htonl((u32) stat->mode);
5619 *p++ = htonl((u32) stat->nlink);
5620 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
5621 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
5622 + *p++ = htonl((u32) nfsd_ruid(rqstp,
5623 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
5624 + *p++ = htonl((u32) nfsd_rgid(rqstp,
5625 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
5627 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
5628 *p++ = htonl(NFS_MAXPATHLEN);
5629 diff -NurpP --minimal linux-3.6.9/fs/ocfs2/dlmglue.c linux-3.6.9-vs2.3.4.4/fs/ocfs2/dlmglue.c
5630 --- linux-3.6.9/fs/ocfs2/dlmglue.c 2012-07-22 23:39:41.000000000 +0200
5631 +++ linux-3.6.9-vs2.3.4.4/fs/ocfs2/dlmglue.c 2012-10-04 18:47:00.000000000 +0200
5632 @@ -2047,6 +2047,7 @@ static void __ocfs2_stuff_meta_lvb(struc
5633 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
5634 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
5635 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
5636 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
5637 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
5638 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
5639 lvb->lvb_iatime_packed =
5640 @@ -2097,6 +2098,7 @@ static void ocfs2_refresh_inode_from_lvb
5642 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
5643 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
5644 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
5645 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
5646 set_nlink(inode, be16_to_cpu(lvb->lvb_inlink));
5647 ocfs2_unpack_timespec(&inode->i_atime,
5648 diff -NurpP --minimal linux-3.6.9/fs/ocfs2/dlmglue.h linux-3.6.9-vs2.3.4.4/fs/ocfs2/dlmglue.h
5649 --- linux-3.6.9/fs/ocfs2/dlmglue.h 2010-10-21 13:07:50.000000000 +0200
5650 +++ linux-3.6.9-vs2.3.4.4/fs/ocfs2/dlmglue.h 2012-10-04 18:47:00.000000000 +0200
5651 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
5654 __be32 lvb_igeneration;
5655 - __be32 lvb_reserved2;
5657 + __be16 lvb_reserved2;
5660 #define OCFS2_QINFO_LVB_VERSION 1
5661 diff -NurpP --minimal linux-3.6.9/fs/ocfs2/file.c linux-3.6.9-vs2.3.4.4/fs/ocfs2/file.c
5662 --- linux-3.6.9/fs/ocfs2/file.c 2012-10-04 15:27:41.000000000 +0200
5663 +++ linux-3.6.9-vs2.3.4.4/fs/ocfs2/file.c 2012-10-04 18:47:00.000000000 +0200
5664 @@ -1123,7 +1123,7 @@ int ocfs2_setattr(struct dentry *dentry,
5665 attr->ia_valid &= ~ATTR_SIZE;
5667 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
5668 - | ATTR_GID | ATTR_UID | ATTR_MODE)
5669 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
5670 if (!(attr->ia_valid & OCFS2_VALID_ATTRS))
5673 diff -NurpP --minimal linux-3.6.9/fs/ocfs2/inode.c linux-3.6.9-vs2.3.4.4/fs/ocfs2/inode.c
5674 --- linux-3.6.9/fs/ocfs2/inode.c 2012-07-22 23:39:41.000000000 +0200
5675 +++ linux-3.6.9-vs2.3.4.4/fs/ocfs2/inode.c 2012-10-04 18:47:00.000000000 +0200
5677 #include <linux/highmem.h>
5678 #include <linux/pagemap.h>
5679 #include <linux/quotaops.h>
5680 +#include <linux/vs_tag.h>
5682 #include <asm/byteorder.h>
5684 @@ -78,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode
5686 unsigned int flags = OCFS2_I(inode)->ip_attr;
5688 - inode->i_flags &= ~(S_IMMUTABLE |
5689 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5690 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5692 if (flags & OCFS2_IMMUTABLE_FL)
5693 inode->i_flags |= S_IMMUTABLE;
5694 + if (flags & OCFS2_IXUNLINK_FL)
5695 + inode->i_flags |= S_IXUNLINK;
5697 if (flags & OCFS2_SYNC_FL)
5698 inode->i_flags |= S_SYNC;
5699 @@ -92,25 +95,44 @@ void ocfs2_set_inode_flags(struct inode
5700 inode->i_flags |= S_NOATIME;
5701 if (flags & OCFS2_DIRSYNC_FL)
5702 inode->i_flags |= S_DIRSYNC;
5704 + inode->i_vflags &= ~(V_BARRIER | V_COW);
5706 + if (flags & OCFS2_BARRIER_FL)
5707 + inode->i_vflags |= V_BARRIER;
5708 + if (flags & OCFS2_COW_FL)
5709 + inode->i_vflags |= V_COW;
5712 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
5713 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
5715 unsigned int flags = oi->vfs_inode.i_flags;
5716 + unsigned int vflags = oi->vfs_inode.i_vflags;
5718 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
5719 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
5720 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
5721 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
5723 + if (flags & S_IMMUTABLE)
5724 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
5725 + if (flags & S_IXUNLINK)
5726 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
5728 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
5729 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
5731 oi->ip_attr |= OCFS2_SYNC_FL;
5732 if (flags & S_APPEND)
5733 oi->ip_attr |= OCFS2_APPEND_FL;
5734 - if (flags & S_IMMUTABLE)
5735 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
5736 if (flags & S_NOATIME)
5737 oi->ip_attr |= OCFS2_NOATIME_FL;
5738 if (flags & S_DIRSYNC)
5739 oi->ip_attr |= OCFS2_DIRSYNC_FL;
5741 + if (vflags & V_BARRIER)
5742 + oi->ip_attr |= OCFS2_BARRIER_FL;
5743 + if (vflags & V_COW)
5744 + oi->ip_attr |= OCFS2_COW_FL;
5747 struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
5748 @@ -241,6 +263,8 @@ void ocfs2_populate_inode(struct inode *
5749 struct super_block *sb;
5750 struct ocfs2_super *osb;
5757 @@ -269,8 +293,12 @@ void ocfs2_populate_inode(struct inode *
5758 inode->i_generation = le32_to_cpu(fe->i_generation);
5759 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
5760 inode->i_mode = le16_to_cpu(fe->i_mode);
5761 - inode->i_uid = le32_to_cpu(fe->i_uid);
5762 - inode->i_gid = le32_to_cpu(fe->i_gid);
5763 + uid = le32_to_cpu(fe->i_uid);
5764 + gid = le32_to_cpu(fe->i_gid);
5765 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5766 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5767 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
5768 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
5770 /* Fast symlinks will have i_size but no allocated clusters. */
5771 if (S_ISLNK(inode->i_mode) && !fe->i_clusters) {
5772 diff -NurpP --minimal linux-3.6.9/fs/ocfs2/inode.h linux-3.6.9-vs2.3.4.4/fs/ocfs2/inode.h
5773 --- linux-3.6.9/fs/ocfs2/inode.h 2012-01-09 16:14:55.000000000 +0100
5774 +++ linux-3.6.9-vs2.3.4.4/fs/ocfs2/inode.h 2012-10-04 18:47:00.000000000 +0200
5775 @@ -154,6 +154,7 @@ struct buffer_head *ocfs2_bread(struct i
5777 void ocfs2_set_inode_flags(struct inode *inode);
5778 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
5779 +int ocfs2_sync_flags(struct inode *inode, int, int);
5781 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
5783 diff -NurpP --minimal linux-3.6.9/fs/ocfs2/ioctl.c linux-3.6.9-vs2.3.4.4/fs/ocfs2/ioctl.c
5784 --- linux-3.6.9/fs/ocfs2/ioctl.c 2012-10-04 15:27:41.000000000 +0200
5785 +++ linux-3.6.9-vs2.3.4.4/fs/ocfs2/ioctl.c 2012-10-04 18:47:00.000000000 +0200
5786 @@ -76,7 +76,41 @@ static int ocfs2_get_inode_attr(struct i
5790 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
5791 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
5793 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
5794 + struct buffer_head *bh = NULL;
5795 + handle_t *handle = NULL;
5798 + status = ocfs2_inode_lock(inode, &bh, 1);
5800 + mlog_errno(status);
5803 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
5804 + if (IS_ERR(handle)) {
5805 + status = PTR_ERR(handle);
5806 + mlog_errno(status);
5810 + inode->i_flags = flags;
5811 + inode->i_vflags = vflags;
5812 + ocfs2_get_inode_flags(OCFS2_I(inode));
5814 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
5816 + mlog_errno(status);
5818 + ocfs2_commit_trans(osb, handle);
5820 + ocfs2_inode_unlock(inode, 1);
5825 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
5828 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
5829 @@ -101,6 +135,11 @@ static int ocfs2_set_inode_attr(struct i
5830 if (!S_ISDIR(inode->i_mode))
5831 flags &= ~OCFS2_DIRSYNC_FL;
5833 + if (IS_BARRIER(inode)) {
5834 + vxwprintk_task(1, "messing with the barrier.");
5838 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
5839 if (IS_ERR(handle)) {
5840 status = PTR_ERR(handle);
5841 @@ -879,6 +918,7 @@ bail:
5846 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5848 struct inode *inode = filp->f_path.dentry->d_inode;
5849 diff -NurpP --minimal linux-3.6.9/fs/ocfs2/namei.c linux-3.6.9-vs2.3.4.4/fs/ocfs2/namei.c
5850 --- linux-3.6.9/fs/ocfs2/namei.c 2012-10-04 15:27:41.000000000 +0200
5851 +++ linux-3.6.9-vs2.3.4.4/fs/ocfs2/namei.c 2012-10-04 18:47:00.000000000 +0200
5853 #include <linux/slab.h>
5854 #include <linux/highmem.h>
5855 #include <linux/quotaops.h>
5856 +#include <linux/vs_tag.h>
5858 #include <cluster/masklog.h>
5860 @@ -475,6 +476,7 @@ static int __ocfs2_mknod_locked(struct i
5861 struct ocfs2_dinode *fe = NULL;
5862 struct ocfs2_extent_list *fel;
5868 @@ -512,8 +514,11 @@ static int __ocfs2_mknod_locked(struct i
5869 fe->i_suballoc_loc = cpu_to_le64(suballoc_loc);
5870 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
5871 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
5872 - fe->i_uid = cpu_to_le32(inode->i_uid);
5873 - fe->i_gid = cpu_to_le32(inode->i_gid);
5875 + tag = dx_current_fstag(osb->sb);
5876 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
5877 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
5878 + inode->i_tag = tag;
5879 fe->i_mode = cpu_to_le16(inode->i_mode);
5880 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
5881 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
5882 diff -NurpP --minimal linux-3.6.9/fs/ocfs2/ocfs2.h linux-3.6.9-vs2.3.4.4/fs/ocfs2/ocfs2.h
5883 --- linux-3.6.9/fs/ocfs2/ocfs2.h 2012-01-09 16:14:55.000000000 +0100
5884 +++ linux-3.6.9-vs2.3.4.4/fs/ocfs2/ocfs2.h 2012-10-04 18:47:00.000000000 +0200
5885 @@ -272,6 +272,7 @@ enum ocfs2_mount_options
5887 OCFS2_MOUNT_HB_NONE = 1 << 13, /* No heartbeat */
5888 OCFS2_MOUNT_HB_GLOBAL = 1 << 14, /* Global heartbeat */
5889 + OCFS2_MOUNT_TAGGED = 1 << 15, /* use tagging */
5892 #define OCFS2_OSB_SOFT_RO 0x0001
5893 diff -NurpP --minimal linux-3.6.9/fs/ocfs2/ocfs2_fs.h linux-3.6.9-vs2.3.4.4/fs/ocfs2/ocfs2_fs.h
5894 --- linux-3.6.9/fs/ocfs2/ocfs2_fs.h 2011-05-22 16:17:53.000000000 +0200
5895 +++ linux-3.6.9-vs2.3.4.4/fs/ocfs2/ocfs2_fs.h 2012-10-04 18:47:00.000000000 +0200
5896 @@ -266,6 +266,11 @@
5897 #define OCFS2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
5898 #define OCFS2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
5900 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
5902 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
5903 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
5905 #define OCFS2_FL_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
5906 #define OCFS2_FL_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
5908 diff -NurpP --minimal linux-3.6.9/fs/ocfs2/super.c linux-3.6.9-vs2.3.4.4/fs/ocfs2/super.c
5909 --- linux-3.6.9/fs/ocfs2/super.c 2012-05-21 18:07:26.000000000 +0200
5910 +++ linux-3.6.9-vs2.3.4.4/fs/ocfs2/super.c 2012-10-04 18:47:00.000000000 +0200
5911 @@ -185,6 +185,7 @@ enum {
5915 + Opt_tag, Opt_notag, Opt_tagid,
5919 @@ -216,6 +217,9 @@ static const match_table_t tokens = {
5920 {Opt_coherency_full, "coherency=full"},
5921 {Opt_resv_level, "resv_level=%u"},
5922 {Opt_dir_resv_level, "dir_resv_level=%u"},
5924 + {Opt_notag, "notag"},
5925 + {Opt_tagid, "tagid=%u"},
5929 @@ -662,6 +666,13 @@ static int ocfs2_remount(struct super_bl
5933 + if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
5934 + (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
5936 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
5940 /* We're going to/from readonly mode. */
5941 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
5942 /* Disable quota accounting before remounting RO */
5943 @@ -1177,6 +1188,9 @@ static int ocfs2_fill_super(struct super
5945 ocfs2_complete_mount_recovery(osb);
5947 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
5948 + sb->s_flags |= MS_TAGGED;
5950 if (ocfs2_mount_local(osb))
5951 snprintf(nodestr, sizeof(nodestr), "local");
5953 @@ -1503,6 +1517,20 @@ static int ocfs2_parse_options(struct su
5954 option < OCFS2_MAX_RESV_LEVEL)
5955 mopt->dir_resv_level = option;
5957 +#ifndef CONFIG_TAGGING_NONE
5959 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
5962 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
5965 +#ifdef CONFIG_PROPAGATE
5968 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
5973 "Unrecognized mount option \"%s\" "
5974 diff -NurpP --minimal linux-3.6.9/fs/open.c linux-3.6.9-vs2.3.4.4/fs/open.c
5975 --- linux-3.6.9/fs/open.c 2012-10-04 15:27:41.000000000 +0200
5976 +++ linux-3.6.9-vs2.3.4.4/fs/open.c 2012-10-04 18:47:00.000000000 +0200
5978 #include <linux/fs_struct.h>
5979 #include <linux/ima.h>
5980 #include <linux/dnotify.h>
5981 +#include <linux/vs_base.h>
5982 +#include <linux/vs_limit.h>
5983 +#include <linux/vs_tag.h>
5984 +#include <linux/vs_cowbl.h>
5985 +#include <linux/vserver/dlimit.h>
5987 #include "internal.h"
5989 @@ -74,6 +79,12 @@ static long do_sys_truncate(const char _
5990 error = user_path(pathname, &path);
5994 +#ifdef CONFIG_VSERVER_COWBL
5995 + error = cow_check_and_break(&path);
5997 + goto dput_and_out;
5999 inode = path.dentry->d_inode;
6001 /* For directories it's -EISDIR, for other non-regulars - -EINVAL */
6002 @@ -495,6 +506,10 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
6004 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
6006 +#ifdef CONFIG_VSERVER_COWBL
6007 + error = cow_check_and_break(&path);
6010 error = chmod_common(&path, mode);
6013 @@ -522,13 +537,13 @@ static int chown_common(struct path *pat
6014 if (!uid_valid(uid))
6016 newattrs.ia_valid |= ATTR_UID;
6017 - newattrs.ia_uid = uid;
6018 + newattrs.ia_uid = dx_map_uid(user);
6020 if (group != (gid_t) -1) {
6021 if (!gid_valid(gid))
6023 newattrs.ia_valid |= ATTR_GID;
6024 - newattrs.ia_gid = gid;
6025 + newattrs.ia_gid = dx_map_gid(group);
6027 if (!S_ISDIR(inode->i_mode))
6028 newattrs.ia_valid |=
6029 @@ -561,6 +576,18 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
6030 error = mnt_want_write(path.mnt);
6033 +#ifdef CONFIG_VSERVER_COWBL
6034 + error = cow_check_and_break(&path);
6037 +#ifdef CONFIG_VSERVER_COWBL
6038 + error = cow_check_and_break(&path);
6041 +#ifdef CONFIG_VSERVER_COWBL
6042 + error = cow_check_and_break(&path);
6045 error = chown_common(&path, user, group);
6046 mnt_drop_write(path.mnt);
6048 @@ -809,6 +836,7 @@ static void __put_unused_fd(struct files
6049 __clear_open_fd(fd, fdt);
6050 if (fd < files->next_fd)
6051 files->next_fd = fd;
6052 + vx_openfd_dec(fd);
6055 void put_unused_fd(unsigned int fd)
6056 diff -NurpP --minimal linux-3.6.9/fs/proc/array.c linux-3.6.9-vs2.3.4.4/fs/proc/array.c
6057 --- linux-3.6.9/fs/proc/array.c 2012-07-22 23:39:42.000000000 +0200
6058 +++ linux-3.6.9-vs2.3.4.4/fs/proc/array.c 2012-10-04 18:47:00.000000000 +0200
6060 #include <linux/ptrace.h>
6061 #include <linux/tracehook.h>
6062 #include <linux/user_namespace.h>
6063 +#include <linux/vs_context.h>
6064 +#include <linux/vs_network.h>
6066 #include <asm/pgtable.h>
6067 #include <asm/processor.h>
6068 @@ -172,6 +174,9 @@ static inline void task_state(struct seq
6070 ppid = pid_alive(p) ?
6071 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
6072 + if (unlikely(vx_current_initpid(p->pid)))
6077 struct task_struct *tracer = ptrace_parent(p);
6078 @@ -296,7 +301,7 @@ static inline void task_sig(struct seq_f
6081 static void render_cap_t(struct seq_file *m, const char *header,
6083 + struct vx_info *vxi, kernel_cap_t *a)
6087 @@ -321,10 +326,11 @@ static inline void task_cap(struct seq_f
6088 cap_bset = cred->cap_bset;
6091 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
6092 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
6093 - render_cap_t(m, "CapEff:\t", &cap_effective);
6094 - render_cap_t(m, "CapBnd:\t", &cap_bset);
6095 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
6096 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
6097 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
6098 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
6099 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
6102 static inline void task_context_switch_counts(struct seq_file *m,
6103 @@ -346,6 +352,42 @@ static void task_cpus_allowed(struct seq
6107 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6108 + struct pid *pid, struct task_struct *task)
6110 + seq_printf(m, "Proxy:\t%p(%c)\n"
6118 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6119 + atomic_read(&task->nsproxy->count),
6120 + task->nsproxy->uts_ns,
6121 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6122 + task->nsproxy->ipc_ns,
6123 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6124 + task->nsproxy->mnt_ns,
6125 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6126 + task->nsproxy->pid_ns,
6127 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6128 + task->nsproxy->net_ns,
6129 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6133 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6135 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6138 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6139 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6143 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6144 struct pid *pid, struct task_struct *task)
6146 @@ -362,6 +404,7 @@ int proc_pid_status(struct seq_file *m,
6148 task_cpus_allowed(m, task);
6149 cpuset_task_status_allowed(m, task);
6150 + task_vs_id(m, task);
6151 task_context_switch_counts(m, task);
6154 @@ -471,6 +514,17 @@ static int do_task_stat(struct seq_file
6155 /* convert nsec -> ticks */
6156 start_time = nsec_to_clock_t(start_time);
6158 + /* fixup start time for virt uptime */
6159 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6160 + unsigned long long bias =
6161 + current->vx_info->cvirt.bias_clock;
6163 + if (start_time > bias)
6164 + start_time -= bias;
6169 seq_printf(m, "%d (%s) %c", pid_nr_ns(pid, ns), tcomm, state);
6170 seq_put_decimal_ll(m, ' ', ppid);
6171 seq_put_decimal_ll(m, ' ', pgid);
6172 diff -NurpP --minimal linux-3.6.9/fs/proc/base.c linux-3.6.9-vs2.3.4.4/fs/proc/base.c
6173 --- linux-3.6.9/fs/proc/base.c 2012-10-04 15:27:41.000000000 +0200
6174 +++ linux-3.6.9-vs2.3.4.4/fs/proc/base.c 2012-10-04 18:47:00.000000000 +0200
6176 #include <linux/fs_struct.h>
6177 #include <linux/slab.h>
6178 #include <linux/flex_array.h>
6179 +#include <linux/vs_context.h>
6180 +#include <linux/vs_network.h>
6181 #ifdef CONFIG_HARDWALL
6182 #include <asm/hardwall.h>
6184 @@ -941,11 +943,16 @@ static ssize_t oom_adjust_write(struct f
6188 - if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
6189 + if (oom_adjust < task->signal->oom_adj &&
6190 + !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
6195 + /* prevent guest processes from circumventing the oom killer */
6196 + if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
6197 + oom_adjust = OOM_ADJUST_MIN;
6200 * Warn that /proc/pid/oom_adj is deprecated, see
6201 * Documentation/feature-removal-schedule.txt.
6202 @@ -1548,6 +1555,8 @@ struct inode *proc_pid_make_inode(struct
6203 inode->i_gid = cred->egid;
6206 + /* procfs is xid tagged */
6207 + inode->i_tag = (vs_tag_t)vx_task_xid(task);
6208 security_task_to_inode(task, inode);
6211 @@ -1593,6 +1602,8 @@ int pid_getattr(struct vfsmount *mnt, st
6215 +static unsigned name_to_int(struct dentry *dentry);
6218 * Exceptional case: normally we are not allowed to unhash a busy
6219 * directory. In this case, however, we can do it - no aliasing problems
6220 @@ -1621,6 +1632,12 @@ int pid_revalidate(struct dentry *dentry
6221 task = get_proc_task(inode);
6224 + unsigned pid = name_to_int(dentry);
6226 + if (pid != ~0U && pid != vx_map_pid(task->pid)) {
6227 + put_task_struct(task);
6230 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
6231 task_dumpable(task)) {
6233 @@ -1637,6 +1654,7 @@ int pid_revalidate(struct dentry *dentry
6234 put_task_struct(task);
6241 @@ -2457,6 +2475,13 @@ static struct dentry *proc_pident_lookup
6245 + /* TODO: maybe we can come up with a generic approach? */
6246 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
6247 + (dentry->d_name.len == 5) &&
6248 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
6249 + !memcmp(dentry->d_name.name, "ninfo", 5)))
6253 * Yes, it does not scale. And it should not. Don't add
6254 * new entries into /proc/<tgid>/ without very good reasons.
6255 @@ -2842,7 +2867,7 @@ out_iput:
6256 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
6258 struct dentry *error;
6259 - struct task_struct *task = get_proc_task(dir);
6260 + struct task_struct *task = get_proc_task_real(dir);
6261 const struct pid_entry *p, *last;
6263 error = ERR_PTR(-ENOENT);
6264 @@ -3017,6 +3042,9 @@ static int proc_pid_personality(struct s
6265 static const struct file_operations proc_task_operations;
6266 static const struct inode_operations proc_task_inode_operations;
6268 +extern int proc_pid_vx_info(struct task_struct *, char *);
6269 +extern int proc_pid_nx_info(struct task_struct *, char *);
6271 static const struct pid_entry tgid_base_stuff[] = {
6272 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
6273 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
6274 @@ -3083,6 +3111,8 @@ static const struct pid_entry tgid_base_
6275 #ifdef CONFIG_CGROUPS
6276 REG("cgroup", S_IRUGO, proc_cgroup_operations),
6278 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
6279 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
6280 INF("oom_score", S_IRUGO, proc_oom_score),
6281 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
6282 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
6283 @@ -3106,6 +3136,7 @@ static const struct pid_entry tgid_base_
6284 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
6285 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
6287 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
6290 static int proc_tgid_base_readdir(struct file * filp,
6291 @@ -3300,7 +3331,7 @@ retry:
6293 pid = find_ge_pid(iter.tgid, ns);
6295 - iter.tgid = pid_nr_ns(pid, ns);
6296 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
6297 iter.task = pid_task(pid, PIDTYPE_PID);
6298 /* What we to know is if the pid we have find is the
6299 * pid of a thread_group_leader. Testing for task
6300 @@ -3330,7 +3361,7 @@ static int proc_pid_fill_cache(struct fi
6301 struct tgid_iter iter)
6303 char name[PROC_NUMBUF];
6304 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
6305 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
6306 return proc_fill_cache(filp, dirent, filldir, name, len,
6307 proc_pid_instantiate, iter.task, NULL);
6309 @@ -3354,7 +3385,7 @@ int proc_pid_readdir(struct file * filp,
6311 nr = filp->f_pos - FIRST_PROCESS_ENTRY;
6313 - reaper = get_proc_task(filp->f_path.dentry->d_inode);
6314 + reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
6318 @@ -3376,6 +3407,8 @@ int proc_pid_readdir(struct file * filp,
6319 __filldir = fake_filldir;
6321 filp->f_pos = iter.tgid + TGID_OFFSET;
6322 + if (!vx_proc_task_visible(iter.task))
6324 if (proc_pid_fill_cache(filp, dirent, __filldir, iter) < 0) {
6325 put_task_struct(iter.task);
6327 @@ -3537,6 +3570,8 @@ static struct dentry *proc_task_lookup(s
6328 tid = name_to_int(dentry);
6331 + if (vx_current_initpid(tid))
6334 ns = dentry->d_sb->s_fs_info;
6336 diff -NurpP --minimal linux-3.6.9/fs/proc/generic.c linux-3.6.9-vs2.3.4.4/fs/proc/generic.c
6337 --- linux-3.6.9/fs/proc/generic.c 2012-10-04 15:27:41.000000000 +0200
6338 +++ linux-3.6.9-vs2.3.4.4/fs/proc/generic.c 2012-10-04 18:47:00.000000000 +0200
6340 #include <linux/bitops.h>
6341 #include <linux/spinlock.h>
6342 #include <linux/completion.h>
6343 +#include <linux/vserver/inode.h>
6344 #include <asm/uaccess.h>
6346 #include "internal.h"
6347 @@ -424,11 +425,15 @@ struct dentry *proc_lookup_de(struct pro
6348 for (de = de->subdir; de ; de = de->next) {
6349 if (de->namelen != dentry->d_name.len)
6351 + if (!vx_hide_check(0, de->vx_flags))
6353 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
6355 spin_unlock(&proc_subdir_lock);
6357 inode = proc_get_inode(dir->i_sb, de);
6358 + /* generic proc entries belong to the host */
6363 @@ -506,6 +511,8 @@ int proc_readdir_de(struct proc_dir_entr
6365 /* filldir passes info to user space */
6367 + if (!vx_hide_check(0, de->vx_flags))
6369 spin_unlock(&proc_subdir_lock);
6370 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
6371 de->low_ino, de->mode >> 12) < 0) {
6372 @@ -513,6 +520,7 @@ int proc_readdir_de(struct proc_dir_entr
6375 spin_lock(&proc_subdir_lock);
6380 @@ -626,6 +634,7 @@ static struct proc_dir_entry *__proc_cre
6382 atomic_set(&ent->count, 1);
6384 + ent->vx_flags = IATTR_PROC_DEFAULT;
6385 spin_lock_init(&ent->pde_unload_lock);
6386 ent->pde_unload_completion = NULL;
6387 INIT_LIST_HEAD(&ent->pde_openers);
6388 @@ -649,7 +658,8 @@ struct proc_dir_entry *proc_symlink(cons
6394 + ent->vx_flags = IATTR_PROC_SYMLINK;
6398 diff -NurpP --minimal linux-3.6.9/fs/proc/inode.c linux-3.6.9-vs2.3.4.4/fs/proc/inode.c
6399 --- linux-3.6.9/fs/proc/inode.c 2012-07-22 23:39:42.000000000 +0200
6400 +++ linux-3.6.9-vs2.3.4.4/fs/proc/inode.c 2012-10-04 18:47:00.000000000 +0200
6401 @@ -458,6 +458,8 @@ struct inode *proc_get_inode(struct supe
6402 inode->i_uid = de->uid;
6403 inode->i_gid = de->gid;
6406 + PROC_I(inode)->vx_flags = de->vx_flags;
6408 inode->i_size = de->size;
6410 diff -NurpP --minimal linux-3.6.9/fs/proc/internal.h linux-3.6.9-vs2.3.4.4/fs/proc/internal.h
6411 --- linux-3.6.9/fs/proc/internal.h 2012-10-04 15:27:41.000000000 +0200
6412 +++ linux-3.6.9-vs2.3.4.4/fs/proc/internal.h 2012-10-04 18:47:00.000000000 +0200
6416 #include <linux/proc_fs.h>
6417 +#include <linux/vs_pid.h>
6419 struct ctl_table_header;
6421 extern struct proc_dir_entry proc_root;
6422 @@ -52,6 +54,9 @@ extern int proc_pid_status(struct seq_fi
6423 struct pid *pid, struct task_struct *task);
6424 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
6425 struct pid *pid, struct task_struct *task);
6426 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6427 + struct pid *pid, struct task_struct *task);
6429 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
6431 extern const struct file_operations proc_tid_children_operations;
6432 @@ -81,11 +86,16 @@ static inline struct pid *proc_pid(struc
6433 return PROC_I(inode)->pid;
6436 -static inline struct task_struct *get_proc_task(struct inode *inode)
6437 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
6439 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
6442 +static inline struct task_struct *get_proc_task(struct inode *inode)
6444 + return vx_get_proc_task(inode, proc_pid(inode));
6447 static inline int proc_fd(struct inode *inode)
6449 return PROC_I(inode)->fd;
6450 diff -NurpP --minimal linux-3.6.9/fs/proc/loadavg.c linux-3.6.9-vs2.3.4.4/fs/proc/loadavg.c
6451 --- linux-3.6.9/fs/proc/loadavg.c 2009-09-10 15:26:23.000000000 +0200
6452 +++ linux-3.6.9-vs2.3.4.4/fs/proc/loadavg.c 2012-10-04 18:47:00.000000000 +0200
6455 static int loadavg_proc_show(struct seq_file *m, void *v)
6457 + unsigned long running;
6458 + unsigned int threads;
6459 unsigned long avnrun[3];
6461 get_avenrun(avnrun, FIXED_1/200, 0);
6463 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
6464 + struct vx_info *vxi = current_vx_info();
6466 + running = atomic_read(&vxi->cvirt.nr_running);
6467 + threads = atomic_read(&vxi->cvirt.nr_threads);
6469 + running = nr_running();
6470 + threads = nr_threads;
6473 seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
6474 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
6475 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
6476 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
6477 - nr_running(), nr_threads,
6479 task_active_pid_ns(current)->last_pid);
6482 diff -NurpP --minimal linux-3.6.9/fs/proc/meminfo.c linux-3.6.9-vs2.3.4.4/fs/proc/meminfo.c
6483 --- linux-3.6.9/fs/proc/meminfo.c 2012-01-09 16:14:55.000000000 +0100
6484 +++ linux-3.6.9-vs2.3.4.4/fs/proc/meminfo.c 2012-10-04 18:47:00.000000000 +0200
6485 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
6486 allowed = ((totalram_pages - hugetlb_total_pages())
6487 * sysctl_overcommit_ratio / 100) + total_swap_pages;
6489 - cached = global_page_state(NR_FILE_PAGES) -
6490 + cached = vx_flags(VXF_VIRT_MEM, 0) ?
6491 + vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
6492 total_swapcache_pages - i.bufferram;
6495 diff -NurpP --minimal linux-3.6.9/fs/proc/root.c linux-3.6.9-vs2.3.4.4/fs/proc/root.c
6496 --- linux-3.6.9/fs/proc/root.c 2012-10-04 15:27:41.000000000 +0200
6497 +++ linux-3.6.9-vs2.3.4.4/fs/proc/root.c 2012-10-04 18:47:00.000000000 +0200
6499 #include <linux/mount.h>
6500 #include <linux/pid_namespace.h>
6501 #include <linux/parser.h>
6502 +#include <linux/vserver/inode.h>
6504 #include "internal.h"
6506 +struct proc_dir_entry *proc_virtual;
6508 +extern void proc_vx_init(void);
6510 static int proc_test_super(struct super_block *sb, void *data)
6512 return sb->s_fs_info == data;
6513 @@ -189,6 +194,7 @@ void __init proc_root_init(void)
6515 proc_mkdir("bus", NULL);
6520 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
6521 @@ -255,6 +261,7 @@ struct proc_dir_entry proc_root = {
6522 .proc_iops = &proc_root_inode_operations,
6523 .proc_fops = &proc_root_operations,
6524 .parent = &proc_root,
6525 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
6529 diff -NurpP --minimal linux-3.6.9/fs/proc/stat.c linux-3.6.9-vs2.3.4.4/fs/proc/stat.c
6530 --- linux-3.6.9/fs/proc/stat.c 2012-12-08 01:34:14.000000000 +0100
6531 +++ linux-3.6.9-vs2.3.4.4/fs/proc/stat.c 2012-11-06 18:43:41.000000000 +0100
6533 #include <linux/slab.h>
6534 #include <linux/time.h>
6535 #include <linux/irqnr.h>
6536 +#include <linux/vserver/cvirt.h>
6537 #include <asm/cputime.h>
6538 #include <linux/tick.h>
6540 @@ -92,6 +93,10 @@ static int show_stat(struct seq_file *p,
6541 irq = softirq = steal = 0;
6542 guest = guest_nice = 0;
6543 getboottime(&boottime);
6545 + if (vx_flags(VXF_VIRT_UPTIME, 0))
6546 + vx_vsi_boottime(&boottime);
6548 jif = boottime.tv_sec;
6550 for_each_possible_cpu(i) {
6551 diff -NurpP --minimal linux-3.6.9/fs/proc/uptime.c linux-3.6.9-vs2.3.4.4/fs/proc/uptime.c
6552 --- linux-3.6.9/fs/proc/uptime.c 2012-03-19 19:47:26.000000000 +0100
6553 +++ linux-3.6.9-vs2.3.4.4/fs/proc/uptime.c 2012-10-04 18:47:00.000000000 +0200
6555 #include <linux/seq_file.h>
6556 #include <linux/time.h>
6557 #include <linux/kernel_stat.h>
6558 +#include <linux/vserver/cvirt.h>
6559 #include <asm/cputime.h>
6561 static int uptime_proc_show(struct seq_file *m, void *v)
6562 @@ -25,6 +26,10 @@ static int uptime_proc_show(struct seq_f
6563 nsec = cputime64_to_jiffies64(idletime) * TICK_NSEC;
6564 idle.tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem);
6567 + if (vx_flags(VXF_VIRT_UPTIME, 0))
6568 + vx_vsi_uptime(&uptime, &idle);
6570 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
6571 (unsigned long) uptime.tv_sec,
6572 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
6573 diff -NurpP --minimal linux-3.6.9/fs/proc_namespace.c linux-3.6.9-vs2.3.4.4/fs/proc_namespace.c
6574 --- linux-3.6.9/fs/proc_namespace.c 2012-10-04 15:27:41.000000000 +0200
6575 +++ linux-3.6.9-vs2.3.4.4/fs/proc_namespace.c 2012-10-04 18:47:00.000000000 +0200
6576 @@ -44,6 +44,8 @@ static int show_sb_opts(struct seq_file
6577 { MS_SYNCHRONOUS, ",sync" },
6578 { MS_DIRSYNC, ",dirsync" },
6579 { MS_MANDLOCK, ",mand" },
6580 + { MS_TAGGED, ",tag" },
6581 + { MS_NOTAGCHECK, ",notagcheck" },
6584 const struct proc_fs_info *fs_infop;
6585 @@ -80,6 +82,34 @@ static inline void mangle(struct seq_fil
6586 seq_escape(m, s, " \t\n\\");
6589 +static int mnt_is_reachable(struct vfsmount *vfsmnt)
6592 + struct dentry *point;
6593 + struct mount *mnt = real_mount(vfsmnt);
6594 + struct mount *root_mnt;
6597 + if (mnt == mnt->mnt_ns->root)
6600 + br_read_lock(&vfsmount_lock);
6601 + root = current->fs->root;
6602 + root_mnt = real_mount(root.mnt);
6603 + point = root.dentry;
6605 + while ((mnt != mnt->mnt_parent) && (mnt != root_mnt)) {
6606 + point = mnt->mnt_mountpoint;
6607 + mnt = mnt->mnt_parent;
6610 + ret = (mnt == root_mnt) && is_subdir(point, root.dentry);
6612 + br_read_unlock(&vfsmount_lock);
6617 static void show_type(struct seq_file *m, struct super_block *sb)
6619 mangle(m, sb->s_type->name);
6620 @@ -96,6 +126,17 @@ static int show_vfsmnt(struct seq_file *
6621 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
6622 struct super_block *sb = mnt_path.dentry->d_sb;
6624 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6626 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6629 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6630 + mnt == current->fs->root.mnt) {
6631 + seq_puts(m, "/dev/root / ");
6635 if (sb->s_op->show_devname) {
6636 err = sb->s_op->show_devname(m, mnt_path.dentry);
6638 @@ -106,6 +147,7 @@ static int show_vfsmnt(struct seq_file *
6640 seq_path(m, &mnt_path, " \t\n\\");
6644 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
6645 err = show_sb_opts(m, sb);
6646 @@ -128,6 +170,11 @@ static int show_mountinfo(struct seq_fil
6647 struct path root = p->root;
6650 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6652 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6655 seq_printf(m, "%i %i %u:%u ", r->mnt_id, r->mnt_parent->mnt_id,
6656 MAJOR(sb->s_dev), MINOR(sb->s_dev));
6657 if (sb->s_op->show_path)
6658 @@ -187,6 +234,17 @@ static int show_vfsstat(struct seq_file
6659 struct super_block *sb = mnt_path.dentry->d_sb;
6662 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6664 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6667 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6668 + mnt == current->fs->root.mnt) {
6669 + seq_puts(m, "device /dev/root mounted on / ");
6674 if (sb->s_op->show_devname) {
6675 seq_puts(m, "device ");
6676 @@ -203,7 +261,7 @@ static int show_vfsstat(struct seq_file
6677 seq_puts(m, " mounted on ");
6678 seq_path(m, &mnt_path, " \t\n\\");
6682 /* file system type */
6683 seq_puts(m, "with fstype ");
6685 diff -NurpP --minimal linux-3.6.9/fs/quota/dquot.c linux-3.6.9-vs2.3.4.4/fs/quota/dquot.c
6686 --- linux-3.6.9/fs/quota/dquot.c 2012-10-04 15:27:41.000000000 +0200
6687 +++ linux-3.6.9-vs2.3.4.4/fs/quota/dquot.c 2012-10-04 18:47:00.000000000 +0200
6688 @@ -1580,6 +1580,9 @@ int __dquot_alloc_space(struct inode *in
6689 struct dquot **dquots = inode->i_dquot;
6690 int reserve = flags & DQUOT_SPACE_RESERVE;
6692 + if ((ret = dl_alloc_space(inode, number)))
6696 * First test before acquiring mutex - solves deadlocks when we
6697 * re-enter the quota code and are already holding the mutex
6698 @@ -1635,6 +1638,9 @@ int dquot_alloc_inode(const struct inode
6699 struct dquot_warn warn[MAXQUOTAS];
6700 struct dquot * const *dquots = inode->i_dquot;
6702 + if ((ret = dl_alloc_inode(inode)))
6705 /* First test before acquiring mutex - solves deadlocks when we
6706 * re-enter the quota code and are already holding the mutex */
6707 if (!dquot_active(inode))
6708 @@ -1706,6 +1712,8 @@ void __dquot_free_space(struct inode *in
6709 struct dquot **dquots = inode->i_dquot;
6710 int reserve = flags & DQUOT_SPACE_RESERVE;
6712 + dl_free_space(inode, number);
6714 /* First test before acquiring mutex - solves deadlocks when we
6715 * re-enter the quota code and are already holding the mutex */
6716 if (!dquot_active(inode)) {
6717 @@ -1750,6 +1758,8 @@ void dquot_free_inode(const struct inode
6718 struct dquot_warn warn[MAXQUOTAS];
6719 struct dquot * const *dquots = inode->i_dquot;
6721 + dl_free_inode(inode);
6723 /* First test before acquiring mutex - solves deadlocks when we
6724 * re-enter the quota code and are already holding the mutex */
6725 if (!dquot_active(inode))
6726 diff -NurpP --minimal linux-3.6.9/fs/quota/quota.c linux-3.6.9-vs2.3.4.4/fs/quota/quota.c
6727 --- linux-3.6.9/fs/quota/quota.c 2012-10-04 15:27:41.000000000 +0200
6728 +++ linux-3.6.9-vs2.3.4.4/fs/quota/quota.c 2012-10-04 18:47:00.000000000 +0200
6730 #include <linux/fs.h>
6731 #include <linux/namei.h>
6732 #include <linux/slab.h>
6733 +#include <linux/vs_context.h>
6734 #include <asm/current.h>
6735 #include <linux/uaccess.h>
6736 #include <linux/kernel.h>
6737 @@ -37,7 +38,7 @@ static int check_quotactl_permission(str
6741 - if (!capable(CAP_SYS_ADMIN))
6742 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
6746 @@ -291,6 +292,46 @@ static int do_quotactl(struct super_bloc
6750 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
6752 +#include <linux/vroot.h>
6753 +#include <linux/major.h>
6754 +#include <linux/module.h>
6755 +#include <linux/kallsyms.h>
6756 +#include <linux/vserver/debug.h>
6758 +static vroot_grb_func *vroot_get_real_bdev = NULL;
6760 +static DEFINE_SPINLOCK(vroot_grb_lock);
6762 +int register_vroot_grb(vroot_grb_func *func) {
6765 + spin_lock(&vroot_grb_lock);
6766 + if (!vroot_get_real_bdev) {
6767 + vroot_get_real_bdev = func;
6770 + spin_unlock(&vroot_grb_lock);
6773 +EXPORT_SYMBOL(register_vroot_grb);
6775 +int unregister_vroot_grb(vroot_grb_func *func) {
6776 + int ret = -EINVAL;
6778 + spin_lock(&vroot_grb_lock);
6779 + if (vroot_get_real_bdev) {
6780 + vroot_get_real_bdev = NULL;
6783 + spin_unlock(&vroot_grb_lock);
6786 +EXPORT_SYMBOL(unregister_vroot_grb);
6790 /* Return 1 if 'cmd' will block on frozen filesystem */
6791 static int quotactl_cmd_write(int cmd)
6793 @@ -323,6 +364,22 @@ static struct super_block *quotactl_bloc
6796 return ERR_CAST(bdev);
6797 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
6798 + if (bdev && bdev->bd_inode &&
6799 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
6800 + struct block_device *bdnew = (void *)-EINVAL;
6802 + if (vroot_get_real_bdev)
6803 + bdnew = vroot_get_real_bdev(bdev);
6805 + vxdprintk(VXD_CBIT(misc, 0),
6806 + "vroot_get_real_bdev not set");
6808 + if (IS_ERR(bdnew))
6809 + return ERR_PTR(PTR_ERR(bdnew));
6813 if (quotactl_cmd_write(cmd))
6814 sb = get_super_thawed(bdev);
6816 diff -NurpP --minimal linux-3.6.9/fs/reiserfs/file.c linux-3.6.9-vs2.3.4.4/fs/reiserfs/file.c
6817 --- linux-3.6.9/fs/reiserfs/file.c 2012-05-21 18:07:26.000000000 +0200
6818 +++ linux-3.6.9-vs2.3.4.4/fs/reiserfs/file.c 2012-10-04 18:47:00.000000000 +0200
6819 @@ -319,5 +319,6 @@ const struct inode_operations reiserfs_f
6820 .listxattr = reiserfs_listxattr,
6821 .removexattr = reiserfs_removexattr,
6822 .permission = reiserfs_permission,
6823 + .sync_flags = reiserfs_sync_flags,
6824 .get_acl = reiserfs_get_acl,
6826 diff -NurpP --minimal linux-3.6.9/fs/reiserfs/inode.c linux-3.6.9-vs2.3.4.4/fs/reiserfs/inode.c
6827 --- linux-3.6.9/fs/reiserfs/inode.c 2012-12-08 01:34:14.000000000 +0100
6828 +++ linux-3.6.9-vs2.3.4.4/fs/reiserfs/inode.c 2012-12-08 01:36:33.000000000 +0100
6830 #include <linux/writeback.h>
6831 #include <linux/quotaops.h>
6832 #include <linux/swap.h>
6833 +#include <linux/vs_tag.h>
6835 int reiserfs_commit_write(struct file *f, struct page *page,
6836 unsigned from, unsigned to);
6837 @@ -1131,6 +1132,8 @@ static void init_inode(struct inode *ino
6838 struct buffer_head *bh;
6839 struct item_head *ih;
6843 //int version = ITEM_VERSION_1;
6845 bh = PATH_PLAST_BUFFER(path);
6846 @@ -1151,12 +1154,13 @@ static void init_inode(struct inode *ino
6847 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
6848 unsigned long blocks;
6850 + uid = sd_v1_uid(sd);
6851 + gid = sd_v1_gid(sd);
6853 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
6854 set_inode_sd_version(inode, STAT_DATA_V1);
6855 inode->i_mode = sd_v1_mode(sd);
6856 set_nlink(inode, sd_v1_nlink(sd));
6857 - inode->i_uid = sd_v1_uid(sd);
6858 - inode->i_gid = sd_v1_gid(sd);
6859 inode->i_size = sd_v1_size(sd);
6860 inode->i_atime.tv_sec = sd_v1_atime(sd);
6861 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
6862 @@ -1198,11 +1202,12 @@ static void init_inode(struct inode *ino
6863 // (directories and symlinks)
6864 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
6866 + uid = sd_v2_uid(sd);
6867 + gid = sd_v2_gid(sd);
6869 inode->i_mode = sd_v2_mode(sd);
6870 set_nlink(inode, sd_v2_nlink(sd));
6871 - inode->i_uid = sd_v2_uid(sd);
6872 inode->i_size = sd_v2_size(sd);
6873 - inode->i_gid = sd_v2_gid(sd);
6874 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
6875 inode->i_atime.tv_sec = sd_v2_atime(sd);
6876 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
6877 @@ -1232,6 +1237,10 @@ static void init_inode(struct inode *ino
6878 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
6881 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6882 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6883 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
6886 if (S_ISREG(inode->i_mode)) {
6887 inode->i_op = &reiserfs_file_inode_operations;
6888 @@ -1254,13 +1263,15 @@ static void init_inode(struct inode *ino
6889 static void inode2sd(void *sd, struct inode *inode, loff_t size)
6891 struct stat_data *sd_v2 = (struct stat_data *)sd;
6892 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
6893 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
6896 + set_sd_v2_uid(sd_v2, uid);
6897 + set_sd_v2_gid(sd_v2, gid);
6898 set_sd_v2_mode(sd_v2, inode->i_mode);
6899 set_sd_v2_nlink(sd_v2, inode->i_nlink);
6900 - set_sd_v2_uid(sd_v2, inode->i_uid);
6901 set_sd_v2_size(sd_v2, size);
6902 - set_sd_v2_gid(sd_v2, inode->i_gid);
6903 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
6904 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
6905 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
6906 @@ -2869,14 +2880,19 @@ int reiserfs_commit_write(struct file *f
6907 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
6909 if (reiserfs_attrs(inode->i_sb)) {
6910 - if (sd_attrs & REISERFS_SYNC_FL)
6911 - inode->i_flags |= S_SYNC;
6913 - inode->i_flags &= ~S_SYNC;
6914 if (sd_attrs & REISERFS_IMMUTABLE_FL)
6915 inode->i_flags |= S_IMMUTABLE;
6917 inode->i_flags &= ~S_IMMUTABLE;
6918 + if (sd_attrs & REISERFS_IXUNLINK_FL)
6919 + inode->i_flags |= S_IXUNLINK;
6921 + inode->i_flags &= ~S_IXUNLINK;
6923 + if (sd_attrs & REISERFS_SYNC_FL)
6924 + inode->i_flags |= S_SYNC;
6926 + inode->i_flags &= ~S_SYNC;
6927 if (sd_attrs & REISERFS_APPEND_FL)
6928 inode->i_flags |= S_APPEND;
6930 @@ -2889,6 +2905,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
6931 REISERFS_I(inode)->i_flags |= i_nopack_mask;
6933 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
6935 + if (sd_attrs & REISERFS_BARRIER_FL)
6936 + inode->i_vflags |= V_BARRIER;
6938 + inode->i_vflags &= ~V_BARRIER;
6939 + if (sd_attrs & REISERFS_COW_FL)
6940 + inode->i_vflags |= V_COW;
6942 + inode->i_vflags &= ~V_COW;
6946 @@ -2899,6 +2924,11 @@ void i_attrs_to_sd_attrs(struct inode *i
6947 *sd_attrs |= REISERFS_IMMUTABLE_FL;
6949 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
6950 + if (inode->i_flags & S_IXUNLINK)
6951 + *sd_attrs |= REISERFS_IXUNLINK_FL;
6953 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
6955 if (inode->i_flags & S_SYNC)
6956 *sd_attrs |= REISERFS_SYNC_FL;
6958 @@ -2911,6 +2941,15 @@ void i_attrs_to_sd_attrs(struct inode *i
6959 *sd_attrs |= REISERFS_NOTAIL_FL;
6961 *sd_attrs &= ~REISERFS_NOTAIL_FL;
6963 + if (inode->i_vflags & V_BARRIER)
6964 + *sd_attrs |= REISERFS_BARRIER_FL;
6966 + *sd_attrs &= ~REISERFS_BARRIER_FL;
6967 + if (inode->i_vflags & V_COW)
6968 + *sd_attrs |= REISERFS_COW_FL;
6970 + *sd_attrs &= ~REISERFS_COW_FL;
6974 @@ -3155,7 +3194,8 @@ int reiserfs_setattr(struct dentry *dent
6977 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
6978 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
6979 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
6980 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
6981 struct reiserfs_transaction_handle th;
6984 @@ -3186,6 +3226,9 @@ int reiserfs_setattr(struct dentry *dent
6985 inode->i_uid = attr->ia_uid;
6986 if (attr->ia_valid & ATTR_GID)
6987 inode->i_gid = attr->ia_gid;
6988 + if ((attr->ia_valid & ATTR_TAG) &&
6990 + inode->i_tag = attr->ia_tag;
6991 mark_inode_dirty(inode);
6992 error = journal_end(&th, inode->i_sb, jbegin_count);
6994 diff -NurpP --minimal linux-3.6.9/fs/reiserfs/ioctl.c linux-3.6.9-vs2.3.4.4/fs/reiserfs/ioctl.c
6995 --- linux-3.6.9/fs/reiserfs/ioctl.c 2012-05-21 18:07:27.000000000 +0200
6996 +++ linux-3.6.9-vs2.3.4.4/fs/reiserfs/ioctl.c 2012-10-04 18:47:00.000000000 +0200
6998 #include <linux/pagemap.h>
6999 #include <linux/compat.h>
7002 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
7004 + __u16 sd_attrs = 0;
7006 + inode->i_flags = flags;
7007 + inode->i_vflags = vflags;
7009 + i_attrs_to_sd_attrs(inode, &sd_attrs);
7010 + REISERFS_I(inode)->i_attrs = sd_attrs;
7011 + inode->i_ctime = CURRENT_TIME_SEC;
7012 + mark_inode_dirty(inode);
7017 * reiserfs_ioctl - handler for ioctl for inode
7018 * supported commands:
7020 long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
7022 struct inode *inode = filp->f_path.dentry->d_inode;
7023 - unsigned int flags;
7024 + unsigned int flags, oldflags;
7027 reiserfs_write_lock(inode->i_sb);
7028 @@ -47,6 +62,7 @@ long reiserfs_ioctl(struct file *filp, u
7030 flags = REISERFS_I(inode)->i_attrs;
7031 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
7032 + flags &= REISERFS_FL_USER_VISIBLE;
7033 err = put_user(flags, (int __user *)arg);
7035 case REISERFS_IOC_SETFLAGS:{
7036 @@ -67,6 +83,10 @@ long reiserfs_ioctl(struct file *filp, u
7040 + if (IS_BARRIER(inode)) {
7041 + vxwprintk_task(1, "messing with the barrier.");
7045 * Is it quota file? Do not allow user to mess with it
7047 @@ -91,6 +111,10 @@ long reiserfs_ioctl(struct file *filp, u
7052 + oldflags = REISERFS_I(inode)->i_attrs;
7053 + flags &= REISERFS_FL_USER_MODIFIABLE;
7054 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
7055 sd_attrs_to_i_attrs(flags, inode);
7056 REISERFS_I(inode)->i_attrs = flags;
7057 inode->i_ctime = CURRENT_TIME_SEC;
7058 diff -NurpP --minimal linux-3.6.9/fs/reiserfs/namei.c linux-3.6.9-vs2.3.4.4/fs/reiserfs/namei.c
7059 --- linux-3.6.9/fs/reiserfs/namei.c 2012-10-04 15:27:41.000000000 +0200
7060 +++ linux-3.6.9-vs2.3.4.4/fs/reiserfs/namei.c 2012-10-04 18:47:00.000000000 +0200
7064 #include <linux/quotaops.h>
7065 +#include <linux/vs_tag.h>
7067 #define INC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) { inc_nlink(i); if (i->i_nlink >= REISERFS_LINK_MAX) set_nlink(i, 1); }
7068 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
7069 @@ -362,6 +363,7 @@ static struct dentry *reiserfs_lookup(st
7070 if (retval == IO_ERROR) {
7071 return ERR_PTR(-EIO);
7073 + dx_propagate_tag(nd, inode);
7075 return d_splice_alias(inode, dentry);
7077 diff -NurpP --minimal linux-3.6.9/fs/reiserfs/reiserfs.h linux-3.6.9-vs2.3.4.4/fs/reiserfs/reiserfs.h
7078 --- linux-3.6.9/fs/reiserfs/reiserfs.h 2012-07-22 23:39:42.000000000 +0200
7079 +++ linux-3.6.9-vs2.3.4.4/fs/reiserfs/reiserfs.h 2012-10-04 18:47:00.000000000 +0200
7080 @@ -549,6 +549,7 @@ enum reiserfs_mount_options {
7081 REISERFS_EXPOSE_PRIVROOT,
7082 REISERFS_BARRIER_NONE,
7083 REISERFS_BARRIER_FLUSH,
7086 /* Actions on error */
7087 REISERFS_ERROR_PANIC,
7088 @@ -1548,6 +1549,11 @@ struct stat_data_v1 {
7089 #define REISERFS_COMPR_FL FS_COMPR_FL
7090 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
7092 +/* unfortunately reiserfs sdattr is only 16 bit */
7093 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
7094 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
7095 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
7097 /* persistent flags that file inherits from the parent directory */
7098 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
7099 REISERFS_SYNC_FL | \
7100 @@ -1557,6 +1563,9 @@ struct stat_data_v1 {
7101 REISERFS_COMPR_FL | \
7102 REISERFS_NOTAIL_FL )
7104 +#define REISERFS_FL_USER_VISIBLE 0x80FF
7105 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
7107 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
7110 @@ -2647,6 +2656,7 @@ static inline void reiserfs_update_sd(st
7111 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
7112 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
7113 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
7114 +int reiserfs_sync_flags(struct inode *inode, int, int);
7116 int __reiserfs_write_begin(struct page *page, unsigned from, unsigned len);
7118 diff -NurpP --minimal linux-3.6.9/fs/reiserfs/super.c linux-3.6.9-vs2.3.4.4/fs/reiserfs/super.c
7119 --- linux-3.6.9/fs/reiserfs/super.c 2012-12-08 01:34:14.000000000 +0100
7120 +++ linux-3.6.9-vs2.3.4.4/fs/reiserfs/super.c 2012-12-08 01:36:33.000000000 +0100
7121 @@ -1020,6 +1020,14 @@ static int reiserfs_parse_options(struct
7122 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
7123 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
7125 +#ifndef CONFIG_TAGGING_NONE
7126 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
7127 + {"tag",.setmask = 1 << REISERFS_TAGGED},
7128 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
7130 +#ifdef CONFIG_PROPAGATE
7131 + {"tag",.arg_required = 'T',.values = NULL},
7133 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
7134 {"acl",.setmask = 1 << REISERFS_POSIXACL},
7135 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
7136 @@ -1338,6 +1346,14 @@ static int reiserfs_remount(struct super
7137 handle_quota_files(s, qf_names, &qfmt);
7140 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
7141 + !(s->s_flags & MS_TAGGED)) {
7142 + reiserfs_warning(s, "super-vs01",
7143 + "reiserfs: tagging not permitted on remount.");
7150 /* Add options that are safe here */
7151 @@ -1831,6 +1847,10 @@ static int reiserfs_fill_super(struct su
7152 goto error_unlocked;
7155 + /* map mount option tagxid */
7156 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
7157 + s->s_flags |= MS_TAGGED;
7159 rs = SB_DISK_SUPER_BLOCK(s);
7160 /* Let's do basic sanity check to verify that underlying device is not
7161 smaller than the filesystem. If the check fails then abort and scream,
7162 diff -NurpP --minimal linux-3.6.9/fs/reiserfs/xattr.c linux-3.6.9-vs2.3.4.4/fs/reiserfs/xattr.c
7163 --- linux-3.6.9/fs/reiserfs/xattr.c 2012-10-04 15:27:41.000000000 +0200
7164 +++ linux-3.6.9-vs2.3.4.4/fs/reiserfs/xattr.c 2012-10-04 18:47:00.000000000 +0200
7166 #include <linux/errno.h>
7167 #include <linux/gfp.h>
7168 #include <linux/fs.h>
7169 +#include <linux/mount.h>
7170 #include <linux/file.h>
7171 #include <linux/pagemap.h>
7172 #include <linux/xattr.h>
7173 diff -NurpP --minimal linux-3.6.9/fs/stat.c linux-3.6.9-vs2.3.4.4/fs/stat.c
7174 --- linux-3.6.9/fs/stat.c 2012-10-04 15:27:41.000000000 +0200
7175 +++ linux-3.6.9-vs2.3.4.4/fs/stat.c 2012-10-04 18:47:00.000000000 +0200
7176 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
7177 stat->nlink = inode->i_nlink;
7178 stat->uid = inode->i_uid;
7179 stat->gid = inode->i_gid;
7180 + stat->tag = inode->i_tag;
7181 stat->rdev = inode->i_rdev;
7182 stat->size = i_size_read(inode);
7183 stat->atime = inode->i_atime;
7184 diff -NurpP --minimal linux-3.6.9/fs/statfs.c linux-3.6.9-vs2.3.4.4/fs/statfs.c
7185 --- linux-3.6.9/fs/statfs.c 2012-07-22 23:39:42.000000000 +0200
7186 +++ linux-3.6.9-vs2.3.4.4/fs/statfs.c 2012-10-04 18:47:00.000000000 +0200
7188 #include <linux/statfs.h>
7189 #include <linux/security.h>
7190 #include <linux/uaccess.h>
7191 +#include <linux/vs_base.h>
7192 +#include <linux/vs_dlimit.h>
7193 #include "internal.h"
7195 static int flags_by_mnt(int mnt_flags)
7196 @@ -60,6 +62,8 @@ static int statfs_by_dentry(struct dentr
7197 retval = dentry->d_sb->s_op->statfs(dentry, buf);
7198 if (retval == 0 && buf->f_frsize == 0)
7199 buf->f_frsize = buf->f_bsize;
7200 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
7201 + vx_vsi_statfs(dentry->d_sb, buf);
7205 diff -NurpP --minimal linux-3.6.9/fs/super.c linux-3.6.9-vs2.3.4.4/fs/super.c
7206 --- linux-3.6.9/fs/super.c 2012-10-04 15:27:41.000000000 +0200
7207 +++ linux-3.6.9-vs2.3.4.4/fs/super.c 2012-10-04 19:06:05.000000000 +0200
7209 #include <linux/cleancache.h>
7210 #include <linux/fsnotify.h>
7211 #include <linux/lockdep.h>
7212 +#include <linux/magic.h>
7213 +#include <linux/vs_context.h>
7214 #include "internal.h"
7217 @@ -1148,6 +1150,13 @@ mount_fs(struct file_system_type *type,
7218 WARN_ON(sb->s_bdi == &default_backing_dev_info);
7219 sb->s_flags |= MS_BORN;
7222 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) &&
7224 + (sb->s_magic != PROC_SUPER_MAGIC) &&
7225 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
7228 error = security_sb_kern_mount(sb, flags, secdata);
7231 diff -NurpP --minimal linux-3.6.9/fs/sysfs/mount.c linux-3.6.9-vs2.3.4.4/fs/sysfs/mount.c
7232 --- linux-3.6.9/fs/sysfs/mount.c 2012-10-04 15:27:41.000000000 +0200
7233 +++ linux-3.6.9-vs2.3.4.4/fs/sysfs/mount.c 2012-10-04 18:47:00.000000000 +0200
7234 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
7236 sb->s_blocksize = PAGE_CACHE_SIZE;
7237 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
7238 - sb->s_magic = SYSFS_MAGIC;
7239 + sb->s_magic = SYSFS_SUPER_MAGIC;
7240 sb->s_op = &sysfs_ops;
7241 sb->s_time_gran = 1;
7243 diff -NurpP --minimal linux-3.6.9/fs/utimes.c linux-3.6.9-vs2.3.4.4/fs/utimes.c
7244 --- linux-3.6.9/fs/utimes.c 2012-07-22 23:39:42.000000000 +0200
7245 +++ linux-3.6.9-vs2.3.4.4/fs/utimes.c 2012-10-04 18:47:00.000000000 +0200
7247 #include <linux/stat.h>
7248 #include <linux/utime.h>
7249 #include <linux/syscalls.h>
7250 +#include <linux/mount.h>
7251 +#include <linux/vs_cowbl.h>
7252 #include <asm/uaccess.h>
7253 #include <asm/unistd.h>
7255 @@ -52,12 +54,18 @@ static int utimes_common(struct path *pa
7258 struct iattr newattrs;
7259 - struct inode *inode = path->dentry->d_inode;
7260 + struct inode *inode;
7262 error = mnt_want_write(path->mnt);
7266 + error = cow_check_and_break(path);
7268 + goto mnt_drop_write_and_out;
7270 + inode = path->dentry->d_inode;
7272 if (times && times[0].tv_nsec == UTIME_NOW &&
7273 times[1].tv_nsec == UTIME_NOW)
7275 diff -NurpP --minimal linux-3.6.9/fs/xattr.c linux-3.6.9-vs2.3.4.4/fs/xattr.c
7276 --- linux-3.6.9/fs/xattr.c 2012-10-04 15:27:44.000000000 +0200
7277 +++ linux-3.6.9-vs2.3.4.4/fs/xattr.c 2012-10-04 18:47:00.000000000 +0200
7279 #include <linux/fsnotify.h>
7280 #include <linux/audit.h>
7281 #include <linux/vmalloc.h>
7282 +#include <linux/mount.h>
7284 #include <asm/uaccess.h>
7286 @@ -51,7 +52,7 @@ xattr_permission(struct inode *inode, co
7287 * The trusted.* namespace can only be accessed by privileged users.
7289 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) {
7290 - if (!capable(CAP_SYS_ADMIN))
7291 + if (!vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED))
7292 return (mask & MAY_WRITE) ? -EPERM : -ENODATA;
7295 diff -NurpP --minimal linux-3.6.9/fs/xfs/xfs_dinode.h linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_dinode.h
7296 --- linux-3.6.9/fs/xfs/xfs_dinode.h 2012-10-04 15:27:44.000000000 +0200
7297 +++ linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_dinode.h 2012-10-04 18:47:00.000000000 +0200
7298 @@ -51,7 +51,9 @@ typedef struct xfs_dinode {
7299 __be32 di_nlink; /* number of links to file */
7300 __be16 di_projid_lo; /* lower part of owner's project id */
7301 __be16 di_projid_hi; /* higher part owner's project id */
7302 - __u8 di_pad[6]; /* unused, zeroed space */
7303 + __u8 di_pad[2]; /* unused, zeroed space */
7304 + __be16 di_tag; /* context tagging */
7305 + __be16 di_vflags; /* vserver specific flags */
7306 __be16 di_flushiter; /* incremented on flush */
7307 xfs_timestamp_t di_atime; /* time last accessed */
7308 xfs_timestamp_t di_mtime; /* time last modified */
7309 @@ -184,6 +186,8 @@ static inline void xfs_dinode_put_rdev(s
7310 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
7311 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
7312 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
7313 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
7315 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
7316 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
7317 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
7318 @@ -199,6 +203,7 @@ static inline void xfs_dinode_put_rdev(s
7319 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
7320 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
7321 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
7322 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
7324 #ifdef CONFIG_XFS_RT
7325 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
7326 @@ -211,6 +216,10 @@ static inline void xfs_dinode_put_rdev(s
7327 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
7328 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
7329 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
7330 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
7331 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
7332 + XFS_DIFLAG_IXUNLINK)
7334 +#define XFS_DIVFLAG_BARRIER 0x01
7335 +#define XFS_DIVFLAG_COW 0x02
7337 #endif /* __XFS_DINODE_H__ */
7338 diff -NurpP --minimal linux-3.6.9/fs/xfs/xfs_fs.h linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_fs.h
7339 --- linux-3.6.9/fs/xfs/xfs_fs.h 2011-10-24 18:45:31.000000000 +0200
7340 +++ linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_fs.h 2012-10-04 18:47:00.000000000 +0200
7341 @@ -67,6 +67,9 @@ struct fsxattr {
7342 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
7343 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
7344 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
7345 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
7346 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
7347 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
7348 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
7351 @@ -302,7 +305,8 @@ typedef struct xfs_bstat {
7352 #define bs_projid bs_projid_lo /* (previously just bs_projid) */
7353 __u16 bs_forkoff; /* inode fork offset in bytes */
7354 __u16 bs_projid_hi; /* higher part of project id */
7355 - unsigned char bs_pad[10]; /* pad space, unused */
7356 + unsigned char bs_pad[8]; /* pad space, unused */
7357 + __u16 bs_tag; /* context tagging */
7358 __u32 bs_dmevmask; /* DMIG event mask */
7359 __u16 bs_dmstate; /* DMIG state info */
7360 __u16 bs_aextents; /* attribute number of extents */
7361 diff -NurpP --minimal linux-3.6.9/fs/xfs/xfs_ialloc.c linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_ialloc.c
7362 --- linux-3.6.9/fs/xfs/xfs_ialloc.c 2012-10-04 15:27:44.000000000 +0200
7363 +++ linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_ialloc.c 2012-10-04 18:47:00.000000000 +0200
7365 #include "xfs_error.h"
7366 #include "xfs_bmap.h"
7370 * Allocation group level functions.
7372 diff -NurpP --minimal linux-3.6.9/fs/xfs/xfs_inode.c linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_inode.c
7373 --- linux-3.6.9/fs/xfs/xfs_inode.c 2012-10-04 15:27:44.000000000 +0200
7374 +++ linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_inode.c 2012-11-16 22:43:16.000000000 +0100
7376 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
7378 #include <linux/log2.h>
7379 +#include <linux/vs_tag.h>
7383 @@ -563,15 +564,25 @@ xfs_iformat_btree(
7385 xfs_dinode_from_disk(
7387 - xfs_dinode_t *from)
7388 + xfs_dinode_t *from,
7391 + uint32_t uid, gid, tag;
7393 to->di_magic = be16_to_cpu(from->di_magic);
7394 to->di_mode = be16_to_cpu(from->di_mode);
7395 to->di_version = from ->di_version;
7396 to->di_format = from->di_format;
7397 to->di_onlink = be16_to_cpu(from->di_onlink);
7398 - to->di_uid = be32_to_cpu(from->di_uid);
7399 - to->di_gid = be32_to_cpu(from->di_gid);
7401 + uid = be32_to_cpu(from->di_uid);
7402 + gid = be32_to_cpu(from->di_gid);
7403 + tag = be16_to_cpu(from->di_tag);
7405 + to->di_uid = INOTAG_UID(tagged, uid, gid);
7406 + to->di_gid = INOTAG_GID(tagged, uid, gid);
7407 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
7409 to->di_nlink = be32_to_cpu(from->di_nlink);
7410 to->di_projid_lo = be16_to_cpu(from->di_projid_lo);
7411 to->di_projid_hi = be16_to_cpu(from->di_projid_hi);
7412 @@ -593,21 +604,26 @@ xfs_dinode_from_disk(
7413 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
7414 to->di_dmstate = be16_to_cpu(from->di_dmstate);
7415 to->di_flags = be16_to_cpu(from->di_flags);
7416 + to->di_vflags = be16_to_cpu(from->di_vflags);
7417 to->di_gen = be32_to_cpu(from->di_gen);
7423 - xfs_icdinode_t *from)
7424 + xfs_icdinode_t *from,
7427 to->di_magic = cpu_to_be16(from->di_magic);
7428 to->di_mode = cpu_to_be16(from->di_mode);
7429 to->di_version = from ->di_version;
7430 to->di_format = from->di_format;
7431 to->di_onlink = cpu_to_be16(from->di_onlink);
7432 - to->di_uid = cpu_to_be32(from->di_uid);
7433 - to->di_gid = cpu_to_be32(from->di_gid);
7435 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
7436 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
7437 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
7439 to->di_nlink = cpu_to_be32(from->di_nlink);
7440 to->di_projid_lo = cpu_to_be16(from->di_projid_lo);
7441 to->di_projid_hi = cpu_to_be16(from->di_projid_hi);
7442 @@ -629,12 +645,14 @@ xfs_dinode_to_disk(
7443 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
7444 to->di_dmstate = cpu_to_be16(from->di_dmstate);
7445 to->di_flags = cpu_to_be16(from->di_flags);
7446 + to->di_vflags = cpu_to_be16(from->di_vflags);
7447 to->di_gen = cpu_to_be32(from->di_gen);
7452 - __uint16_t di_flags)
7453 + __uint16_t di_flags,
7454 + __uint16_t di_vflags)
7458 @@ -645,6 +663,8 @@ _xfs_dic2xflags(
7459 flags |= XFS_XFLAG_PREALLOC;
7460 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7461 flags |= XFS_XFLAG_IMMUTABLE;
7462 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7463 + flags |= XFS_XFLAG_IXUNLINK;
7464 if (di_flags & XFS_DIFLAG_APPEND)
7465 flags |= XFS_XFLAG_APPEND;
7466 if (di_flags & XFS_DIFLAG_SYNC)
7467 @@ -669,6 +689,10 @@ _xfs_dic2xflags(
7468 flags |= XFS_XFLAG_FILESTREAM;
7471 + if (di_vflags & XFS_DIVFLAG_BARRIER)
7472 + flags |= FS_BARRIER_FL;
7473 + if (di_vflags & XFS_DIVFLAG_COW)
7474 + flags |= FS_COW_FL;
7478 @@ -678,7 +702,7 @@ xfs_ip2xflags(
7480 xfs_icdinode_t *dic = &ip->i_d;
7482 - return _xfs_dic2xflags(dic->di_flags) |
7483 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
7484 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
7487 @@ -686,7 +710,8 @@ uint
7491 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
7492 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
7493 + be16_to_cpu(dip->di_vflags)) |
7494 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
7497 @@ -740,7 +765,8 @@ xfs_iread(
7498 * Otherwise, just get the truly permanent information.
7501 - xfs_dinode_from_disk(&ip->i_d, dip);
7502 + xfs_dinode_from_disk(&ip->i_d, dip,
7503 + mp->m_flags & XFS_MOUNT_TAGGED);
7504 error = xfs_iformat(ip, dip);
7507 @@ -927,6 +953,7 @@ xfs_ialloc(
7508 ASSERT(ip->i_d.di_nlink == nlink);
7509 ip->i_d.di_uid = current_fsuid();
7510 ip->i_d.di_gid = current_fsgid();
7511 + ip->i_d.di_tag = current_fstag(&ip->i_vnode);
7512 xfs_set_projid(ip, prid);
7513 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
7515 @@ -986,6 +1013,7 @@ xfs_ialloc(
7516 ip->i_d.di_dmevmask = 0;
7517 ip->i_d.di_dmstate = 0;
7518 ip->i_d.di_flags = 0;
7519 + ip->i_d.di_vflags = 0;
7520 flags = XFS_ILOG_CORE;
7521 switch (mode & S_IFMT) {
7523 @@ -1667,6 +1695,7 @@ xfs_ifree(
7525 ip->i_d.di_mode = 0; /* mark incore inode as free */
7526 ip->i_d.di_flags = 0;
7527 + ip->i_d.di_vflags = 0;
7528 ip->i_d.di_dmevmask = 0;
7529 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
7530 ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
7531 @@ -1833,6 +1862,7 @@ xfs_iroot_realloc(
7535 +#include <linux/vs_tag.h>
7538 * This is called when the amount of space needed for if_data
7539 @@ -2521,7 +2551,8 @@ xfs_iflush_int(
7540 * because if the inode is dirty at all the core must
7543 - xfs_dinode_to_disk(dip, &ip->i_d);
7544 + xfs_dinode_to_disk(dip, &ip->i_d,
7545 + mp->m_flags & XFS_MOUNT_TAGGED);
7547 /* Wrap, we never let the log put out DI_MAX_FLUSH */
7548 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
7549 diff -NurpP --minimal linux-3.6.9/fs/xfs/xfs_inode.h linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_inode.h
7550 --- linux-3.6.9/fs/xfs/xfs_inode.h 2012-10-04 15:27:44.000000000 +0200
7551 +++ linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_inode.h 2012-10-04 18:47:00.000000000 +0200
7552 @@ -134,7 +134,9 @@ typedef struct xfs_icdinode {
7553 __uint32_t di_nlink; /* number of links to file */
7554 __uint16_t di_projid_lo; /* lower part of owner's project id */
7555 __uint16_t di_projid_hi; /* higher part of owner's project id */
7556 - __uint8_t di_pad[6]; /* unused, zeroed space */
7557 + __uint8_t di_pad[2]; /* unused, zeroed space */
7558 + __uint16_t di_tag; /* context tagging */
7559 + __uint16_t di_vflags; /* vserver specific flags */
7560 __uint16_t di_flushiter; /* incremented on flush */
7561 xfs_ictimestamp_t di_atime; /* time last accessed */
7562 xfs_ictimestamp_t di_mtime; /* time last modified */
7563 @@ -561,7 +563,7 @@ int xfs_imap_to_bp(struct xfs_mount *,
7564 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
7565 struct xfs_inode *, uint);
7566 void xfs_dinode_to_disk(struct xfs_dinode *,
7567 - struct xfs_icdinode *);
7568 + struct xfs_icdinode *, int);
7569 void xfs_idestroy_fork(struct xfs_inode *, int);
7570 void xfs_idata_realloc(struct xfs_inode *, int, int);
7571 void xfs_iroot_realloc(struct xfs_inode *, int, int);
7572 diff -NurpP --minimal linux-3.6.9/fs/xfs/xfs_ioctl.c linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_ioctl.c
7573 --- linux-3.6.9/fs/xfs/xfs_ioctl.c 2012-10-04 15:27:44.000000000 +0200
7574 +++ linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_ioctl.c 2012-10-04 18:47:00.000000000 +0200
7576 #include "xfs_bmap_btree.h"
7577 #include "xfs_dinode.h"
7578 #include "xfs_inode.h"
7579 -#include "xfs_ioctl.h"
7580 +// #include "xfs_ioctl.h"
7581 #include "xfs_rtalloc.h"
7582 #include "xfs_itable.h"
7583 #include "xfs_error.h"
7584 @@ -762,6 +762,10 @@ xfs_merge_ioc_xflags(
7585 xflags |= XFS_XFLAG_IMMUTABLE;
7587 xflags &= ~XFS_XFLAG_IMMUTABLE;
7588 + if (flags & FS_IXUNLINK_FL)
7589 + xflags |= XFS_XFLAG_IXUNLINK;
7591 + xflags &= ~XFS_XFLAG_IXUNLINK;
7592 if (flags & FS_APPEND_FL)
7593 xflags |= XFS_XFLAG_APPEND;
7595 @@ -790,6 +794,8 @@ xfs_di2lxflags(
7597 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7598 flags |= FS_IMMUTABLE_FL;
7599 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7600 + flags |= FS_IXUNLINK_FL;
7601 if (di_flags & XFS_DIFLAG_APPEND)
7602 flags |= FS_APPEND_FL;
7603 if (di_flags & XFS_DIFLAG_SYNC)
7604 @@ -850,6 +856,8 @@ xfs_set_diflags(
7605 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
7606 if (xflags & XFS_XFLAG_IMMUTABLE)
7607 di_flags |= XFS_DIFLAG_IMMUTABLE;
7608 + if (xflags & XFS_XFLAG_IXUNLINK)
7609 + di_flags |= XFS_DIFLAG_IXUNLINK;
7610 if (xflags & XFS_XFLAG_APPEND)
7611 di_flags |= XFS_DIFLAG_APPEND;
7612 if (xflags & XFS_XFLAG_SYNC)
7613 @@ -892,6 +900,10 @@ xfs_diflags_to_linux(
7614 inode->i_flags |= S_IMMUTABLE;
7616 inode->i_flags &= ~S_IMMUTABLE;
7617 + if (xflags & XFS_XFLAG_IXUNLINK)
7618 + inode->i_flags |= S_IXUNLINK;
7620 + inode->i_flags &= ~S_IXUNLINK;
7621 if (xflags & XFS_XFLAG_APPEND)
7622 inode->i_flags |= S_APPEND;
7624 @@ -1396,10 +1408,18 @@ xfs_file_ioctl(
7625 case XFS_IOC_FSGETXATTRA:
7626 return xfs_ioc_fsgetxattr(ip, 1, arg);
7627 case XFS_IOC_FSSETXATTR:
7628 + if (IS_BARRIER(inode)) {
7629 + vxwprintk_task(1, "messing with the barrier.");
7630 + return -XFS_ERROR(EACCES);
7632 return xfs_ioc_fssetxattr(ip, filp, arg);
7633 case XFS_IOC_GETXFLAGS:
7634 return xfs_ioc_getxflags(ip, arg);
7635 case XFS_IOC_SETXFLAGS:
7636 + if (IS_BARRIER(inode)) {
7637 + vxwprintk_task(1, "messing with the barrier.");
7638 + return -XFS_ERROR(EACCES);
7640 return xfs_ioc_setxflags(ip, filp, arg);
7642 case XFS_IOC_FSSETDM: {
7643 diff -NurpP --minimal linux-3.6.9/fs/xfs/xfs_ioctl.h linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_ioctl.h
7644 --- linux-3.6.9/fs/xfs/xfs_ioctl.h 2011-10-24 18:45:31.000000000 +0200
7645 +++ linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_ioctl.h 2012-10-04 18:47:00.000000000 +0200
7646 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
7647 void __user *uhandle,
7652 + struct inode *inode,
7659 diff -NurpP --minimal linux-3.6.9/fs/xfs/xfs_iops.c linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_iops.c
7660 --- linux-3.6.9/fs/xfs/xfs_iops.c 2012-10-04 15:27:44.000000000 +0200
7661 +++ linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_iops.c 2012-11-16 22:14:53.000000000 +0100
7663 #include "xfs_bmap_btree.h"
7664 #include "xfs_dinode.h"
7665 #include "xfs_inode.h"
7666 +#include "xfs_ioctl.h"
7667 #include "xfs_bmap.h"
7668 #include "xfs_rtalloc.h"
7669 #include "xfs_error.h"
7671 #include <linux/security.h>
7672 #include <linux/fiemap.h>
7673 #include <linux/slab.h>
7674 +#include <linux/vs_tag.h>
7678 @@ -421,6 +423,7 @@ xfs_vn_getattr(
7679 stat->nlink = ip->i_d.di_nlink;
7680 stat->uid = ip->i_d.di_uid;
7681 stat->gid = ip->i_d.di_gid;
7682 + stat->tag = ip->i_d.di_tag;
7683 stat->ino = ip->i_ino;
7684 stat->atime = inode->i_atime;
7685 stat->mtime = inode->i_mtime;
7686 @@ -1033,6 +1036,7 @@ static const struct inode_operations xfs
7687 .listxattr = xfs_vn_listxattr,
7688 .fiemap = xfs_vn_fiemap,
7689 .update_time = xfs_vn_update_time,
7690 + .sync_flags = xfs_sync_flags,
7693 static const struct inode_operations xfs_dir_inode_operations = {
7694 @@ -1059,6 +1063,7 @@ static const struct inode_operations xfs
7695 .removexattr = generic_removexattr,
7696 .listxattr = xfs_vn_listxattr,
7697 .update_time = xfs_vn_update_time,
7698 + .sync_flags = xfs_sync_flags,
7701 static const struct inode_operations xfs_dir_ci_inode_operations = {
7702 @@ -1110,6 +1115,10 @@ xfs_diflags_to_iflags(
7703 inode->i_flags |= S_IMMUTABLE;
7705 inode->i_flags &= ~S_IMMUTABLE;
7706 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
7707 + inode->i_flags |= S_IXUNLINK;
7709 + inode->i_flags &= ~S_IXUNLINK;
7710 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
7711 inode->i_flags |= S_APPEND;
7713 @@ -1122,6 +1131,15 @@ xfs_diflags_to_iflags(
7714 inode->i_flags |= S_NOATIME;
7716 inode->i_flags &= ~S_NOATIME;
7718 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
7719 + inode->i_vflags |= V_BARRIER;
7721 + inode->i_vflags &= ~V_BARRIER;
7722 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
7723 + inode->i_vflags |= V_COW;
7725 + inode->i_vflags &= ~V_COW;
7729 @@ -1153,6 +1171,7 @@ xfs_setup_inode(
7730 set_nlink(inode, ip->i_d.di_nlink);
7731 inode->i_uid = ip->i_d.di_uid;
7732 inode->i_gid = ip->i_d.di_gid;
7733 + inode->i_tag = ip->i_d.di_tag;
7735 switch (inode->i_mode & S_IFMT) {
7737 diff -NurpP --minimal linux-3.6.9/fs/xfs/xfs_itable.c linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_itable.c
7738 --- linux-3.6.9/fs/xfs/xfs_itable.c 2012-10-04 15:27:44.000000000 +0200
7739 +++ linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_itable.c 2012-10-04 18:47:00.000000000 +0200
7740 @@ -96,6 +96,7 @@ xfs_bulkstat_one_int(
7741 buf->bs_mode = dic->di_mode;
7742 buf->bs_uid = dic->di_uid;
7743 buf->bs_gid = dic->di_gid;
7744 + buf->bs_tag = dic->di_tag;
7745 buf->bs_size = dic->di_size;
7746 buf->bs_atime.tv_sec = dic->di_atime.t_sec;
7747 buf->bs_atime.tv_nsec = dic->di_atime.t_nsec;
7748 diff -NurpP --minimal linux-3.6.9/fs/xfs/xfs_linux.h linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_linux.h
7749 --- linux-3.6.9/fs/xfs/xfs_linux.h 2011-10-24 18:45:31.000000000 +0200
7750 +++ linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_linux.h 2012-10-04 18:47:00.000000000 +0200
7753 #define current_cpu() (raw_smp_processor_id())
7754 #define current_pid() (current->pid)
7755 +#define current_fstag(vp) (dx_current_fstag((vp)->i_sb))
7756 #define current_test_flags(f) (current->flags & (f))
7757 #define current_set_flags_nested(sp, f) \
7758 (*(sp) = current->flags, current->flags |= (f))
7759 diff -NurpP --minimal linux-3.6.9/fs/xfs/xfs_log_recover.c linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_log_recover.c
7760 --- linux-3.6.9/fs/xfs/xfs_log_recover.c 2012-12-08 01:34:14.000000000 +0100
7761 +++ linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_log_recover.c 2012-12-08 01:36:33.000000000 +0100
7762 @@ -2359,7 +2359,8 @@ xlog_recover_inode_pass2(
7765 /* The core is in in-core format */
7766 - xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr);
7767 + xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr,
7768 + mp->m_flags & XFS_MOUNT_TAGGED);
7770 /* the rest is in on-disk format */
7771 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
7772 diff -NurpP --minimal linux-3.6.9/fs/xfs/xfs_mount.h linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_mount.h
7773 --- linux-3.6.9/fs/xfs/xfs_mount.h 2012-10-04 15:27:44.000000000 +0200
7774 +++ linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_mount.h 2012-10-04 18:47:00.000000000 +0200
7775 @@ -251,6 +251,7 @@ typedef struct xfs_mount {
7777 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
7779 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
7782 * Default minimum read and write sizes.
7783 diff -NurpP --minimal linux-3.6.9/fs/xfs/xfs_super.c linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_super.c
7784 --- linux-3.6.9/fs/xfs/xfs_super.c 2012-10-04 15:27:44.000000000 +0200
7785 +++ linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_super.c 2012-10-04 18:47:00.000000000 +0200
7786 @@ -112,6 +112,9 @@ mempool_t *xfs_ioend_pool;
7787 #define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed logging disabled */
7788 #define MNTOPT_DISCARD "discard" /* Discard unused blocks */
7789 #define MNTOPT_NODISCARD "nodiscard" /* Do not discard unused blocks */
7790 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
7791 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
7792 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
7795 * Table driven mount option parser.
7796 @@ -120,10 +123,14 @@ mempool_t *xfs_ioend_pool;
7797 * in the future, too.
7800 + Opt_tag, Opt_notag,
7801 Opt_barrier, Opt_nobarrier, Opt_err
7804 static const match_table_t tokens = {
7805 + {Opt_tag, "tagxid"},
7807 + {Opt_notag, "notag"},
7808 {Opt_barrier, "barrier"},
7809 {Opt_nobarrier, "nobarrier"},
7811 @@ -371,6 +378,19 @@ xfs_parseargs(
7812 } else if (!strcmp(this_char, "irixsgid")) {
7814 "irixsgid is now a sysctl(2) variable, option is deprecated.");
7815 +#ifndef CONFIG_TAGGING_NONE
7816 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7817 + mp->m_flags |= XFS_MOUNT_TAGGED;
7818 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
7819 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
7820 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
7821 + mp->m_flags |= XFS_MOUNT_TAGGED;
7823 +#ifdef CONFIG_PROPAGATE
7824 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7826 + mp->m_flags |= XFS_MOUNT_TAGGED;
7829 xfs_warn(mp, "unknown mount option [%s].", this_char);
7831 @@ -1056,6 +1076,16 @@ xfs_fs_remount(
7833 mp->m_flags &= ~XFS_MOUNT_BARRIER;
7836 + if (!(sb->s_flags & MS_TAGGED)) {
7838 + "XFS: %s: tagging not permitted on remount.\n",
7847 * Logically we would return an error here to prevent
7848 @@ -1275,6 +1305,9 @@ xfs_fs_fill_super(
7852 + if (mp->m_flags & XFS_MOUNT_TAGGED)
7853 + sb->s_flags |= MS_TAGGED;
7856 * we must configure the block size in the superblock before we run the
7857 * full mount process as the mount process can lookup and cache inodes.
7858 diff -NurpP --minimal linux-3.6.9/fs/xfs/xfs_vnodeops.c linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_vnodeops.c
7859 --- linux-3.6.9/fs/xfs/xfs_vnodeops.c 2012-10-04 15:27:44.000000000 +0200
7860 +++ linux-3.6.9-vs2.3.4.4/fs/xfs/xfs_vnodeops.c 2012-10-04 18:47:00.000000000 +0200
7861 @@ -103,6 +103,77 @@ xfs_readlink_bmap(
7867 +xfs_get_inode_flags(
7870 + struct inode *inode = VFS_I(ip);
7871 + unsigned int flags = inode->i_flags;
7872 + unsigned int vflags = inode->i_vflags;
7874 + if (flags & S_IMMUTABLE)
7875 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
7877 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
7878 + if (flags & S_IXUNLINK)
7879 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
7881 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
7883 + if (vflags & V_BARRIER)
7884 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
7886 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
7887 + if (vflags & V_COW)
7888 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
7890 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
7895 + struct inode *inode,
7899 + struct xfs_inode *ip = XFS_I(inode);
7900 + struct xfs_mount *mp = ip->i_mount;
7901 + struct xfs_trans *tp;
7902 + unsigned int lock_flags = 0;
7905 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
7906 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
7910 + xfs_ilock(ip, XFS_ILOCK_EXCL);
7911 + xfs_trans_ijoin(tp, ip, 0);
7913 + inode->i_flags = flags;
7914 + inode->i_vflags = vflags;
7915 + xfs_get_inode_flags(ip);
7917 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
7918 + xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
7920 + XFS_STATS_INC(xs_ig_attrchg);
7922 + if (mp->m_flags & XFS_MOUNT_WSYNC)
7923 + xfs_trans_set_sync(tp);
7924 + code = xfs_trans_commit(tp, 0);
7925 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
7929 + xfs_trans_cancel(tp, 0);
7931 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
7939 diff -NurpP --minimal linux-3.6.9/include/linux/Kbuild linux-3.6.9-vs2.3.4.4/include/linux/Kbuild
7940 --- linux-3.6.9/include/linux/Kbuild 2012-10-04 15:27:45.000000000 +0200
7941 +++ linux-3.6.9-vs2.3.4.4/include/linux/Kbuild 2012-10-04 18:47:00.000000000 +0200
7942 @@ -18,6 +18,7 @@ header-y += netfilter_bridge/
7943 header-y += netfilter_ipv4/
7944 header-y += netfilter_ipv6/
7946 +header-y += vserver/
7949 objhdr-y += version.h
7950 diff -NurpP --minimal linux-3.6.9/include/linux/capability.h linux-3.6.9-vs2.3.4.4/include/linux/capability.h
7951 --- linux-3.6.9/include/linux/capability.h 2012-07-22 23:39:43.000000000 +0200
7952 +++ linux-3.6.9-vs2.3.4.4/include/linux/capability.h 2012-10-04 18:47:00.000000000 +0200
7953 @@ -280,6 +280,7 @@ struct cpu_vfs_cap_data {
7954 arbitrary SCSI commands */
7955 /* Allow setting encryption key on loopback filesystem */
7956 /* Allow setting zone reclaim policy */
7957 +/* Allow the selection of a security context */
7959 #define CAP_SYS_ADMIN 21
7961 @@ -366,7 +367,12 @@ struct cpu_vfs_cap_data {
7963 #define CAP_LAST_CAP CAP_BLOCK_SUSPEND
7965 -#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
7966 +/* Allow context manipulations */
7967 +/* Allow changing context info on files */
7969 +#define CAP_CONTEXT 63
7971 +#define cap_valid(x) ((x) >= 0 && ((x) <= CAP_LAST_CAP || (x) == CAP_CONTEXT))
7974 * Bit location of each capability (used by user-space library and kernel)
7975 diff -NurpP --minimal linux-3.6.9/include/linux/cred.h linux-3.6.9-vs2.3.4.4/include/linux/cred.h
7976 --- linux-3.6.9/include/linux/cred.h 2012-07-22 23:39:43.000000000 +0200
7977 +++ linux-3.6.9-vs2.3.4.4/include/linux/cred.h 2012-10-04 18:47:00.000000000 +0200
7978 @@ -157,6 +157,7 @@ extern void exit_creds(struct task_struc
7979 extern int copy_creds(struct task_struct *, unsigned long);
7980 extern const struct cred *get_task_cred(struct task_struct *);
7981 extern struct cred *cred_alloc_blank(void);
7982 +extern struct cred *__prepare_creds(const struct cred *);
7983 extern struct cred *prepare_creds(void);
7984 extern struct cred *prepare_exec_creds(void);
7985 extern int commit_creds(struct cred *);
7986 @@ -210,6 +211,31 @@ static inline void validate_process_cred
7990 +static inline void set_cred_subscribers(struct cred *cred, int n)
7992 +#ifdef CONFIG_DEBUG_CREDENTIALS
7993 + atomic_set(&cred->subscribers, n);
7997 +static inline int read_cred_subscribers(const struct cred *cred)
7999 +#ifdef CONFIG_DEBUG_CREDENTIALS
8000 + return atomic_read(&cred->subscribers);
8006 +static inline void alter_cred_subscribers(const struct cred *_cred, int n)
8008 +#ifdef CONFIG_DEBUG_CREDENTIALS
8009 + struct cred *cred = (struct cred *) _cred;
8011 + atomic_add(n, &cred->subscribers);
8016 * get_new_cred - Get a reference on a new set of credentials
8017 * @cred: The new credentials to reference
8018 diff -NurpP --minimal linux-3.6.9/include/linux/devpts_fs.h linux-3.6.9-vs2.3.4.4/include/linux/devpts_fs.h
8019 --- linux-3.6.9/include/linux/devpts_fs.h 2008-12-25 00:26:37.000000000 +0100
8020 +++ linux-3.6.9-vs2.3.4.4/include/linux/devpts_fs.h 2012-10-04 18:47:00.000000000 +0200
8021 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
8026 #endif /* _LINUX_DEVPTS_FS_H */
8027 diff -NurpP --minimal linux-3.6.9/include/linux/fs.h linux-3.6.9-vs2.3.4.4/include/linux/fs.h
8028 --- linux-3.6.9/include/linux/fs.h 2012-10-04 15:27:45.000000000 +0200
8029 +++ linux-3.6.9-vs2.3.4.4/include/linux/fs.h 2012-10-04 18:47:00.000000000 +0200
8030 @@ -225,6 +225,9 @@ struct inodes_stat_t {
8031 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
8032 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
8033 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
8034 +#define MS_TAGGED (1<<25) /* use generic inode tagging */
8035 +#define MS_TAGID (1<<26) /* use specific tag for this mount */
8036 +#define MS_NOTAGCHECK (1<<27) /* don't check tags */
8037 #define MS_NOSEC (1<<28)
8038 #define MS_BORN (1<<29)
8039 #define MS_ACTIVE (1<<30)
8040 @@ -256,6 +259,14 @@ struct inodes_stat_t {
8041 #define S_IMA 1024 /* Inode has an associated IMA struct */
8042 #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */
8043 #define S_NOSEC 4096 /* no suid or xattr security attributes */
8044 +#define S_IXUNLINK 8192 /* Immutable Invert on unlink */
8046 +/* Linux-VServer related Inode flags */
8050 +#define V_BARRIER 4 /* Barrier for chroot() */
8051 +#define V_COW 8 /* Copy on Write */
8054 * Note that nosuid etc flags are inode-specific: setting some file-system
8055 @@ -278,12 +289,15 @@ struct inodes_stat_t {
8056 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
8057 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
8058 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
8059 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8060 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8061 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8062 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8063 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
8065 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
8066 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
8067 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
8068 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
8069 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
8070 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
8072 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
8073 @@ -294,6 +308,16 @@ struct inodes_stat_t {
8074 #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT)
8075 #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC)
8077 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
8079 +#ifdef CONFIG_VSERVER_COWBL
8080 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
8081 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
8083 +# define IS_COW(inode) (0)
8084 +# define IS_COW_LINK(inode) (0)
8087 /* the read-only stuff doesn't really belong here, but any other place is
8088 probably as bad and I don't want to create yet another include file. */
8090 @@ -380,11 +404,14 @@ struct inodes_stat_t {
8091 #define FS_EXTENT_FL 0x00080000 /* Extents */
8092 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
8093 #define FS_NOCOW_FL 0x00800000 /* Do not cow file */
8094 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8095 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
8097 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8098 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8099 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8100 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
8102 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8103 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8105 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
8106 #define SYNC_FILE_RANGE_WRITE 2
8107 @@ -472,6 +499,7 @@ typedef void (dio_iodone_t)(struct kiocb
8108 #define ATTR_KILL_PRIV (1 << 14)
8109 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
8110 #define ATTR_TIMES_SET (1 << 16)
8111 +#define ATTR_TAG (1 << 17)
8114 * This is the Inode Attributes structure, used for notify_change(). It
8115 @@ -487,6 +515,7 @@ struct iattr {
8121 struct timespec ia_atime;
8122 struct timespec ia_mtime;
8123 @@ -500,6 +529,9 @@ struct iattr {
8124 struct file *ia_file;
8127 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
8128 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
8131 * Includes for diskquotas.
8133 @@ -784,7 +816,9 @@ struct inode {
8134 unsigned short i_opflags;
8137 - unsigned int i_flags;
8139 + unsigned short i_flags;
8140 + unsigned short i_vflags;
8142 #ifdef CONFIG_FS_POSIX_ACL
8143 struct posix_acl *i_acl;
8144 @@ -813,6 +847,7 @@ struct inode {
8145 unsigned int __i_nlink;
8150 struct timespec i_atime;
8151 struct timespec i_mtime;
8152 @@ -975,12 +1010,12 @@ static inline void i_gid_write(struct in
8154 static inline unsigned iminor(const struct inode *inode)
8156 - return MINOR(inode->i_rdev);
8157 + return MINOR(inode->i_mdev);
8160 static inline unsigned imajor(const struct inode *inode)
8162 - return MAJOR(inode->i_rdev);
8163 + return MAJOR(inode->i_mdev);
8166 extern struct block_device *I_BDEV(struct inode *inode);
8167 @@ -1047,6 +1082,7 @@ struct file {
8169 struct fown_struct f_owner;
8170 const struct cred *f_cred;
8172 struct file_ra_state f_ra;
8175 @@ -1194,6 +1230,7 @@ struct file_lock {
8176 struct file *fl_file;
8181 struct fasync_struct * fl_fasync; /* for lease break notifications */
8182 /* for lease breaks: */
8183 @@ -1829,6 +1866,7 @@ struct inode_operations {
8184 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
8185 ssize_t (*listxattr) (struct dentry *, char *, size_t);
8186 int (*removexattr) (struct dentry *, const char *);
8187 + int (*sync_flags) (struct inode *, int, int);
8188 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
8190 int (*update_time)(struct inode *, struct timespec *, int);
8191 @@ -1850,6 +1888,7 @@ extern ssize_t vfs_readv(struct file *,
8192 unsigned long, loff_t *);
8193 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
8194 unsigned long, loff_t *);
8195 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
8197 struct super_operations {
8198 struct inode *(*alloc_inode)(struct super_block *sb);
8199 @@ -2692,6 +2731,7 @@ extern int dcache_dir_open(struct inode
8200 extern int dcache_dir_close(struct inode *, struct file *);
8201 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
8202 extern int dcache_readdir(struct file *, void *, filldir_t);
8203 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
8204 extern int simple_setattr(struct dentry *, struct iattr *);
8205 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
8206 extern int simple_statfs(struct dentry *, struct kstatfs *);
8207 diff -NurpP --minimal linux-3.6.9/include/linux/gfs2_ondisk.h linux-3.6.9-vs2.3.4.4/include/linux/gfs2_ondisk.h
8208 --- linux-3.6.9/include/linux/gfs2_ondisk.h 2012-10-04 15:27:45.000000000 +0200
8209 +++ linux-3.6.9-vs2.3.4.4/include/linux/gfs2_ondisk.h 2012-10-04 18:54:29.000000000 +0200
8210 @@ -225,6 +225,9 @@ enum {
8213 gfs2fl_TopLevel = 10,
8214 + gfs2fl_IXUnlink = 16,
8215 + gfs2fl_Barrier = 17,
8217 gfs2fl_TruncInProg = 29,
8218 gfs2fl_InheritDirectio = 30,
8219 gfs2fl_InheritJdata = 31,
8220 @@ -242,6 +245,9 @@ enum {
8221 #define GFS2_DIF_SYNC 0x00000100
8222 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
8223 #define GFS2_DIF_TOPDIR 0x00000400 /* New in gfs2 */
8224 +#define GFS2_DIF_IXUNLINK 0x00010000
8225 +#define GFS2_DIF_BARRIER 0x00020000
8226 +#define GFS2_DIF_COW 0x00040000
8227 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
8228 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000 /* only in gfs1 */
8229 #define GFS2_DIF_INHERIT_JDATA 0x80000000
8230 diff -NurpP --minimal linux-3.6.9/include/linux/if_tun.h linux-3.6.9-vs2.3.4.4/include/linux/if_tun.h
8231 --- linux-3.6.9/include/linux/if_tun.h 2010-08-02 16:52:54.000000000 +0200
8232 +++ linux-3.6.9-vs2.3.4.4/include/linux/if_tun.h 2012-10-04 18:47:00.000000000 +0200
8234 #define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog)
8235 #define TUNGETVNETHDRSZ _IOR('T', 215, int)
8236 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
8237 +#define TUNSETNID _IOW('T', 217, int)
8239 /* TUNSETIFF ifr flags */
8240 #define IFF_TUN 0x0001
8241 diff -NurpP --minimal linux-3.6.9/include/linux/init_task.h linux-3.6.9-vs2.3.4.4/include/linux/init_task.h
8242 --- linux-3.6.9/include/linux/init_task.h 2012-10-04 15:27:45.000000000 +0200
8243 +++ linux-3.6.9-vs2.3.4.4/include/linux/init_task.h 2012-10-04 18:47:00.000000000 +0200
8244 @@ -210,6 +210,10 @@ extern struct task_group root_task_group
8245 INIT_TRACE_RECURSION \
8246 INIT_TASK_RCU_PREEMPT(tsk) \
8249 + .vx_info = NULL, \
8251 + .nx_info = NULL, \
8255 diff -NurpP --minimal linux-3.6.9/include/linux/ipc.h linux-3.6.9-vs2.3.4.4/include/linux/ipc.h
8256 --- linux-3.6.9/include/linux/ipc.h 2012-03-19 19:47:28.000000000 +0100
8257 +++ linux-3.6.9-vs2.3.4.4/include/linux/ipc.h 2012-10-04 18:47:00.000000000 +0200
8258 @@ -91,6 +91,7 @@ struct kern_ipc_perm
8266 diff -NurpP --minimal linux-3.6.9/include/linux/ipc_namespace.h linux-3.6.9-vs2.3.4.4/include/linux/ipc_namespace.h
8267 --- linux-3.6.9/include/linux/ipc_namespace.h 2012-07-22 23:39:43.000000000 +0200
8268 +++ linux-3.6.9-vs2.3.4.4/include/linux/ipc_namespace.h 2012-10-04 18:47:00.000000000 +0200
8269 @@ -133,7 +133,8 @@ static inline int mq_init_ns(struct ipc_
8271 #if defined(CONFIG_IPC_NS)
8272 extern struct ipc_namespace *copy_ipcs(unsigned long flags,
8273 - struct task_struct *tsk);
8274 + struct ipc_namespace *old_ns,
8275 + struct user_namespace *user_ns);
8276 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
8279 @@ -144,12 +145,13 @@ static inline struct ipc_namespace *get_
8280 extern void put_ipc_ns(struct ipc_namespace *ns);
8282 static inline struct ipc_namespace *copy_ipcs(unsigned long flags,
8283 - struct task_struct *tsk)
8284 + struct ipc_namespace *old_ns,
8285 + struct user_namespace *user_ns)
8287 if (flags & CLONE_NEWIPC)
8288 return ERR_PTR(-EINVAL);
8290 - return tsk->nsproxy->ipc_ns;
8294 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
8295 diff -NurpP --minimal linux-3.6.9/include/linux/loop.h linux-3.6.9-vs2.3.4.4/include/linux/loop.h
8296 --- linux-3.6.9/include/linux/loop.h 2012-01-09 16:14:58.000000000 +0100
8297 +++ linux-3.6.9-vs2.3.4.4/include/linux/loop.h 2012-10-04 18:47:00.000000000 +0200
8298 @@ -45,6 +45,7 @@ struct loop_device {
8299 struct loop_func_table *lo_encryption;
8301 uid_t lo_key_owner; /* Who set the key */
8303 int (*ioctl)(struct loop_device *, int cmd,
8306 diff -NurpP --minimal linux-3.6.9/include/linux/magic.h linux-3.6.9-vs2.3.4.4/include/linux/magic.h
8307 --- linux-3.6.9/include/linux/magic.h 2012-05-21 18:07:31.000000000 +0200
8308 +++ linux-3.6.9-vs2.3.4.4/include/linux/magic.h 2012-10-04 18:47:00.000000000 +0200
8311 #define ADFS_SUPER_MAGIC 0xadf5
8312 #define AFFS_SUPER_MAGIC 0xadff
8313 -#define AFS_SUPER_MAGIC 0x5346414F
8314 +#define AFS_SUPER_MAGIC 0x5346414F
8315 #define AUTOFS_SUPER_MAGIC 0x0187
8316 #define CODA_SUPER_MAGIC 0x73757245
8317 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
8318 diff -NurpP --minimal linux-3.6.9/include/linux/major.h linux-3.6.9-vs2.3.4.4/include/linux/major.h
8319 --- linux-3.6.9/include/linux/major.h 2009-09-10 15:26:25.000000000 +0200
8320 +++ linux-3.6.9-vs2.3.4.4/include/linux/major.h 2012-10-04 18:47:00.000000000 +0200
8322 #define HD_MAJOR IDE0_MAJOR
8323 #define PTY_SLAVE_MAJOR 3
8325 +#define VROOT_MAJOR 4
8326 #define TTYAUX_MAJOR 5
8329 diff -NurpP --minimal linux-3.6.9/include/linux/memcontrol.h linux-3.6.9-vs2.3.4.4/include/linux/memcontrol.h
8330 --- linux-3.6.9/include/linux/memcontrol.h 2012-10-04 15:27:45.000000000 +0200
8331 +++ linux-3.6.9-vs2.3.4.4/include/linux/memcontrol.h 2012-10-04 18:47:00.000000000 +0200
8332 @@ -83,6 +83,13 @@ extern struct mem_cgroup *try_get_mem_cg
8333 extern struct mem_cgroup *parent_mem_cgroup(struct mem_cgroup *memcg);
8334 extern struct mem_cgroup *mem_cgroup_from_cont(struct cgroup *cont);
8336 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
8337 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
8339 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
8340 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
8341 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
8344 int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
8346 diff -NurpP --minimal linux-3.6.9/include/linux/mm_types.h linux-3.6.9-vs2.3.4.4/include/linux/mm_types.h
8347 --- linux-3.6.9/include/linux/mm_types.h 2012-10-04 15:27:46.000000000 +0200
8348 +++ linux-3.6.9-vs2.3.4.4/include/linux/mm_types.h 2012-10-04 18:47:00.000000000 +0200
8349 @@ -370,6 +370,7 @@ struct mm_struct {
8351 /* Architecture-specific MM context */
8352 mm_context_t context;
8353 + struct vx_info *mm_vx_info;
8355 unsigned long flags; /* Must use atomic bitops to access the bits */
8357 diff -NurpP --minimal linux-3.6.9/include/linux/mmzone.h linux-3.6.9-vs2.3.4.4/include/linux/mmzone.h
8358 --- linux-3.6.9/include/linux/mmzone.h 2012-12-08 01:34:14.000000000 +0100
8359 +++ linux-3.6.9-vs2.3.4.4/include/linux/mmzone.h 2012-12-08 01:36:33.000000000 +0100
8360 @@ -727,6 +727,13 @@ typedef struct pglist_data {
8361 __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
8364 +#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
8366 +#define node_end_pfn(nid) ({\
8367 + pg_data_t *__pgdat = NODE_DATA(nid);\
8368 + __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
8371 #include <linux/memory_hotplug.h>
8373 extern struct mutex zonelists_mutex;
8374 diff -NurpP --minimal linux-3.6.9/include/linux/mount.h linux-3.6.9-vs2.3.4.4/include/linux/mount.h
8375 --- linux-3.6.9/include/linux/mount.h 2012-03-19 19:47:28.000000000 +0100
8376 +++ linux-3.6.9-vs2.3.4.4/include/linux/mount.h 2012-10-04 18:47:00.000000000 +0200
8377 @@ -47,6 +47,9 @@ struct mnt_namespace;
8379 #define MNT_INTERNAL 0x4000
8381 +#define MNT_TAGID 0x10000
8382 +#define MNT_NOTAG 0x20000
8385 struct dentry *mnt_root; /* root of the mounted tree */
8386 struct super_block *mnt_sb; /* pointer to superblock */
8387 diff -NurpP --minimal linux-3.6.9/include/linux/net.h linux-3.6.9-vs2.3.4.4/include/linux/net.h
8388 --- linux-3.6.9/include/linux/net.h 2012-10-04 15:27:46.000000000 +0200
8389 +++ linux-3.6.9-vs2.3.4.4/include/linux/net.h 2012-10-04 18:47:00.000000000 +0200
8390 @@ -73,6 +73,7 @@ struct net;
8391 #define SOCK_PASSCRED 3
8392 #define SOCK_PASSSEC 4
8393 #define SOCK_EXTERNALLY_ALLOCATED 5
8394 +#define SOCK_USER_SOCKET 6
8396 #ifndef ARCH_HAS_SOCKET_TYPES
8398 diff -NurpP --minimal linux-3.6.9/include/linux/netdevice.h linux-3.6.9-vs2.3.4.4/include/linux/netdevice.h
8399 --- linux-3.6.9/include/linux/netdevice.h 2012-10-04 15:27:46.000000000 +0200
8400 +++ linux-3.6.9-vs2.3.4.4/include/linux/netdevice.h 2012-10-04 18:47:00.000000000 +0200
8401 @@ -1651,6 +1651,7 @@ extern void netdev_resync_ops(struct ne
8403 extern struct net_device *dev_get_by_index(struct net *net, int ifindex);
8404 extern struct net_device *__dev_get_by_index(struct net *net, int ifindex);
8405 +extern struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex);
8406 extern struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex);
8407 extern int dev_restart(struct net_device *dev);
8408 #ifdef CONFIG_NETPOLL_TRAP
8409 diff -NurpP --minimal linux-3.6.9/include/linux/nfs_mount.h linux-3.6.9-vs2.3.4.4/include/linux/nfs_mount.h
8410 --- linux-3.6.9/include/linux/nfs_mount.h 2011-01-05 21:50:31.000000000 +0100
8411 +++ linux-3.6.9-vs2.3.4.4/include/linux/nfs_mount.h 2012-10-04 18:47:00.000000000 +0200
8412 @@ -63,7 +63,8 @@ struct nfs_mount_data {
8413 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
8414 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
8415 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
8416 -#define NFS_MOUNT_FLAGMASK 0xFFFF
8417 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
8418 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
8420 /* The following are for internal use only */
8421 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
8422 diff -NurpP --minimal linux-3.6.9/include/linux/nsproxy.h linux-3.6.9-vs2.3.4.4/include/linux/nsproxy.h
8423 --- linux-3.6.9/include/linux/nsproxy.h 2011-10-24 18:45:32.000000000 +0200
8424 +++ linux-3.6.9-vs2.3.4.4/include/linux/nsproxy.h 2012-10-04 18:47:00.000000000 +0200
8427 #include <linux/spinlock.h>
8428 #include <linux/sched.h>
8429 +#include <linux/vserver/debug.h>
8431 struct mnt_namespace;
8432 struct uts_namespace;
8433 @@ -63,6 +64,7 @@ static inline struct nsproxy *task_nspro
8436 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
8437 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
8438 void exit_task_namespaces(struct task_struct *tsk);
8439 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
8440 void free_nsproxy(struct nsproxy *ns);
8441 @@ -70,16 +72,26 @@ int unshare_nsproxy_namespaces(unsigned
8442 struct fs_struct *);
8443 int __init nsproxy_cache_init(void);
8445 -static inline void put_nsproxy(struct nsproxy *ns)
8446 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
8448 +static inline void __get_nsproxy(struct nsproxy *ns,
8449 + const char *_file, int _line)
8451 - if (atomic_dec_and_test(&ns->count)) {
8454 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
8455 + ns, atomic_read(&ns->count), _file, _line);
8456 + atomic_inc(&ns->count);
8459 -static inline void get_nsproxy(struct nsproxy *ns)
8460 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
8462 +static inline void __put_nsproxy(struct nsproxy *ns,
8463 + const char *_file, int _line)
8465 - atomic_inc(&ns->count);
8466 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
8467 + ns, atomic_read(&ns->count), _file, _line);
8468 + if (atomic_dec_and_test(&ns->count)) {
8474 diff -NurpP --minimal linux-3.6.9/include/linux/pid.h linux-3.6.9-vs2.3.4.4/include/linux/pid.h
8475 --- linux-3.6.9/include/linux/pid.h 2011-07-22 11:18:11.000000000 +0200
8476 +++ linux-3.6.9-vs2.3.4.4/include/linux/pid.h 2012-10-04 18:47:00.000000000 +0200
8477 @@ -8,7 +8,8 @@ enum pid_type
8487 @@ -171,6 +172,7 @@ static inline pid_t pid_nr(struct pid *p
8490 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
8491 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
8492 pid_t pid_vnr(struct pid *pid);
8494 #define do_each_pid_task(pid, type, task) \
8495 diff -NurpP --minimal linux-3.6.9/include/linux/proc_fs.h linux-3.6.9-vs2.3.4.4/include/linux/proc_fs.h
8496 --- linux-3.6.9/include/linux/proc_fs.h 2012-07-22 23:39:44.000000000 +0200
8497 +++ linux-3.6.9-vs2.3.4.4/include/linux/proc_fs.h 2012-10-04 18:47:00.000000000 +0200
8498 @@ -54,6 +54,7 @@ struct proc_dir_entry {
8504 const struct inode_operations *proc_iops;
8506 @@ -252,12 +253,18 @@ extern const struct proc_ns_operations n
8507 extern const struct proc_ns_operations utsns_operations;
8508 extern const struct proc_ns_operations ipcns_operations;
8514 int (*proc_get_link)(struct dentry *, struct path *);
8515 int (*proc_read)(struct task_struct *task, char *page);
8516 int (*proc_show)(struct seq_file *m,
8517 struct pid_namespace *ns, struct pid *pid,
8518 struct task_struct *task);
8519 + int (*proc_vs_read)(char *page);
8520 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
8521 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
8524 struct ctl_table_header;
8525 @@ -265,6 +272,7 @@ struct ctl_table;
8532 struct proc_dir_entry *pde;
8533 diff -NurpP --minimal linux-3.6.9/include/linux/quotaops.h linux-3.6.9-vs2.3.4.4/include/linux/quotaops.h
8534 --- linux-3.6.9/include/linux/quotaops.h 2012-10-04 15:27:46.000000000 +0200
8535 +++ linux-3.6.9-vs2.3.4.4/include/linux/quotaops.h 2012-10-04 18:47:00.000000000 +0200
8537 #define _LINUX_QUOTAOPS_
8539 #include <linux/fs.h>
8540 +#include <linux/vs_dlimit.h>
8542 #define DQUOT_SPACE_WARN 0x1
8543 #define DQUOT_SPACE_RESERVE 0x2
8544 @@ -205,11 +206,12 @@ static inline void dquot_drop(struct ino
8546 static inline int dquot_alloc_inode(const struct inode *inode)
8549 + return dl_alloc_inode(inode);
8552 static inline void dquot_free_inode(const struct inode *inode)
8554 + dl_free_inode(inode);
8557 static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
8558 @@ -220,6 +222,10 @@ static inline int dquot_transfer(struct
8559 static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
8564 + if ((ret = dl_alloc_space(inode, number)))
8566 if (!(flags & DQUOT_SPACE_RESERVE))
8567 inode_add_bytes(inode, number);
8569 @@ -230,6 +236,7 @@ static inline void __dquot_free_space(st
8571 if (!(flags & DQUOT_SPACE_RESERVE))
8572 inode_sub_bytes(inode, number);
8573 + dl_free_space(inode, number);
8576 static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
8577 diff -NurpP --minimal linux-3.6.9/include/linux/reboot.h linux-3.6.9-vs2.3.4.4/include/linux/reboot.h
8578 --- linux-3.6.9/include/linux/reboot.h 2011-10-24 18:45:32.000000000 +0200
8579 +++ linux-3.6.9-vs2.3.4.4/include/linux/reboot.h 2012-10-04 18:47:00.000000000 +0200
8581 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
8582 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
8583 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
8584 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
8588 diff -NurpP --minimal linux-3.6.9/include/linux/sched.h linux-3.6.9-vs2.3.4.4/include/linux/sched.h
8589 --- linux-3.6.9/include/linux/sched.h 2012-10-04 15:27:46.000000000 +0200
8590 +++ linux-3.6.9-vs2.3.4.4/include/linux/sched.h 2012-10-04 18:47:00.000000000 +0200
8591 @@ -1422,6 +1422,14 @@ struct task_struct {
8593 struct seccomp seccomp;
8595 +/* vserver context data */
8596 + struct vx_info *vx_info;
8597 + struct nx_info *nx_info;
8603 /* Thread group tracking */
8606 @@ -1668,6 +1676,11 @@ struct pid_namespace;
8607 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
8608 struct pid_namespace *ns);
8610 +#include <linux/vserver/base.h>
8611 +#include <linux/vserver/context.h>
8612 +#include <linux/vserver/debug.h>
8613 +#include <linux/vserver/pid.h>
8615 static inline pid_t task_pid_nr(struct task_struct *tsk)
8618 @@ -1681,7 +1694,8 @@ static inline pid_t task_pid_nr_ns(struc
8620 static inline pid_t task_pid_vnr(struct task_struct *tsk)
8622 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
8623 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
8624 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
8628 @@ -1694,7 +1708,7 @@ pid_t task_tgid_nr_ns(struct task_struct
8630 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
8632 - return pid_vnr(task_tgid(tsk));
8633 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
8637 diff -NurpP --minimal linux-3.6.9/include/linux/shmem_fs.h linux-3.6.9-vs2.3.4.4/include/linux/shmem_fs.h
8638 --- linux-3.6.9/include/linux/shmem_fs.h 2012-07-22 23:39:44.000000000 +0200
8639 +++ linux-3.6.9-vs2.3.4.4/include/linux/shmem_fs.h 2012-10-04 18:47:00.000000000 +0200
8642 /* inode in-kernel data */
8644 +#define TMPFS_SUPER_MAGIC 0x01021994
8647 struct shmem_inode_info {
8649 unsigned long flags;
8650 diff -NurpP --minimal linux-3.6.9/include/linux/stat.h linux-3.6.9-vs2.3.4.4/include/linux/stat.h
8651 --- linux-3.6.9/include/linux/stat.h 2012-07-22 23:39:44.000000000 +0200
8652 +++ linux-3.6.9-vs2.3.4.4/include/linux/stat.h 2012-10-04 18:47:00.000000000 +0200
8653 @@ -67,6 +67,7 @@ struct kstat {
8660 struct timespec atime;
8661 diff -NurpP --minimal linux-3.6.9/include/linux/sunrpc/auth.h linux-3.6.9-vs2.3.4.4/include/linux/sunrpc/auth.h
8662 --- linux-3.6.9/include/linux/sunrpc/auth.h 2012-10-04 15:27:46.000000000 +0200
8663 +++ linux-3.6.9-vs2.3.4.4/include/linux/sunrpc/auth.h 2012-10-04 18:47:00.000000000 +0200
8669 struct group_info *group_info;
8670 const char *principal;
8671 unsigned char machine_cred : 1;
8672 diff -NurpP --minimal linux-3.6.9/include/linux/sunrpc/clnt.h linux-3.6.9-vs2.3.4.4/include/linux/sunrpc/clnt.h
8673 --- linux-3.6.9/include/linux/sunrpc/clnt.h 2012-05-21 18:07:32.000000000 +0200
8674 +++ linux-3.6.9-vs2.3.4.4/include/linux/sunrpc/clnt.h 2012-10-04 18:47:00.000000000 +0200
8675 @@ -49,7 +49,8 @@ struct rpc_clnt {
8676 unsigned int cl_softrtry : 1,/* soft timeouts */
8677 cl_discrtry : 1,/* disconnect before retry */
8678 cl_autobind : 1,/* use getport() */
8679 - cl_chatty : 1;/* be verbose */
8680 + cl_chatty : 1,/* be verbose */
8681 + cl_tag : 1;/* context tagging */
8683 struct rpc_rtt * cl_rtt; /* RTO estimator data */
8684 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
8685 diff -NurpP --minimal linux-3.6.9/include/linux/sysctl.h linux-3.6.9-vs2.3.4.4/include/linux/sysctl.h
8686 --- linux-3.6.9/include/linux/sysctl.h 2012-05-21 18:07:32.000000000 +0200
8687 +++ linux-3.6.9-vs2.3.4.4/include/linux/sysctl.h 2012-10-04 18:47:00.000000000 +0200
8688 @@ -60,6 +60,7 @@ enum
8689 CTL_ABI=9, /* Binary emulation */
8690 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
8691 CTL_ARLAN=254, /* arlan wireless driver */
8692 + CTL_VSERVER=4242, /* Linux-VServer debug */
8693 CTL_S390DBF=5677, /* s390 debug */
8694 CTL_SUNRPC=7249, /* sunrpc debug */
8695 CTL_PM=9899, /* frv power management */
8696 @@ -94,6 +95,7 @@ enum
8698 KERN_PANIC=15, /* int: panic timeout */
8699 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
8700 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
8702 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
8703 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
8704 diff -NurpP --minimal linux-3.6.9/include/linux/sysfs.h linux-3.6.9-vs2.3.4.4/include/linux/sysfs.h
8705 --- linux-3.6.9/include/linux/sysfs.h 2012-07-22 23:39:44.000000000 +0200
8706 +++ linux-3.6.9-vs2.3.4.4/include/linux/sysfs.h 2012-10-04 18:47:00.000000000 +0200
8708 #include <linux/kobject_ns.h>
8709 #include <linux/atomic.h>
8711 +#define SYSFS_SUPER_MAGIC 0x62656572
8716 diff -NurpP --minimal linux-3.6.9/include/linux/time.h linux-3.6.9-vs2.3.4.4/include/linux/time.h
8717 --- linux-3.6.9/include/linux/time.h 2012-10-04 15:27:46.000000000 +0200
8718 +++ linux-3.6.9-vs2.3.4.4/include/linux/time.h 2012-10-04 18:47:00.000000000 +0200
8719 @@ -280,6 +280,8 @@ static __always_inline void timespec_add
8723 +#include <linux/vs_time.h>
8725 #endif /* __KERNEL__ */
8728 diff -NurpP --minimal linux-3.6.9/include/linux/types.h linux-3.6.9-vs2.3.4.4/include/linux/types.h
8729 --- linux-3.6.9/include/linux/types.h 2012-10-04 15:27:47.000000000 +0200
8730 +++ linux-3.6.9-vs2.3.4.4/include/linux/types.h 2012-10-04 18:47:00.000000000 +0200
8731 @@ -41,6 +41,9 @@ typedef __kernel_uid32_t uid_t;
8732 typedef __kernel_gid32_t gid_t;
8733 typedef __kernel_uid16_t uid16_t;
8734 typedef __kernel_gid16_t gid16_t;
8735 +typedef unsigned int xid_t;
8736 +typedef unsigned int nid_t;
8737 +typedef unsigned int vs_tag_t;
8739 typedef unsigned long uintptr_t;
8741 diff -NurpP --minimal linux-3.6.9/include/linux/utsname.h linux-3.6.9-vs2.3.4.4/include/linux/utsname.h
8742 --- linux-3.6.9/include/linux/utsname.h 2012-01-09 16:14:59.000000000 +0100
8743 +++ linux-3.6.9-vs2.3.4.4/include/linux/utsname.h 2012-10-04 18:47:00.000000000 +0200
8744 @@ -62,7 +62,8 @@ static inline void get_uts_ns(struct uts
8747 extern struct uts_namespace *copy_utsname(unsigned long flags,
8748 - struct task_struct *tsk);
8749 + struct uts_namespace *old_ns,
8750 + struct user_namespace *user_ns);
8751 extern void free_uts_ns(struct kref *kref);
8753 static inline void put_uts_ns(struct uts_namespace *ns)
8754 @@ -79,12 +80,13 @@ static inline void put_uts_ns(struct uts
8757 static inline struct uts_namespace *copy_utsname(unsigned long flags,
8758 - struct task_struct *tsk)
8759 + struct uts_namespace *old_ns,
8760 + struct user_namespace *user_ns)
8762 if (flags & CLONE_NEWUTS)
8763 return ERR_PTR(-EINVAL);
8765 - return tsk->nsproxy->uts_ns;
8770 diff -NurpP --minimal linux-3.6.9/include/linux/vroot.h linux-3.6.9-vs2.3.4.4/include/linux/vroot.h
8771 --- linux-3.6.9/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
8772 +++ linux-3.6.9-vs2.3.4.4/include/linux/vroot.h 2012-10-04 18:47:00.000000000 +0200
8776 + * include/linux/vroot.h
8778 + * written by Herbert Pötzl, 9/11/2002
8779 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
8781 + * Copyright (C) 2002-2007 by Herbert Pötzl.
8782 + * Redistribution of this file is permitted under the
8783 + * GNU General Public License.
8786 +#ifndef _LINUX_VROOT_H
8787 +#define _LINUX_VROOT_H
8792 +/* Possible states of device */
8798 +struct vroot_device {
8802 + struct semaphore vr_ctl_mutex;
8803 + struct block_device *vr_device;
8808 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
8810 +extern int register_vroot_grb(vroot_grb_func *);
8811 +extern int unregister_vroot_grb(vroot_grb_func *);
8813 +#endif /* __KERNEL__ */
8815 +#define MAX_VROOT_DEFAULT 8
8818 + * IOCTL commands --- we will commandeer 0x56 ('V')
8821 +#define VROOT_SET_DEV 0x5600
8822 +#define VROOT_CLR_DEV 0x5601
8824 +#endif /* _LINUX_VROOT_H */
8825 diff -NurpP --minimal linux-3.6.9/include/linux/vs_base.h linux-3.6.9-vs2.3.4.4/include/linux/vs_base.h
8826 --- linux-3.6.9/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
8827 +++ linux-3.6.9-vs2.3.4.4/include/linux/vs_base.h 2012-10-04 18:47:00.000000000 +0200
8832 +#include "vserver/base.h"
8833 +#include "vserver/check.h"
8834 +#include "vserver/debug.h"
8837 +#warning duplicate inclusion
8839 diff -NurpP --minimal linux-3.6.9/include/linux/vs_context.h linux-3.6.9-vs2.3.4.4/include/linux/vs_context.h
8840 --- linux-3.6.9/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
8841 +++ linux-3.6.9-vs2.3.4.4/include/linux/vs_context.h 2012-10-04 18:47:00.000000000 +0200
8843 +#ifndef _VS_CONTEXT_H
8844 +#define _VS_CONTEXT_H
8846 +#include "vserver/base.h"
8847 +#include "vserver/check.h"
8848 +#include "vserver/context.h"
8849 +#include "vserver/history.h"
8850 +#include "vserver/debug.h"
8852 +#include <linux/sched.h>
8855 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
8857 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
8858 + const char *_file, int _line, void *_here)
8863 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
8864 + vxi, vxi ? vxi->vx_id : 0,
8865 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8867 + __vxh_get_vx_info(vxi, _here);
8869 + atomic_inc(&vxi->vx_usecnt);
8874 +extern void free_vx_info(struct vx_info *);
8876 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
8878 +static inline void __put_vx_info(struct vx_info *vxi,
8879 + const char *_file, int _line, void *_here)
8884 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
8885 + vxi, vxi ? vxi->vx_id : 0,
8886 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8888 + __vxh_put_vx_info(vxi, _here);
8890 + if (atomic_dec_and_test(&vxi->vx_usecnt))
8891 + free_vx_info(vxi);
8895 +#define init_vx_info(p, i) \
8896 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
8898 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
8899 + const char *_file, int _line, void *_here)
8902 + vxlprintk(VXD_CBIT(xid, 3),
8903 + "init_vx_info(%p[#%d.%d])",
8904 + vxi, vxi ? vxi->vx_id : 0,
8905 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8907 + __vxh_init_vx_info(vxi, vxp, _here);
8909 + atomic_inc(&vxi->vx_usecnt);
8915 +#define set_vx_info(p, i) \
8916 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
8918 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
8919 + const char *_file, int _line, void *_here)
8921 + struct vx_info *vxo;
8926 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
8927 + vxi, vxi ? vxi->vx_id : 0,
8928 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8930 + __vxh_set_vx_info(vxi, vxp, _here);
8932 + atomic_inc(&vxi->vx_usecnt);
8933 + vxo = xchg(vxp, vxi);
8938 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
8940 +static inline void __clr_vx_info(struct vx_info **vxp,
8941 + const char *_file, int _line, void *_here)
8943 + struct vx_info *vxo;
8945 + vxo = xchg(vxp, NULL);
8949 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
8950 + vxo, vxo ? vxo->vx_id : 0,
8951 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
8953 + __vxh_clr_vx_info(vxo, vxp, _here);
8955 + if (atomic_dec_and_test(&vxo->vx_usecnt))
8956 + free_vx_info(vxo);
8960 +#define claim_vx_info(v, p) \
8961 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
8963 +static inline void __claim_vx_info(struct vx_info *vxi,
8964 + struct task_struct *task,
8965 + const char *_file, int _line, void *_here)
8967 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
8968 + vxi, vxi ? vxi->vx_id : 0,
8969 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8970 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
8971 + task, _file, _line);
8972 + __vxh_claim_vx_info(vxi, task, _here);
8974 + atomic_inc(&vxi->vx_tasks);
8978 +extern void unhash_vx_info(struct vx_info *);
8980 +#define release_vx_info(v, p) \
8981 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
8983 +static inline void __release_vx_info(struct vx_info *vxi,
8984 + struct task_struct *task,
8985 + const char *_file, int _line, void *_here)
8987 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
8988 + vxi, vxi ? vxi->vx_id : 0,
8989 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8990 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
8991 + task, _file, _line);
8992 + __vxh_release_vx_info(vxi, task, _here);
8996 + if (atomic_dec_and_test(&vxi->vx_tasks))
8997 + unhash_vx_info(vxi);
9001 +#define task_get_vx_info(p) \
9002 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
9004 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
9005 + const char *_file, int _line, void *_here)
9007 + struct vx_info *vxi;
9010 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
9012 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
9018 +static inline void __wakeup_vx_info(struct vx_info *vxi)
9020 + if (waitqueue_active(&vxi->vx_wait))
9021 + wake_up_interruptible(&vxi->vx_wait);
9025 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
9027 +static inline void __enter_vx_info(struct vx_info *vxi,
9028 + struct vx_info_save *vxis, const char *_file, int _line)
9030 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
9031 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
9032 + current->xid, current->vx_info, _file, _line);
9033 + vxis->vxi = xchg(¤t->vx_info, vxi);
9034 + vxis->xid = current->xid;
9035 + current->xid = vxi ? vxi->vx_id : 0;
9038 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
9040 +static inline void __leave_vx_info(struct vx_info_save *vxis,
9041 + const char *_file, int _line)
9043 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
9044 + vxis, vxis->xid, vxis->vxi, current,
9045 + current->xid, current->vx_info, _file, _line);
9046 + (void)xchg(¤t->vx_info, vxis->vxi);
9047 + current->xid = vxis->xid;
9051 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
9053 + vxis->vxi = xchg(¤t->vx_info, NULL);
9054 + vxis->xid = xchg(¤t->xid, (xid_t)0);
9057 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
9059 + (void)xchg(¤t->xid, vxis->xid);
9060 + (void)xchg(¤t->vx_info, vxis->vxi);
9063 +#define task_is_init(p) \
9064 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
9066 +static inline int __task_is_init(struct task_struct *p,
9067 + const char *_file, int _line, void *_here)
9069 + int is_init = is_global_init(p);
9073 + is_init = p->vx_info->vx_initpid == p->pid;
9078 +extern void exit_vx_info(struct task_struct *, int);
9079 +extern void exit_vx_info_early(struct task_struct *, int);
9083 +#warning duplicate inclusion
9085 diff -NurpP --minimal linux-3.6.9/include/linux/vs_cowbl.h linux-3.6.9-vs2.3.4.4/include/linux/vs_cowbl.h
9086 --- linux-3.6.9/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
9087 +++ linux-3.6.9-vs2.3.4.4/include/linux/vs_cowbl.h 2012-10-04 18:47:00.000000000 +0200
9089 +#ifndef _VS_COWBL_H
9090 +#define _VS_COWBL_H
9092 +#include <linux/fs.h>
9093 +#include <linux/dcache.h>
9094 +#include <linux/namei.h>
9095 +#include <linux/slab.h>
9097 +extern struct dentry *cow_break_link(const char *pathname);
9099 +static inline int cow_check_and_break(struct path *path)
9101 + struct inode *inode = path->dentry->d_inode;
9104 + /* do we need this check? */
9105 + if (IS_RDONLY(inode))
9108 + if (IS_COW(inode)) {
9109 + if (IS_COW_LINK(inode)) {
9110 + struct dentry *new_dentry, *old_dentry = path->dentry;
9113 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
9117 + pp = d_path(path, buf, PATH_MAX);
9118 + new_dentry = cow_break_link(pp);
9120 + if (!IS_ERR(new_dentry)) {
9121 + path->dentry = new_dentry;
9124 + error = PTR_ERR(new_dentry);
9126 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
9127 + inode->i_ctime = CURRENT_TIME;
9128 + mark_inode_dirty(inode);
9135 +#warning duplicate inclusion
9137 diff -NurpP --minimal linux-3.6.9/include/linux/vs_cvirt.h linux-3.6.9-vs2.3.4.4/include/linux/vs_cvirt.h
9138 --- linux-3.6.9/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
9139 +++ linux-3.6.9-vs2.3.4.4/include/linux/vs_cvirt.h 2012-10-04 18:47:00.000000000 +0200
9141 +#ifndef _VS_CVIRT_H
9142 +#define _VS_CVIRT_H
9144 +#include "vserver/cvirt.h"
9145 +#include "vserver/context.h"
9146 +#include "vserver/base.h"
9147 +#include "vserver/check.h"
9148 +#include "vserver/debug.h"
9151 +static inline void vx_activate_task(struct task_struct *p)
9153 + struct vx_info *vxi;
9155 + if ((vxi = p->vx_info)) {
9156 + vx_update_load(vxi);
9157 + atomic_inc(&vxi->cvirt.nr_running);
9161 +static inline void vx_deactivate_task(struct task_struct *p)
9163 + struct vx_info *vxi;
9165 + if ((vxi = p->vx_info)) {
9166 + vx_update_load(vxi);
9167 + atomic_dec(&vxi->cvirt.nr_running);
9171 +static inline void vx_uninterruptible_inc(struct task_struct *p)
9173 + struct vx_info *vxi;
9175 + if ((vxi = p->vx_info))
9176 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
9179 +static inline void vx_uninterruptible_dec(struct task_struct *p)
9181 + struct vx_info *vxi;
9183 + if ((vxi = p->vx_info))
9184 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
9189 +#warning duplicate inclusion
9191 diff -NurpP --minimal linux-3.6.9/include/linux/vs_device.h linux-3.6.9-vs2.3.4.4/include/linux/vs_device.h
9192 --- linux-3.6.9/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
9193 +++ linux-3.6.9-vs2.3.4.4/include/linux/vs_device.h 2012-10-04 18:47:00.000000000 +0200
9195 +#ifndef _VS_DEVICE_H
9196 +#define _VS_DEVICE_H
9198 +#include "vserver/base.h"
9199 +#include "vserver/device.h"
9200 +#include "vserver/debug.h"
9203 +#ifdef CONFIG_VSERVER_DEVICE
9205 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
9207 +#define vs_device_perm(v, d, m, p) \
9208 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
9213 +int vs_map_device(struct vx_info *vxi,
9214 + dev_t device, dev_t *target, umode_t mode)
9221 +#define vs_device_perm(v, d, m, p) ((p) == (p))
9226 +#define vs_map_chrdev(d, t, p) \
9227 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
9228 +#define vs_map_blkdev(d, t, p) \
9229 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
9231 +#define vs_chrdev_perm(d, p) \
9232 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
9233 +#define vs_blkdev_perm(d, p) \
9234 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
9238 +#warning duplicate inclusion
9240 diff -NurpP --minimal linux-3.6.9/include/linux/vs_dlimit.h linux-3.6.9-vs2.3.4.4/include/linux/vs_dlimit.h
9241 --- linux-3.6.9/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
9242 +++ linux-3.6.9-vs2.3.4.4/include/linux/vs_dlimit.h 2012-10-04 18:47:00.000000000 +0200
9244 +#ifndef _VS_DLIMIT_H
9245 +#define _VS_DLIMIT_H
9247 +#include <linux/fs.h>
9249 +#include "vserver/dlimit.h"
9250 +#include "vserver/base.h"
9251 +#include "vserver/debug.h"
9254 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
9256 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
9257 + const char *_file, int _line)
9261 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
9262 + dli, dli ? dli->dl_tag : 0,
9263 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9265 + atomic_inc(&dli->dl_usecnt);
9270 +#define free_dl_info(i) \
9271 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
9273 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
9275 +static inline void __put_dl_info(struct dl_info *dli,
9276 + const char *_file, int _line)
9280 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
9281 + dli, dli ? dli->dl_tag : 0,
9282 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9284 + if (atomic_dec_and_test(&dli->dl_usecnt))
9285 + free_dl_info(dli);
9289 +#define __dlimit_char(d) ((d) ? '*' : ' ')
9291 +static inline int __dl_alloc_space(struct super_block *sb,
9292 + vs_tag_t tag, dlsize_t nr, const char *file, int line)
9294 + struct dl_info *dli = NULL;
9299 + dli = locate_dl_info(sb, tag);
9303 + spin_lock(&dli->dl_lock);
9304 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
9306 + dli->dl_space_used += nr;
9307 + spin_unlock(&dli->dl_lock);
9310 + vxlprintk(VXD_CBIT(dlim, 1),
9311 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
9312 + sb, tag, __dlimit_char(dli), (long long)nr,
9314 + return ret ? -ENOSPC : 0;
9317 +static inline void __dl_free_space(struct super_block *sb,
9318 + vs_tag_t tag, dlsize_t nr, const char *_file, int _line)
9320 + struct dl_info *dli = NULL;
9324 + dli = locate_dl_info(sb, tag);
9328 + spin_lock(&dli->dl_lock);
9329 + if (dli->dl_space_used > nr)
9330 + dli->dl_space_used -= nr;
9332 + dli->dl_space_used = 0;
9333 + spin_unlock(&dli->dl_lock);
9336 + vxlprintk(VXD_CBIT(dlim, 1),
9337 + "FREE (%p,#%d)%c %lld bytes",
9338 + sb, tag, __dlimit_char(dli), (long long)nr,
9342 +static inline int __dl_alloc_inode(struct super_block *sb,
9343 + vs_tag_t tag, const char *_file, int _line)
9345 + struct dl_info *dli;
9348 + dli = locate_dl_info(sb, tag);
9352 + spin_lock(&dli->dl_lock);
9353 + dli->dl_inodes_used++;
9354 + ret = (dli->dl_inodes_used > dli->dl_inodes_total);
9355 + spin_unlock(&dli->dl_lock);
9358 + vxlprintk(VXD_CBIT(dlim, 0),
9359 + "ALLOC (%p,#%d)%c inode (%d)",
9360 + sb, tag, __dlimit_char(dli), ret, _file, _line);
9361 + return ret ? -ENOSPC : 0;
9364 +static inline void __dl_free_inode(struct super_block *sb,
9365 + vs_tag_t tag, const char *_file, int _line)
9367 + struct dl_info *dli;
9369 + dli = locate_dl_info(sb, tag);
9373 + spin_lock(&dli->dl_lock);
9374 + if (dli->dl_inodes_used > 1)
9375 + dli->dl_inodes_used--;
9377 + dli->dl_inodes_used = 0;
9378 + spin_unlock(&dli->dl_lock);
9381 + vxlprintk(VXD_CBIT(dlim, 0),
9382 + "FREE (%p,#%d)%c inode",
9383 + sb, tag, __dlimit_char(dli), _file, _line);
9386 +static inline void __dl_adjust_block(struct super_block *sb, vs_tag_t tag,
9387 + unsigned long long *free_blocks, unsigned long long *root_blocks,
9388 + const char *_file, int _line)
9390 + struct dl_info *dli;
9391 + uint64_t broot, bfree;
9393 + dli = locate_dl_info(sb, tag);
9397 + spin_lock(&dli->dl_lock);
9398 + broot = (dli->dl_space_total -
9399 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
9400 + >> sb->s_blocksize_bits;
9401 + bfree = (dli->dl_space_total - dli->dl_space_used)
9402 + >> sb->s_blocksize_bits;
9403 + spin_unlock(&dli->dl_lock);
9405 + vxlprintk(VXD_CBIT(dlim, 2),
9406 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
9407 + (long long)bfree, (long long)broot,
9408 + *free_blocks, *root_blocks, dli->dl_nrlmult,
9410 + if (free_blocks) {
9411 + if (*free_blocks > bfree)
9412 + *free_blocks = bfree;
9414 + if (root_blocks) {
9415 + if (*root_blocks > broot)
9416 + *root_blocks = broot;
9421 +#define dl_prealloc_space(in, bytes) \
9422 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9423 + __FILE__, __LINE__ )
9425 +#define dl_alloc_space(in, bytes) \
9426 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9427 + __FILE__, __LINE__ )
9429 +#define dl_reserve_space(in, bytes) \
9430 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9431 + __FILE__, __LINE__ )
9433 +#define dl_claim_space(in, bytes) (0)
9435 +#define dl_release_space(in, bytes) \
9436 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9437 + __FILE__, __LINE__ )
9439 +#define dl_free_space(in, bytes) \
9440 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9441 + __FILE__, __LINE__ )
9445 +#define dl_alloc_inode(in) \
9446 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
9448 +#define dl_free_inode(in) \
9449 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
9452 +#define dl_adjust_block(sb, tag, fb, rb) \
9453 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
9457 +#warning duplicate inclusion
9459 diff -NurpP --minimal linux-3.6.9/include/linux/vs_inet.h linux-3.6.9-vs2.3.4.4/include/linux/vs_inet.h
9460 --- linux-3.6.9/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
9461 +++ linux-3.6.9-vs2.3.4.4/include/linux/vs_inet.h 2012-10-04 18:47:00.000000000 +0200
9466 +#include "vserver/base.h"
9467 +#include "vserver/network.h"
9468 +#include "vserver/debug.h"
9470 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
9472 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
9473 + NIPQUAD((a)->mask), (a)->type
9474 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
9476 +#define NIPQUAD(addr) \
9477 + ((unsigned char *)&addr)[0], \
9478 + ((unsigned char *)&addr)[1], \
9479 + ((unsigned char *)&addr)[2], \
9480 + ((unsigned char *)&addr)[3]
9482 +#define NIPQUAD_FMT "%u.%u.%u.%u"
9486 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
9488 + __be32 ip = nxa->ip[0].s_addr;
9489 + __be32 mask = nxa->mask.s_addr;
9490 + __be32 bcast = ip | ~mask;
9493 + switch (nxa->type & tmask) {
9494 + case NXA_TYPE_MASK:
9495 + ret = (ip == (addr & mask));
9497 + case NXA_TYPE_ADDR:
9501 + /* fall through to broadcast */
9502 + case NXA_MOD_BCAST:
9503 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
9505 + case NXA_TYPE_RANGE:
9506 + ret = ((nxa->ip[0].s_addr <= addr) &&
9507 + (nxa->ip[1].s_addr > addr));
9509 + case NXA_TYPE_ANY:
9514 + vxdprintk(VXD_CBIT(net, 0),
9515 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
9516 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
9521 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
9523 + struct nx_addr_v4 *nxa;
9530 + /* allow 127.0.0.1 when remapping lback */
9531 + if ((tmask & NXA_LOOPBACK) &&
9532 + (addr == IPI_LOOPBACK) &&
9533 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9536 + /* check for lback address */
9537 + if ((tmask & NXA_MOD_LBACK) &&
9538 + (nxi->v4_lback.s_addr == addr))
9541 + /* check for broadcast address */
9542 + if ((tmask & NXA_MOD_BCAST) &&
9543 + (nxi->v4_bcast.s_addr == addr))
9546 + /* check for v4 addresses */
9547 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
9548 + if (v4_addr_match(nxa, addr, tmask))
9552 + vxdprintk(VXD_CBIT(net, 0),
9553 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
9554 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
9559 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
9561 + /* FIXME: needs full range checks */
9562 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
9566 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
9568 + struct nx_addr_v4 *ptr;
9570 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
9571 + if (v4_nx_addr_match(ptr, nxa, mask))
9576 +#include <net/inet_sock.h>
9579 + * Check if a given address matches for a socket
9581 + * nxi: the socket's nx_info if any
9582 + * addr: to be verified address
9585 +int v4_sock_addr_match (
9586 + struct nx_info *nxi,
9587 + struct inet_sock *inet,
9590 + __be32 saddr = inet->inet_rcv_saddr;
9591 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
9593 + if (addr && (saddr == addr || bcast == addr))
9596 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
9601 +/* inet related checks and helpers */
9610 +#include <linux/netdevice.h>
9611 +#include <linux/inetdevice.h>
9612 +#include <net/inet_sock.h>
9613 +#include <net/inet_timewait_sock.h>
9616 +int dev_in_nx_info(struct net_device *, struct nx_info *);
9617 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
9618 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
9622 + * check if address is covered by socket
9624 + * sk: the socket to check against
9625 + * addr: the address in question (must be != 0)
9629 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
9631 + struct nx_info *nxi = sk->sk_nx_info;
9632 + __be32 saddr = sk_rcv_saddr(sk);
9634 + vxdprintk(VXD_CBIT(net, 5),
9635 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
9636 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
9637 + (sk->sk_socket?sk->sk_socket->flags:0));
9639 + if (saddr) { /* direct address match */
9640 + return v4_addr_match(nxa, saddr, -1);
9641 + } else if (nxi) { /* match against nx_info */
9642 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
9643 + } else { /* unrestricted any socket */
9651 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
9653 + vxdprintk(VXD_CBIT(net, 1),
9654 + "nx_dev_visible(%p[#%u],%p " VS_Q("%s") ") %d",
9655 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
9656 + nxi ? dev_in_nx_info(dev, nxi) : 0);
9658 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9660 + if (dev_in_nx_info(dev, nxi))
9667 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
9673 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
9677 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
9679 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
9680 + nxi, nxi ? nxi->nx_id : 0, ifa,
9681 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
9683 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9685 + if (v4_ifa_in_nx_info(ifa, nxi))
9691 +struct nx_v4_sock_addr {
9692 + __be32 saddr; /* Address used for validation */
9693 + __be32 baddr; /* Address used for socket bind */
9697 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
9698 + struct nx_v4_sock_addr *nsa)
9700 + struct sock *sk = &inet->sk;
9701 + struct nx_info *nxi = sk->sk_nx_info;
9702 + __be32 saddr = addr->sin_addr.s_addr;
9703 + __be32 baddr = saddr;
9705 + vxdprintk(VXD_CBIT(net, 3),
9706 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
9707 + sk, sk->sk_nx_info, sk->sk_socket,
9708 + (sk->sk_socket ? sk->sk_socket->flags : 0),
9712 + if (saddr == INADDR_ANY) {
9713 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
9714 + baddr = nxi->v4.ip[0].s_addr;
9715 + } else if (saddr == IPI_LOOPBACK) {
9716 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9717 + baddr = nxi->v4_lback.s_addr;
9718 + } else if (!ipv4_is_multicast(saddr) ||
9719 + !nx_info_ncaps(nxi, NXC_MULTICAST)) {
9720 + /* normal address bind */
9721 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
9722 + return -EADDRNOTAVAIL;
9726 + vxdprintk(VXD_CBIT(net, 3),
9727 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
9728 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
9730 + nsa->saddr = saddr;
9731 + nsa->baddr = baddr;
9736 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
9738 + inet->inet_saddr = nsa->baddr;
9739 + inet->inet_rcv_saddr = nsa->baddr;
9744 + * helper to simplify inet_lookup_listener
9746 + * nxi: the socket's nx_info if any
9747 + * addr: to be verified address
9748 + * saddr: socket address
9750 +static inline int v4_inet_addr_match (
9751 + struct nx_info *nxi,
9755 + if (addr && (saddr == addr))
9758 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
9762 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
9764 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
9765 + (addr == nxi->v4_lback.s_addr))
9766 + return IPI_LOOPBACK;
9771 +int nx_info_has_v4(struct nx_info *nxi)
9777 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9782 +#else /* CONFIG_INET */
9785 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
9791 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
9797 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
9803 +int nx_info_has_v4(struct nx_info *nxi)
9808 +#endif /* CONFIG_INET */
9810 +#define current_nx_info_has_v4() \
9811 + nx_info_has_v4(current_nx_info())
9814 +// #warning duplicate inclusion
9816 diff -NurpP --minimal linux-3.6.9/include/linux/vs_inet6.h linux-3.6.9-vs2.3.4.4/include/linux/vs_inet6.h
9817 --- linux-3.6.9/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
9818 +++ linux-3.6.9-vs2.3.4.4/include/linux/vs_inet6.h 2012-10-04 18:47:00.000000000 +0200
9820 +#ifndef _VS_INET6_H
9821 +#define _VS_INET6_H
9823 +#include "vserver/base.h"
9824 +#include "vserver/network.h"
9825 +#include "vserver/debug.h"
9827 +#include <net/ipv6.h>
9829 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
9830 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
9836 +int v6_addr_match(struct nx_addr_v6 *nxa,
9837 + const struct in6_addr *addr, uint16_t mask)
9841 + switch (nxa->type & mask) {
9842 + case NXA_TYPE_MASK:
9843 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
9845 + case NXA_TYPE_ADDR:
9846 + ret = ipv6_addr_equal(&nxa->ip, addr);
9848 + case NXA_TYPE_ANY:
9852 + vxdprintk(VXD_CBIT(net, 0),
9853 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
9854 + nxa, NXAV6(nxa), addr, mask, ret);
9859 +int v6_addr_in_nx_info(struct nx_info *nxi,
9860 + const struct in6_addr *addr, uint16_t mask)
9862 + struct nx_addr_v6 *nxa;
9867 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
9868 + if (v6_addr_match(nxa, addr, mask))
9872 + vxdprintk(VXD_CBIT(net, 0),
9873 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
9874 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
9879 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
9881 + /* FIXME: needs full range checks */
9882 + return v6_addr_match(nxa, &addr->ip, mask);
9886 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
9888 + struct nx_addr_v6 *ptr;
9890 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
9891 + if (v6_nx_addr_match(ptr, nxa, mask))
9898 + * Check if a given address matches for a socket
9900 + * nxi: the socket's nx_info if any
9901 + * addr: to be verified address
9904 +int v6_sock_addr_match (
9905 + struct nx_info *nxi,
9906 + struct inet_sock *inet,
9907 + struct in6_addr *addr)
9909 + struct sock *sk = &inet->sk;
9910 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
9912 + if (!ipv6_addr_any(addr) &&
9913 + ipv6_addr_equal(saddr, addr))
9915 + if (ipv6_addr_any(saddr))
9916 + return v6_addr_in_nx_info(nxi, addr, -1);
9921 + * check if address is covered by socket
9923 + * sk: the socket to check against
9924 + * addr: the address in question (must be != 0)
9928 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
9930 + struct nx_info *nxi = sk->sk_nx_info;
9931 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
9933 + vxdprintk(VXD_CBIT(net, 5),
9934 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
9935 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
9936 + (sk->sk_socket?sk->sk_socket->flags:0));
9938 + if (!ipv6_addr_any(saddr)) { /* direct address match */
9939 + return v6_addr_match(nxa, saddr, -1);
9940 + } else if (nxi) { /* match against nx_info */
9941 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
9942 + } else { /* unrestricted any socket */
9948 +/* inet related checks and helpers */
9956 +#include <linux/netdevice.h>
9957 +#include <linux/inetdevice.h>
9958 +#include <net/inet_timewait_sock.h>
9961 +int dev_in_nx_info(struct net_device *, struct nx_info *);
9962 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
9963 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
9968 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
9974 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
9978 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
9980 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
9981 + nxi, nxi ? nxi->nx_id : 0, ifa,
9982 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
9984 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9986 + if (v6_ifa_in_nx_info(ifa, nxi))
9992 +struct nx_v6_sock_addr {
9993 + struct in6_addr saddr; /* Address used for validation */
9994 + struct in6_addr baddr; /* Address used for socket bind */
9998 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
9999 + struct nx_v6_sock_addr *nsa)
10001 + // struct sock *sk = &inet->sk;
10002 + // struct nx_info *nxi = sk->sk_nx_info;
10003 + struct in6_addr saddr = addr->sin6_addr;
10004 + struct in6_addr baddr = saddr;
10006 + nsa->saddr = saddr;
10007 + nsa->baddr = baddr;
10012 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
10014 + // struct sock *sk = &inet->sk;
10015 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
10017 + // *saddr = nsa->baddr;
10018 + // inet->inet_saddr = nsa->baddr;
10022 +int nx_info_has_v6(struct nx_info *nxi)
10026 + if (NX_IPV6(nxi))
10031 +#else /* CONFIG_IPV6 */
10034 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
10041 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
10047 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
10053 +int nx_info_has_v6(struct nx_info *nxi)
10058 +#endif /* CONFIG_IPV6 */
10060 +#define current_nx_info_has_v6() \
10061 + nx_info_has_v6(current_nx_info())
10064 +#warning duplicate inclusion
10066 diff -NurpP --minimal linux-3.6.9/include/linux/vs_limit.h linux-3.6.9-vs2.3.4.4/include/linux/vs_limit.h
10067 --- linux-3.6.9/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
10068 +++ linux-3.6.9-vs2.3.4.4/include/linux/vs_limit.h 2012-10-04 18:47:00.000000000 +0200
10070 +#ifndef _VS_LIMIT_H
10071 +#define _VS_LIMIT_H
10073 +#include "vserver/limit.h"
10074 +#include "vserver/base.h"
10075 +#include "vserver/context.h"
10076 +#include "vserver/debug.h"
10077 +#include "vserver/context.h"
10078 +#include "vserver/limit_int.h"
10081 +#define vx_acc_cres(v, d, p, r) \
10082 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
10084 +#define vx_acc_cres_cond(x, d, p, r) \
10085 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
10086 + r, d, p, __FILE__, __LINE__)
10089 +#define vx_add_cres(v, a, p, r) \
10090 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
10091 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
10093 +#define vx_add_cres_cond(x, a, p, r) \
10094 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
10095 + r, a, p, __FILE__, __LINE__)
10096 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
10099 +/* process and file limits */
10101 +#define vx_nproc_inc(p) \
10102 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
10104 +#define vx_nproc_dec(p) \
10105 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
10107 +#define vx_files_inc(f) \
10108 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
10110 +#define vx_files_dec(f) \
10111 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
10113 +#define vx_locks_inc(l) \
10114 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
10116 +#define vx_locks_dec(l) \
10117 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
10119 +#define vx_openfd_inc(f) \
10120 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
10122 +#define vx_openfd_dec(f) \
10123 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
10126 +#define vx_cres_avail(v, n, r) \
10127 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
10130 +#define vx_nproc_avail(n) \
10131 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
10133 +#define vx_files_avail(n) \
10134 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
10136 +#define vx_locks_avail(n) \
10137 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
10139 +#define vx_openfd_avail(n) \
10140 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
10143 +/* dentry limits */
10145 +#define vx_dentry_inc(d) do { \
10146 + if ((d)->d_count == 1) \
10147 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
10150 +#define vx_dentry_dec(d) do { \
10151 + if ((d)->d_count == 0) \
10152 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
10155 +#define vx_dentry_avail(n) \
10156 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
10159 +/* socket limits */
10161 +#define vx_sock_inc(s) \
10162 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
10164 +#define vx_sock_dec(s) \
10165 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
10167 +#define vx_sock_avail(n) \
10168 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
10171 +/* ipc resource limits */
10173 +#define vx_ipcmsg_add(v, u, a) \
10174 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
10176 +#define vx_ipcmsg_sub(v, u, a) \
10177 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
10179 +#define vx_ipcmsg_avail(v, a) \
10180 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
10183 +#define vx_ipcshm_add(v, k, a) \
10184 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
10186 +#define vx_ipcshm_sub(v, k, a) \
10187 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
10189 +#define vx_ipcshm_avail(v, a) \
10190 + vx_cres_avail(v, a, VLIMIT_SHMEM)
10193 +#define vx_semary_inc(a) \
10194 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
10196 +#define vx_semary_dec(a) \
10197 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
10200 +#define vx_nsems_add(a,n) \
10201 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10203 +#define vx_nsems_sub(a,n) \
10204 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10208 +#warning duplicate inclusion
10210 diff -NurpP --minimal linux-3.6.9/include/linux/vs_network.h linux-3.6.9-vs2.3.4.4/include/linux/vs_network.h
10211 --- linux-3.6.9/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
10212 +++ linux-3.6.9-vs2.3.4.4/include/linux/vs_network.h 2012-10-04 18:47:00.000000000 +0200
10214 +#ifndef _NX_VS_NETWORK_H
10215 +#define _NX_VS_NETWORK_H
10217 +#include "vserver/context.h"
10218 +#include "vserver/network.h"
10219 +#include "vserver/base.h"
10220 +#include "vserver/check.h"
10221 +#include "vserver/debug.h"
10223 +#include <linux/sched.h>
10226 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
10228 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
10229 + const char *_file, int _line)
10234 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
10235 + nxi, nxi ? nxi->nx_id : 0,
10236 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10239 + atomic_inc(&nxi->nx_usecnt);
10244 +extern void free_nx_info(struct nx_info *);
10246 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
10248 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
10253 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
10254 + nxi, nxi ? nxi->nx_id : 0,
10255 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10258 + if (atomic_dec_and_test(&nxi->nx_usecnt))
10259 + free_nx_info(nxi);
10263 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
10265 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
10266 + const char *_file, int _line)
10269 + vxlprintk(VXD_CBIT(nid, 3),
10270 + "init_nx_info(%p[#%d.%d])",
10271 + nxi, nxi ? nxi->nx_id : 0,
10272 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10275 + atomic_inc(&nxi->nx_usecnt);
10281 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
10283 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
10284 + const char *_file, int _line)
10286 + struct nx_info *nxo;
10291 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
10292 + nxi, nxi ? nxi->nx_id : 0,
10293 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10296 + atomic_inc(&nxi->nx_usecnt);
10297 + nxo = xchg(nxp, nxi);
10301 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
10303 +static inline void __clr_nx_info(struct nx_info **nxp,
10304 + const char *_file, int _line)
10306 + struct nx_info *nxo;
10308 + nxo = xchg(nxp, NULL);
10312 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
10313 + nxo, nxo ? nxo->nx_id : 0,
10314 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
10317 + if (atomic_dec_and_test(&nxo->nx_usecnt))
10318 + free_nx_info(nxo);
10322 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
10324 +static inline void __claim_nx_info(struct nx_info *nxi,
10325 + struct task_struct *task, const char *_file, int _line)
10327 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
10328 + nxi, nxi ? nxi->nx_id : 0,
10329 + nxi?atomic_read(&nxi->nx_usecnt):0,
10330 + nxi?atomic_read(&nxi->nx_tasks):0,
10331 + task, _file, _line);
10333 + atomic_inc(&nxi->nx_tasks);
10337 +extern void unhash_nx_info(struct nx_info *);
10339 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
10341 +static inline void __release_nx_info(struct nx_info *nxi,
10342 + struct task_struct *task, const char *_file, int _line)
10344 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
10345 + nxi, nxi ? nxi->nx_id : 0,
10346 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10347 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
10348 + task, _file, _line);
10352 + if (atomic_dec_and_test(&nxi->nx_tasks))
10353 + unhash_nx_info(nxi);
10357 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
10359 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
10360 + const char *_file, int _line)
10362 + struct nx_info *nxi;
10365 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
10366 + p, _file, _line);
10367 + nxi = __get_nx_info(p->nx_info, _file, _line);
10373 +static inline void exit_nx_info(struct task_struct *p)
10376 + release_nx_info(p->nx_info, p);
10381 +#warning duplicate inclusion
10383 diff -NurpP --minimal linux-3.6.9/include/linux/vs_pid.h linux-3.6.9-vs2.3.4.4/include/linux/vs_pid.h
10384 --- linux-3.6.9/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
10385 +++ linux-3.6.9-vs2.3.4.4/include/linux/vs_pid.h 2012-10-04 18:47:00.000000000 +0200
10390 +#include "vserver/base.h"
10391 +#include "vserver/check.h"
10392 +#include "vserver/context.h"
10393 +#include "vserver/debug.h"
10394 +#include "vserver/pid.h"
10395 +#include <linux/pid_namespace.h>
10398 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
10401 +int vx_proc_task_visible(struct task_struct *task)
10403 + if ((task->pid == 1) &&
10404 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
10405 + /* show a blend through init */
10407 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
10414 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
10418 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
10420 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
10422 + if (task && !vx_proc_task_visible(task)) {
10423 + vxdprintk(VXD_CBIT(misc, 6),
10424 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
10425 + task, task->xid, task->pid,
10426 + current, current->xid, current->pid);
10427 + put_task_struct(task);
10435 +#warning duplicate inclusion
10437 diff -NurpP --minimal linux-3.6.9/include/linux/vs_sched.h linux-3.6.9-vs2.3.4.4/include/linux/vs_sched.h
10438 --- linux-3.6.9/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
10439 +++ linux-3.6.9-vs2.3.4.4/include/linux/vs_sched.h 2012-10-04 18:47:00.000000000 +0200
10441 +#ifndef _VS_SCHED_H
10442 +#define _VS_SCHED_H
10444 +#include "vserver/base.h"
10445 +#include "vserver/context.h"
10446 +#include "vserver/sched.h"
10449 +#define MAX_PRIO_BIAS 20
10450 +#define MIN_PRIO_BIAS -20
10453 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
10455 + struct vx_info *vxi = p->vx_info;
10458 + prio += vx_cpu(vxi, sched_pc).prio_bias;
10462 +static inline void vx_account_user(struct vx_info *vxi,
10463 + cputime_t cputime, int nice)
10467 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
10470 +static inline void vx_account_system(struct vx_info *vxi,
10471 + cputime_t cputime, int idle)
10475 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
10479 +#warning duplicate inclusion
10481 diff -NurpP --minimal linux-3.6.9/include/linux/vs_socket.h linux-3.6.9-vs2.3.4.4/include/linux/vs_socket.h
10482 --- linux-3.6.9/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
10483 +++ linux-3.6.9-vs2.3.4.4/include/linux/vs_socket.h 2012-10-04 18:47:00.000000000 +0200
10485 +#ifndef _VS_SOCKET_H
10486 +#define _VS_SOCKET_H
10488 +#include "vserver/debug.h"
10489 +#include "vserver/base.h"
10490 +#include "vserver/cacct.h"
10491 +#include "vserver/context.h"
10492 +#include "vserver/tag.h"
10495 +/* socket accounting */
10497 +#include <linux/socket.h>
10499 +static inline int vx_sock_type(int family)
10501 + switch (family) {
10503 + return VXA_SOCK_UNSPEC;
10505 + return VXA_SOCK_UNIX;
10507 + return VXA_SOCK_INET;
10509 + return VXA_SOCK_INET6;
10511 + return VXA_SOCK_PACKET;
10513 + return VXA_SOCK_OTHER;
10517 +#define vx_acc_sock(v, f, p, s) \
10518 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
10520 +static inline void __vx_acc_sock(struct vx_info *vxi,
10521 + int family, int pos, int size, char *file, int line)
10524 + int type = vx_sock_type(family);
10526 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
10527 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
10531 +#define vx_sock_recv(sk, s) \
10532 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
10533 +#define vx_sock_send(sk, s) \
10534 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
10535 +#define vx_sock_fail(sk, s) \
10536 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
10539 +#define sock_vx_init(s) do { \
10540 + (s)->sk_xid = 0; \
10541 + (s)->sk_vx_info = NULL; \
10544 +#define sock_nx_init(s) do { \
10545 + (s)->sk_nid = 0; \
10546 + (s)->sk_nx_info = NULL; \
10550 +#warning duplicate inclusion
10552 diff -NurpP --minimal linux-3.6.9/include/linux/vs_tag.h linux-3.6.9-vs2.3.4.4/include/linux/vs_tag.h
10553 --- linux-3.6.9/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
10554 +++ linux-3.6.9-vs2.3.4.4/include/linux/vs_tag.h 2012-10-04 18:47:00.000000000 +0200
10559 +#include <linux/vserver/tag.h>
10561 +/* check conditions */
10563 +#define DX_ADMIN 0x0001
10564 +#define DX_WATCH 0x0002
10565 +#define DX_HOSTID 0x0008
10567 +#define DX_IDENT 0x0010
10569 +#define DX_ARG_MASK 0x0010
10572 +#define dx_task_tag(t) ((t)->tag)
10574 +#define dx_current_tag() dx_task_tag(current)
10576 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
10578 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
10582 + * check current context for ADMIN/WATCH and
10583 + * optionally against supplied argument
10585 +static inline int __dx_check(vs_tag_t cid, vs_tag_t id, unsigned int mode)
10587 + if (mode & DX_ARG_MASK) {
10588 + if ((mode & DX_IDENT) && (id == cid))
10591 + return (((mode & DX_ADMIN) && (cid == 0)) ||
10592 + ((mode & DX_WATCH) && (cid == 1)) ||
10593 + ((mode & DX_HOSTID) && (id == 0)));
10597 +int dx_permission(const struct inode *inode, int mask);
10601 +#warning duplicate inclusion
10603 diff -NurpP --minimal linux-3.6.9/include/linux/vs_time.h linux-3.6.9-vs2.3.4.4/include/linux/vs_time.h
10604 --- linux-3.6.9/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
10605 +++ linux-3.6.9-vs2.3.4.4/include/linux/vs_time.h 2012-10-04 18:47:00.000000000 +0200
10607 +#ifndef _VS_TIME_H
10608 +#define _VS_TIME_H
10611 +/* time faking stuff */
10613 +#ifdef CONFIG_VSERVER_VTIME
10615 +extern void vx_adjust_timespec(struct timespec *ts);
10616 +extern int vx_settimeofday(const struct timespec *ts);
10619 +#define vx_adjust_timespec(t) do { } while (0)
10620 +#define vx_settimeofday(t) do_settimeofday(t)
10624 +#warning duplicate inclusion
10626 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/Kbuild linux-3.6.9-vs2.3.4.4/include/linux/vserver/Kbuild
10627 --- linux-3.6.9/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
10628 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/Kbuild 2012-10-04 18:47:00.000000000 +0200
10631 +header-y += context_cmd.h network_cmd.h space_cmd.h \
10632 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
10633 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
10634 + debug_cmd.h device_cmd.h
10636 +header-y += switch.h network.h monitor.h inode.h device.h
10638 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/base.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/base.h
10639 --- linux-3.6.9/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
10640 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/base.h 2012-10-04 18:47:00.000000000 +0200
10642 +#ifndef _VX_BASE_H
10643 +#define _VX_BASE_H
10646 +/* context state changes */
10658 +#define vx_task_xid(t) ((t)->xid)
10660 +#define vx_current_xid() vx_task_xid(current)
10662 +#define current_vx_info() (current->vx_info)
10665 +#define nx_task_nid(t) ((t)->nid)
10667 +#define nx_current_nid() nx_task_nid(current)
10669 +#define current_nx_info() (current->nx_info)
10672 +/* generic flag merging */
10674 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
10676 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
10678 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
10680 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
10683 +/* context flags */
10685 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
10687 +#define vx_current_flags() __vx_flags(current_vx_info())
10689 +#define vx_info_flags(v, m, f) \
10690 + vs_check_flags(__vx_flags(v), m, f)
10692 +#define task_vx_flags(t, m, f) \
10693 + ((t) && vx_info_flags((t)->vx_info, m, f))
10695 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
10698 +/* context caps */
10700 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
10702 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
10704 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
10706 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
10710 +/* network flags */
10712 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
10714 +#define nx_current_flags() __nx_flags(current_nx_info())
10716 +#define nx_info_flags(n, m, f) \
10717 + vs_check_flags(__nx_flags(n), m, f)
10719 +#define task_nx_flags(t, m, f) \
10720 + ((t) && nx_info_flags((t)->nx_info, m, f))
10722 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
10725 +/* network caps */
10727 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
10729 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
10731 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
10733 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
10736 +/* context mask capabilities */
10738 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
10740 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
10742 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
10745 +/* context bcap mask */
10747 +#define __vx_bcaps(v) ((v)->vx_bcaps)
10749 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
10752 +/* mask given bcaps */
10754 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
10756 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
10759 +/* masked cap_bset */
10761 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
10763 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
10766 +#define vx_info_mbcap(v, b) \
10767 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
10768 + vx_info_bcaps(v, b) : (b))
10770 +#define task_vx_mbcap(t, b) \
10771 + vx_info_mbcap((t)->vx_info, (t)->b)
10773 +#define vx_mbcap(b) task_vx_mbcap(current, b)
10776 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
10778 +#define vx_capable(b, c) (capable(b) || \
10779 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10781 +#define vx_ns_capable(n, b, c) (ns_capable(n, b) || \
10782 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10784 +#define nx_capable(b, c) (capable(b) || \
10785 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
10787 +#define vx_task_initpid(t, n) \
10788 + ((t)->vx_info && \
10789 + ((t)->vx_info->vx_initpid == (n)))
10791 +#define vx_current_initpid(n) vx_task_initpid(current, n)
10794 +/* context unshare mask */
10796 +#define __vx_umask(v) ((v)->vx_umask)
10798 +#define vx_current_umask() __vx_umask(current_vx_info())
10800 +#define vx_can_unshare(b, f) (capable(b) || \
10801 + (cap_raised(current_cap(), b) && \
10802 + !((f) & ~vx_current_umask())))
10805 +#define __vx_wmask(v) ((v)->vx_wmask)
10807 +#define vx_current_wmask() __vx_wmask(current_vx_info())
10810 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
10812 +#define vx_info_state(v, m) (__vx_state(v) & (m))
10815 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
10817 +#define nx_info_state(n, m) (__nx_state(n) & (m))
10820 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/cacct.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/cacct.h
10821 --- linux-3.6.9/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
10822 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/cacct.h 2012-10-04 18:47:00.000000000 +0200
10824 +#ifndef _VX_CACCT_H
10825 +#define _VX_CACCT_H
10828 +enum sock_acc_field {
10829 + VXA_SOCK_UNSPEC = 0,
10835 + VXA_SOCK_SIZE /* array size */
10838 +#endif /* _VX_CACCT_H */
10839 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/cacct_cmd.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/cacct_cmd.h
10840 --- linux-3.6.9/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
10841 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/cacct_cmd.h 2012-10-04 18:47:00.000000000 +0200
10843 +#ifndef _VX_CACCT_CMD_H
10844 +#define _VX_CACCT_CMD_H
10847 +/* virtual host info name commands */
10849 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
10851 +struct vcmd_sock_stat_v0 {
10853 + uint32_t count[3];
10854 + uint64_t total[3];
10860 +#include <linux/compiler.h>
10862 +extern int vc_sock_stat(struct vx_info *, void __user *);
10864 +#endif /* __KERNEL__ */
10865 +#endif /* _VX_CACCT_CMD_H */
10866 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/cacct_def.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/cacct_def.h
10867 --- linux-3.6.9/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
10868 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/cacct_def.h 2012-10-04 18:47:00.000000000 +0200
10870 +#ifndef _VX_CACCT_DEF_H
10871 +#define _VX_CACCT_DEF_H
10873 +#include <asm/atomic.h>
10874 +#include <linux/vserver/cacct.h>
10877 +struct _vx_sock_acc {
10878 + atomic_long_t count;
10879 + atomic_long_t total;
10882 +/* context sub struct */
10884 +struct _vx_cacct {
10885 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
10886 + atomic_t slab[8];
10887 + atomic_t page[6][8];
10890 +#ifdef CONFIG_VSERVER_DEBUG
10892 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
10896 + printk("\t_vx_cacct:");
10897 + for (i = 0; i < 6; i++) {
10898 + struct _vx_sock_acc *ptr = cacct->sock[i];
10900 + printk("\t [%d] =", i);
10901 + for (j = 0; j < 3; j++) {
10902 + printk(" [%d] = %8lu, %8lu", j,
10903 + atomic_long_read(&ptr[j].count),
10904 + atomic_long_read(&ptr[j].total));
10912 +#endif /* _VX_CACCT_DEF_H */
10913 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/cacct_int.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/cacct_int.h
10914 --- linux-3.6.9/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
10915 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/cacct_int.h 2012-10-04 18:47:00.000000000 +0200
10917 +#ifndef _VX_CACCT_INT_H
10918 +#define _VX_CACCT_INT_H
10924 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
10926 + return atomic_long_read(&cacct->sock[type][pos].count);
10931 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
10933 + return atomic_long_read(&cacct->sock[type][pos].total);
10936 +#endif /* __KERNEL__ */
10937 +#endif /* _VX_CACCT_INT_H */
10938 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/check.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/check.h
10939 --- linux-3.6.9/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
10940 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/check.h 2012-10-04 18:47:00.000000000 +0200
10942 +#ifndef _VS_CHECK_H
10943 +#define _VS_CHECK_H
10946 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
10948 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
10949 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
10951 +#define MIN_D_CONTEXT 65536
10954 +/* check conditions */
10956 +#define VS_ADMIN 0x0001
10957 +#define VS_WATCH 0x0002
10958 +#define VS_HIDE 0x0004
10959 +#define VS_HOSTID 0x0008
10961 +#define VS_IDENT 0x0010
10962 +#define VS_EQUIV 0x0020
10963 +#define VS_PARENT 0x0040
10964 +#define VS_CHILD 0x0080
10966 +#define VS_ARG_MASK 0x00F0
10968 +#define VS_DYNAMIC 0x0100
10969 +#define VS_STATIC 0x0200
10971 +#define VS_ATR_MASK 0x0F00
10973 +#ifdef CONFIG_VSERVER_PRIVACY
10974 +#define VS_ADMIN_P (0)
10975 +#define VS_WATCH_P (0)
10977 +#define VS_ADMIN_P VS_ADMIN
10978 +#define VS_WATCH_P VS_WATCH
10981 +#define VS_HARDIRQ 0x1000
10982 +#define VS_SOFTIRQ 0x2000
10983 +#define VS_IRQ 0x4000
10985 +#define VS_IRQ_MASK 0xF000
10987 +#include <linux/hardirq.h>
10990 + * check current context for ADMIN/WATCH and
10991 + * optionally against supplied argument
10993 +static inline int __vs_check(int cid, int id, unsigned int mode)
10995 + if (mode & VS_ARG_MASK) {
10996 + if ((mode & VS_IDENT) && (id == cid))
10999 + if (mode & VS_ATR_MASK) {
11000 + if ((mode & VS_DYNAMIC) &&
11001 + (id >= MIN_D_CONTEXT) &&
11002 + (id <= MAX_S_CONTEXT))
11004 + if ((mode & VS_STATIC) &&
11005 + (id > 1) && (id < MIN_D_CONTEXT))
11008 + if (mode & VS_IRQ_MASK) {
11009 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
11011 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
11013 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
11016 + return (((mode & VS_ADMIN) && (cid == 0)) ||
11017 + ((mode & VS_WATCH) && (cid == 1)) ||
11018 + ((mode & VS_HOSTID) && (id == 0)));
11021 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
11023 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
11026 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
11028 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
11031 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/context.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/context.h
11032 --- linux-3.6.9/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
11033 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/context.h 2012-10-04 18:47:00.000000000 +0200
11035 +#ifndef _VX_CONTEXT_H
11036 +#define _VX_CONTEXT_H
11038 +#include <linux/types.h>
11039 +#include <linux/capability.h>
11042 +/* context flags */
11044 +#define VXF_INFO_SCHED 0x00000002
11045 +#define VXF_INFO_NPROC 0x00000004
11046 +#define VXF_INFO_PRIVATE 0x00000008
11048 +#define VXF_INFO_INIT 0x00000010
11049 +#define VXF_INFO_HIDE 0x00000020
11050 +#define VXF_INFO_ULIMIT 0x00000040
11051 +#define VXF_INFO_NSPACE 0x00000080
11053 +#define VXF_SCHED_HARD 0x00000100
11054 +#define VXF_SCHED_PRIO 0x00000200
11055 +#define VXF_SCHED_PAUSE 0x00000400
11057 +#define VXF_VIRT_MEM 0x00010000
11058 +#define VXF_VIRT_UPTIME 0x00020000
11059 +#define VXF_VIRT_CPU 0x00040000
11060 +#define VXF_VIRT_LOAD 0x00080000
11061 +#define VXF_VIRT_TIME 0x00100000
11063 +#define VXF_HIDE_MOUNT 0x01000000
11064 +/* was VXF_HIDE_NETIF 0x02000000 */
11065 +#define VXF_HIDE_VINFO 0x04000000
11067 +#define VXF_STATE_SETUP (1ULL << 32)
11068 +#define VXF_STATE_INIT (1ULL << 33)
11069 +#define VXF_STATE_ADMIN (1ULL << 34)
11071 +#define VXF_SC_HELPER (1ULL << 36)
11072 +#define VXF_REBOOT_KILL (1ULL << 37)
11073 +#define VXF_PERSISTENT (1ULL << 38)
11075 +#define VXF_FORK_RSS (1ULL << 48)
11076 +#define VXF_PROLIFIC (1ULL << 49)
11078 +#define VXF_IGNEG_NICE (1ULL << 52)
11080 +#define VXF_ONE_TIME (0x0007ULL << 32)
11082 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
11085 +/* context migration */
11087 +#define VXM_SET_INIT 0x00000001
11088 +#define VXM_SET_REAPER 0x00000002
11090 +/* context caps */
11092 +#define VXC_SET_UTSNAME 0x00000001
11093 +#define VXC_SET_RLIMIT 0x00000002
11094 +#define VXC_FS_SECURITY 0x00000004
11095 +#define VXC_FS_TRUSTED 0x00000008
11096 +#define VXC_TIOCSTI 0x00000010
11098 +/* was VXC_RAW_ICMP 0x00000100 */
11099 +#define VXC_SYSLOG 0x00001000
11100 +#define VXC_OOM_ADJUST 0x00002000
11101 +#define VXC_AUDIT_CONTROL 0x00004000
11103 +#define VXC_SECURE_MOUNT 0x00010000
11104 +#define VXC_SECURE_REMOUNT 0x00020000
11105 +#define VXC_BINARY_MOUNT 0x00040000
11107 +#define VXC_QUOTA_CTL 0x00100000
11108 +#define VXC_ADMIN_MAPPER 0x00200000
11109 +#define VXC_ADMIN_CLOOP 0x00400000
11111 +#define VXC_KTHREAD 0x01000000
11112 +#define VXC_NAMESPACE 0x02000000
11117 +#include <linux/list.h>
11118 +#include <linux/spinlock.h>
11119 +#include <linux/rcupdate.h>
11121 +#include "limit_def.h"
11122 +#include "sched_def.h"
11123 +#include "cvirt_def.h"
11124 +#include "cacct_def.h"
11125 +#include "device_def.h"
11127 +#define VX_SPACES 2
11129 +struct _vx_info_pc {
11130 + struct _vx_sched_pc sched_pc;
11131 + struct _vx_cvirt_pc cvirt_pc;
11134 +struct _vx_space {
11135 + unsigned long vx_nsmask; /* assignment mask */
11136 + struct nsproxy *vx_nsproxy; /* private namespaces */
11137 + struct fs_struct *vx_fs; /* private namespace fs */
11138 + const struct cred *vx_cred; /* task credentials */
11142 + struct hlist_node vx_hlist; /* linked list of contexts */
11143 + xid_t vx_id; /* context id */
11144 + atomic_t vx_usecnt; /* usage count */
11145 + atomic_t vx_tasks; /* tasks count */
11146 + struct vx_info *vx_parent; /* parent context */
11147 + int vx_state; /* context state */
11149 + struct _vx_space space[VX_SPACES]; /* namespace store */
11151 + uint64_t vx_flags; /* context flags */
11152 + uint64_t vx_ccaps; /* context caps (vserver) */
11153 + uint64_t vx_umask; /* unshare mask (guest) */
11154 + uint64_t vx_wmask; /* warn mask (guest) */
11155 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
11157 + struct task_struct *vx_reaper; /* guest reaper process */
11158 + pid_t vx_initpid; /* PID of guest init */
11159 + int64_t vx_badness_bias; /* OOM points bias */
11161 + struct _vx_limit limit; /* vserver limits */
11162 + struct _vx_sched sched; /* vserver scheduler */
11163 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
11164 + struct _vx_cacct cacct; /* context accounting */
11166 + struct _vx_device dmap; /* default device map targets */
11168 +#ifndef CONFIG_SMP
11169 + struct _vx_info_pc info_pc; /* per cpu data */
11171 + struct _vx_info_pc *ptr_pc; /* per cpu array */
11174 + wait_queue_head_t vx_wait; /* context exit waitqueue */
11175 + int reboot_cmd; /* last sys_reboot() cmd */
11176 + int exit_code; /* last process exit code */
11178 + char vx_name[65]; /* vserver name */
11181 +#ifndef CONFIG_SMP
11182 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
11183 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
11185 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
11186 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
11189 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
11192 +struct vx_info_save {
11193 + struct vx_info *vxi;
11198 +/* status flags */
11200 +#define VXS_HASHED 0x0001
11201 +#define VXS_PAUSED 0x0010
11202 +#define VXS_SHUTDOWN 0x0100
11203 +#define VXS_HELPER 0x1000
11204 +#define VXS_RELEASED 0x8000
11207 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
11208 +extern void release_vx_info(struct vx_info *, struct task_struct *);
11210 +extern struct vx_info *lookup_vx_info(int);
11211 +extern struct vx_info *lookup_or_create_vx_info(int);
11213 +extern int get_xid_list(int, unsigned int *, int);
11214 +extern int xid_is_hashed(xid_t);
11216 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
11218 +extern long vs_state_change(struct vx_info *, unsigned int);
11221 +#endif /* __KERNEL__ */
11222 +#endif /* _VX_CONTEXT_H */
11223 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/context_cmd.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/context_cmd.h
11224 --- linux-3.6.9/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
11225 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/context_cmd.h 2012-10-04 18:47:00.000000000 +0200
11227 +#ifndef _VX_CONTEXT_CMD_H
11228 +#define _VX_CONTEXT_CMD_H
11231 +/* vinfo commands */
11233 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
11236 +extern int vc_task_xid(uint32_t);
11238 +#endif /* __KERNEL__ */
11240 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
11242 +struct vcmd_vx_info_v0 {
11244 + uint32_t initpid;
11245 + /* more to come */
11249 +extern int vc_vx_info(struct vx_info *, void __user *);
11251 +#endif /* __KERNEL__ */
11253 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
11255 +struct vcmd_ctx_stat_v0 {
11258 + /* more to come */
11262 +extern int vc_ctx_stat(struct vx_info *, void __user *);
11264 +#endif /* __KERNEL__ */
11266 +/* context commands */
11268 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
11269 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
11271 +struct vcmd_ctx_create {
11272 + uint64_t flagword;
11275 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
11276 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
11278 +struct vcmd_ctx_migrate {
11279 + uint64_t flagword;
11283 +extern int vc_ctx_create(uint32_t, void __user *);
11284 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
11286 +#endif /* __KERNEL__ */
11289 +/* flag commands */
11291 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
11292 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
11294 +struct vcmd_ctx_flags_v0 {
11295 + uint64_t flagword;
11300 +extern int vc_get_cflags(struct vx_info *, void __user *);
11301 +extern int vc_set_cflags(struct vx_info *, void __user *);
11303 +#endif /* __KERNEL__ */
11306 +/* context caps commands */
11308 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
11309 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
11311 +struct vcmd_ctx_caps_v1 {
11317 +extern int vc_get_ccaps(struct vx_info *, void __user *);
11318 +extern int vc_set_ccaps(struct vx_info *, void __user *);
11320 +#endif /* __KERNEL__ */
11323 +/* bcaps commands */
11325 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
11326 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
11328 +struct vcmd_bcaps {
11334 +extern int vc_get_bcaps(struct vx_info *, void __user *);
11335 +extern int vc_set_bcaps(struct vx_info *, void __user *);
11337 +#endif /* __KERNEL__ */
11340 +/* umask commands */
11342 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
11343 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
11345 +struct vcmd_umask {
11351 +extern int vc_get_umask(struct vx_info *, void __user *);
11352 +extern int vc_set_umask(struct vx_info *, void __user *);
11354 +#endif /* __KERNEL__ */
11357 +/* wmask commands */
11359 +#define VCMD_get_wmask VC_CMD(FLAGS, 15, 0)
11360 +#define VCMD_set_wmask VC_CMD(FLAGS, 16, 0)
11362 +struct vcmd_wmask {
11368 +extern int vc_get_wmask(struct vx_info *, void __user *);
11369 +extern int vc_set_wmask(struct vx_info *, void __user *);
11371 +#endif /* __KERNEL__ */
11376 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
11377 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
11379 +struct vcmd_badness_v0 {
11384 +extern int vc_get_badness(struct vx_info *, void __user *);
11385 +extern int vc_set_badness(struct vx_info *, void __user *);
11387 +#endif /* __KERNEL__ */
11388 +#endif /* _VX_CONTEXT_CMD_H */
11389 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/cvirt.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/cvirt.h
11390 --- linux-3.6.9/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
11391 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/cvirt.h 2012-10-04 18:47:00.000000000 +0200
11393 +#ifndef _VX_CVIRT_H
11394 +#define _VX_CVIRT_H
11401 +void vx_vsi_boottime(struct timespec *);
11403 +void vx_vsi_uptime(struct timespec *, struct timespec *);
11408 +void vx_update_load(struct vx_info *);
11411 +int vx_do_syslog(int, char __user *, int);
11413 +#endif /* __KERNEL__ */
11414 +#endif /* _VX_CVIRT_H */
11415 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/cvirt_cmd.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/cvirt_cmd.h
11416 --- linux-3.6.9/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
11417 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/cvirt_cmd.h 2012-10-04 18:47:00.000000000 +0200
11419 +#ifndef _VX_CVIRT_CMD_H
11420 +#define _VX_CVIRT_CMD_H
11423 +/* virtual host info name commands */
11425 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
11426 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
11428 +struct vcmd_vhi_name_v0 {
11434 +enum vhi_name_field {
11435 + VHIN_CONTEXT = 0,
11447 +#include <linux/compiler.h>
11449 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
11450 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
11452 +#endif /* __KERNEL__ */
11454 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
11456 +struct vcmd_virt_stat_v0 {
11459 + uint32_t nr_threads;
11460 + uint32_t nr_running;
11461 + uint32_t nr_uninterruptible;
11462 + uint32_t nr_onhold;
11463 + uint32_t nr_forks;
11464 + uint32_t load[3];
11468 +extern int vc_virt_stat(struct vx_info *, void __user *);
11470 +#endif /* __KERNEL__ */
11471 +#endif /* _VX_CVIRT_CMD_H */
11472 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/cvirt_def.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/cvirt_def.h
11473 --- linux-3.6.9/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
11474 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/cvirt_def.h 2012-10-04 18:47:00.000000000 +0200
11476 +#ifndef _VX_CVIRT_DEF_H
11477 +#define _VX_CVIRT_DEF_H
11479 +#include <linux/jiffies.h>
11480 +#include <linux/spinlock.h>
11481 +#include <linux/wait.h>
11482 +#include <linux/time.h>
11483 +#include <asm/atomic.h>
11486 +struct _vx_usage_stat {
11490 + uint64_t softirq;
11496 +struct _vx_syslog {
11497 + wait_queue_head_t log_wait;
11498 + spinlock_t logbuf_lock; /* lock for the log buffer */
11500 + unsigned long log_start; /* next char to be read by syslog() */
11501 + unsigned long con_start; /* next char to be sent to consoles */
11502 + unsigned long log_end; /* most-recently-written-char + 1 */
11503 + unsigned long logged_chars; /* #chars since last read+clear operation */
11505 + char log_buf[1024];
11509 +/* context sub struct */
11511 +struct _vx_cvirt {
11512 + atomic_t nr_threads; /* number of current threads */
11513 + atomic_t nr_running; /* number of running threads */
11514 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
11516 + atomic_t nr_onhold; /* processes on hold */
11517 + uint32_t onhold_last; /* jiffies when put on hold */
11519 + struct timespec bias_ts; /* time offset to the host */
11520 + struct timespec bias_idle;
11521 + struct timespec bias_uptime; /* context creation point */
11522 + uint64_t bias_clock; /* offset in clock_t */
11524 + spinlock_t load_lock; /* lock for the load averages */
11525 + atomic_t load_updates; /* nr of load updates done so far */
11526 + uint32_t load_last; /* last time load was calculated */
11527 + uint32_t load[3]; /* load averages 1,5,15 */
11529 + atomic_t total_forks; /* number of forks so far */
11531 + struct _vx_syslog syslog;
11534 +struct _vx_cvirt_pc {
11535 + struct _vx_usage_stat cpustat;
11539 +#ifdef CONFIG_VSERVER_DEBUG
11541 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
11543 + printk("\t_vx_cvirt:\n");
11544 + printk("\t threads: %4d, %4d, %4d, %4d\n",
11545 + atomic_read(&cvirt->nr_threads),
11546 + atomic_read(&cvirt->nr_running),
11547 + atomic_read(&cvirt->nr_uninterruptible),
11548 + atomic_read(&cvirt->nr_onhold));
11549 + /* add rest here */
11550 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
11555 +#endif /* _VX_CVIRT_DEF_H */
11556 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/debug.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/debug.h
11557 --- linux-3.6.9/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
11558 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/debug.h 2012-10-04 18:47:00.000000000 +0200
11560 +#ifndef _VX_DEBUG_H
11561 +#define _VX_DEBUG_H
11564 +#define VXD_CBIT(n, m) (vs_debug_ ## n & (1 << (m)))
11565 +#define VXD_CMIN(n, m) (vs_debug_ ## n > (m))
11566 +#define VXD_MASK(n, m) (vs_debug_ ## n & (m))
11568 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
11569 + imajor((d)->bd_inode), iminor((d)->bd_inode)
11570 +#define VXF_DEV "%p[%lu,%d:%d]"
11572 +#if defined(CONFIG_QUOTES_UTF8)
11573 +#define VS_Q_LQM "\xc2\xbb"
11574 +#define VS_Q_RQM "\xc2\xab"
11575 +#elif defined(CONFIG_QUOTES_ASCII)
11576 +#define VS_Q_LQM "\x27"
11577 +#define VS_Q_RQM "\x27"
11579 +#define VS_Q_LQM "\xbb"
11580 +#define VS_Q_RQM "\xab"
11583 +#define VS_Q(f) VS_Q_LQM f VS_Q_RQM
11586 +#define vxd_path(p) \
11587 + ({ static char _buffer[PATH_MAX]; \
11588 + d_path(p, _buffer, sizeof(_buffer)); })
11590 +#define vxd_cond_path(n) \
11591 + ((n) ? vxd_path(&(n)->path) : "<null>" )
11594 +#ifdef CONFIG_VSERVER_DEBUG
11596 +extern unsigned int vs_debug_switch;
11597 +extern unsigned int vs_debug_xid;
11598 +extern unsigned int vs_debug_nid;
11599 +extern unsigned int vs_debug_tag;
11600 +extern unsigned int vs_debug_net;
11601 +extern unsigned int vs_debug_limit;
11602 +extern unsigned int vs_debug_cres;
11603 +extern unsigned int vs_debug_dlim;
11604 +extern unsigned int vs_debug_quota;
11605 +extern unsigned int vs_debug_cvirt;
11606 +extern unsigned int vs_debug_space;
11607 +extern unsigned int vs_debug_perm;
11608 +extern unsigned int vs_debug_misc;
11611 +#define VX_LOGLEVEL "vxD: "
11612 +#define VX_PROC_FMT "%p: "
11613 +#define VX_PROCESS current
11615 +#define vxdprintk(c, f, x...) \
11618 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
11619 + VX_PROCESS , ##x); \
11622 +#define vxlprintk(c, f, x...) \
11625 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
11628 +#define vxfprintk(c, f, x...) \
11631 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
11637 +void dump_vx_info(struct vx_info *, int);
11638 +void dump_vx_info_inactive(int);
11640 +#else /* CONFIG_VSERVER_DEBUG */
11642 +#define vs_debug_switch 0
11643 +#define vs_debug_xid 0
11644 +#define vs_debug_nid 0
11645 +#define vs_debug_tag 0
11646 +#define vs_debug_net 0
11647 +#define vs_debug_limit 0
11648 +#define vs_debug_cres 0
11649 +#define vs_debug_dlim 0
11650 +#define vs_debug_quota 0
11651 +#define vs_debug_cvirt 0
11652 +#define vs_debug_space 0
11653 +#define vs_debug_perm 0
11654 +#define vs_debug_misc 0
11656 +#define vxdprintk(x...) do { } while (0)
11657 +#define vxlprintk(x...) do { } while (0)
11658 +#define vxfprintk(x...) do { } while (0)
11660 +#endif /* CONFIG_VSERVER_DEBUG */
11663 +#ifdef CONFIG_VSERVER_WARN
11665 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
11666 +#define VX_WARN_TASK "[" VS_Q("%s") ",%u:#%u|%u|%u] "
11667 +#define VX_WARN_XID "[xid #%u] "
11668 +#define VX_WARN_NID "[nid #%u] "
11669 +#define VX_WARN_TAG "[tag #%u] "
11671 +#define vxwprintk(c, f, x...) \
11674 + printk(VX_WARNLEVEL f "\n", ##x); \
11677 +#else /* CONFIG_VSERVER_WARN */
11679 +#define vxwprintk(x...) do { } while (0)
11681 +#endif /* CONFIG_VSERVER_WARN */
11683 +#define vxwprintk_task(c, f, x...) \
11684 + vxwprintk(c, VX_WARN_TASK f, \
11685 + current->comm, current->pid, \
11686 + current->xid, current->nid, current->tag, ##x)
11687 +#define vxwprintk_xid(c, f, x...) \
11688 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
11689 +#define vxwprintk_nid(c, f, x...) \
11690 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
11691 +#define vxwprintk_tag(c, f, x...) \
11692 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
11694 +#ifdef CONFIG_VSERVER_DEBUG
11695 +#define vxd_assert_lock(l) assert_spin_locked(l)
11696 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
11697 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
11699 +#define vxd_assert_lock(l) do { } while (0)
11700 +#define vxd_assert(c, f, x...) do { } while (0)
11704 +#endif /* _VX_DEBUG_H */
11705 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/debug_cmd.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/debug_cmd.h
11706 --- linux-3.6.9/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
11707 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/debug_cmd.h 2012-10-04 18:47:00.000000000 +0200
11709 +#ifndef _VX_DEBUG_CMD_H
11710 +#define _VX_DEBUG_CMD_H
11713 +/* debug commands */
11715 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
11717 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
11718 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
11720 +struct vcmd_read_history_v0 {
11723 + char __user *data;
11726 +struct vcmd_read_monitor_v0 {
11729 + char __user *data;
11735 +#ifdef CONFIG_COMPAT
11737 +#include <asm/compat.h>
11739 +struct vcmd_read_history_v0_x32 {
11742 + compat_uptr_t data_ptr;
11745 +struct vcmd_read_monitor_v0_x32 {
11748 + compat_uptr_t data_ptr;
11751 +#endif /* CONFIG_COMPAT */
11753 +extern int vc_dump_history(uint32_t);
11755 +extern int vc_read_history(uint32_t, void __user *);
11756 +extern int vc_read_monitor(uint32_t, void __user *);
11758 +#ifdef CONFIG_COMPAT
11760 +extern int vc_read_history_x32(uint32_t, void __user *);
11761 +extern int vc_read_monitor_x32(uint32_t, void __user *);
11763 +#endif /* CONFIG_COMPAT */
11765 +#endif /* __KERNEL__ */
11766 +#endif /* _VX_DEBUG_CMD_H */
11767 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/device.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/device.h
11768 --- linux-3.6.9/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
11769 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/device.h 2012-10-04 18:47:00.000000000 +0200
11771 +#ifndef _VX_DEVICE_H
11772 +#define _VX_DEVICE_H
11775 +#define DATTR_CREATE 0x00000001
11776 +#define DATTR_OPEN 0x00000002
11778 +#define DATTR_REMAP 0x00000010
11780 +#define DATTR_MASK 0x00000013
11783 +#else /* _VX_DEVICE_H */
11784 +#warning duplicate inclusion
11785 +#endif /* _VX_DEVICE_H */
11786 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/device_cmd.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/device_cmd.h
11787 --- linux-3.6.9/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
11788 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/device_cmd.h 2012-10-04 18:47:00.000000000 +0200
11790 +#ifndef _VX_DEVICE_CMD_H
11791 +#define _VX_DEVICE_CMD_H
11794 +/* device vserver commands */
11796 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
11797 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
11799 +struct vcmd_set_mapping_v0 {
11800 + const char __user *device;
11801 + const char __user *target;
11808 +#ifdef CONFIG_COMPAT
11810 +#include <asm/compat.h>
11812 +struct vcmd_set_mapping_v0_x32 {
11813 + compat_uptr_t device_ptr;
11814 + compat_uptr_t target_ptr;
11818 +#endif /* CONFIG_COMPAT */
11820 +#include <linux/compiler.h>
11822 +extern int vc_set_mapping(struct vx_info *, void __user *);
11823 +extern int vc_unset_mapping(struct vx_info *, void __user *);
11825 +#ifdef CONFIG_COMPAT
11827 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
11828 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
11830 +#endif /* CONFIG_COMPAT */
11832 +#endif /* __KERNEL__ */
11833 +#endif /* _VX_DEVICE_CMD_H */
11834 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/device_def.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/device_def.h
11835 --- linux-3.6.9/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
11836 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/device_def.h 2012-10-04 18:47:00.000000000 +0200
11838 +#ifndef _VX_DEVICE_DEF_H
11839 +#define _VX_DEVICE_DEF_H
11841 +#include <linux/types.h>
11843 +struct vx_dmap_target {
11848 +struct _vx_device {
11849 +#ifdef CONFIG_VSERVER_DEVICE
11850 + struct vx_dmap_target targets[2];
11854 +#endif /* _VX_DEVICE_DEF_H */
11855 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/dlimit.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/dlimit.h
11856 --- linux-3.6.9/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
11857 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/dlimit.h 2012-10-04 18:47:00.000000000 +0200
11859 +#ifndef _VX_DLIMIT_H
11860 +#define _VX_DLIMIT_H
11862 +#include "switch.h"
11867 +/* keep in sync with CDLIM_INFINITY */
11869 +#define DLIM_INFINITY (~0ULL)
11871 +#include <linux/spinlock.h>
11872 +#include <linux/rcupdate.h>
11874 +struct super_block;
11877 + struct hlist_node dl_hlist; /* linked list of contexts */
11878 + struct rcu_head dl_rcu; /* the rcu head */
11879 + vs_tag_t dl_tag; /* context tag */
11880 + atomic_t dl_usecnt; /* usage count */
11881 + atomic_t dl_refcnt; /* reference count */
11883 + struct super_block *dl_sb; /* associated superblock */
11885 + spinlock_t dl_lock; /* protect the values */
11887 + unsigned long long dl_space_used; /* used space in bytes */
11888 + unsigned long long dl_space_total; /* maximum space in bytes */
11889 + unsigned long dl_inodes_used; /* used inodes */
11890 + unsigned long dl_inodes_total; /* maximum inodes */
11892 + unsigned int dl_nrlmult; /* non root limit mult */
11897 +extern void rcu_free_dl_info(struct rcu_head *);
11898 +extern void unhash_dl_info(struct dl_info *);
11900 +extern struct dl_info *locate_dl_info(struct super_block *, vs_tag_t);
11905 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
11907 +typedef uint64_t dlsize_t;
11909 +#endif /* __KERNEL__ */
11910 +#else /* _VX_DLIMIT_H */
11911 +#warning duplicate inclusion
11912 +#endif /* _VX_DLIMIT_H */
11913 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/dlimit_cmd.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/dlimit_cmd.h
11914 --- linux-3.6.9/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
11915 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/dlimit_cmd.h 2012-10-04 18:47:00.000000000 +0200
11917 +#ifndef _VX_DLIMIT_CMD_H
11918 +#define _VX_DLIMIT_CMD_H
11921 +/* dlimit vserver commands */
11923 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
11924 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
11926 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
11927 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
11929 +struct vcmd_ctx_dlimit_base_v0 {
11930 + const char __user *name;
11934 +struct vcmd_ctx_dlimit_v0 {
11935 + const char __user *name;
11936 + uint32_t space_used; /* used space in kbytes */
11937 + uint32_t space_total; /* maximum space in kbytes */
11938 + uint32_t inodes_used; /* used inodes */
11939 + uint32_t inodes_total; /* maximum inodes */
11940 + uint32_t reserved; /* reserved for root in % */
11944 +#define CDLIM_UNSET ((uint32_t)0UL)
11945 +#define CDLIM_INFINITY ((uint32_t)~0UL)
11946 +#define CDLIM_KEEP ((uint32_t)~1UL)
11948 +#define DLIME_UNIT 0
11949 +#define DLIME_KILO 1
11950 +#define DLIME_MEGA 2
11951 +#define DLIME_GIGA 3
11953 +#define DLIMF_SHIFT 0x10
11955 +#define DLIMS_USED 0
11956 +#define DLIMS_TOTAL 2
11959 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
11961 + int exp = (flags & DLIMF_SHIFT) ?
11962 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
11963 + return ((uint64_t)val) << (10 * exp);
11967 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
11971 + if (*flags & DLIMF_SHIFT) {
11972 + while (val > (1LL << 32) && (exp < 3)) {
11976 + *flags &= ~(DLIME_GIGA << shift);
11977 + *flags |= exp << shift;
11985 +#ifdef CONFIG_COMPAT
11987 +#include <asm/compat.h>
11989 +struct vcmd_ctx_dlimit_base_v0_x32 {
11990 + compat_uptr_t name_ptr;
11994 +struct vcmd_ctx_dlimit_v0_x32 {
11995 + compat_uptr_t name_ptr;
11996 + uint32_t space_used; /* used space in kbytes */
11997 + uint32_t space_total; /* maximum space in kbytes */
11998 + uint32_t inodes_used; /* used inodes */
11999 + uint32_t inodes_total; /* maximum inodes */
12000 + uint32_t reserved; /* reserved for root in % */
12004 +#endif /* CONFIG_COMPAT */
12006 +#include <linux/compiler.h>
12008 +extern int vc_add_dlimit(uint32_t, void __user *);
12009 +extern int vc_rem_dlimit(uint32_t, void __user *);
12011 +extern int vc_set_dlimit(uint32_t, void __user *);
12012 +extern int vc_get_dlimit(uint32_t, void __user *);
12014 +#ifdef CONFIG_COMPAT
12016 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
12017 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
12019 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
12020 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
12022 +#endif /* CONFIG_COMPAT */
12024 +#endif /* __KERNEL__ */
12025 +#endif /* _VX_DLIMIT_CMD_H */
12026 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/global.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/global.h
12027 --- linux-3.6.9/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
12028 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/global.h 2012-10-04 18:47:00.000000000 +0200
12030 +#ifndef _VX_GLOBAL_H
12031 +#define _VX_GLOBAL_H
12034 +extern atomic_t vx_global_ctotal;
12035 +extern atomic_t vx_global_cactive;
12037 +extern atomic_t nx_global_ctotal;
12038 +extern atomic_t nx_global_cactive;
12040 +extern atomic_t vs_global_nsproxy;
12041 +extern atomic_t vs_global_fs;
12042 +extern atomic_t vs_global_mnt_ns;
12043 +extern atomic_t vs_global_uts_ns;
12044 +extern atomic_t vs_global_user_ns;
12045 +extern atomic_t vs_global_pid_ns;
12048 +#endif /* _VX_GLOBAL_H */
12049 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/history.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/history.h
12050 --- linux-3.6.9/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
12051 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/history.h 2012-10-04 18:47:00.000000000 +0200
12053 +#ifndef _VX_HISTORY_H
12054 +#define _VX_HISTORY_H
12059 + VXH_THROW_OOPS = 1,
12063 + VXH_INIT_VX_INFO,
12066 + VXH_CLAIM_VX_INFO,
12067 + VXH_RELEASE_VX_INFO,
12068 + VXH_ALLOC_VX_INFO,
12069 + VXH_DEALLOC_VX_INFO,
12070 + VXH_HASH_VX_INFO,
12071 + VXH_UNHASH_VX_INFO,
12073 + VXH_LOOKUP_VX_INFO,
12074 + VXH_CREATE_VX_INFO,
12077 +struct _vxhe_vxi {
12078 + struct vx_info *ptr;
12084 +struct _vxhe_set_clr {
12088 +struct _vxhe_loc_lookup {
12092 +struct _vx_hist_entry {
12094 + unsigned short seq;
12095 + unsigned short type;
12096 + struct _vxhe_vxi vxi;
12098 + struct _vxhe_set_clr sc;
12099 + struct _vxhe_loc_lookup ll;
12103 +#ifdef CONFIG_VSERVER_HISTORY
12105 +extern unsigned volatile int vxh_active;
12107 +struct _vx_hist_entry *vxh_advance(void *loc);
12111 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
12113 + entry->vxi.ptr = vxi;
12115 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
12116 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
12117 + entry->vxi.xid = vxi->vx_id;
12122 +#define __HERE__ current_text_addr()
12124 +#define __VXH_BODY(__type, __data, __here) \
12125 + struct _vx_hist_entry *entry; \
12127 + preempt_disable(); \
12128 + entry = vxh_advance(__here); \
12130 + entry->type = __type; \
12131 + preempt_enable();
12134 + /* pass vxi only */
12136 +#define __VXH_SMPL \
12137 + __vxh_copy_vxi(entry, vxi)
12140 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
12142 + __VXH_BODY(__type, __VXH_SMPL, __here)
12145 + /* pass vxi and data (void *) */
12147 +#define __VXH_DATA \
12148 + __vxh_copy_vxi(entry, vxi); \
12149 + entry->sc.data = data
12152 +void __vxh_data(struct vx_info *vxi, void *data,
12153 + int __type, void *__here)
12155 + __VXH_BODY(__type, __VXH_DATA, __here)
12158 + /* pass vxi and arg (long) */
12160 +#define __VXH_LONG \
12161 + __vxh_copy_vxi(entry, vxi); \
12162 + entry->ll.arg = arg
12165 +void __vxh_long(struct vx_info *vxi, long arg,
12166 + int __type, void *__here)
12168 + __VXH_BODY(__type, __VXH_LONG, __here)
12173 +void __vxh_throw_oops(void *__here)
12175 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
12176 + /* prevent further acquisition */
12181 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
12183 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
12184 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
12186 +#define __vxh_init_vx_info(v, d, h) \
12187 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
12188 +#define __vxh_set_vx_info(v, d, h) \
12189 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
12190 +#define __vxh_clr_vx_info(v, d, h) \
12191 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
12193 +#define __vxh_claim_vx_info(v, d, h) \
12194 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
12195 +#define __vxh_release_vx_info(v, d, h) \
12196 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
12198 +#define vxh_alloc_vx_info(v) \
12199 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
12200 +#define vxh_dealloc_vx_info(v) \
12201 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
12203 +#define vxh_hash_vx_info(v) \
12204 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
12205 +#define vxh_unhash_vx_info(v) \
12206 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
12208 +#define vxh_loc_vx_info(v, l) \
12209 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
12210 +#define vxh_lookup_vx_info(v, l) \
12211 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
12212 +#define vxh_create_vx_info(v, l) \
12213 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
12215 +extern void vxh_dump_history(void);
12218 +#else /* CONFIG_VSERVER_HISTORY */
12220 +#define __HERE__ 0
12222 +#define vxh_throw_oops() do { } while (0)
12224 +#define __vxh_get_vx_info(v, h) do { } while (0)
12225 +#define __vxh_put_vx_info(v, h) do { } while (0)
12227 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
12228 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
12229 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
12231 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
12232 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
12234 +#define vxh_alloc_vx_info(v) do { } while (0)
12235 +#define vxh_dealloc_vx_info(v) do { } while (0)
12237 +#define vxh_hash_vx_info(v) do { } while (0)
12238 +#define vxh_unhash_vx_info(v) do { } while (0)
12240 +#define vxh_loc_vx_info(v, l) do { } while (0)
12241 +#define vxh_lookup_vx_info(v, l) do { } while (0)
12242 +#define vxh_create_vx_info(v, l) do { } while (0)
12244 +#define vxh_dump_history() do { } while (0)
12247 +#endif /* CONFIG_VSERVER_HISTORY */
12249 +#endif /* _VX_HISTORY_H */
12250 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/inode.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/inode.h
12251 --- linux-3.6.9/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
12252 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/inode.h 2012-10-04 18:47:00.000000000 +0200
12254 +#ifndef _VX_INODE_H
12255 +#define _VX_INODE_H
12258 +#define IATTR_TAG 0x01000000
12260 +#define IATTR_ADMIN 0x00000001
12261 +#define IATTR_WATCH 0x00000002
12262 +#define IATTR_HIDE 0x00000004
12263 +#define IATTR_FLAGS 0x00000007
12265 +#define IATTR_BARRIER 0x00010000
12266 +#define IATTR_IXUNLINK 0x00020000
12267 +#define IATTR_IMMUTABLE 0x00040000
12268 +#define IATTR_COW 0x00080000
12273 +#ifdef CONFIG_VSERVER_PROC_SECURE
12274 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
12275 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
12277 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
12278 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
12281 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
12283 +#endif /* __KERNEL__ */
12285 +/* inode ioctls */
12287 +#define FIOC_GETXFLG _IOR('x', 5, long)
12288 +#define FIOC_SETXFLG _IOW('x', 6, long)
12290 +#else /* _VX_INODE_H */
12291 +#warning duplicate inclusion
12292 +#endif /* _VX_INODE_H */
12293 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/inode_cmd.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/inode_cmd.h
12294 --- linux-3.6.9/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
12295 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/inode_cmd.h 2012-10-04 18:47:00.000000000 +0200
12297 +#ifndef _VX_INODE_CMD_H
12298 +#define _VX_INODE_CMD_H
12301 +/* inode vserver commands */
12303 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
12304 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
12306 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
12307 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
12309 +struct vcmd_ctx_iattr_v1 {
12310 + const char __user *name;
12316 +struct vcmd_ctx_fiattr_v0 {
12326 +#ifdef CONFIG_COMPAT
12328 +#include <asm/compat.h>
12330 +struct vcmd_ctx_iattr_v1_x32 {
12331 + compat_uptr_t name_ptr;
12337 +#endif /* CONFIG_COMPAT */
12339 +#include <linux/compiler.h>
12341 +extern int vc_get_iattr(void __user *);
12342 +extern int vc_set_iattr(void __user *);
12344 +extern int vc_fget_iattr(uint32_t, void __user *);
12345 +extern int vc_fset_iattr(uint32_t, void __user *);
12347 +#ifdef CONFIG_COMPAT
12349 +extern int vc_get_iattr_x32(void __user *);
12350 +extern int vc_set_iattr_x32(void __user *);
12352 +#endif /* CONFIG_COMPAT */
12354 +#endif /* __KERNEL__ */
12355 +#endif /* _VX_INODE_CMD_H */
12356 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/limit.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/limit.h
12357 --- linux-3.6.9/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
12358 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/limit.h 2012-10-04 18:47:00.000000000 +0200
12360 +#ifndef _VX_LIMIT_H
12361 +#define _VX_LIMIT_H
12363 +#define VLIMIT_NSOCK 16
12364 +#define VLIMIT_OPENFD 17
12365 +#define VLIMIT_ANON 18
12366 +#define VLIMIT_SHMEM 19
12367 +#define VLIMIT_SEMARY 20
12368 +#define VLIMIT_NSEMS 21
12369 +#define VLIMIT_DENTRY 22
12370 +#define VLIMIT_MAPPED 23
12375 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
12377 +/* keep in sync with CRLIM_INFINITY */
12379 +#define VLIM_INFINITY (~0ULL)
12381 +#include <asm/atomic.h>
12382 +#include <asm/resource.h>
12384 +#ifndef RLIM_INFINITY
12385 +#warning RLIM_INFINITY is undefined
12388 +#define __rlim_val(l, r, v) ((l)->res[r].v)
12390 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
12391 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
12393 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
12394 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
12395 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
12397 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
12398 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
12400 +typedef atomic_long_t rlim_atomic_t;
12401 +typedef unsigned long rlim_t;
12403 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
12404 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
12405 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
12406 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
12407 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
12408 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
12411 +#if (RLIM_INFINITY == VLIM_INFINITY)
12412 +#define VX_VLIM(r) ((long long)(long)(r))
12413 +#define VX_RLIM(v) ((rlim_t)(v))
12415 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
12416 + ? VLIM_INFINITY : (long long)(r))
12417 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
12418 + ? RLIM_INFINITY : (rlim_t)(v))
12423 +void vx_vsi_meminfo(struct sysinfo *);
12424 +void vx_vsi_swapinfo(struct sysinfo *);
12425 +long vx_vsi_cached(struct sysinfo *);
12427 +#define NUM_LIMITS 24
12429 +#endif /* __KERNEL__ */
12430 +#endif /* _VX_LIMIT_H */
12431 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/limit_cmd.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/limit_cmd.h
12432 --- linux-3.6.9/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
12433 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/limit_cmd.h 2012-10-04 18:47:00.000000000 +0200
12435 +#ifndef _VX_LIMIT_CMD_H
12436 +#define _VX_LIMIT_CMD_H
12439 +/* rlimit vserver commands */
12441 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
12442 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
12443 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
12444 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
12445 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
12447 +struct vcmd_ctx_rlimit_v0 {
12449 + uint64_t minimum;
12450 + uint64_t softlimit;
12451 + uint64_t maximum;
12454 +struct vcmd_ctx_rlimit_mask_v0 {
12455 + uint32_t minimum;
12456 + uint32_t softlimit;
12457 + uint32_t maximum;
12460 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
12462 +struct vcmd_rlimit_stat_v0 {
12466 + uint64_t minimum;
12467 + uint64_t maximum;
12470 +#define CRLIM_UNSET (0ULL)
12471 +#define CRLIM_INFINITY (~0ULL)
12472 +#define CRLIM_KEEP (~1ULL)
12476 +#ifdef CONFIG_IA32_EMULATION
12478 +struct vcmd_ctx_rlimit_v0_x32 {
12480 + uint64_t minimum;
12481 + uint64_t softlimit;
12482 + uint64_t maximum;
12483 +} __attribute__ ((packed));
12485 +#endif /* CONFIG_IA32_EMULATION */
12487 +#include <linux/compiler.h>
12489 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
12490 +extern int vc_get_rlimit(struct vx_info *, void __user *);
12491 +extern int vc_set_rlimit(struct vx_info *, void __user *);
12492 +extern int vc_reset_hits(struct vx_info *, void __user *);
12493 +extern int vc_reset_minmax(struct vx_info *, void __user *);
12495 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
12497 +#ifdef CONFIG_IA32_EMULATION
12499 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
12500 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
12502 +#endif /* CONFIG_IA32_EMULATION */
12504 +#endif /* __KERNEL__ */
12505 +#endif /* _VX_LIMIT_CMD_H */
12506 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/limit_def.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/limit_def.h
12507 --- linux-3.6.9/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
12508 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/limit_def.h 2012-10-04 18:47:00.000000000 +0200
12510 +#ifndef _VX_LIMIT_DEF_H
12511 +#define _VX_LIMIT_DEF_H
12513 +#include <asm/atomic.h>
12514 +#include <asm/resource.h>
12516 +#include "limit.h"
12519 +struct _vx_res_limit {
12520 + rlim_t soft; /* Context soft limit */
12521 + rlim_t hard; /* Context hard limit */
12523 + rlim_atomic_t rcur; /* Current value */
12524 + rlim_t rmin; /* Context minimum */
12525 + rlim_t rmax; /* Context maximum */
12527 + atomic_t lhit; /* Limit hits */
12530 +/* context sub struct */
12532 +struct _vx_limit {
12533 + struct _vx_res_limit res[NUM_LIMITS];
12536 +#ifdef CONFIG_VSERVER_DEBUG
12538 +static inline void __dump_vx_limit(struct _vx_limit *limit)
12542 + printk("\t_vx_limit:");
12543 + for (i = 0; i < NUM_LIMITS; i++) {
12544 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
12545 + i, (unsigned long)__rlim_get(limit, i),
12546 + (unsigned long)__rlim_rmin(limit, i),
12547 + (unsigned long)__rlim_rmax(limit, i),
12548 + (long)__rlim_soft(limit, i),
12549 + (long)__rlim_hard(limit, i),
12550 + atomic_read(&__rlim_lhit(limit, i)));
12556 +#endif /* _VX_LIMIT_DEF_H */
12557 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/limit_int.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/limit_int.h
12558 --- linux-3.6.9/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
12559 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/limit_int.h 2012-10-04 18:47:00.000000000 +0200
12561 +#ifndef _VX_LIMIT_INT_H
12562 +#define _VX_LIMIT_INT_H
12564 +#include "context.h"
12568 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
12569 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
12571 +extern const char *vlimit_name[NUM_LIMITS];
12573 +static inline void __vx_acc_cres(struct vx_info *vxi,
12574 + int res, int dir, void *_data, char *_file, int _line)
12576 + if (VXD_RCRES_COND(res))
12577 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
12578 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12579 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12580 + (dir > 0) ? "++" : "--", _data, _file, _line);
12585 + __rlim_inc(&vxi->limit, res);
12587 + __rlim_dec(&vxi->limit, res);
12590 +static inline void __vx_add_cres(struct vx_info *vxi,
12591 + int res, int amount, void *_data, char *_file, int _line)
12593 + if (VXD_RCRES_COND(res))
12594 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
12595 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12596 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12597 + amount, _data, _file, _line);
12602 + __rlim_add(&vxi->limit, res, amount);
12606 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
12608 + int cond = (value > __rlim_rmax(limit, res));
12611 + __rlim_rmax(limit, res) = value;
12616 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
12618 + int cond = (value < __rlim_rmin(limit, res));
12621 + __rlim_rmin(limit, res) = value;
12626 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
12628 + if (!__vx_cres_adjust_max(limit, res, value))
12629 + __vx_cres_adjust_min(limit, res, value);
12634 + +1 ... no limit hit
12635 + -1 ... over soft limit
12636 + 0 ... over hard limit */
12638 +static inline int __vx_cres_avail(struct vx_info *vxi,
12639 + int res, int num, char *_file, int _line)
12641 + struct _vx_limit *limit;
12644 + if (VXD_RLIMIT_COND(res))
12645 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
12646 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12647 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
12648 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
12649 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12650 + num, _file, _line);
12654 + limit = &vxi->limit;
12655 + value = __rlim_get(limit, res);
12657 + if (!__vx_cres_adjust_max(limit, res, value))
12658 + __vx_cres_adjust_min(limit, res, value);
12663 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
12665 + if (value + num <= __rlim_soft(limit, res))
12668 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
12670 + if (value + num <= __rlim_hard(limit, res))
12673 + __rlim_hit(limit, res);
12678 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
12681 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
12683 + rlim_t value, sum = 0;
12686 + while ((res = *array++)) {
12687 + value = __rlim_get(limit, res);
12688 + __vx_cres_fixup(limit, res, value);
12695 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
12697 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
12698 + int res = *array;
12700 + if (value == __rlim_get(limit, res))
12703 + __rlim_set(limit, res, value);
12704 + /* now adjust min/max */
12705 + if (!__vx_cres_adjust_max(limit, res, value))
12706 + __vx_cres_adjust_min(limit, res, value);
12711 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
12712 + const int *array, int num, char *_file, int _line)
12714 + struct _vx_limit *limit;
12715 + rlim_t value = 0;
12723 + limit = &vxi->limit;
12725 + value = __vx_cres_array_sum(limit, array + 1);
12727 + __rlim_set(limit, res, value);
12728 + __vx_cres_fixup(limit, res, value);
12730 + return __vx_cres_avail(vxi, res, num, _file, _line);
12734 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
12739 + /* complex resources first */
12740 + if ((id < 0) || (id == RLIMIT_RSS))
12741 + __vx_cres_array_fixup(limit, VLA_RSS);
12743 + for (res = 0; res < NUM_LIMITS; res++) {
12744 + if ((id > 0) && (res != id))
12747 + value = __rlim_get(limit, res);
12748 + __vx_cres_fixup(limit, res, value);
12750 + /* not supposed to happen, maybe warn? */
12751 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
12752 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
12757 +#endif /* __KERNEL__ */
12758 +#endif /* _VX_LIMIT_INT_H */
12759 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/monitor.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/monitor.h
12760 --- linux-3.6.9/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
12761 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/monitor.h 2012-10-04 18:47:00.000000000 +0200
12763 +#ifndef _VX_MONITOR_H
12764 +#define _VX_MONITOR_H
12766 +#include <linux/types.h>
12773 + VXM_UPDATE = 0x20,
12777 + VXM_RQINFO_1 = 0x24,
12780 + VXM_ACTIVATE = 0x40,
12787 + VXM_MIGRATE = 0x48,
12790 + /* all other bits are flags */
12791 + VXM_SCHED = 0x80,
12794 +struct _vxm_update_1 {
12795 + uint32_t tokens_max;
12796 + uint32_t fill_rate;
12797 + uint32_t interval;
12800 +struct _vxm_update_2 {
12801 + uint32_t tokens_min;
12802 + uint32_t fill_rate;
12803 + uint32_t interval;
12806 +struct _vxm_rqinfo_1 {
12807 + uint16_t running;
12811 + uint32_t idle_tokens;
12814 +struct _vxm_rqinfo_2 {
12815 + uint32_t norm_time;
12816 + uint32_t idle_time;
12817 + uint32_t idle_skip;
12820 +struct _vxm_sched {
12822 + uint32_t norm_time;
12823 + uint32_t idle_time;
12826 +struct _vxm_task {
12831 +struct _vxm_event {
12840 + struct _vxm_task tsk;
12844 +struct _vx_mon_entry {
12848 + struct _vxm_event ev;
12849 + struct _vxm_sched sd;
12850 + struct _vxm_update_1 u1;
12851 + struct _vxm_update_2 u2;
12852 + struct _vxm_rqinfo_1 q1;
12853 + struct _vxm_rqinfo_2 q2;
12858 +#endif /* _VX_MONITOR_H */
12859 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/network.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/network.h
12860 --- linux-3.6.9/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
12861 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/network.h 2012-10-04 18:47:00.000000000 +0200
12863 +#ifndef _VX_NETWORK_H
12864 +#define _VX_NETWORK_H
12866 +#include <linux/types.h>
12869 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
12872 +/* network flags */
12874 +#define NXF_INFO_PRIVATE 0x00000008
12876 +#define NXF_SINGLE_IP 0x00000100
12877 +#define NXF_LBACK_REMAP 0x00000200
12878 +#define NXF_LBACK_ALLOW 0x00000400
12880 +#define NXF_HIDE_NETIF 0x02000000
12881 +#define NXF_HIDE_LBACK 0x04000000
12883 +#define NXF_STATE_SETUP (1ULL << 32)
12884 +#define NXF_STATE_ADMIN (1ULL << 34)
12886 +#define NXF_SC_HELPER (1ULL << 36)
12887 +#define NXF_PERSISTENT (1ULL << 38)
12889 +#define NXF_ONE_TIME (0x0005ULL << 32)
12892 +#define NXF_INIT_SET (__nxf_init_set())
12894 +static inline uint64_t __nxf_init_set(void) {
12895 + return NXF_STATE_ADMIN
12896 +#ifdef CONFIG_VSERVER_AUTO_LBACK
12897 + | NXF_LBACK_REMAP
12900 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
12903 + | NXF_HIDE_NETIF;
12907 +/* network caps */
12909 +#define NXC_TUN_CREATE 0x00000001
12911 +#define NXC_RAW_ICMP 0x00000100
12913 +#define NXC_MULTICAST 0x00001000
12916 +/* address types */
12918 +#define NXA_TYPE_IPV4 0x0001
12919 +#define NXA_TYPE_IPV6 0x0002
12921 +#define NXA_TYPE_NONE 0x0000
12922 +#define NXA_TYPE_ANY 0x00FF
12924 +#define NXA_TYPE_ADDR 0x0010
12925 +#define NXA_TYPE_MASK 0x0020
12926 +#define NXA_TYPE_RANGE 0x0040
12928 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
12930 +#define NXA_MOD_BCAST 0x0100
12931 +#define NXA_MOD_LBACK 0x0200
12933 +#define NXA_LOOPBACK 0x1000
12935 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
12936 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
12940 +#include <linux/list.h>
12941 +#include <linux/spinlock.h>
12942 +#include <linux/rcupdate.h>
12943 +#include <linux/in.h>
12944 +#include <linux/in6.h>
12945 +#include <asm/atomic.h>
12947 +struct nx_addr_v4 {
12948 + struct nx_addr_v4 *next;
12949 + struct in_addr ip[2];
12950 + struct in_addr mask;
12955 +struct nx_addr_v6 {
12956 + struct nx_addr_v6 *next;
12957 + struct in6_addr ip;
12958 + struct in6_addr mask;
12965 + struct hlist_node nx_hlist; /* linked list of nxinfos */
12966 + nid_t nx_id; /* vnet id */
12967 + atomic_t nx_usecnt; /* usage count */
12968 + atomic_t nx_tasks; /* tasks count */
12969 + int nx_state; /* context state */
12971 + uint64_t nx_flags; /* network flag word */
12972 + uint64_t nx_ncaps; /* network capabilities */
12974 + struct in_addr v4_lback; /* Loopback address */
12975 + struct in_addr v4_bcast; /* Broadcast address */
12976 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
12977 +#ifdef CONFIG_IPV6
12978 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
12980 + char nx_name[65]; /* network context name */
12984 +/* status flags */
12986 +#define NXS_HASHED 0x0001
12987 +#define NXS_SHUTDOWN 0x0100
12988 +#define NXS_RELEASED 0x8000
12990 +extern struct nx_info *lookup_nx_info(int);
12992 +extern int get_nid_list(int, unsigned int *, int);
12993 +extern int nid_is_hashed(nid_t);
12995 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
12997 +extern long vs_net_change(struct nx_info *, unsigned int);
13002 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
13003 +#ifdef CONFIG_IPV6
13004 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
13006 +#define NX_IPV6(n) (0)
13009 +#endif /* __KERNEL__ */
13010 +#endif /* _VX_NETWORK_H */
13011 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/network_cmd.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/network_cmd.h
13012 --- linux-3.6.9/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
13013 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/network_cmd.h 2012-10-04 18:47:00.000000000 +0200
13015 +#ifndef _VX_NETWORK_CMD_H
13016 +#define _VX_NETWORK_CMD_H
13019 +/* vinfo commands */
13021 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
13024 +extern int vc_task_nid(uint32_t);
13026 +#endif /* __KERNEL__ */
13028 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
13030 +struct vcmd_nx_info_v0 {
13032 + /* more to come */
13036 +extern int vc_nx_info(struct nx_info *, void __user *);
13038 +#endif /* __KERNEL__ */
13040 +#include <linux/in.h>
13041 +#include <linux/in6.h>
13043 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
13044 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
13046 +struct vcmd_net_create {
13047 + uint64_t flagword;
13050 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
13052 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
13053 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
13055 +struct vcmd_net_addr_v0 {
13058 + struct in_addr ip[4];
13059 + struct in_addr mask[4];
13062 +#define VCMD_net_add_ipv4_v1 VC_CMD(NETALT, 1, 1)
13063 +#define VCMD_net_rem_ipv4_v1 VC_CMD(NETALT, 2, 1)
13065 +struct vcmd_net_addr_ipv4_v1 {
13068 + struct in_addr ip;
13069 + struct in_addr mask;
13072 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 2)
13073 +#define VCMD_net_rem_ipv4 VC_CMD(NETALT, 2, 2)
13075 +struct vcmd_net_addr_ipv4_v2 {
13078 + struct in_addr ip;
13079 + struct in_addr ip2;
13080 + struct in_addr mask;
13083 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
13084 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
13086 +struct vcmd_net_addr_ipv6_v1 {
13090 + struct in6_addr ip;
13091 + struct in6_addr mask;
13094 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
13095 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
13097 +struct vcmd_match_ipv4_v0 {
13102 + struct in_addr ip;
13103 + struct in_addr ip2;
13104 + struct in_addr mask;
13107 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
13108 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
13110 +struct vcmd_match_ipv6_v0 {
13115 + struct in6_addr ip;
13116 + struct in6_addr ip2;
13117 + struct in6_addr mask;
13122 +extern int vc_net_create(uint32_t, void __user *);
13123 +extern int vc_net_migrate(struct nx_info *, void __user *);
13125 +extern int vc_net_add(struct nx_info *, void __user *);
13126 +extern int vc_net_remove(struct nx_info *, void __user *);
13128 +extern int vc_net_add_ipv4_v1(struct nx_info *, void __user *);
13129 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
13131 +extern int vc_net_rem_ipv4_v1(struct nx_info *, void __user *);
13132 +extern int vc_net_rem_ipv4(struct nx_info *, void __user *);
13134 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
13135 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
13137 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
13138 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
13140 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
13141 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
13143 +#endif /* __KERNEL__ */
13146 +/* flag commands */
13148 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
13149 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
13151 +struct vcmd_net_flags_v0 {
13152 + uint64_t flagword;
13157 +extern int vc_get_nflags(struct nx_info *, void __user *);
13158 +extern int vc_set_nflags(struct nx_info *, void __user *);
13160 +#endif /* __KERNEL__ */
13163 +/* network caps commands */
13165 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
13166 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
13168 +struct vcmd_net_caps_v0 {
13174 +extern int vc_get_ncaps(struct nx_info *, void __user *);
13175 +extern int vc_set_ncaps(struct nx_info *, void __user *);
13177 +#endif /* __KERNEL__ */
13178 +#endif /* _VX_CONTEXT_CMD_H */
13179 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/percpu.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/percpu.h
13180 --- linux-3.6.9/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
13181 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/percpu.h 2012-10-04 18:47:00.000000000 +0200
13183 +#ifndef _VX_PERCPU_H
13184 +#define _VX_PERCPU_H
13186 +#include "cvirt_def.h"
13187 +#include "sched_def.h"
13189 +struct _vx_percpu {
13190 + struct _vx_cvirt_pc cvirt;
13191 + struct _vx_sched_pc sched;
13194 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
13196 +#endif /* _VX_PERCPU_H */
13197 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/pid.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/pid.h
13198 --- linux-3.6.9/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
13199 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/pid.h 2012-10-04 18:47:00.000000000 +0200
13201 +#ifndef _VSERVER_PID_H
13202 +#define _VSERVER_PID_H
13204 +/* pid faking stuff */
13206 +#define vx_info_map_pid(v, p) \
13207 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
13208 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
13209 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
13210 +#define vx_map_tgid(p) vx_map_pid(p)
13212 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
13213 + const char *func, const char *file, int line)
13215 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13216 + vxfprintk(VXD_CBIT(cvirt, 2),
13217 + "vx_map_tgid: %p/%llx: %d -> %d",
13218 + vxi, (long long)vxi->vx_flags, pid,
13219 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
13220 + func, file, line);
13223 + if (pid == vxi->vx_initpid)
13229 +#define vx_info_rmap_pid(v, p) \
13230 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
13231 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
13232 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
13234 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
13235 + const char *func, const char *file, int line)
13237 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13238 + vxfprintk(VXD_CBIT(cvirt, 2),
13239 + "vx_rmap_tgid: %p/%llx: %d -> %d",
13240 + vxi, (long long)vxi->vx_flags, pid,
13241 + (pid == 1) ? vxi->vx_initpid : pid,
13242 + func, file, line);
13243 + if ((pid == 1) && vxi->vx_initpid)
13244 + return vxi->vx_initpid;
13245 + if (pid == vxi->vx_initpid)
13252 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/sched.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/sched.h
13253 --- linux-3.6.9/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
13254 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/sched.h 2012-10-04 18:47:00.000000000 +0200
13256 +#ifndef _VX_SCHED_H
13257 +#define _VX_SCHED_H
13264 +void vx_vsi_uptime(struct timespec *, struct timespec *);
13269 +void vx_update_load(struct vx_info *);
13272 +void vx_update_sched_param(struct _vx_sched *sched,
13273 + struct _vx_sched_pc *sched_pc);
13275 +#endif /* __KERNEL__ */
13276 +#else /* _VX_SCHED_H */
13277 +#warning duplicate inclusion
13278 +#endif /* _VX_SCHED_H */
13279 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/sched_cmd.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/sched_cmd.h
13280 --- linux-3.6.9/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
13281 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/sched_cmd.h 2012-10-04 18:47:00.000000000 +0200
13283 +#ifndef _VX_SCHED_CMD_H
13284 +#define _VX_SCHED_CMD_H
13287 +struct vcmd_prio_bias {
13289 + int32_t prio_bias;
13292 +#define VCMD_set_prio_bias VC_CMD(SCHED, 4, 0)
13293 +#define VCMD_get_prio_bias VC_CMD(SCHED, 5, 0)
13297 +#include <linux/compiler.h>
13299 +extern int vc_set_prio_bias(struct vx_info *, void __user *);
13300 +extern int vc_get_prio_bias(struct vx_info *, void __user *);
13302 +#endif /* __KERNEL__ */
13303 +#endif /* _VX_SCHED_CMD_H */
13304 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/sched_def.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/sched_def.h
13305 --- linux-3.6.9/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
13306 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/sched_def.h 2012-10-04 18:47:00.000000000 +0200
13308 +#ifndef _VX_SCHED_DEF_H
13309 +#define _VX_SCHED_DEF_H
13311 +#include <linux/spinlock.h>
13312 +#include <linux/jiffies.h>
13313 +#include <linux/cpumask.h>
13314 +#include <asm/atomic.h>
13315 +#include <asm/param.h>
13318 +/* context sub struct */
13320 +struct _vx_sched {
13321 + int prio_bias; /* bias offset for priority */
13323 + cpumask_t update; /* CPUs which should update */
13326 +struct _vx_sched_pc {
13327 + int prio_bias; /* bias offset for priority */
13329 + uint64_t user_ticks; /* token tick events */
13330 + uint64_t sys_ticks; /* token tick events */
13331 + uint64_t hold_ticks; /* token ticks paused */
13335 +#ifdef CONFIG_VSERVER_DEBUG
13337 +static inline void __dump_vx_sched(struct _vx_sched *sched)
13339 + printk("\t_vx_sched:\n");
13340 + printk("\t priority = %4d\n", sched->prio_bias);
13345 +#endif /* _VX_SCHED_DEF_H */
13346 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/signal.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/signal.h
13347 --- linux-3.6.9/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
13348 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/signal.h 2012-10-04 18:47:00.000000000 +0200
13350 +#ifndef _VX_SIGNAL_H
13351 +#define _VX_SIGNAL_H
13358 +int vx_info_kill(struct vx_info *, int, int);
13360 +#endif /* __KERNEL__ */
13361 +#else /* _VX_SIGNAL_H */
13362 +#warning duplicate inclusion
13363 +#endif /* _VX_SIGNAL_H */
13364 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/signal_cmd.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/signal_cmd.h
13365 --- linux-3.6.9/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
13366 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/signal_cmd.h 2012-10-04 18:47:00.000000000 +0200
13368 +#ifndef _VX_SIGNAL_CMD_H
13369 +#define _VX_SIGNAL_CMD_H
13372 +/* signalling vserver commands */
13374 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
13375 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
13377 +struct vcmd_ctx_kill_v0 {
13382 +struct vcmd_wait_exit_v0 {
13383 + int32_t reboot_cmd;
13384 + int32_t exit_code;
13389 +extern int vc_ctx_kill(struct vx_info *, void __user *);
13390 +extern int vc_wait_exit(struct vx_info *, void __user *);
13392 +#endif /* __KERNEL__ */
13394 +/* process alteration commands */
13396 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
13397 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
13399 +struct vcmd_pflags_v0 {
13400 + uint32_t flagword;
13406 +extern int vc_get_pflags(uint32_t pid, void __user *);
13407 +extern int vc_set_pflags(uint32_t pid, void __user *);
13409 +#endif /* __KERNEL__ */
13410 +#endif /* _VX_SIGNAL_CMD_H */
13411 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/space.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/space.h
13412 --- linux-3.6.9/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
13413 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/space.h 2012-10-04 18:47:00.000000000 +0200
13415 +#ifndef _VX_SPACE_H
13416 +#define _VX_SPACE_H
13418 +#include <linux/types.h>
13422 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
13424 +#else /* _VX_SPACE_H */
13425 +#warning duplicate inclusion
13426 +#endif /* _VX_SPACE_H */
13427 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/space_cmd.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/space_cmd.h
13428 --- linux-3.6.9/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
13429 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/space_cmd.h 2012-10-04 18:47:00.000000000 +0200
13431 +#ifndef _VX_SPACE_CMD_H
13432 +#define _VX_SPACE_CMD_H
13435 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
13436 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
13437 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
13439 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
13440 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
13441 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
13443 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
13445 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
13446 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
13449 +struct vcmd_space_mask_v1 {
13453 +struct vcmd_space_mask_v2 {
13461 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
13462 +extern int vc_set_space_v1(struct vx_info *, void __user *);
13463 +extern int vc_enter_space(struct vx_info *, void __user *);
13464 +extern int vc_set_space(struct vx_info *, void __user *);
13465 +extern int vc_get_space_mask(void __user *, int);
13467 +#endif /* __KERNEL__ */
13468 +#endif /* _VX_SPACE_CMD_H */
13469 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/switch.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/switch.h
13470 --- linux-3.6.9/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
13471 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/switch.h 2012-10-04 18:47:00.000000000 +0200
13473 +#ifndef _VX_SWITCH_H
13474 +#define _VX_SWITCH_H
13476 +#include <linux/types.h>
13479 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
13480 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
13481 +#define VC_VERSION(c) ((c) & 0xFFF)
13483 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
13484 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
13488 + Syscall Matrix V2.8
13490 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
13491 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
13492 + |INFO |SETUP | |MOVE | | | | | |
13493 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13494 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
13495 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
13496 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13497 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
13498 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
13499 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13500 + MEMORY | | | | |MEMCTRL| | |SWAP | |
13501 + | 16| 17| 18| 19| 20| 21| | 22| 23|
13502 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13503 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
13504 + | 24| 25| 26| 27| 28| 29| | 30| 31|
13505 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13506 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
13507 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
13508 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13509 + OTHER |VSTAT | | | | | | |VINFO | |
13510 + | 40| 41| 42| 43| 44| 45| | 46| 47|
13511 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
13512 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
13513 + | 48| 49| 50| 51| 52| 53| | 54| 55|
13514 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13515 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
13516 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
13517 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13521 +#define VC_CAT_VERSION 0
13523 +#define VC_CAT_VSETUP 1
13524 +#define VC_CAT_VHOST 2
13526 +#define VC_CAT_DEVICE 6
13528 +#define VC_CAT_VPROC 9
13529 +#define VC_CAT_PROCALT 10
13530 +#define VC_CAT_PROCMIG 11
13531 +#define VC_CAT_PROCTRL 12
13533 +#define VC_CAT_SCHED 14
13534 +#define VC_CAT_MEMCTRL 20
13536 +#define VC_CAT_VNET 25
13537 +#define VC_CAT_NETALT 26
13538 +#define VC_CAT_NETMIG 27
13539 +#define VC_CAT_NETCTRL 28
13541 +#define VC_CAT_TAGMIG 35
13542 +#define VC_CAT_DLIMIT 36
13543 +#define VC_CAT_INODE 38
13545 +#define VC_CAT_VSTAT 40
13546 +#define VC_CAT_VINFO 46
13547 +#define VC_CAT_EVENT 48
13549 +#define VC_CAT_FLAGS 52
13550 +#define VC_CAT_VSPACE 54
13551 +#define VC_CAT_DEBUG 56
13552 +#define VC_CAT_RLIMIT 60
13554 +#define VC_CAT_SYSTEST 61
13555 +#define VC_CAT_COMPAT 63
13557 +/* query version */
13559 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
13560 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
13565 +#include <linux/errno.h>
13567 +#endif /* __KERNEL__ */
13569 +#endif /* _VX_SWITCH_H */
13571 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/tag.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/tag.h
13572 --- linux-3.6.9/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
13573 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/tag.h 2012-10-04 18:47:00.000000000 +0200
13578 +#include <linux/types.h>
13581 +#define DX_TAG(in) (IS_TAGGED(in))
13584 +#ifdef CONFIG_TAG_NFSD
13585 +#define DX_TAG_NFSD 1
13587 +#define DX_TAG_NFSD 0
13591 +#ifdef CONFIG_TAGGING_NONE
13593 +#define MAX_UID 0xFFFFFFFF
13594 +#define MAX_GID 0xFFFFFFFF
13596 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
13598 +#define TAGINO_UID(cond, uid, tag) (uid)
13599 +#define TAGINO_GID(cond, gid, tag) (gid)
13604 +#ifdef CONFIG_TAGGING_GID16
13606 +#define MAX_UID 0xFFFFFFFF
13607 +#define MAX_GID 0x0000FFFF
13609 +#define INOTAG_TAG(cond, uid, gid, tag) \
13610 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
13612 +#define TAGINO_UID(cond, uid, tag) (uid)
13613 +#define TAGINO_GID(cond, gid, tag) \
13614 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
13619 +#ifdef CONFIG_TAGGING_ID24
13621 +#define MAX_UID 0x00FFFFFF
13622 +#define MAX_GID 0x00FFFFFF
13624 +#define INOTAG_TAG(cond, uid, gid, tag) \
13625 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
13627 +#define TAGINO_UID(cond, uid, tag) \
13628 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
13629 +#define TAGINO_GID(cond, gid, tag) \
13630 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
13635 +#ifdef CONFIG_TAGGING_UID16
13637 +#define MAX_UID 0x0000FFFF
13638 +#define MAX_GID 0xFFFFFFFF
13640 +#define INOTAG_TAG(cond, uid, gid, tag) \
13641 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
13643 +#define TAGINO_UID(cond, uid, tag) \
13644 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
13645 +#define TAGINO_GID(cond, gid, tag) (gid)
13650 +#ifdef CONFIG_TAGGING_INTERN
13652 +#define MAX_UID 0xFFFFFFFF
13653 +#define MAX_GID 0xFFFFFFFF
13655 +#define INOTAG_TAG(cond, uid, gid, tag) \
13656 + ((cond) ? (tag) : 0)
13658 +#define TAGINO_UID(cond, uid, tag) (uid)
13659 +#define TAGINO_GID(cond, gid, tag) (gid)
13664 +#ifndef CONFIG_TAGGING_NONE
13665 +#define dx_current_fstag(sb) \
13666 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
13668 +#define dx_current_fstag(sb) (0)
13671 +#ifndef CONFIG_TAGGING_INTERN
13672 +#define TAGINO_TAG(cond, tag) (0)
13674 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
13677 +#define INOTAG_UID(cond, uid, gid) \
13678 + ((cond) ? ((uid) & MAX_UID) : (uid))
13679 +#define INOTAG_GID(cond, uid, gid) \
13680 + ((cond) ? ((gid) & MAX_GID) : (gid))
13683 +static inline uid_t dx_map_uid(uid_t uid)
13685 + if ((uid > MAX_UID) && (uid != -1))
13687 + return (uid & MAX_UID);
13690 +static inline gid_t dx_map_gid(gid_t gid)
13692 + if ((gid > MAX_GID) && (gid != -1))
13694 + return (gid & MAX_GID);
13702 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
13704 +int dx_parse_tag(char *string, vs_tag_t *tag, int remove, int *mnt_flags,
13705 + unsigned long *flags);
13707 +#ifdef CONFIG_PROPAGATE
13709 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
13711 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
13714 +#define dx_propagate_tag(n, i) do { } while (0)
13717 +#endif /* _DX_TAG_H */
13718 diff -NurpP --minimal linux-3.6.9/include/linux/vserver/tag_cmd.h linux-3.6.9-vs2.3.4.4/include/linux/vserver/tag_cmd.h
13719 --- linux-3.6.9/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
13720 +++ linux-3.6.9-vs2.3.4.4/include/linux/vserver/tag_cmd.h 2012-10-04 18:47:00.000000000 +0200
13722 +#ifndef _VX_TAG_CMD_H
13723 +#define _VX_TAG_CMD_H
13726 +/* vinfo commands */
13728 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
13731 +extern int vc_task_tag(uint32_t);
13733 +#endif /* __KERNEL__ */
13735 +/* context commands */
13737 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
13740 +extern int vc_tag_migrate(uint32_t);
13742 +#endif /* __KERNEL__ */
13743 +#endif /* _VX_TAG_CMD_H */
13744 diff -NurpP --minimal linux-3.6.9/include/net/addrconf.h linux-3.6.9-vs2.3.4.4/include/net/addrconf.h
13745 --- linux-3.6.9/include/net/addrconf.h 2012-10-04 15:27:47.000000000 +0200
13746 +++ linux-3.6.9-vs2.3.4.4/include/net/addrconf.h 2012-10-04 18:47:00.000000000 +0200
13747 @@ -81,7 +81,8 @@ extern int ipv6_dev_get_saddr(struct n
13748 struct net_device *dev,
13749 const struct in6_addr *daddr,
13750 unsigned int srcprefs,
13751 - struct in6_addr *saddr);
13752 + struct in6_addr *saddr,
13753 + struct nx_info *nxi);
13754 extern int ipv6_get_lladdr(struct net_device *dev,
13755 struct in6_addr *addr,
13756 unsigned char banned_flags);
13757 diff -NurpP --minimal linux-3.6.9/include/net/af_unix.h linux-3.6.9-vs2.3.4.4/include/net/af_unix.h
13758 --- linux-3.6.9/include/net/af_unix.h 2012-10-04 15:27:47.000000000 +0200
13759 +++ linux-3.6.9-vs2.3.4.4/include/net/af_unix.h 2012-10-04 18:47:00.000000000 +0200
13761 #include <linux/socket.h>
13762 #include <linux/un.h>
13763 #include <linux/mutex.h>
13764 +#include <linux/vs_base.h>
13765 #include <net/sock.h>
13767 extern void unix_inflight(struct file *fp);
13768 diff -NurpP --minimal linux-3.6.9/include/net/inet_timewait_sock.h linux-3.6.9-vs2.3.4.4/include/net/inet_timewait_sock.h
13769 --- linux-3.6.9/include/net/inet_timewait_sock.h 2012-03-19 19:47:29.000000000 +0100
13770 +++ linux-3.6.9-vs2.3.4.4/include/net/inet_timewait_sock.h 2012-10-04 18:47:00.000000000 +0200
13771 @@ -112,6 +112,10 @@ struct inet_timewait_sock {
13772 #define tw_net __tw_common.skc_net
13773 #define tw_daddr __tw_common.skc_daddr
13774 #define tw_rcv_saddr __tw_common.skc_rcv_saddr
13775 +#define tw_xid __tw_common.skc_xid
13776 +#define tw_vx_info __tw_common.skc_vx_info
13777 +#define tw_nid __tw_common.skc_nid
13778 +#define tw_nx_info __tw_common.skc_nx_info
13780 volatile unsigned char tw_substate;
13781 unsigned char tw_rcv_wscale;
13782 diff -NurpP --minimal linux-3.6.9/include/net/ip6_route.h linux-3.6.9-vs2.3.4.4/include/net/ip6_route.h
13783 --- linux-3.6.9/include/net/ip6_route.h 2012-10-04 15:27:47.000000000 +0200
13784 +++ linux-3.6.9-vs2.3.4.4/include/net/ip6_route.h 2012-10-04 18:47:00.000000000 +0200
13785 @@ -97,7 +97,8 @@ extern int ip6_route_get_saddr(struct
13786 struct rt6_info *rt,
13787 const struct in6_addr *daddr,
13788 unsigned int prefs,
13789 - struct in6_addr *saddr);
13790 + struct in6_addr *saddr,
13791 + struct nx_info *nxi);
13793 extern struct rt6_info *rt6_lookup(struct net *net,
13794 const struct in6_addr *daddr,
13795 diff -NurpP --minimal linux-3.6.9/include/net/route.h linux-3.6.9-vs2.3.4.4/include/net/route.h
13796 --- linux-3.6.9/include/net/route.h 2012-12-08 01:34:14.000000000 +0100
13797 +++ linux-3.6.9-vs2.3.4.4/include/net/route.h 2012-11-06 18:43:41.000000000 +0100
13798 @@ -204,6 +204,9 @@ static inline void ip_rt_put(struct rtab
13799 dst_release(&rt->dst);
13802 +#include <linux/vs_base.h>
13803 +#include <linux/vs_inet.h>
13805 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
13807 extern const __u8 ip_tos2prio[16];
13808 @@ -253,6 +256,9 @@ static inline void ip_route_connect_init
13809 protocol, flow_flags, dst, src, dport, sport);
13812 +extern struct rtable *ip_v4_find_src(struct net *net, struct nx_info *,
13813 + struct flowi4 *);
13815 static inline struct rtable *ip_route_connect(struct flowi4 *fl4,
13816 __be32 dst, __be32 src, u32 tos,
13817 int oif, u8 protocol,
13818 @@ -261,11 +267,25 @@ static inline struct rtable *ip_route_co
13820 struct net *net = sock_net(sk);
13822 + struct nx_info *nx_info = current_nx_info();
13824 ip_route_connect_init(fl4, dst, src, tos, oif, protocol,
13825 sport, dport, sk, can_sleep);
13827 - if (!dst || !src) {
13829 + nx_info = sk->sk_nx_info;
13831 + vxdprintk(VXD_CBIT(net, 4),
13832 + "ip_route_connect(%p) %p,%p;%lx",
13833 + sk, nx_info, sk->sk_socket,
13834 + (sk->sk_socket?sk->sk_socket->flags:0));
13836 + rt = ip_v4_find_src(net, nx_info, fl4);
13841 + if (!fl4->daddr || !fl4->saddr) {
13842 rt = __ip_route_output_key(net, fl4);
13845 diff -NurpP --minimal linux-3.6.9/include/net/sock.h linux-3.6.9-vs2.3.4.4/include/net/sock.h
13846 --- linux-3.6.9/include/net/sock.h 2012-10-04 15:27:47.000000000 +0200
13847 +++ linux-3.6.9-vs2.3.4.4/include/net/sock.h 2012-10-04 18:47:00.000000000 +0200
13848 @@ -171,6 +171,10 @@ struct sock_common {
13849 #ifdef CONFIG_NET_NS
13850 struct net *skc_net;
13853 + struct vx_info *skc_vx_info;
13855 + struct nx_info *skc_nx_info;
13857 * fields between dontcopy_begin/dontcopy_end
13858 * are not copied in sock_copy()
13859 @@ -284,6 +288,10 @@ struct sock {
13860 #define sk_bind_node __sk_common.skc_bind_node
13861 #define sk_prot __sk_common.skc_prot
13862 #define sk_net __sk_common.skc_net
13863 +#define sk_xid __sk_common.skc_xid
13864 +#define sk_vx_info __sk_common.skc_vx_info
13865 +#define sk_nid __sk_common.skc_nid
13866 +#define sk_nx_info __sk_common.skc_nx_info
13867 socket_lock_t sk_lock;
13868 struct sk_buff_head sk_receive_queue;
13870 diff -NurpP --minimal linux-3.6.9/init/Kconfig linux-3.6.9-vs2.3.4.4/init/Kconfig
13871 --- linux-3.6.9/init/Kconfig 2012-10-04 15:27:48.000000000 +0200
13872 +++ linux-3.6.9-vs2.3.4.4/init/Kconfig 2012-10-04 18:47:00.000000000 +0200
13873 @@ -624,6 +624,7 @@ config HAVE_UNSTABLE_SCHED_CLOCK
13875 boolean "Control Group support"
13879 This option adds support for grouping sets of processes together, for
13880 use with process control subsystems such as Cpusets, CFS, memory
13881 @@ -889,6 +890,7 @@ config USER_NS
13882 bool "User namespace (EXPERIMENTAL)"
13883 depends on EXPERIMENTAL
13884 depends on UIDGID_CONVERTED
13885 + depends on VSERVER_DISABLED
13886 select UIDGID_STRICT_TYPE_CHECKS
13889 diff -NurpP --minimal linux-3.6.9/init/main.c linux-3.6.9-vs2.3.4.4/init/main.c
13890 --- linux-3.6.9/init/main.c 2012-12-08 01:34:14.000000000 +0100
13891 +++ linux-3.6.9-vs2.3.4.4/init/main.c 2012-11-06 18:43:41.000000000 +0100
13893 #include <linux/slab.h>
13894 #include <linux/perf_event.h>
13895 #include <linux/file.h>
13896 +#include <linux/vserver/percpu.h>
13898 #include <asm/io.h>
13899 #include <asm/bugs.h>
13900 diff -NurpP --minimal linux-3.6.9/ipc/mqueue.c linux-3.6.9-vs2.3.4.4/ipc/mqueue.c
13901 --- linux-3.6.9/ipc/mqueue.c 2012-10-04 15:27:48.000000000 +0200
13902 +++ linux-3.6.9-vs2.3.4.4/ipc/mqueue.c 2012-10-04 18:47:00.000000000 +0200
13904 #include <linux/ipc_namespace.h>
13905 #include <linux/user_namespace.h>
13906 #include <linux/slab.h>
13907 +#include <linux/vs_context.h>
13908 +#include <linux/vs_limit.h>
13910 #include <net/sock.h>
13912 @@ -76,6 +78,7 @@ struct mqueue_inode_info {
13913 struct pid* notify_owner;
13914 struct user_namespace *notify_user_ns;
13915 struct user_struct *user; /* user who created, for accounting */
13916 + struct vx_info *vxi;
13917 struct sock *notify_sock;
13918 struct sk_buff *notify_cookie;
13920 @@ -235,6 +238,7 @@ static struct inode *mqueue_get_inode(st
13921 if (S_ISREG(mode)) {
13922 struct mqueue_inode_info *info;
13923 unsigned long mq_bytes, mq_treesize;
13924 + struct vx_info *vxi = current_vx_info();
13926 inode->i_fop = &mqueue_file_operations;
13927 inode->i_size = FILENT_SIZE;
13928 @@ -248,6 +252,7 @@ static struct inode *mqueue_get_inode(st
13929 info->notify_user_ns = NULL;
13931 info->user = NULL; /* set when all is ok */
13932 + info->vxi = NULL;
13933 info->msg_tree = RB_ROOT;
13934 info->node_cache = NULL;
13935 memset(&info->attr, 0, sizeof(info->attr));
13936 @@ -281,17 +286,20 @@ static struct inode *mqueue_get_inode(st
13938 spin_lock(&mq_lock);
13939 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
13940 - u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
13941 + u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE) ||
13942 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
13943 spin_unlock(&mq_lock);
13944 /* mqueue_evict_inode() releases info->messages */
13948 u->mq_bytes += mq_bytes;
13949 + vx_ipcmsg_add(vxi, u, mq_bytes);
13950 spin_unlock(&mq_lock);
13953 info->user = get_uid(u);
13954 + info->vxi = get_vx_info(vxi);
13955 } else if (S_ISDIR(mode)) {
13957 /* Some things misbehave if size == 0 on a directory */
13958 @@ -395,8 +403,11 @@ static void mqueue_evict_inode(struct in
13962 + struct vx_info *vxi = info->vxi;
13964 spin_lock(&mq_lock);
13965 user->mq_bytes -= mq_bytes;
13966 + vx_ipcmsg_sub(vxi, user, mq_bytes);
13968 * get_ns_from_inode() ensures that the
13969 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
13970 @@ -406,6 +417,7 @@ static void mqueue_evict_inode(struct in
13972 ipc_ns->mq_queues_count--;
13973 spin_unlock(&mq_lock);
13974 + put_vx_info(vxi);
13978 diff -NurpP --minimal linux-3.6.9/ipc/msg.c linux-3.6.9-vs2.3.4.4/ipc/msg.c
13979 --- linux-3.6.9/ipc/msg.c 2011-05-22 16:17:59.000000000 +0200
13980 +++ linux-3.6.9-vs2.3.4.4/ipc/msg.c 2012-10-04 18:47:00.000000000 +0200
13982 #include <linux/rwsem.h>
13983 #include <linux/nsproxy.h>
13984 #include <linux/ipc_namespace.h>
13985 +#include <linux/vs_base.h>
13987 #include <asm/current.h>
13988 #include <asm/uaccess.h>
13989 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
13991 msq->q_perm.mode = msgflg & S_IRWXUGO;
13992 msq->q_perm.key = key;
13993 + msq->q_perm.xid = vx_current_xid();
13995 msq->q_perm.security = NULL;
13996 retval = security_msg_queue_alloc(msq);
13997 diff -NurpP --minimal linux-3.6.9/ipc/namespace.c linux-3.6.9-vs2.3.4.4/ipc/namespace.c
13998 --- linux-3.6.9/ipc/namespace.c 2012-07-22 23:39:46.000000000 +0200
13999 +++ linux-3.6.9-vs2.3.4.4/ipc/namespace.c 2012-10-04 18:47:00.000000000 +0200
14000 @@ -13,11 +13,12 @@
14001 #include <linux/mount.h>
14002 #include <linux/user_namespace.h>
14003 #include <linux/proc_fs.h>
14004 +#include <linux/vs_base.h>
14005 +#include <linux/vserver/global.h>
14009 -static struct ipc_namespace *create_ipc_ns(struct task_struct *tsk,
14010 - struct ipc_namespace *old_ns)
14011 +static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns)
14013 struct ipc_namespace *ns;
14015 @@ -46,19 +47,19 @@ static struct ipc_namespace *create_ipc_
14016 ipcns_notify(IPCNS_CREATED);
14017 register_ipcns_notifier(ns);
14019 - ns->user_ns = get_user_ns(task_cred_xxx(tsk, user_ns));
14020 + // ns->user_ns = get_user_ns(task_cred_xxx(tsk, user_ns));
14021 + ns->user_ns = get_user_ns(user_ns);
14026 struct ipc_namespace *copy_ipcs(unsigned long flags,
14027 - struct task_struct *tsk)
14028 + struct ipc_namespace *old_ns,
14029 + struct user_namespace *user_ns)
14031 - struct ipc_namespace *ns = tsk->nsproxy->ipc_ns;
14033 if (!(flags & CLONE_NEWIPC))
14034 - return get_ipc_ns(ns);
14035 - return create_ipc_ns(tsk, ns);
14036 + return get_ipc_ns(old_ns);
14037 + return create_ipc_ns(user_ns);
14041 diff -NurpP --minimal linux-3.6.9/ipc/sem.c linux-3.6.9-vs2.3.4.4/ipc/sem.c
14042 --- linux-3.6.9/ipc/sem.c 2012-01-09 16:14:59.000000000 +0100
14043 +++ linux-3.6.9-vs2.3.4.4/ipc/sem.c 2012-10-04 18:47:00.000000000 +0200
14045 #include <linux/rwsem.h>
14046 #include <linux/nsproxy.h>
14047 #include <linux/ipc_namespace.h>
14048 +#include <linux/vs_base.h>
14049 +#include <linux/vs_limit.h>
14051 #include <asm/uaccess.h>
14053 @@ -306,6 +308,7 @@ static int newary(struct ipc_namespace *
14055 sma->sem_perm.mode = (semflg & S_IRWXUGO);
14056 sma->sem_perm.key = key;
14057 + sma->sem_perm.xid = vx_current_xid();
14059 sma->sem_perm.security = NULL;
14060 retval = security_sem_alloc(sma);
14061 @@ -321,6 +324,9 @@ static int newary(struct ipc_namespace *
14064 ns->used_sems += nsems;
14065 + /* FIXME: obsoleted? */
14066 + vx_semary_inc(sma);
14067 + vx_nsems_add(sma, nsems);
14069 sma->sem_base = (struct sem *) &sma[1];
14071 @@ -770,6 +776,9 @@ static void freeary(struct ipc_namespace
14073 wake_up_sem_queue_do(&tasks);
14074 ns->used_sems -= sma->sem_nsems;
14075 + /* FIXME: obsoleted? */
14076 + vx_nsems_sub(sma, sma->sem_nsems);
14077 + vx_semary_dec(sma);
14078 security_sem_free(sma);
14079 ipc_rcu_putref(sma);
14081 diff -NurpP --minimal linux-3.6.9/ipc/shm.c linux-3.6.9-vs2.3.4.4/ipc/shm.c
14082 --- linux-3.6.9/ipc/shm.c 2012-10-04 15:27:48.000000000 +0200
14083 +++ linux-3.6.9-vs2.3.4.4/ipc/shm.c 2012-10-04 18:47:00.000000000 +0200
14085 #include <linux/nsproxy.h>
14086 #include <linux/mount.h>
14087 #include <linux/ipc_namespace.h>
14088 +#include <linux/vs_context.h>
14089 +#include <linux/vs_limit.h>
14091 #include <asm/uaccess.h>
14093 @@ -187,7 +189,12 @@ static void shm_open(struct vm_area_stru
14095 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
14097 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14098 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
14099 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14101 + vx_ipcshm_sub(vxi, shp, numpages);
14102 + ns->shm_tot -= numpages;
14106 if (!is_file_hugepages(shp->shm_file))
14107 @@ -197,6 +204,7 @@ static void shm_destroy(struct ipc_names
14109 fput (shp->shm_file);
14110 security_shm_free(shp);
14111 + put_vx_info(vxi);
14112 ipc_rcu_putref(shp);
14115 @@ -474,11 +482,15 @@ static int newseg(struct ipc_namespace *
14116 if (ns->shm_tot + numpages > ns->shm_ctlall)
14119 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
14122 shp = ipc_rcu_alloc(sizeof(*shp));
14126 shp->shm_perm.key = key;
14127 + shp->shm_perm.xid = vx_current_xid();
14128 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
14129 shp->mlock_user = NULL;
14131 @@ -533,6 +545,7 @@ static int newseg(struct ipc_namespace *
14132 ns->shm_tot += numpages;
14133 error = shp->shm_perm.id;
14135 + vx_ipcshm_add(current_vx_info(), key, numpages);
14139 diff -NurpP --minimal linux-3.6.9/kernel/Makefile linux-3.6.9-vs2.3.4.4/kernel/Makefile
14140 --- linux-3.6.9/kernel/Makefile 2012-07-22 23:39:46.000000000 +0200
14141 +++ linux-3.6.9-vs2.3.4.4/kernel/Makefile 2012-10-04 18:47:00.000000000 +0200
14142 @@ -24,6 +24,7 @@ endif
14148 ifeq ($(CONFIG_CHECKPOINT_RESTORE),y)
14149 obj-$(CONFIG_X86) += kcmp.o
14150 diff -NurpP --minimal linux-3.6.9/kernel/auditsc.c linux-3.6.9-vs2.3.4.4/kernel/auditsc.c
14151 --- linux-3.6.9/kernel/auditsc.c 2012-07-22 23:39:46.000000000 +0200
14152 +++ linux-3.6.9-vs2.3.4.4/kernel/auditsc.c 2012-10-04 18:47:00.000000000 +0200
14153 @@ -2309,7 +2309,7 @@ int audit_set_loginuid(uid_t loginuid)
14154 if (task->loginuid != -1)
14156 #else /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
14157 - if (!capable(CAP_AUDIT_CONTROL))
14158 + if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
14160 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
14162 diff -NurpP --minimal linux-3.6.9/kernel/capability.c linux-3.6.9-vs2.3.4.4/kernel/capability.c
14163 --- linux-3.6.9/kernel/capability.c 2012-07-22 23:39:46.000000000 +0200
14164 +++ linux-3.6.9-vs2.3.4.4/kernel/capability.c 2012-10-04 18:47:00.000000000 +0200
14166 #include <linux/syscalls.h>
14167 #include <linux/pid_namespace.h>
14168 #include <linux/user_namespace.h>
14169 +#include <linux/vs_context.h>
14170 #include <asm/uaccess.h>
14173 @@ -116,6 +117,7 @@ static int cap_validate_magic(cap_user_h
14179 * The only thing that can change the capabilities of the current
14180 * process is the current process. As such, we can't be in this code
14181 @@ -349,6 +351,8 @@ bool has_ns_capability_noaudit(struct ta
14185 +#include <linux/vserver/base.h>
14188 * has_capability_noaudit - Does a task have a capability (unaudited) in the
14190 diff -NurpP --minimal linux-3.6.9/kernel/compat.c linux-3.6.9-vs2.3.4.4/kernel/compat.c
14191 --- linux-3.6.9/kernel/compat.c 2012-07-22 23:39:46.000000000 +0200
14192 +++ linux-3.6.9-vs2.3.4.4/kernel/compat.c 2012-10-04 18:47:00.000000000 +0200
14193 @@ -1054,7 +1054,7 @@ asmlinkage long compat_sys_stime(compat_
14197 - do_settimeofday(&tv);
14198 + vx_settimeofday(&tv);
14202 diff -NurpP --minimal linux-3.6.9/kernel/cred.c linux-3.6.9-vs2.3.4.4/kernel/cred.c
14203 --- linux-3.6.9/kernel/cred.c 2012-07-22 23:39:46.000000000 +0200
14204 +++ linux-3.6.9-vs2.3.4.4/kernel/cred.c 2012-10-04 18:47:00.000000000 +0200
14205 @@ -70,31 +70,6 @@ struct cred init_cred = {
14209 -static inline void set_cred_subscribers(struct cred *cred, int n)
14211 -#ifdef CONFIG_DEBUG_CREDENTIALS
14212 - atomic_set(&cred->subscribers, n);
14216 -static inline int read_cred_subscribers(const struct cred *cred)
14218 -#ifdef CONFIG_DEBUG_CREDENTIALS
14219 - return atomic_read(&cred->subscribers);
14225 -static inline void alter_cred_subscribers(const struct cred *_cred, int n)
14227 -#ifdef CONFIG_DEBUG_CREDENTIALS
14228 - struct cred *cred = (struct cred *) _cred;
14230 - atomic_add(n, &cred->subscribers);
14235 * Dispose of the shared task group credentials
14237 @@ -284,21 +259,16 @@ error:
14239 * Call commit_creds() or abort_creds() to clean up.
14241 -struct cred *prepare_creds(void)
14242 +struct cred *__prepare_creds(const struct cred *old)
14244 - struct task_struct *task = current;
14245 - const struct cred *old;
14248 - validate_process_creds();
14250 new = kmem_cache_alloc(cred_jar, GFP_KERNEL);
14254 kdebug("prepare_creds() alloc %p", new);
14256 - old = task->cred;
14257 memcpy(new, old, sizeof(struct cred));
14259 atomic_set(&new->usage, 1);
14260 @@ -326,6 +296,13 @@ error:
14265 +struct cred *prepare_creds(void)
14267 + validate_process_creds();
14269 + return __prepare_creds(current->cred);
14271 EXPORT_SYMBOL(prepare_creds);
14274 diff -NurpP --minimal linux-3.6.9/kernel/exit.c linux-3.6.9-vs2.3.4.4/kernel/exit.c
14275 --- linux-3.6.9/kernel/exit.c 2012-10-04 15:27:48.000000000 +0200
14276 +++ linux-3.6.9-vs2.3.4.4/kernel/exit.c 2012-12-08 01:20:39.000000000 +0100
14278 #include <linux/fs_struct.h>
14279 #include <linux/init_task.h>
14280 #include <linux/perf_event.h>
14281 +#include <linux/vs_limit.h>
14282 +#include <linux/vs_context.h>
14283 +#include <linux/vs_network.h>
14284 +#include <linux/vs_pid.h>
14285 #include <trace/events/sched.h>
14286 #include <linux/hw_breakpoint.h>
14287 #include <linux/oom.h>
14288 @@ -494,9 +498,11 @@ static void close_files(struct files_str
14289 filp_close(file, files);
14292 + vx_openfd_dec(i);
14300 @@ -711,15 +717,25 @@ static struct task_struct *find_new_reap
14301 __acquires(&tasklist_lock)
14303 struct pid_namespace *pid_ns = task_active_pid_ns(father);
14304 - struct task_struct *thread;
14305 + struct vx_info *vxi = task_get_vx_info(father);
14306 + struct task_struct *thread = father;
14307 + struct task_struct *reaper;
14310 while_each_thread(father, thread) {
14311 if (thread->flags & PF_EXITING)
14313 if (unlikely(pid_ns->child_reaper == father))
14314 pid_ns->child_reaper = thread;
14320 + reaper = pid_ns->child_reaper;
14322 + BUG_ON(!vxi->vx_reaper);
14323 + if (vxi->vx_reaper != init_pid_ns.child_reaper &&
14324 + vxi->vx_reaper != father)
14325 + reaper = vxi->vx_reaper;
14328 if (unlikely(pid_ns->child_reaper == father)) {
14329 @@ -757,7 +773,9 @@ static struct task_struct *find_new_reap
14333 - return pid_ns->child_reaper;
14335 + put_vx_info(vxi);
14340 @@ -808,10 +826,15 @@ static void forget_original_parent(struc
14341 list_for_each_entry_safe(p, n, &father->children, sibling) {
14342 struct task_struct *t = p;
14344 - t->real_parent = reaper;
14345 + struct task_struct *new_parent = reaper;
14347 + if (unlikely(p == reaper))
14348 + new_parent = task_active_pid_ns(p)->child_reaper;
14350 + t->real_parent = new_parent;
14351 if (t->parent == father) {
14353 - t->parent = t->real_parent;
14354 + t->parent = new_parent;
14356 if (t->pdeath_signal)
14357 group_send_sig_info(t->pdeath_signal,
14358 @@ -1018,6 +1041,9 @@ void do_exit(long code)
14360 ptrace_put_breakpoints(tsk);
14362 + /* needs to stay before exit_notify() */
14363 + exit_vx_info_early(tsk, code);
14365 exit_notify(tsk, group_dead);
14368 @@ -1068,10 +1094,15 @@ void do_exit(long code)
14370 raw_spin_unlock_wait(&tsk->pi_lock);
14372 + /* needs to stay after exit_notify() */
14373 + exit_vx_info(tsk, code);
14374 + exit_nx_info(tsk);
14376 /* causes final put_task_struct in finish_task_switch(). */
14377 tsk->state = TASK_DEAD;
14378 tsk->flags |= PF_NOFREEZE; /* tell freezer to ignore us */
14380 + printk("bad task: %p [%lx]\n", current, current->state);
14382 /* Avoid "noreturn function does return". */
14384 diff -NurpP --minimal linux-3.6.9/kernel/fork.c linux-3.6.9-vs2.3.4.4/kernel/fork.c
14385 --- linux-3.6.9/kernel/fork.c 2012-10-04 15:27:48.000000000 +0200
14386 +++ linux-3.6.9-vs2.3.4.4/kernel/fork.c 2012-10-04 18:47:00.000000000 +0200
14388 #include <linux/khugepaged.h>
14389 #include <linux/signalfd.h>
14390 #include <linux/uprobes.h>
14391 +#include <linux/vs_context.h>
14392 +#include <linux/vs_network.h>
14393 +#include <linux/vs_limit.h>
14395 #include <asm/pgtable.h>
14396 #include <asm/pgalloc.h>
14397 @@ -210,6 +213,8 @@ void free_task(struct task_struct *tsk)
14398 arch_release_thread_info(tsk->stack);
14399 free_thread_info(tsk->stack);
14400 rt_mutex_debug_task_free(tsk);
14401 + clr_vx_info(&tsk->vx_info);
14402 + clr_nx_info(&tsk->nx_info);
14403 ftrace_graph_exit_task(tsk);
14404 put_seccomp_filter(tsk);
14405 arch_release_task_struct(tsk);
14406 @@ -541,6 +546,7 @@ static struct mm_struct *mm_init(struct
14407 if (likely(!mm_alloc_pgd(mm))) {
14409 mmu_notifier_mm_init(mm);
14410 + set_vx_info(&mm->mm_vx_info, p->vx_info);
14414 @@ -593,6 +599,7 @@ void __mmdrop(struct mm_struct *mm)
14415 destroy_context(mm);
14416 mmu_notifier_mm_destroy(mm);
14418 + clr_vx_info(&mm->mm_vx_info);
14421 EXPORT_SYMBOL_GPL(__mmdrop);
14422 @@ -834,6 +841,7 @@ struct mm_struct *dup_mm(struct task_str
14425 memcpy(mm, oldmm, sizeof(*mm));
14426 + mm->mm_vx_info = NULL;
14427 mm_init_cpumask(mm);
14429 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
14430 @@ -874,6 +882,7 @@ fail_nocontext:
14431 * If init_new_context() failed, we cannot use mmput() to free the mm
14432 * because it calls destroy_context()
14434 + clr_vx_info(&mm->mm_vx_info);
14438 @@ -1157,6 +1166,8 @@ static struct task_struct *copy_process(
14440 struct task_struct *p;
14441 int cgroup_callbacks_done = 0;
14442 + struct vx_info *vxi;
14443 + struct nx_info *nxi;
14445 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
14446 return ERR_PTR(-EINVAL);
14447 @@ -1204,7 +1215,12 @@ static struct task_struct *copy_process(
14448 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
14449 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
14451 + init_vx_info(&p->vx_info, current_vx_info());
14452 + init_nx_info(&p->nx_info, current_nx_info());
14455 + if (!vx_nproc_avail(1))
14456 + goto bad_fork_free;
14457 if (atomic_read(&p->real_cred->user->processes) >=
14458 task_rlimit(p, RLIMIT_NPROC)) {
14459 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
14460 @@ -1483,6 +1499,18 @@ static struct task_struct *copy_process(
14463 spin_unlock(¤t->sighand->siglock);
14465 + /* p is copy of current */
14466 + vxi = p->vx_info;
14468 + claim_vx_info(vxi, p);
14469 + atomic_inc(&vxi->cvirt.nr_threads);
14470 + atomic_inc(&vxi->cvirt.total_forks);
14473 + nxi = p->nx_info;
14475 + claim_nx_info(nxi, p);
14476 write_unlock_irq(&tasklist_lock);
14477 proc_fork_connector(p);
14478 cgroup_post_fork(p);
14479 diff -NurpP --minimal linux-3.6.9/kernel/kthread.c linux-3.6.9-vs2.3.4.4/kernel/kthread.c
14480 --- linux-3.6.9/kernel/kthread.c 2012-10-04 15:27:48.000000000 +0200
14481 +++ linux-3.6.9-vs2.3.4.4/kernel/kthread.c 2012-10-04 18:47:00.000000000 +0200
14483 #include <linux/mutex.h>
14484 #include <linux/slab.h>
14485 #include <linux/freezer.h>
14486 +#include <linux/vs_pid.h>
14487 #include <trace/events/sched.h>
14489 static DEFINE_SPINLOCK(kthread_create_lock);
14490 diff -NurpP --minimal linux-3.6.9/kernel/nsproxy.c linux-3.6.9-vs2.3.4.4/kernel/nsproxy.c
14491 --- linux-3.6.9/kernel/nsproxy.c 2012-01-09 16:15:00.000000000 +0100
14492 +++ linux-3.6.9-vs2.3.4.4/kernel/nsproxy.c 2012-10-04 18:47:00.000000000 +0200
14493 @@ -20,11 +20,14 @@
14494 #include <linux/mnt_namespace.h>
14495 #include <linux/utsname.h>
14496 #include <linux/pid_namespace.h>
14497 +#include <linux/vserver/global.h>
14498 +#include <linux/vserver/debug.h>
14499 #include <net/net_namespace.h>
14500 #include <linux/ipc_namespace.h>
14501 #include <linux/proc_fs.h>
14502 #include <linux/file.h>
14503 #include <linux/syscalls.h>
14504 +#include "../fs/mount.h"
14506 static struct kmem_cache *nsproxy_cachep;
14508 @@ -46,8 +49,11 @@ static inline struct nsproxy *create_nsp
14509 struct nsproxy *nsproxy;
14511 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
14514 atomic_set(&nsproxy->count, 1);
14515 + atomic_inc(&vs_global_nsproxy);
14517 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
14521 @@ -56,8 +62,11 @@ static inline struct nsproxy *create_nsp
14522 * Return the newly created nsproxy. Do not attach this to the task,
14523 * leave it to the caller to do proper locking and attach it to task.
14525 -static struct nsproxy *create_new_namespaces(unsigned long flags,
14526 - struct task_struct *tsk, struct fs_struct *new_fs)
14527 +static struct nsproxy *unshare_namespaces(unsigned long flags,
14528 + struct nsproxy *orig,
14529 + struct fs_struct *new_fs,
14530 + struct user_namespace *new_user,
14531 + struct pid_namespace *new_pid)
14533 struct nsproxy *new_nsp;
14535 @@ -66,31 +75,31 @@ static struct nsproxy *create_new_namesp
14537 return ERR_PTR(-ENOMEM);
14539 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
14540 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
14541 if (IS_ERR(new_nsp->mnt_ns)) {
14542 err = PTR_ERR(new_nsp->mnt_ns);
14546 - new_nsp->uts_ns = copy_utsname(flags, tsk);
14547 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns, new_user);
14548 if (IS_ERR(new_nsp->uts_ns)) {
14549 err = PTR_ERR(new_nsp->uts_ns);
14553 - new_nsp->ipc_ns = copy_ipcs(flags, tsk);
14554 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns, new_user);
14555 if (IS_ERR(new_nsp->ipc_ns)) {
14556 err = PTR_ERR(new_nsp->ipc_ns);
14560 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
14561 + new_nsp->pid_ns = copy_pid_ns(flags, new_pid);
14562 if (IS_ERR(new_nsp->pid_ns)) {
14563 err = PTR_ERR(new_nsp->pid_ns);
14567 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
14568 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
14569 if (IS_ERR(new_nsp->net_ns)) {
14570 err = PTR_ERR(new_nsp->net_ns);
14572 @@ -115,6 +124,40 @@ out_ns:
14573 return ERR_PTR(err);
14576 +static struct nsproxy *create_new_namespaces(unsigned long flags,
14577 + struct task_struct *tsk, struct fs_struct *new_fs)
14579 + return unshare_namespaces(flags, tsk->nsproxy,
14580 + new_fs, task_cred_xxx(tsk, user_ns),
14581 + task_active_pid_ns(tsk));
14585 + * copies the nsproxy, setting refcount to 1, and grabbing a
14586 + * reference to all contained namespaces.
14588 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
14590 + struct nsproxy *ns = create_nsproxy();
14593 + memcpy(ns, orig, sizeof(struct nsproxy));
14594 + atomic_set(&ns->count, 1);
14597 + get_mnt_ns(ns->mnt_ns);
14599 + get_uts_ns(ns->uts_ns);
14601 + get_ipc_ns(ns->ipc_ns);
14603 + get_pid_ns(ns->pid_ns);
14605 + get_net(ns->net_ns);
14611 * called from clone. This now handles copy for nsproxy and all
14612 * namespaces therein.
14613 @@ -122,9 +165,12 @@ out_ns:
14614 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
14616 struct nsproxy *old_ns = tsk->nsproxy;
14617 - struct nsproxy *new_ns;
14618 + struct nsproxy *new_ns = NULL;
14621 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
14622 + flags, tsk, old_ns);
14627 @@ -134,7 +180,7 @@ int copy_namespaces(unsigned long flags,
14628 CLONE_NEWPID | CLONE_NEWNET)))
14631 - if (!capable(CAP_SYS_ADMIN)) {
14632 + if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
14636 @@ -161,6 +207,9 @@ int copy_namespaces(unsigned long flags,
14639 put_nsproxy(old_ns);
14640 + vxdprintk(VXD_CBIT(space, 3),
14641 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
14642 + flags, tsk, old_ns, err, new_ns);
14646 @@ -174,7 +223,9 @@ void free_nsproxy(struct nsproxy *ns)
14647 put_ipc_ns(ns->ipc_ns);
14649 put_pid_ns(ns->pid_ns);
14650 - put_net(ns->net_ns);
14652 + put_net(ns->net_ns);
14653 + atomic_dec(&vs_global_nsproxy);
14654 kmem_cache_free(nsproxy_cachep, ns);
14657 @@ -187,11 +238,15 @@ int unshare_nsproxy_namespaces(unsigned
14661 + vxdprintk(VXD_CBIT(space, 4),
14662 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
14663 + unshare_flags, current->nsproxy);
14665 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
14669 - if (!capable(CAP_SYS_ADMIN))
14670 + if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
14673 *new_nsp = create_new_namespaces(unshare_flags, current,
14674 diff -NurpP --minimal linux-3.6.9/kernel/pid.c linux-3.6.9-vs2.3.4.4/kernel/pid.c
14675 --- linux-3.6.9/kernel/pid.c 2012-07-22 23:39:46.000000000 +0200
14676 +++ linux-3.6.9-vs2.3.4.4/kernel/pid.c 2012-10-04 18:47:00.000000000 +0200
14678 #include <linux/pid_namespace.h>
14679 #include <linux/init_task.h>
14680 #include <linux/syscalls.h>
14681 +#include <linux/vs_pid.h>
14683 #define pid_hashfn(nr, ns) \
14684 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
14685 @@ -344,7 +345,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
14687 struct pid *find_vpid(int nr)
14689 - return find_pid_ns(nr, current->nsproxy->pid_ns);
14690 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
14692 EXPORT_SYMBOL_GPL(find_vpid);
14694 @@ -404,6 +405,9 @@ void transfer_pid(struct task_struct *ol
14695 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
14697 struct task_struct *result = NULL;
14699 + if (type == PIDTYPE_REALPID)
14700 + type = PIDTYPE_PID;
14702 struct hlist_node *first;
14703 first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]),
14704 @@ -423,7 +427,7 @@ struct task_struct *find_task_by_pid_ns(
14705 rcu_lockdep_assert(rcu_read_lock_held(),
14706 "find_task_by_pid_ns() needs rcu_read_lock()"
14708 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
14709 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
14712 struct task_struct *find_task_by_vpid(pid_t vnr)
14713 @@ -467,7 +471,7 @@ struct pid *find_get_pid(pid_t nr)
14715 EXPORT_SYMBOL_GPL(find_get_pid);
14717 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
14718 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
14722 @@ -480,6 +484,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
14726 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
14728 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
14731 pid_t pid_vnr(struct pid *pid)
14733 return pid_nr_ns(pid, current->nsproxy->pid_ns);
14734 diff -NurpP --minimal linux-3.6.9/kernel/pid_namespace.c linux-3.6.9-vs2.3.4.4/kernel/pid_namespace.c
14735 --- linux-3.6.9/kernel/pid_namespace.c 2012-10-04 15:27:48.000000000 +0200
14736 +++ linux-3.6.9-vs2.3.4.4/kernel/pid_namespace.c 2012-10-04 18:47:00.000000000 +0200
14738 #include <linux/slab.h>
14739 #include <linux/proc_fs.h>
14740 #include <linux/reboot.h>
14741 +#include <linux/vserver/global.h>
14743 #define BITS_PER_PAGE (PAGE_SIZE*8)
14745 @@ -89,6 +90,7 @@ static struct pid_namespace *create_pid_
14748 kref_init(&ns->kref);
14749 + atomic_inc(&vs_global_pid_ns);
14751 ns->parent = get_pid_ns(parent_pid_ns);
14753 @@ -120,6 +122,7 @@ static void destroy_pid_namespace(struct
14755 for (i = 0; i < PIDMAP_ENTRIES; i++)
14756 kfree(ns->pidmap[i].page);
14757 + atomic_dec(&vs_global_pid_ns);
14758 kmem_cache_free(pid_ns_cachep, ns);
14761 diff -NurpP --minimal linux-3.6.9/kernel/posix-timers.c linux-3.6.9-vs2.3.4.4/kernel/posix-timers.c
14762 --- linux-3.6.9/kernel/posix-timers.c 2012-01-09 16:15:00.000000000 +0100
14763 +++ linux-3.6.9-vs2.3.4.4/kernel/posix-timers.c 2012-10-04 18:47:00.000000000 +0200
14765 #include <linux/wait.h>
14766 #include <linux/workqueue.h>
14767 #include <linux/export.h>
14768 +#include <linux/vs_context.h>
14771 * Management arrays for POSIX timers. Timers are kept in slab memory
14772 @@ -340,6 +341,7 @@ int posix_timer_event(struct k_itimer *t
14774 struct task_struct *task;
14775 int shared, ret = -1;
14778 * FIXME: if ->sigq is queued we can race with
14779 * dequeue_signal()->do_schedule_next_timer().
14780 @@ -356,10 +358,18 @@ int posix_timer_event(struct k_itimer *t
14782 task = pid_task(timr->it_pid, PIDTYPE_PID);
14784 + struct vx_info_save vxis;
14785 + struct vx_info *vxi;
14787 + vxi = get_vx_info(task->vx_info);
14788 + enter_vx_info(vxi, &vxis);
14789 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
14790 ret = send_sigqueue(timr->sigq, task, shared);
14791 + leave_vx_info(&vxis);
14792 + put_vx_info(vxi);
14796 /* If we failed to send the signal the timer stops. */
14799 diff -NurpP --minimal linux-3.6.9/kernel/printk.c linux-3.6.9-vs2.3.4.4/kernel/printk.c
14800 --- linux-3.6.9/kernel/printk.c 2012-10-04 15:27:48.000000000 +0200
14801 +++ linux-3.6.9-vs2.3.4.4/kernel/printk.c 2012-10-04 18:47:00.000000000 +0200
14803 #include <linux/notifier.h>
14804 #include <linux/rculist.h>
14805 #include <linux/poll.h>
14806 +#include <linux/vs_cvirt.h>
14808 #include <asm/uaccess.h>
14810 @@ -818,7 +819,7 @@ static int check_syslog_permissions(int
14813 if (syslog_action_restricted(type)) {
14814 - if (capable(CAP_SYSLOG))
14815 + if (vx_capable(CAP_SYSLOG, VXC_SYSLOG))
14817 /* For historical reasons, accept CAP_SYS_ADMIN too, with a warning */
14818 if (capable(CAP_SYS_ADMIN)) {
14819 @@ -1111,12 +1112,9 @@ int do_syslog(int type, char __user *buf
14824 - case SYSLOG_ACTION_CLOSE: /* Close log */
14826 - case SYSLOG_ACTION_OPEN: /* Open log */
14828 - case SYSLOG_ACTION_READ: /* Read from log */
14829 + if ((type == SYSLOG_ACTION_READ) ||
14830 + (type == SYSLOG_ACTION_READ_ALL) ||
14831 + (type == SYSLOG_ACTION_READ_CLEAR)) {
14833 if (!buf || len < 0)
14835 @@ -1127,6 +1125,16 @@ int do_syslog(int type, char __user *buf
14840 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
14841 + return vx_do_syslog(type, buf, len);
14844 + case SYSLOG_ACTION_CLOSE: /* Close log */
14846 + case SYSLOG_ACTION_OPEN: /* Open log */
14848 + case SYSLOG_ACTION_READ: /* Read from log */
14849 error = wait_event_interruptible(log_wait,
14850 syslog_seq != log_next_seq);
14852 @@ -1139,16 +1147,6 @@ int do_syslog(int type, char __user *buf
14854 /* Read last kernel messages */
14855 case SYSLOG_ACTION_READ_ALL:
14857 - if (!buf || len < 0)
14862 - if (!access_ok(VERIFY_WRITE, buf, len)) {
14866 error = syslog_print_all(buf, len, clear);
14868 /* Clear ring buffer */
14869 diff -NurpP --minimal linux-3.6.9/kernel/ptrace.c linux-3.6.9-vs2.3.4.4/kernel/ptrace.c
14870 --- linux-3.6.9/kernel/ptrace.c 2012-07-22 23:39:46.000000000 +0200
14871 +++ linux-3.6.9-vs2.3.4.4/kernel/ptrace.c 2012-10-04 18:47:00.000000000 +0200
14873 #include <linux/syscalls.h>
14874 #include <linux/uaccess.h>
14875 #include <linux/regset.h>
14876 +#include <linux/vs_context.h>
14877 #include <linux/hw_breakpoint.h>
14878 #include <linux/cn_proc.h>
14880 @@ -216,6 +217,11 @@ ok:
14881 dumpable = get_dumpable(task->mm);
14882 if (!dumpable && !ptrace_has_cap(task_user_ns(task), mode))
14884 + if (!vx_check(task->xid, VS_ADMIN_P|VS_WATCH_P|VS_IDENT))
14886 + if (!vx_check(task->xid, VS_IDENT) &&
14887 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
14890 return security_ptrace_access_check(task, mode);
14892 diff -NurpP --minimal linux-3.6.9/kernel/sched/core.c linux-3.6.9-vs2.3.4.4/kernel/sched/core.c
14893 --- linux-3.6.9/kernel/sched/core.c 2012-12-08 01:34:15.000000000 +0100
14894 +++ linux-3.6.9-vs2.3.4.4/kernel/sched/core.c 2012-11-06 18:43:41.000000000 +0100
14896 #include <linux/slab.h>
14897 #include <linux/init_task.h>
14898 #include <linux/binfmts.h>
14899 +#include <linux/vs_sched.h>
14900 +#include <linux/vs_cvirt.h>
14902 #include <asm/switch_to.h>
14903 #include <asm/tlb.h>
14904 @@ -2223,9 +2225,17 @@ EXPORT_SYMBOL(avenrun); /* should be rem
14906 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
14908 - loads[0] = (avenrun[0] + offset) << shift;
14909 - loads[1] = (avenrun[1] + offset) << shift;
14910 - loads[2] = (avenrun[2] + offset) << shift;
14911 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
14912 + struct vx_info *vxi = current_vx_info();
14914 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
14915 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
14916 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
14918 + loads[0] = (avenrun[0] + offset) << shift;
14919 + loads[1] = (avenrun[1] + offset) << shift;
14920 + loads[2] = (avenrun[2] + offset) << shift;
14924 static long calc_load_fold_active(struct rq *this_rq)
14925 @@ -2854,14 +2864,17 @@ static inline void task_group_account_fi
14926 void account_user_time(struct task_struct *p, cputime_t cputime,
14927 cputime_t cputime_scaled)
14929 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
14930 + int nice = (TASK_NICE(p) > 0);
14933 /* Add user time to process. */
14934 p->utime += cputime;
14935 p->utimescaled += cputime_scaled;
14936 + vx_account_user(vxi, cputime, nice);
14937 account_group_user_time(p, cputime);
14939 - index = (TASK_NICE(p) > 0) ? CPUTIME_NICE : CPUTIME_USER;
14940 + index = (nice) ? CPUTIME_NICE : CPUTIME_USER;
14942 /* Add user time to cpustat. */
14943 task_group_account_field(p, index, (__force u64) cputime);
14944 @@ -2908,9 +2921,12 @@ static inline
14945 void __account_system_time(struct task_struct *p, cputime_t cputime,
14946 cputime_t cputime_scaled, int index)
14948 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
14950 /* Add system time to process. */
14951 p->stime += cputime;
14952 p->stimescaled += cputime_scaled;
14953 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
14954 account_group_system_time(p, cputime);
14956 /* Add system time to cpustat. */
14957 @@ -4137,7 +4153,7 @@ SYSCALL_DEFINE1(nice, int, increment)
14960 if (increment < 0 && !can_nice(current, nice))
14962 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
14964 retval = security_task_setnice(current, nice);
14966 diff -NurpP --minimal linux-3.6.9/kernel/sched/fair.c linux-3.6.9-vs2.3.4.4/kernel/sched/fair.c
14967 --- linux-3.6.9/kernel/sched/fair.c 2012-10-04 15:27:48.000000000 +0200
14968 +++ linux-3.6.9-vs2.3.4.4/kernel/sched/fair.c 2012-10-04 18:47:00.000000000 +0200
14970 #include <linux/slab.h>
14971 #include <linux/profile.h>
14972 #include <linux/interrupt.h>
14973 +#include <linux/vs_cvirt.h>
14975 #include <trace/events/sched.h>
14977 @@ -1111,6 +1112,8 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
14978 __enqueue_entity(cfs_rq, se);
14981 + if (entity_is_task(se))
14982 + vx_activate_task(task_of(se));
14983 if (cfs_rq->nr_running == 1) {
14984 list_add_leaf_cfs_rq(cfs_rq);
14985 check_enqueue_throttle(cfs_rq);
14986 @@ -1191,6 +1194,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
14987 if (se != cfs_rq->curr)
14988 __dequeue_entity(cfs_rq, se);
14990 + if (entity_is_task(se))
14991 + vx_deactivate_task(task_of(se));
14992 update_cfs_load(cfs_rq, 0);
14993 account_entity_dequeue(cfs_rq, se);
14995 diff -NurpP --minimal linux-3.6.9/kernel/signal.c linux-3.6.9-vs2.3.4.4/kernel/signal.c
14996 --- linux-3.6.9/kernel/signal.c 2012-10-04 15:27:48.000000000 +0200
14997 +++ linux-3.6.9-vs2.3.4.4/kernel/signal.c 2012-10-04 18:47:00.000000000 +0200
14999 #include <linux/nsproxy.h>
15000 #include <linux/user_namespace.h>
15001 #include <linux/uprobes.h>
15002 +#include <linux/vs_context.h>
15003 +#include <linux/vs_pid.h>
15004 #define CREATE_TRACE_POINTS
15005 #include <trace/events/signal.h>
15007 @@ -790,9 +792,18 @@ static int check_kill_permission(int sig
15011 + vxdprintk(VXD_CBIT(misc, 7),
15012 + "check_kill_permission(%d,%p,%p[#%u,%u])",
15013 + sig, info, t, vx_task_xid(t), t->pid);
15015 if (!valid_signal(sig))
15018 +/* FIXME: needed? if so, why?
15019 + if ((info != SEND_SIG_NOINFO) &&
15020 + (is_si_special(info) || !si_fromuser(info)))
15023 if (!si_fromuser(info))
15026 @@ -816,6 +827,20 @@ static int check_kill_permission(int sig
15031 + if (t->pid == 1 && current->xid)
15035 + /* FIXME: we shouldn't return ESRCH ever, to avoid
15036 + loops, maybe ENOENT or EACCES? */
15037 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
15038 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
15039 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
15040 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
15044 return security_task_kill(t, info, sig, 0);
15047 @@ -1351,7 +1376,7 @@ int kill_pid_info(int sig, struct siginf
15050 p = pid_task(pid, PIDTYPE_PID);
15052 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
15053 error = group_send_sig_info(sig, info, p);
15054 if (unlikely(error == -ESRCH))
15056 @@ -1399,7 +1424,7 @@ int kill_pid_info_as_cred(int sig, struc
15059 p = pid_task(pid, PIDTYPE_PID);
15061 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
15065 @@ -1451,8 +1476,10 @@ static int kill_something_info(int sig,
15066 struct task_struct * p;
15068 for_each_process(p) {
15069 - if (task_pid_vnr(p) > 1 &&
15070 - !same_thread_group(p, current)) {
15071 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
15072 + task_pid_vnr(p) > 1 &&
15073 + !same_thread_group(p, current) &&
15074 + !vx_current_initpid(p->pid)) {
15075 int err = group_send_sig_info(sig, info, p);
15078 @@ -2317,6 +2344,11 @@ relock:
15079 !sig_kernel_only(signr))
15082 + /* virtual init is protected against user signals */
15083 + if ((info->si_code == SI_USER) &&
15084 + vx_current_initpid(current->pid))
15087 if (sig_kernel_stop(signr)) {
15089 * The default action is to stop all threads in
15090 diff -NurpP --minimal linux-3.6.9/kernel/softirq.c linux-3.6.9-vs2.3.4.4/kernel/softirq.c
15091 --- linux-3.6.9/kernel/softirq.c 2012-10-04 15:27:48.000000000 +0200
15092 +++ linux-3.6.9-vs2.3.4.4/kernel/softirq.c 2012-10-04 18:47:00.000000000 +0200
15094 #include <linux/ftrace.h>
15095 #include <linux/smp.h>
15096 #include <linux/tick.h>
15097 +#include <linux/vs_context.h>
15099 #define CREATE_TRACE_POINTS
15100 #include <trace/events/irq.h>
15101 diff -NurpP --minimal linux-3.6.9/kernel/sys.c linux-3.6.9-vs2.3.4.4/kernel/sys.c
15102 --- linux-3.6.9/kernel/sys.c 2012-12-08 01:34:15.000000000 +0100
15103 +++ linux-3.6.9-vs2.3.4.4/kernel/sys.c 2012-11-06 18:43:41.000000000 +0100
15105 #include <linux/syscalls.h>
15106 #include <linux/kprobes.h>
15107 #include <linux/user_namespace.h>
15108 +#include <linux/vs_pid.h>
15110 #include <linux/kmsg_dump.h>
15111 /* Move somewhere else to avoid recompiling? */
15112 @@ -154,7 +155,10 @@ static int set_one_prio(struct task_stru
15115 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
15117 + if (vx_flags(VXF_IGNEG_NICE, 0))
15123 no_nice = security_task_setnice(p, niceval);
15124 @@ -205,6 +209,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
15126 pgrp = task_pgrp(current);
15127 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15128 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15130 error = set_one_prio(p, niceval, error);
15131 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
15133 @@ -270,6 +276,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
15135 pgrp = task_pgrp(current);
15136 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15137 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15139 niceval = 20 - task_nice(p);
15140 if (niceval > retval)
15142 @@ -422,6 +430,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
15144 static DEFINE_MUTEX(reboot_mutex);
15146 +long vs_reboot(unsigned int, void __user *);
15149 * Reboot system call: for obvious reasons only root may call it,
15150 * and even root needs to set up some magic numbers in the registers
15151 @@ -463,6 +473,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
15152 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
15153 cmd = LINUX_REBOOT_CMD_HALT;
15155 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15156 + return vs_reboot(cmd, arg);
15158 mutex_lock(&reboot_mutex);
15160 case LINUX_REBOOT_CMD_RESTART:
15161 @@ -1370,7 +1383,8 @@ SYSCALL_DEFINE2(sethostname, char __user
15163 char tmp[__NEW_UTS_LEN];
15165 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
15166 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
15167 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15170 if (len < 0 || len > __NEW_UTS_LEN)
15171 @@ -1421,7 +1435,8 @@ SYSCALL_DEFINE2(setdomainname, char __us
15173 char tmp[__NEW_UTS_LEN];
15175 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
15176 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
15177 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15179 if (len < 0 || len > __NEW_UTS_LEN)
15181 @@ -1540,7 +1555,7 @@ int do_prlimit(struct task_struct *tsk,
15182 /* Keep the capable check against init_user_ns until
15183 cgroups can contain all limits */
15184 if (new_rlim->rlim_max > rlim->rlim_max &&
15185 - !capable(CAP_SYS_RESOURCE))
15186 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
15189 retval = security_task_setrlimit(tsk->group_leader,
15190 @@ -1593,7 +1608,8 @@ static int check_prlimit_permission(stru
15191 gid_eq(cred->gid, tcred->sgid) &&
15192 gid_eq(cred->gid, tcred->gid))
15194 - if (ns_capable(tcred->user_ns, CAP_SYS_RESOURCE))
15195 + if (vx_ns_capable(tcred->user_ns,
15196 + CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
15200 diff -NurpP --minimal linux-3.6.9/kernel/sysctl.c linux-3.6.9-vs2.3.4.4/kernel/sysctl.c
15201 --- linux-3.6.9/kernel/sysctl.c 2012-10-04 15:27:48.000000000 +0200
15202 +++ linux-3.6.9-vs2.3.4.4/kernel/sysctl.c 2012-10-04 18:47:00.000000000 +0200
15204 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
15205 #include <linux/lockdep.h>
15207 +extern char vshelper_path[];
15208 #ifdef CONFIG_CHR_DEV_SG
15209 #include <scsi/sg.h>
15211 @@ -568,6 +569,13 @@ static struct ctl_table kern_table[] = {
15212 .proc_handler = proc_dostring,
15216 + .procname = "vshelper",
15217 + .data = &vshelper_path,
15220 + .proc_handler = &proc_dostring,
15222 #ifdef CONFIG_CHR_DEV_SG
15224 .procname = "sg-big-buff",
15225 diff -NurpP --minimal linux-3.6.9/kernel/sysctl_binary.c linux-3.6.9-vs2.3.4.4/kernel/sysctl_binary.c
15226 --- linux-3.6.9/kernel/sysctl_binary.c 2012-10-04 15:27:48.000000000 +0200
15227 +++ linux-3.6.9-vs2.3.4.4/kernel/sysctl_binary.c 2012-10-04 18:47:00.000000000 +0200
15228 @@ -73,6 +73,7 @@ static const struct bin_table bin_kern_t
15230 { CTL_INT, KERN_PANIC, "panic" },
15231 { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
15232 + { CTL_STR, KERN_VSHELPER, "vshelper" },
15234 { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
15235 { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
15236 diff -NurpP --minimal linux-3.6.9/kernel/time/timekeeping.c linux-3.6.9-vs2.3.4.4/kernel/time/timekeeping.c
15237 --- linux-3.6.9/kernel/time/timekeeping.c 2012-12-08 01:34:15.000000000 +0100
15238 +++ linux-3.6.9-vs2.3.4.4/kernel/time/timekeeping.c 2012-11-06 18:43:41.000000000 +0100
15239 @@ -309,6 +309,7 @@ void getnstimeofday(struct timespec *ts)
15242 timespec_add_ns(ts, nsecs);
15243 + vx_adjust_timespec(ts);
15245 EXPORT_SYMBOL(getnstimeofday);
15247 diff -NurpP --minimal linux-3.6.9/kernel/time.c linux-3.6.9-vs2.3.4.4/kernel/time.c
15248 --- linux-3.6.9/kernel/time.c 2012-05-21 18:07:34.000000000 +0200
15249 +++ linux-3.6.9-vs2.3.4.4/kernel/time.c 2012-10-04 18:47:00.000000000 +0200
15250 @@ -92,7 +92,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
15254 - do_settimeofday(&tv);
15255 + vx_settimeofday(&tv);
15259 @@ -172,7 +172,7 @@ int do_sys_settimeofday(const struct tim
15263 - return do_settimeofday(tv);
15264 + return vx_settimeofday(tv);
15268 diff -NurpP --minimal linux-3.6.9/kernel/timer.c linux-3.6.9-vs2.3.4.4/kernel/timer.c
15269 --- linux-3.6.9/kernel/timer.c 2012-12-08 01:34:15.000000000 +0100
15270 +++ linux-3.6.9-vs2.3.4.4/kernel/timer.c 2012-11-06 18:43:41.000000000 +0100
15272 #include <linux/irq_work.h>
15273 #include <linux/sched.h>
15274 #include <linux/slab.h>
15275 +#include <linux/vs_base.h>
15276 +#include <linux/vs_cvirt.h>
15277 +#include <linux/vs_pid.h>
15278 +#include <linux/vserver/sched.h>
15280 #include <asm/uaccess.h>
15281 #include <asm/unistd.h>
15282 diff -NurpP --minimal linux-3.6.9/kernel/user_namespace.c linux-3.6.9-vs2.3.4.4/kernel/user_namespace.c
15283 --- linux-3.6.9/kernel/user_namespace.c 2012-07-22 23:39:47.000000000 +0200
15284 +++ linux-3.6.9-vs2.3.4.4/kernel/user_namespace.c 2012-10-04 18:47:00.000000000 +0200
15286 #include <linux/fs.h>
15287 #include <linux/uaccess.h>
15288 #include <linux/ctype.h>
15289 +#include <linux/vserver/global.h>
15291 static struct kmem_cache *user_ns_cachep __read_mostly;
15293 @@ -52,6 +53,7 @@ int create_user_ns(struct cred *new)
15296 kref_init(&ns->kref);
15297 + atomic_inc(&vs_global_user_ns);
15298 ns->parent = parent_ns;
15301 @@ -84,6 +86,9 @@ void free_user_ns(struct kref *kref)
15303 parent = ns->parent;
15304 kmem_cache_free(user_ns_cachep, ns);
15306 + /* FIXME: maybe move into destroyer? */
15307 + atomic_dec(&vs_global_user_ns);
15308 put_user_ns(parent);
15310 EXPORT_SYMBOL(free_user_ns);
15311 diff -NurpP --minimal linux-3.6.9/kernel/utsname.c linux-3.6.9-vs2.3.4.4/kernel/utsname.c
15312 --- linux-3.6.9/kernel/utsname.c 2012-07-22 23:39:47.000000000 +0200
15313 +++ linux-3.6.9-vs2.3.4.4/kernel/utsname.c 2012-10-04 18:47:00.000000000 +0200
15314 @@ -16,14 +16,17 @@
15315 #include <linux/slab.h>
15316 #include <linux/user_namespace.h>
15317 #include <linux/proc_fs.h>
15318 +#include <linux/vserver/global.h>
15320 static struct uts_namespace *create_uts_ns(void)
15322 struct uts_namespace *uts_ns;
15324 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
15327 kref_init(&uts_ns->kref);
15328 + atomic_inc(&vs_global_uts_ns);
15333 @@ -32,8 +35,8 @@ static struct uts_namespace *create_uts_
15334 * @old_ns: namespace to clone
15335 * Return NULL on error (failure to kmalloc), new ns otherwise
15337 -static struct uts_namespace *clone_uts_ns(struct task_struct *tsk,
15338 - struct uts_namespace *old_ns)
15339 +static struct uts_namespace *clone_uts_ns(struct uts_namespace *old_ns,
15340 + struct user_namespace *old_user)
15342 struct uts_namespace *ns;
15344 @@ -43,7 +46,7 @@ static struct uts_namespace *clone_uts_n
15346 down_read(&uts_sem);
15347 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
15348 - ns->user_ns = get_user_ns(task_cred_xxx(tsk, user_ns));
15349 + ns->user_ns = get_user_ns(old_user);
15353 @@ -55,9 +58,9 @@ static struct uts_namespace *clone_uts_n
15356 struct uts_namespace *copy_utsname(unsigned long flags,
15357 - struct task_struct *tsk)
15358 + struct uts_namespace *old_ns,
15359 + struct user_namespace *user_ns)
15361 - struct uts_namespace *old_ns = tsk->nsproxy->uts_ns;
15362 struct uts_namespace *new_ns;
15365 @@ -66,7 +69,7 @@ struct uts_namespace *copy_utsname(unsig
15366 if (!(flags & CLONE_NEWUTS))
15369 - new_ns = clone_uts_ns(tsk, old_ns);
15370 + new_ns = clone_uts_ns(old_ns, user_ns);
15372 put_uts_ns(old_ns);
15374 @@ -78,6 +81,7 @@ void free_uts_ns(struct kref *kref)
15376 ns = container_of(kref, struct uts_namespace, kref);
15377 put_user_ns(ns->user_ns);
15378 + atomic_dec(&vs_global_uts_ns);
15382 diff -NurpP --minimal linux-3.6.9/kernel/vserver/Kconfig linux-3.6.9-vs2.3.4.4/kernel/vserver/Kconfig
15383 --- linux-3.6.9/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
15384 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/Kconfig 2012-10-04 18:47:00.000000000 +0200
15387 +# Linux VServer configuration
15390 +menu "Linux VServer"
15392 +config VSERVER_AUTO_LBACK
15393 + bool "Automatically Assign Loopback IP"
15396 + Automatically assign a guest specific loopback
15397 + IP and add it to the kernel network stack on
15400 +config VSERVER_AUTO_SINGLE
15401 + bool "Automatic Single IP Special Casing"
15402 + depends on EXPERIMENTAL
15405 + This allows network contexts with a single IP to
15406 + automatically remap 0.0.0.0 bindings to that IP,
15407 + avoiding further network checks and improving
15410 + (note: such guests do not allow to change the ip
15411 + on the fly and do not show loopback addresses)
15413 +config VSERVER_COWBL
15414 + bool "Enable COW Immutable Link Breaking"
15417 + This enables the COW (Copy-On-Write) link break code.
15418 + It allows you to treat unified files like normal files
15419 + when writing to them (which will implicitely break the
15420 + link and create a copy of the unified file)
15422 +config VSERVER_VTIME
15423 + bool "Enable Virtualized Guest Time"
15424 + depends on EXPERIMENTAL
15427 + This enables per guest time offsets to allow for
15428 + adjusting the system clock individually per guest.
15429 + this adds some overhead to the time functions and
15430 + therefore should not be enabled without good reason.
15432 +config VSERVER_DEVICE
15433 + bool "Enable Guest Device Mapping"
15434 + depends on EXPERIMENTAL
15437 + This enables generic device remapping.
15439 +config VSERVER_PROC_SECURE
15440 + bool "Enable Proc Security"
15441 + depends on PROC_FS
15444 + This configures ProcFS security to initially hide
15445 + non-process entries for all contexts except the main and
15446 + spectator context (i.e. for all guests), which is a secure
15449 + (note: on 1.2x the entries were visible by default)
15452 + prompt "Persistent Inode Tagging"
15453 + default TAGGING_ID24
15455 + This adds persistent context information to filesystems
15456 + mounted with the tagxid option. Tagging is a requirement
15457 + for per-context disk limits and per-context quota.
15460 +config TAGGING_NONE
15463 + do not store per-context information in inodes.
15465 +config TAGGING_UID16
15466 + bool "UID16/GID32"
15468 + reduces UID to 16 bit, but leaves GID at 32 bit.
15470 +config TAGGING_GID16
15471 + bool "UID32/GID16"
15473 + reduces GID to 16 bit, but leaves UID at 32 bit.
15475 +config TAGGING_ID24
15476 + bool "UID24/GID24"
15478 + uses the upper 8bit from UID and GID for XID tagging
15479 + which leaves 24bit for UID/GID each, which should be
15480 + more than sufficient for normal use.
15482 +config TAGGING_INTERN
15483 + bool "UID32/GID32"
15485 + this uses otherwise reserved inode fields in the on
15486 + disk representation, which limits the use to a few
15487 + filesystems (currently ext2 and ext3)
15492 + bool "Tag NFSD User Auth and Files"
15495 + Enable this if you do want the in-kernel NFS
15496 + Server to use the tagging specified above.
15497 + (will require patched clients too)
15499 +config VSERVER_PRIVACY
15500 + bool "Honor Privacy Aspects of Guests"
15503 + When enabled, most context checks will disallow
15504 + access to structures assigned to a specific context,
15505 + like ptys or loop devices.
15507 +config VSERVER_CONTEXTS
15508 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
15510 + default "768" if 64BIT
15513 + This setting will optimize certain data structures
15514 + and memory allocations according to the expected
15517 + note: this is not a strict upper limit.
15519 +config VSERVER_WARN
15520 + bool "VServer Warnings"
15523 + This enables various runtime warnings, which will
15524 + notify about potential manipulation attempts or
15525 + resource shortage. It is generally considered to
15526 + be a good idea to have that enabled.
15528 +config VSERVER_WARN_DEVPTS
15529 + bool "VServer DevPTS Warnings"
15530 + depends on VSERVER_WARN
15533 + This enables DevPTS related warnings, issued when a
15534 + process inside a context tries to lookup or access
15535 + a dynamic pts from the host or a different context.
15537 +config VSERVER_DEBUG
15538 + bool "VServer Debugging Code"
15541 + Set this to yes if you want to be able to activate
15542 + debugging output at runtime. It adds a very small
15543 + overhead to all vserver related functions and
15544 + increases the kernel size by about 20k.
15546 +config VSERVER_HISTORY
15547 + bool "VServer History Tracing"
15548 + depends on VSERVER_DEBUG
15551 + Set this to yes if you want to record the history of
15552 + linux-vserver activities, so they can be replayed in
15553 + the event of a kernel panic or oops.
15555 +config VSERVER_HISTORY_SIZE
15556 + int "Per-CPU History Size (32-65536)"
15557 + depends on VSERVER_HISTORY
15561 + This allows you to specify the number of entries in
15562 + the per-CPU history buffer.
15565 + prompt "Quotes used in debug and warn messages"
15566 + default QUOTES_ISO8859
15568 +config QUOTES_ISO8859
15569 + bool "Extended ASCII (ISO 8859) angle quotes"
15571 + This uses the extended ASCII characters \xbb
15572 + and \xab for quoting file and process names.
15574 +config QUOTES_UTF8
15575 + bool "UTF-8 angle quotes"
15577 + This uses the the UTF-8 sequences for angle
15578 + quotes to quote file and process names.
15580 +config QUOTES_ASCII
15581 + bool "ASCII single quotes"
15583 + This uses the ASCII single quote character
15584 + (\x27) to quote file and process names.
15594 + select NAMESPACES
15600 +config VSERVER_SECURITY
15602 + depends on SECURITY
15604 + select SECURITY_CAPABILITIES
15606 +config VSERVER_DISABLED
15610 diff -NurpP --minimal linux-3.6.9/kernel/vserver/Makefile linux-3.6.9-vs2.3.4.4/kernel/vserver/Makefile
15611 --- linux-3.6.9/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
15612 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/Makefile 2012-10-04 18:47:00.000000000 +0200
15615 +# Makefile for the Linux vserver routines.
15619 +obj-y += vserver.o
15621 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
15622 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
15625 +vserver-$(CONFIG_INET) += inet.o
15626 +vserver-$(CONFIG_PROC_FS) += proc.o
15627 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
15628 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
15629 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
15630 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
15632 diff -NurpP --minimal linux-3.6.9/kernel/vserver/cacct.c linux-3.6.9-vs2.3.4.4/kernel/vserver/cacct.c
15633 --- linux-3.6.9/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
15634 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/cacct.c 2012-10-04 18:47:00.000000000 +0200
15637 + * linux/kernel/vserver/cacct.c
15639 + * Virtual Server: Context Accounting
15641 + * Copyright (C) 2006-2007 Herbert Pötzl
15643 + * V0.01 added accounting stats
15647 +#include <linux/types.h>
15648 +#include <linux/vs_context.h>
15649 +#include <linux/vserver/cacct_cmd.h>
15650 +#include <linux/vserver/cacct_int.h>
15652 +#include <asm/errno.h>
15653 +#include <asm/uaccess.h>
15656 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
15658 + struct vcmd_sock_stat_v0 vc_data;
15661 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
15664 + field = vc_data.field;
15665 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
15668 + for (j = 0; j < 3; j++) {
15669 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
15670 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
15673 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
15678 diff -NurpP --minimal linux-3.6.9/kernel/vserver/cacct_init.h linux-3.6.9-vs2.3.4.4/kernel/vserver/cacct_init.h
15679 --- linux-3.6.9/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
15680 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/cacct_init.h 2012-10-04 18:47:00.000000000 +0200
15684 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
15689 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
15690 + for (j = 0; j < 3; j++) {
15691 + atomic_long_set(&cacct->sock[i][j].count, 0);
15692 + atomic_long_set(&cacct->sock[i][j].total, 0);
15695 + for (i = 0; i < 8; i++)
15696 + atomic_set(&cacct->slab[i], 0);
15697 + for (i = 0; i < 5; i++)
15698 + for (j = 0; j < 4; j++)
15699 + atomic_set(&cacct->page[i][j], 0);
15702 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
15707 diff -NurpP --minimal linux-3.6.9/kernel/vserver/cacct_proc.h linux-3.6.9-vs2.3.4.4/kernel/vserver/cacct_proc.h
15708 --- linux-3.6.9/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
15709 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/cacct_proc.h 2012-10-04 18:47:00.000000000 +0200
15711 +#ifndef _VX_CACCT_PROC_H
15712 +#define _VX_CACCT_PROC_H
15714 +#include <linux/vserver/cacct_int.h>
15717 +#define VX_SOCKA_TOP \
15718 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
15720 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
15722 + int i, j, length = 0;
15723 + static char *type[VXA_SOCK_SIZE] = {
15724 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
15727 + length += sprintf(buffer + length, VX_SOCKA_TOP);
15728 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
15729 + length += sprintf(buffer + length, "%s:", type[i]);
15730 + for (j = 0; j < 3; j++) {
15731 + length += sprintf(buffer + length,
15732 + "\t%10lu/%-10lu",
15733 + vx_sock_count(cacct, i, j),
15734 + vx_sock_total(cacct, i, j));
15736 + buffer[length++] = '\n';
15739 + length += sprintf(buffer + length, "\n");
15740 + length += sprintf(buffer + length,
15741 + "slab:\t %8u %8u %8u %8u\n",
15742 + atomic_read(&cacct->slab[1]),
15743 + atomic_read(&cacct->slab[4]),
15744 + atomic_read(&cacct->slab[0]),
15745 + atomic_read(&cacct->slab[2]));
15747 + length += sprintf(buffer + length, "\n");
15748 + for (i = 0; i < 5; i++) {
15749 + length += sprintf(buffer + length,
15750 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
15751 + atomic_read(&cacct->page[i][0]),
15752 + atomic_read(&cacct->page[i][1]),
15753 + atomic_read(&cacct->page[i][2]),
15754 + atomic_read(&cacct->page[i][3]),
15755 + atomic_read(&cacct->page[i][4]),
15756 + atomic_read(&cacct->page[i][5]),
15757 + atomic_read(&cacct->page[i][6]),
15758 + atomic_read(&cacct->page[i][7]));
15763 +#endif /* _VX_CACCT_PROC_H */
15764 diff -NurpP --minimal linux-3.6.9/kernel/vserver/context.c linux-3.6.9-vs2.3.4.4/kernel/vserver/context.c
15765 --- linux-3.6.9/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
15766 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/context.c 2012-10-04 18:47:00.000000000 +0200
15769 + * linux/kernel/vserver/context.c
15771 + * Virtual Server: Context Support
15773 + * Copyright (C) 2003-2011 Herbert Pötzl
15775 + * V0.01 context helper
15776 + * V0.02 vx_ctx_kill syscall command
15777 + * V0.03 replaced context_info calls
15778 + * V0.04 redesign of struct (de)alloc
15779 + * V0.05 rlimit basic implementation
15780 + * V0.06 task_xid and info commands
15781 + * V0.07 context flags and caps
15782 + * V0.08 switch to RCU based hash
15783 + * V0.09 revert to non RCU for now
15784 + * V0.10 and back to working RCU hash
15785 + * V0.11 and back to locking again
15786 + * V0.12 referenced context store
15787 + * V0.13 separate per cpu data
15788 + * V0.14 changed vcmds to vxi arg
15789 + * V0.15 added context stat
15790 + * V0.16 have __create claim() the vxi
15791 + * V0.17 removed older and legacy stuff
15792 + * V0.18 added user credentials
15793 + * V0.19 added warn mask
15797 +#include <linux/slab.h>
15798 +#include <linux/types.h>
15799 +#include <linux/security.h>
15800 +#include <linux/pid_namespace.h>
15801 +#include <linux/capability.h>
15803 +#include <linux/vserver/context.h>
15804 +#include <linux/vserver/network.h>
15805 +#include <linux/vserver/debug.h>
15806 +#include <linux/vserver/limit.h>
15807 +#include <linux/vserver/limit_int.h>
15808 +#include <linux/vserver/space.h>
15809 +#include <linux/init_task.h>
15810 +#include <linux/fs_struct.h>
15811 +#include <linux/cred.h>
15813 +#include <linux/vs_context.h>
15814 +#include <linux/vs_limit.h>
15815 +#include <linux/vs_pid.h>
15816 +#include <linux/vserver/context_cmd.h>
15818 +#include "cvirt_init.h"
15819 +#include "cacct_init.h"
15820 +#include "limit_init.h"
15821 +#include "sched_init.h"
15824 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
15825 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
15828 +/* now inactive context structures */
15830 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
15832 +static DEFINE_SPINLOCK(vx_info_inactive_lock);
15835 +/* __alloc_vx_info()
15837 + * allocate an initialized vx_info struct
15838 + * doesn't make it visible (hash) */
15840 +static struct vx_info *__alloc_vx_info(xid_t xid)
15842 + struct vx_info *new = NULL;
15845 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
15847 + /* would this benefit from a slab cache? */
15848 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
15852 + memset(new, 0, sizeof(struct vx_info));
15854 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
15855 + if (!new->ptr_pc)
15858 + new->vx_id = xid;
15859 + INIT_HLIST_NODE(&new->vx_hlist);
15860 + atomic_set(&new->vx_usecnt, 0);
15861 + atomic_set(&new->vx_tasks, 0);
15862 + new->vx_parent = NULL;
15863 + new->vx_state = 0;
15864 + init_waitqueue_head(&new->vx_wait);
15866 + /* prepare reaper */
15867 + get_task_struct(init_pid_ns.child_reaper);
15868 + new->vx_reaper = init_pid_ns.child_reaper;
15869 + new->vx_badness_bias = 0;
15871 + /* rest of init goes here */
15872 + vx_info_init_limit(&new->limit);
15873 + vx_info_init_sched(&new->sched);
15874 + vx_info_init_cvirt(&new->cvirt);
15875 + vx_info_init_cacct(&new->cacct);
15877 + /* per cpu data structures */
15878 + for_each_possible_cpu(cpu) {
15879 + vx_info_init_sched_pc(
15880 + &vx_per_cpu(new, sched_pc, cpu), cpu);
15881 + vx_info_init_cvirt_pc(
15882 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
15885 + new->vx_flags = VXF_INIT_SET;
15886 + new->vx_bcaps = CAP_FULL_SET; // maybe ~CAP_SETPCAP
15887 + new->vx_ccaps = 0;
15888 + new->vx_umask = 0;
15889 + new->vx_wmask = 0;
15891 + new->reboot_cmd = 0;
15892 + new->exit_code = 0;
15894 + // preconfig spaces
15895 + for (index = 0; index < VX_SPACES; index++) {
15896 + struct _vx_space *space = &new->space[index];
15899 + spin_lock(&init_fs.lock);
15901 + spin_unlock(&init_fs.lock);
15902 + space->vx_fs = &init_fs;
15904 + /* FIXME: do we want defaults? */
15905 + // space->vx_real_cred = 0;
15906 + // space->vx_cred = 0;
15910 + vxdprintk(VXD_CBIT(xid, 0),
15911 + "alloc_vx_info(%d) = %p", xid, new);
15912 + vxh_alloc_vx_info(new);
15913 + atomic_inc(&vx_global_ctotal);
15922 +/* __dealloc_vx_info()
15924 + * final disposal of vx_info */
15926 +static void __dealloc_vx_info(struct vx_info *vxi)
15928 +#ifdef CONFIG_VSERVER_WARN
15929 + struct vx_info_save vxis;
15932 + vxdprintk(VXD_CBIT(xid, 0),
15933 + "dealloc_vx_info(%p)", vxi);
15934 + vxh_dealloc_vx_info(vxi);
15936 +#ifdef CONFIG_VSERVER_WARN
15937 + enter_vx_info(vxi, &vxis);
15938 + vx_info_exit_limit(&vxi->limit);
15939 + vx_info_exit_sched(&vxi->sched);
15940 + vx_info_exit_cvirt(&vxi->cvirt);
15941 + vx_info_exit_cacct(&vxi->cacct);
15943 + for_each_possible_cpu(cpu) {
15944 + vx_info_exit_sched_pc(
15945 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
15946 + vx_info_exit_cvirt_pc(
15947 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
15949 + leave_vx_info(&vxis);
15953 + vxi->vx_state |= VXS_RELEASED;
15956 + free_percpu(vxi->ptr_pc);
15959 + atomic_dec(&vx_global_ctotal);
15962 +static void __shutdown_vx_info(struct vx_info *vxi)
15964 + struct nsproxy *nsproxy;
15965 + struct fs_struct *fs;
15966 + struct cred *cred;
15971 + vxi->vx_state |= VXS_SHUTDOWN;
15972 + vs_state_change(vxi, VSC_SHUTDOWN);
15974 + for (index = 0; index < VX_SPACES; index++) {
15975 + struct _vx_space *space = &vxi->space[index];
15977 + nsproxy = xchg(&space->vx_nsproxy, NULL);
15979 + put_nsproxy(nsproxy);
15981 + fs = xchg(&space->vx_fs, NULL);
15982 + spin_lock(&fs->lock);
15983 + kill = !--fs->users;
15984 + spin_unlock(&fs->lock);
15986 + free_fs_struct(fs);
15988 + cred = (struct cred *)xchg(&space->vx_cred, NULL);
15990 + abort_creds(cred);
15994 +/* exported stuff */
15996 +void free_vx_info(struct vx_info *vxi)
15998 + unsigned long flags;
16001 + /* check for reference counts first */
16002 + BUG_ON(atomic_read(&vxi->vx_usecnt));
16003 + BUG_ON(atomic_read(&vxi->vx_tasks));
16005 + /* context must not be hashed */
16006 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16008 + /* context shutdown is mandatory */
16009 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
16011 + /* spaces check */
16012 + for (index = 0; index < VX_SPACES; index++) {
16013 + struct _vx_space *space = &vxi->space[index];
16015 + BUG_ON(space->vx_nsproxy);
16016 + BUG_ON(space->vx_fs);
16017 + // BUG_ON(space->vx_real_cred);
16018 + // BUG_ON(space->vx_cred);
16021 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16022 + hlist_del(&vxi->vx_hlist);
16023 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16025 + __dealloc_vx_info(vxi);
16029 +/* hash table for vx_info hash */
16031 +#define VX_HASH_SIZE 13
16033 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
16034 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
16036 +static DEFINE_SPINLOCK(vx_info_hash_lock);
16039 +static inline unsigned int __hashval(xid_t xid)
16041 + return (xid % VX_HASH_SIZE);
16046 +/* __hash_vx_info()
16048 + * add the vxi to the global hash table
16049 + * requires the hash_lock to be held */
16051 +static inline void __hash_vx_info(struct vx_info *vxi)
16053 + struct hlist_head *head;
16055 + vxd_assert_lock(&vx_info_hash_lock);
16056 + vxdprintk(VXD_CBIT(xid, 4),
16057 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
16058 + vxh_hash_vx_info(vxi);
16060 + /* context must not be hashed */
16061 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16063 + vxi->vx_state |= VXS_HASHED;
16064 + head = &vx_info_hash[__hashval(vxi->vx_id)];
16065 + hlist_add_head(&vxi->vx_hlist, head);
16066 + atomic_inc(&vx_global_cactive);
16069 +/* __unhash_vx_info()
16071 + * remove the vxi from the global hash table
16072 + * requires the hash_lock to be held */
16074 +static inline void __unhash_vx_info(struct vx_info *vxi)
16076 + unsigned long flags;
16078 + vxd_assert_lock(&vx_info_hash_lock);
16079 + vxdprintk(VXD_CBIT(xid, 4),
16080 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
16081 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
16082 + vxh_unhash_vx_info(vxi);
16084 + /* context must be hashed */
16085 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
16086 + /* but without tasks */
16087 + BUG_ON(atomic_read(&vxi->vx_tasks));
16089 + vxi->vx_state &= ~VXS_HASHED;
16090 + hlist_del_init(&vxi->vx_hlist);
16091 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16092 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
16093 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16094 + atomic_dec(&vx_global_cactive);
16098 +/* __lookup_vx_info()
16100 + * requires the hash_lock to be held
16101 + * doesn't increment the vx_refcnt */
16103 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
16105 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
16106 + struct hlist_node *pos;
16107 + struct vx_info *vxi;
16109 + vxd_assert_lock(&vx_info_hash_lock);
16110 + hlist_for_each(pos, head) {
16111 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16113 + if (vxi->vx_id == xid)
16118 + vxdprintk(VXD_CBIT(xid, 0),
16119 + "__lookup_vx_info(#%u): %p[#%u]",
16120 + xid, vxi, vxi ? vxi->vx_id : 0);
16121 + vxh_lookup_vx_info(vxi, xid);
16126 +/* __create_vx_info()
16128 + * create the requested context
16129 + * get(), claim() and hash it */
16131 +static struct vx_info *__create_vx_info(int id)
16133 + struct vx_info *new, *vxi = NULL;
16135 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
16137 + if (!(new = __alloc_vx_info(id)))
16138 + return ERR_PTR(-ENOMEM);
16140 + /* required to make dynamic xids unique */
16141 + spin_lock(&vx_info_hash_lock);
16143 + /* static context requested */
16144 + if ((vxi = __lookup_vx_info(id))) {
16145 + vxdprintk(VXD_CBIT(xid, 0),
16146 + "create_vx_info(%d) = %p (already there)", id, vxi);
16147 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16148 + vxi = ERR_PTR(-EBUSY);
16150 + vxi = ERR_PTR(-EEXIST);
16153 + /* new context */
16154 + vxdprintk(VXD_CBIT(xid, 0),
16155 + "create_vx_info(%d) = %p (new)", id, new);
16156 + claim_vx_info(new, NULL);
16157 + __hash_vx_info(get_vx_info(new));
16158 + vxi = new, new = NULL;
16161 + spin_unlock(&vx_info_hash_lock);
16162 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
16164 + __dealloc_vx_info(new);
16169 +/* exported stuff */
16172 +void unhash_vx_info(struct vx_info *vxi)
16174 + spin_lock(&vx_info_hash_lock);
16175 + __unhash_vx_info(vxi);
16176 + spin_unlock(&vx_info_hash_lock);
16177 + __shutdown_vx_info(vxi);
16178 + __wakeup_vx_info(vxi);
16182 +/* lookup_vx_info()
16184 + * search for a vx_info and get() it
16185 + * negative id means current */
16187 +struct vx_info *lookup_vx_info(int id)
16189 + struct vx_info *vxi = NULL;
16192 + vxi = get_vx_info(current_vx_info());
16193 + } else if (id > 1) {
16194 + spin_lock(&vx_info_hash_lock);
16195 + vxi = get_vx_info(__lookup_vx_info(id));
16196 + spin_unlock(&vx_info_hash_lock);
16201 +/* xid_is_hashed()
16203 + * verify that xid is still hashed */
16205 +int xid_is_hashed(xid_t xid)
16209 + spin_lock(&vx_info_hash_lock);
16210 + hashed = (__lookup_vx_info(xid) != NULL);
16211 + spin_unlock(&vx_info_hash_lock);
16215 +#ifdef CONFIG_PROC_FS
16219 + * get a subset of hashed xids for proc
16220 + * assumes size is at least one */
16222 +int get_xid_list(int index, unsigned int *xids, int size)
16224 + int hindex, nr_xids = 0;
16226 + /* only show current and children */
16227 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
16230 + xids[nr_xids] = vx_current_xid();
16234 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
16235 + struct hlist_head *head = &vx_info_hash[hindex];
16236 + struct hlist_node *pos;
16238 + spin_lock(&vx_info_hash_lock);
16239 + hlist_for_each(pos, head) {
16240 + struct vx_info *vxi;
16245 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16246 + xids[nr_xids] = vxi->vx_id;
16247 + if (++nr_xids >= size) {
16248 + spin_unlock(&vx_info_hash_lock);
16252 + /* keep the lock time short */
16253 + spin_unlock(&vx_info_hash_lock);
16260 +#ifdef CONFIG_VSERVER_DEBUG
16262 +void dump_vx_info_inactive(int level)
16264 + struct hlist_node *entry, *next;
16266 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
16267 + struct vx_info *vxi =
16268 + list_entry(entry, struct vx_info, vx_hlist);
16270 + dump_vx_info(vxi, level);
16277 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
16279 + struct user_struct *new_user, *old_user;
16284 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
16287 + new_user = alloc_uid(vxi->vx_id, p->uid);
16291 + old_user = p->user;
16292 + if (new_user != old_user) {
16293 + atomic_inc(&new_user->processes);
16294 + atomic_dec(&old_user->processes);
16295 + p->user = new_user;
16297 + free_uid(old_user);
16303 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
16305 + // p->cap_effective &= vxi->vx_cap_bset;
16306 + p->cap_effective =
16307 + cap_intersect(p->cap_effective, vxi->cap_bset);
16308 + // p->cap_inheritable &= vxi->vx_cap_bset;
16309 + p->cap_inheritable =
16310 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
16311 + // p->cap_permitted &= vxi->vx_cap_bset;
16312 + p->cap_permitted =
16313 + cap_intersect(p->cap_permitted, vxi->cap_bset);
16318 +#include <linux/file.h>
16319 +#include <linux/fdtable.h>
16321 +static int vx_openfd_task(struct task_struct *tsk)
16323 + struct files_struct *files = tsk->files;
16324 + struct fdtable *fdt;
16325 + const unsigned long *bptr;
16326 + int count, total;
16328 + /* no rcu_read_lock() because of spin_lock() */
16329 + spin_lock(&files->file_lock);
16330 + fdt = files_fdtable(files);
16331 + bptr = fdt->open_fds;
16332 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
16333 + for (total = 0; count > 0; count--) {
16335 + total += hweight_long(*bptr);
16338 + spin_unlock(&files->file_lock);
16343 +/* for *space compatibility */
16345 +asmlinkage long sys_unshare(unsigned long);
16348 + * migrate task to new context
16349 + * gets vxi, puts old_vxi on change
16350 + * optionally unshares namespaces (hack)
16353 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
16355 + struct vx_info *old_vxi;
16361 + vxdprintk(VXD_CBIT(xid, 5),
16362 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
16363 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
16365 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
16366 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16369 + if (vx_info_state(vxi, VXS_SHUTDOWN))
16372 + old_vxi = task_get_vx_info(p);
16373 + if (old_vxi == vxi)
16376 +// if (!(ret = vx_migrate_user(p, vxi))) {
16381 + openfd = vx_openfd_task(p);
16384 + atomic_dec(&old_vxi->cvirt.nr_threads);
16385 + atomic_dec(&old_vxi->cvirt.nr_running);
16386 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
16387 + /* FIXME: what about the struct files here? */
16388 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
16389 + /* account for the executable */
16390 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
16392 + atomic_inc(&vxi->cvirt.nr_threads);
16393 + atomic_inc(&vxi->cvirt.nr_running);
16394 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
16395 + /* FIXME: what about the struct files here? */
16396 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
16397 + /* account for the executable */
16398 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
16401 + release_vx_info(old_vxi, p);
16402 + clr_vx_info(&p->vx_info);
16404 + claim_vx_info(vxi, p);
16405 + set_vx_info(&p->vx_info, vxi);
16406 + p->xid = vxi->vx_id;
16408 + vxdprintk(VXD_CBIT(xid, 5),
16409 + "moved task %p into vxi:%p[#%d]",
16410 + p, vxi, vxi->vx_id);
16412 + // vx_mask_cap_bset(vxi, p);
16415 + /* hack for *spaces to provide compatibility */
16417 + struct nsproxy *old_nsp, *new_nsp;
16419 + ret = unshare_nsproxy_namespaces(
16420 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
16425 + old_nsp = xchg(&p->nsproxy, new_nsp);
16426 + vx_set_space(vxi,
16427 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
16428 + put_nsproxy(old_nsp);
16432 + put_vx_info(old_vxi);
16436 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
16438 + struct task_struct *old_reaper;
16439 + struct vx_info *reaper_vxi;
16444 + vxdprintk(VXD_CBIT(xid, 6),
16445 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
16446 + vxi, vxi->vx_id, p, p->xid, p->pid);
16448 + old_reaper = vxi->vx_reaper;
16449 + if (old_reaper == p)
16452 + reaper_vxi = task_get_vx_info(p);
16453 + if (reaper_vxi && reaper_vxi != vxi) {
16455 + "Unsuitable reaper [" VS_Q("%s") ",%u:#%u] "
16457 + p->comm, p->pid, p->xid, vx_current_xid());
16461 + /* set new child reaper */
16462 + get_task_struct(p);
16463 + vxi->vx_reaper = p;
16464 + put_task_struct(old_reaper);
16466 + put_vx_info(reaper_vxi);
16470 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
16475 + vxdprintk(VXD_CBIT(xid, 6),
16476 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
16477 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16479 + vxi->vx_flags &= ~VXF_STATE_INIT;
16480 + // vxi->vx_initpid = p->tgid;
16481 + vxi->vx_initpid = p->pid;
16485 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
16487 + vxdprintk(VXD_CBIT(xid, 6),
16488 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
16489 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16491 + vxi->exit_code = code;
16492 + vxi->vx_initpid = 0;
16496 +void vx_set_persistent(struct vx_info *vxi)
16498 + vxdprintk(VXD_CBIT(xid, 6),
16499 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
16501 + get_vx_info(vxi);
16502 + claim_vx_info(vxi, NULL);
16505 +void vx_clear_persistent(struct vx_info *vxi)
16507 + vxdprintk(VXD_CBIT(xid, 6),
16508 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
16510 + release_vx_info(vxi, NULL);
16511 + put_vx_info(vxi);
16514 +void vx_update_persistent(struct vx_info *vxi)
16516 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
16517 + vx_set_persistent(vxi);
16519 + vx_clear_persistent(vxi);
16523 +/* task must be current or locked */
16525 +void exit_vx_info(struct task_struct *p, int code)
16527 + struct vx_info *vxi = p->vx_info;
16530 + atomic_dec(&vxi->cvirt.nr_threads);
16533 + vxi->exit_code = code;
16534 + release_vx_info(vxi, p);
16538 +void exit_vx_info_early(struct task_struct *p, int code)
16540 + struct vx_info *vxi = p->vx_info;
16543 + if (vxi->vx_initpid == p->pid)
16544 + vx_exit_init(vxi, p, code);
16545 + if (vxi->vx_reaper == p)
16546 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
16551 +/* vserver syscall commands below here */
16553 +/* taks xid and vx_info functions */
16555 +#include <asm/uaccess.h>
16558 +int vc_task_xid(uint32_t id)
16563 + struct task_struct *tsk;
16566 + tsk = find_task_by_real_pid(id);
16567 + xid = (tsk) ? tsk->xid : -ESRCH;
16568 + rcu_read_unlock();
16570 + xid = vx_current_xid();
16575 +int vc_vx_info(struct vx_info *vxi, void __user *data)
16577 + struct vcmd_vx_info_v0 vc_data;
16579 + vc_data.xid = vxi->vx_id;
16580 + vc_data.initpid = vxi->vx_initpid;
16582 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16588 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
16590 + struct vcmd_ctx_stat_v0 vc_data;
16592 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
16593 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
16595 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16601 +/* context functions */
16603 +int vc_ctx_create(uint32_t xid, void __user *data)
16605 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
16606 + struct vx_info *new_vxi;
16609 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16612 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
16615 + new_vxi = __create_vx_info(xid);
16616 + if (IS_ERR(new_vxi))
16617 + return PTR_ERR(new_vxi);
16619 + /* initial flags */
16620 + new_vxi->vx_flags = vc_data.flagword;
16623 + if (vs_state_change(new_vxi, VSC_STARTUP))
16626 + ret = vx_migrate_task(current, new_vxi, (!data));
16630 + /* return context id on success */
16631 + ret = new_vxi->vx_id;
16633 + /* get a reference for persistent contexts */
16634 + if ((vc_data.flagword & VXF_PERSISTENT))
16635 + vx_set_persistent(new_vxi);
16637 + release_vx_info(new_vxi, NULL);
16638 + put_vx_info(new_vxi);
16643 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
16645 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
16648 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16651 + ret = vx_migrate_task(current, vxi, 0);
16654 + if (vc_data.flagword & VXM_SET_INIT)
16655 + ret = vx_set_init(vxi, current);
16658 + if (vc_data.flagword & VXM_SET_REAPER)
16659 + ret = vx_set_reaper(vxi, current);
16664 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
16666 + struct vcmd_ctx_flags_v0 vc_data;
16668 + vc_data.flagword = vxi->vx_flags;
16670 + /* special STATE flag handling */
16671 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
16673 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16678 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
16680 + struct vcmd_ctx_flags_v0 vc_data;
16681 + uint64_t mask, trigger;
16683 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16686 + /* special STATE flag handling */
16687 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
16688 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
16690 + if (vxi == current_vx_info()) {
16691 + /* if (trigger & VXF_STATE_SETUP)
16692 + vx_mask_cap_bset(vxi, current); */
16693 + if (trigger & VXF_STATE_INIT) {
16696 + ret = vx_set_init(vxi, current);
16699 + ret = vx_set_reaper(vxi, current);
16705 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
16706 + vc_data.flagword, mask);
16707 + if (trigger & VXF_PERSISTENT)
16708 + vx_update_persistent(vxi);
16714 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
16716 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
16718 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
16722 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
16724 + kernel_cap_t c = __cap_empty_set;
16726 + c.cap[0] = v & 0xFFFFFFFF;
16727 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
16729 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
16734 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
16737 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
16739 + *ccaps = vxi->vx_ccaps;
16744 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
16746 + struct vcmd_ctx_caps_v1 vc_data;
16749 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
16752 + vc_data.cmask = ~0ULL;
16754 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16759 +static int do_set_caps(struct vx_info *vxi,
16760 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
16762 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
16765 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
16766 + bcaps, bmask, ccaps, cmask);
16768 + vxi->vx_bcaps = cap_t_from_caps(
16769 + vs_mask_flags(bcold, bcaps, bmask));
16770 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
16775 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
16777 + struct vcmd_ctx_caps_v1 vc_data;
16779 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16782 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
16785 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
16787 + struct vcmd_bcaps vc_data;
16790 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
16793 + vc_data.bmask = ~0ULL;
16795 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16800 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
16802 + struct vcmd_bcaps vc_data;
16804 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16807 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
16811 +int vc_get_umask(struct vx_info *vxi, void __user *data)
16813 + struct vcmd_umask vc_data;
16815 + vc_data.umask = vxi->vx_umask;
16816 + vc_data.mask = ~0ULL;
16818 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16823 +int vc_set_umask(struct vx_info *vxi, void __user *data)
16825 + struct vcmd_umask vc_data;
16827 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16830 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
16831 + vc_data.umask, vc_data.mask);
16836 +int vc_get_wmask(struct vx_info *vxi, void __user *data)
16838 + struct vcmd_wmask vc_data;
16840 + vc_data.wmask = vxi->vx_wmask;
16841 + vc_data.mask = ~0ULL;
16843 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16848 +int vc_set_wmask(struct vx_info *vxi, void __user *data)
16850 + struct vcmd_wmask vc_data;
16852 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16855 + vxi->vx_wmask = vs_mask_flags(vxi->vx_wmask,
16856 + vc_data.wmask, vc_data.mask);
16861 +int vc_get_badness(struct vx_info *vxi, void __user *data)
16863 + struct vcmd_badness_v0 vc_data;
16865 + vc_data.bias = vxi->vx_badness_bias;
16867 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16872 +int vc_set_badness(struct vx_info *vxi, void __user *data)
16874 + struct vcmd_badness_v0 vc_data;
16876 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16879 + vxi->vx_badness_bias = vc_data.bias;
16883 +#include <linux/module.h>
16885 +EXPORT_SYMBOL_GPL(free_vx_info);
16887 diff -NurpP --minimal linux-3.6.9/kernel/vserver/cvirt.c linux-3.6.9-vs2.3.4.4/kernel/vserver/cvirt.c
16888 --- linux-3.6.9/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
16889 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/cvirt.c 2012-10-04 18:47:00.000000000 +0200
16892 + * linux/kernel/vserver/cvirt.c
16894 + * Virtual Server: Context Virtualization
16896 + * Copyright (C) 2004-2007 Herbert Pötzl
16898 + * V0.01 broken out from limit.c
16899 + * V0.02 added utsname stuff
16900 + * V0.03 changed vcmds to vxi arg
16904 +#include <linux/types.h>
16905 +#include <linux/utsname.h>
16906 +#include <linux/vs_cvirt.h>
16907 +#include <linux/vserver/switch.h>
16908 +#include <linux/vserver/cvirt_cmd.h>
16910 +#include <asm/uaccess.h>
16913 +void vx_vsi_boottime(struct timespec *boottime)
16915 + struct vx_info *vxi = current_vx_info();
16917 + set_normalized_timespec(boottime,
16918 + boottime->tv_sec + vxi->cvirt.bias_uptime.tv_sec,
16919 + boottime->tv_nsec + vxi->cvirt.bias_uptime.tv_nsec);
16923 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
16925 + struct vx_info *vxi = current_vx_info();
16927 + set_normalized_timespec(uptime,
16928 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
16929 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
16932 + set_normalized_timespec(idle,
16933 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
16934 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
16938 +uint64_t vx_idle_jiffies(void)
16940 + return init_task.utime + init_task.stime;
16945 +static inline uint32_t __update_loadavg(uint32_t load,
16946 + int wsize, int delta, int n)
16948 + unsigned long long calc, prev;
16950 + /* just set it to n */
16951 + if (unlikely(delta >= wsize))
16952 + return (n << FSHIFT);
16954 + calc = delta * n;
16956 + prev = (wsize - delta);
16959 + do_div(calc, wsize);
16964 +void vx_update_load(struct vx_info *vxi)
16966 + uint32_t now, last, delta;
16967 + unsigned int nr_running, nr_uninterruptible;
16968 + unsigned int total;
16969 + unsigned long flags;
16971 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
16974 + last = vxi->cvirt.load_last;
16975 + delta = now - last;
16977 + if (delta < 5*HZ)
16980 + nr_running = atomic_read(&vxi->cvirt.nr_running);
16981 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
16982 + total = nr_running + nr_uninterruptible;
16984 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
16985 + 60*HZ, delta, total);
16986 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
16987 + 5*60*HZ, delta, total);
16988 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
16989 + 15*60*HZ, delta, total);
16991 + vxi->cvirt.load_last = now;
16993 + atomic_inc(&vxi->cvirt.load_updates);
16994 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
16999 + * Commands to do_syslog:
17001 + * 0 -- Close the log. Currently a NOP.
17002 + * 1 -- Open the log. Currently a NOP.
17003 + * 2 -- Read from the log.
17004 + * 3 -- Read all messages remaining in the ring buffer.
17005 + * 4 -- Read and clear all messages remaining in the ring buffer
17006 + * 5 -- Clear ring buffer.
17007 + * 6 -- Disable printk's to console
17008 + * 7 -- Enable printk's to console
17009 + * 8 -- Set level of messages printed to console
17010 + * 9 -- Return number of unread characters in the log buffer
17011 + * 10 -- Return size of the log buffer
17013 +int vx_do_syslog(int type, char __user *buf, int len)
17016 + int do_clear = 0;
17017 + struct vx_info *vxi = current_vx_info();
17018 + struct _vx_syslog *log;
17022 + log = &vxi->cvirt.syslog;
17025 + case 0: /* Close log */
17026 + case 1: /* Open log */
17028 + case 2: /* Read from log */
17029 + error = wait_event_interruptible(log->log_wait,
17030 + (log->log_start - log->log_end));
17033 + spin_lock_irq(&log->logbuf_lock);
17034 + spin_unlock_irq(&log->logbuf_lock);
17036 + case 4: /* Read/clear last kernel messages */
17038 + /* fall through */
17039 + case 3: /* Read last kernel messages */
17042 + case 5: /* Clear ring buffer */
17045 + case 6: /* Disable logging to console */
17046 + case 7: /* Enable logging to console */
17047 + case 8: /* Set level of messages printed to console */
17050 + case 9: /* Number of chars in the log buffer */
17052 + case 10: /* Size of the log buffer */
17062 +/* virtual host info names */
17064 +static char *vx_vhi_name(struct vx_info *vxi, int id)
17066 + struct nsproxy *nsproxy;
17067 + struct uts_namespace *uts;
17069 + if (id == VHIN_CONTEXT)
17070 + return vxi->vx_name;
17072 + nsproxy = vxi->space[0].vx_nsproxy;
17076 + uts = nsproxy->uts_ns;
17081 + case VHIN_SYSNAME:
17082 + return uts->name.sysname;
17083 + case VHIN_NODENAME:
17084 + return uts->name.nodename;
17085 + case VHIN_RELEASE:
17086 + return uts->name.release;
17087 + case VHIN_VERSION:
17088 + return uts->name.version;
17089 + case VHIN_MACHINE:
17090 + return uts->name.machine;
17091 + case VHIN_DOMAINNAME:
17092 + return uts->name.domainname;
17099 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
17101 + struct vcmd_vhi_name_v0 vc_data;
17104 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17107 + name = vx_vhi_name(vxi, vc_data.field);
17111 + memcpy(name, vc_data.name, 65);
17115 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
17117 + struct vcmd_vhi_name_v0 vc_data;
17120 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17123 + name = vx_vhi_name(vxi, vc_data.field);
17127 + memcpy(vc_data.name, name, 65);
17128 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17134 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
17136 + struct vcmd_virt_stat_v0 vc_data;
17137 + struct _vx_cvirt *cvirt = &vxi->cvirt;
17138 + struct timespec uptime;
17140 + do_posix_clock_monotonic_gettime(&uptime);
17141 + set_normalized_timespec(&uptime,
17142 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
17143 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
17145 + vc_data.offset = timespec_to_ns(&cvirt->bias_ts);
17146 + vc_data.uptime = timespec_to_ns(&uptime);
17147 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
17148 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
17149 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
17150 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
17151 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
17152 + vc_data.load[0] = cvirt->load[0];
17153 + vc_data.load[1] = cvirt->load[1];
17154 + vc_data.load[2] = cvirt->load[2];
17156 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17162 +#ifdef CONFIG_VSERVER_VTIME
17164 +/* virtualized time base */
17166 +void vx_adjust_timespec(struct timespec *ts)
17168 + struct vx_info *vxi;
17170 + if (!vx_flags(VXF_VIRT_TIME, 0))
17173 + vxi = current_vx_info();
17174 + ts->tv_sec += vxi->cvirt.bias_ts.tv_sec;
17175 + ts->tv_nsec += vxi->cvirt.bias_ts.tv_nsec;
17177 + if (ts->tv_nsec >= NSEC_PER_SEC) {
17179 + ts->tv_nsec -= NSEC_PER_SEC;
17180 + } else if (ts->tv_nsec < 0) {
17182 + ts->tv_nsec += NSEC_PER_SEC;
17186 +int vx_settimeofday(const struct timespec *ts)
17188 + struct timespec ats, delta;
17189 + struct vx_info *vxi;
17191 + if (!vx_flags(VXF_VIRT_TIME, 0))
17192 + return do_settimeofday(ts);
17194 + getnstimeofday(&ats);
17195 + delta = timespec_sub(*ts, ats);
17197 + vxi = current_vx_info();
17198 + vxi->cvirt.bias_ts = timespec_add(vxi->cvirt.bias_ts, delta);
17204 diff -NurpP --minimal linux-3.6.9/kernel/vserver/cvirt_init.h linux-3.6.9-vs2.3.4.4/kernel/vserver/cvirt_init.h
17205 --- linux-3.6.9/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
17206 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/cvirt_init.h 2012-10-04 18:47:00.000000000 +0200
17210 +extern uint64_t vx_idle_jiffies(void);
17212 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
17214 + uint64_t idle_jiffies = vx_idle_jiffies();
17215 + uint64_t nsuptime;
17217 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
17218 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
17219 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
17220 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
17221 + cvirt->bias_ts.tv_sec = 0;
17222 + cvirt->bias_ts.tv_nsec = 0;
17224 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
17225 + atomic_set(&cvirt->nr_threads, 0);
17226 + atomic_set(&cvirt->nr_running, 0);
17227 + atomic_set(&cvirt->nr_uninterruptible, 0);
17228 + atomic_set(&cvirt->nr_onhold, 0);
17230 + spin_lock_init(&cvirt->load_lock);
17231 + cvirt->load_last = jiffies;
17232 + atomic_set(&cvirt->load_updates, 0);
17233 + cvirt->load[0] = 0;
17234 + cvirt->load[1] = 0;
17235 + cvirt->load[2] = 0;
17236 + atomic_set(&cvirt->total_forks, 0);
17238 + spin_lock_init(&cvirt->syslog.logbuf_lock);
17239 + init_waitqueue_head(&cvirt->syslog.log_wait);
17240 + cvirt->syslog.log_start = 0;
17241 + cvirt->syslog.log_end = 0;
17242 + cvirt->syslog.con_start = 0;
17243 + cvirt->syslog.logged_chars = 0;
17247 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17249 + // cvirt_pc->cpustat = { 0 };
17252 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
17254 +#ifdef CONFIG_VSERVER_WARN
17257 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
17258 + "!!! cvirt: %p[nr_threads] = %d on exit.",
17260 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
17261 + "!!! cvirt: %p[nr_running] = %d on exit.",
17263 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
17264 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
17266 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
17267 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
17273 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17278 diff -NurpP --minimal linux-3.6.9/kernel/vserver/cvirt_proc.h linux-3.6.9-vs2.3.4.4/kernel/vserver/cvirt_proc.h
17279 --- linux-3.6.9/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
17280 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/cvirt_proc.h 2012-10-04 18:47:00.000000000 +0200
17282 +#ifndef _VX_CVIRT_PROC_H
17283 +#define _VX_CVIRT_PROC_H
17285 +#include <linux/nsproxy.h>
17286 +#include <linux/mnt_namespace.h>
17287 +#include <linux/ipc_namespace.h>
17288 +#include <linux/utsname.h>
17289 +#include <linux/ipc.h>
17291 +extern int vx_info_mnt_namespace(struct mnt_namespace *, char *);
17294 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
17296 + struct mnt_namespace *ns;
17297 + struct uts_namespace *uts;
17298 + struct ipc_namespace *ipc;
17304 + length += sprintf(buffer + length,
17305 + "NSProxy:\t%p [%p,%p,%p]\n",
17306 + nsproxy, nsproxy->mnt_ns,
17307 + nsproxy->uts_ns, nsproxy->ipc_ns);
17309 + ns = nsproxy->mnt_ns;
17313 + length += vx_info_mnt_namespace(ns, buffer + length);
17317 + uts = nsproxy->uts_ns;
17321 + length += sprintf(buffer + length,
17322 + "SysName:\t%.*s\n"
17323 + "NodeName:\t%.*s\n"
17324 + "Release:\t%.*s\n"
17325 + "Version:\t%.*s\n"
17326 + "Machine:\t%.*s\n"
17327 + "DomainName:\t%.*s\n",
17328 + __NEW_UTS_LEN, uts->name.sysname,
17329 + __NEW_UTS_LEN, uts->name.nodename,
17330 + __NEW_UTS_LEN, uts->name.release,
17331 + __NEW_UTS_LEN, uts->name.version,
17332 + __NEW_UTS_LEN, uts->name.machine,
17333 + __NEW_UTS_LEN, uts->name.domainname);
17336 + ipc = nsproxy->ipc_ns;
17340 + length += sprintf(buffer + length,
17341 + "SEMS:\t\t%d %d %d %d %d\n"
17342 + "MSG:\t\t%d %d %d\n"
17343 + "SHM:\t\t%lu %lu %d %d\n",
17344 + ipc->sem_ctls[0], ipc->sem_ctls[1],
17345 + ipc->sem_ctls[2], ipc->sem_ctls[3],
17347 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
17348 + (unsigned long)ipc->shm_ctlmax,
17349 + (unsigned long)ipc->shm_ctlall,
17350 + ipc->shm_ctlmni, ipc->shm_tot);
17357 +#include <linux/sched.h>
17359 +#define LOAD_INT(x) ((x) >> FSHIFT)
17360 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
17363 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
17368 + length += sprintf(buffer + length,
17369 + "BiasUptime:\t%lu.%02lu\n",
17370 + (unsigned long)cvirt->bias_uptime.tv_sec,
17371 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
17373 + a = cvirt->load[0] + (FIXED_1 / 200);
17374 + b = cvirt->load[1] + (FIXED_1 / 200);
17375 + c = cvirt->load[2] + (FIXED_1 / 200);
17376 + length += sprintf(buffer + length,
17377 + "nr_threads:\t%d\n"
17378 + "nr_running:\t%d\n"
17379 + "nr_unintr:\t%d\n"
17380 + "nr_onhold:\t%d\n"
17381 + "load_updates:\t%d\n"
17382 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
17383 + "total_forks:\t%d\n",
17384 + atomic_read(&cvirt->nr_threads),
17385 + atomic_read(&cvirt->nr_running),
17386 + atomic_read(&cvirt->nr_uninterruptible),
17387 + atomic_read(&cvirt->nr_onhold),
17388 + atomic_read(&cvirt->load_updates),
17389 + LOAD_INT(a), LOAD_FRAC(a),
17390 + LOAD_INT(b), LOAD_FRAC(b),
17391 + LOAD_INT(c), LOAD_FRAC(c),
17392 + atomic_read(&cvirt->total_forks));
17397 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
17398 + char *buffer, int cpu)
17404 +#endif /* _VX_CVIRT_PROC_H */
17405 diff -NurpP --minimal linux-3.6.9/kernel/vserver/debug.c linux-3.6.9-vs2.3.4.4/kernel/vserver/debug.c
17406 --- linux-3.6.9/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
17407 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/debug.c 2012-10-04 18:47:00.000000000 +0200
17410 + * kernel/vserver/debug.c
17412 + * Copyright (C) 2005-2007 Herbert Pötzl
17414 + * V0.01 vx_info dump support
17418 +#include <linux/module.h>
17420 +#include <linux/vserver/context.h>
17423 +void dump_vx_info(struct vx_info *vxi, int level)
17425 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
17426 + atomic_read(&vxi->vx_usecnt),
17427 + atomic_read(&vxi->vx_tasks),
17430 + __dump_vx_limit(&vxi->limit);
17431 + __dump_vx_sched(&vxi->sched);
17432 + __dump_vx_cvirt(&vxi->cvirt);
17433 + __dump_vx_cacct(&vxi->cacct);
17439 +EXPORT_SYMBOL_GPL(dump_vx_info);
17441 diff -NurpP --minimal linux-3.6.9/kernel/vserver/device.c linux-3.6.9-vs2.3.4.4/kernel/vserver/device.c
17442 --- linux-3.6.9/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
17443 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/device.c 2012-10-04 18:47:00.000000000 +0200
17446 + * linux/kernel/vserver/device.c
17448 + * Linux-VServer: Device Support
17450 + * Copyright (C) 2006 Herbert Pötzl
17451 + * Copyright (C) 2007 Daniel Hokka Zakrisson
17453 + * V0.01 device mapping basics
17454 + * V0.02 added defaults
17458 +#include <linux/slab.h>
17459 +#include <linux/rcupdate.h>
17460 +#include <linux/fs.h>
17461 +#include <linux/namei.h>
17462 +#include <linux/hash.h>
17464 +#include <asm/errno.h>
17465 +#include <asm/uaccess.h>
17466 +#include <linux/vserver/base.h>
17467 +#include <linux/vserver/debug.h>
17468 +#include <linux/vserver/context.h>
17469 +#include <linux/vserver/device.h>
17470 +#include <linux/vserver/device_cmd.h>
17473 +#define DMAP_HASH_BITS 4
17476 +struct vs_mapping {
17478 + struct hlist_node hlist;
17479 + struct list_head list;
17481 +#define dm_hlist u.hlist
17482 +#define dm_list u.list
17485 + struct vx_dmap_target target;
17489 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
17491 +static DEFINE_SPINLOCK(dmap_main_hash_lock);
17493 +static struct vx_dmap_target dmap_defaults[2] = {
17494 + { .flags = DATTR_OPEN },
17495 + { .flags = DATTR_OPEN },
17499 +struct kmem_cache *dmap_cachep __read_mostly;
17501 +int __init dmap_cache_init(void)
17503 + dmap_cachep = kmem_cache_create("dmap_cache",
17504 + sizeof(struct vs_mapping), 0,
17505 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
17509 +__initcall(dmap_cache_init);
17512 +static inline unsigned int __hashval(dev_t dev, int bits)
17514 + return hash_long((unsigned long)dev, bits);
17518 +/* __hash_mapping()
17519 + * add the mapping to the hash table
17521 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
17523 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17524 + struct hlist_head *head, *hash = dmap_main_hash;
17525 + int device = vdm->device;
17527 + spin_lock(hash_lock);
17528 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
17529 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
17531 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
17532 + hlist_add_head(&vdm->dm_hlist, head);
17533 + spin_unlock(hash_lock);
17537 +static inline int __mode_to_default(umode_t mode)
17550 +/* __set_default()
17553 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
17554 + struct vx_dmap_target *vdmt)
17556 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17557 + spin_lock(hash_lock);
17560 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
17562 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
17565 + spin_unlock(hash_lock);
17567 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
17568 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
17572 +/* __remove_default()
17573 + * remove a default
17575 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
17577 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17578 + spin_lock(hash_lock);
17581 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
17582 + else /* remove == reset */
17583 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
17585 + spin_unlock(hash_lock);
17590 +/* __find_mapping()
17591 + * find a mapping in the hash table
17593 + * caller must hold hash_lock
17595 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
17596 + struct vs_mapping **local, struct vs_mapping **global)
17598 + struct hlist_head *hash = dmap_main_hash;
17599 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
17600 + struct hlist_node *pos;
17601 + struct vs_mapping *vdm;
17607 + hlist_for_each(pos, head) {
17608 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
17610 + if ((vdm->device == device) &&
17611 + !((vdm->target.flags ^ mode) & S_IFMT)) {
17612 + if (vdm->xid == xid) {
17615 + } else if (global && vdm->xid == 0)
17620 + if (global && *global)
17627 +/* __lookup_mapping()
17628 + * find a mapping and store the result in target and flags
17630 +static inline int __lookup_mapping(struct vx_info *vxi,
17631 + dev_t device, dev_t *target, int *flags, umode_t mode)
17633 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17634 + struct vs_mapping *vdm, *global;
17635 + struct vx_dmap_target *vdmt;
17637 + xid_t xid = vxi->vx_id;
17640 + spin_lock(hash_lock);
17641 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
17643 + vdmt = &vdm->target;
17647 + index = __mode_to_default(mode);
17648 + if (vxi && vxi->dmap.targets[index].flags) {
17650 + vdmt = &vxi->dmap.targets[index];
17651 + } else if (global) {
17653 + vdmt = &global->target;
17657 + vdmt = &dmap_defaults[index];
17661 + if (target && (vdmt->flags & DATTR_REMAP))
17662 + *target = vdmt->target;
17664 + *target = device;
17666 + *flags = vdmt->flags;
17668 + spin_unlock(hash_lock);
17674 +/* __remove_mapping()
17675 + * remove a mapping from the hash table
17677 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
17680 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17681 + struct vs_mapping *vdm = NULL;
17684 + spin_lock(hash_lock);
17686 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
17688 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
17689 + vxi, vxi ? vxi->vx_id : 0, device, mode);
17692 + hlist_del(&vdm->dm_hlist);
17695 + spin_unlock(hash_lock);
17697 + kmem_cache_free(dmap_cachep, vdm);
17703 +int vs_map_device(struct vx_info *vxi,
17704 + dev_t device, dev_t *target, umode_t mode)
17706 + int ret, flags = DATTR_MASK;
17710 + *target = device;
17713 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
17714 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
17715 + device, target ? *target : 0, flags, mode, ret);
17717 + return (flags & DATTR_MASK);
17722 +static int do_set_mapping(struct vx_info *vxi,
17723 + dev_t device, dev_t target, int flags, umode_t mode)
17726 + struct vs_mapping *new;
17728 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
17732 + INIT_HLIST_NODE(&new->dm_hlist);
17733 + new->device = device;
17734 + new->target.target = target;
17735 + new->target.flags = flags | mode;
17736 + new->xid = (vxi ? vxi->vx_id : 0);
17738 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
17739 + __hash_mapping(vxi, new);
17741 + struct vx_dmap_target new = {
17742 + .target = target,
17743 + .flags = flags | mode,
17745 + __set_default(vxi, mode, &new);
17751 +static int do_unset_mapping(struct vx_info *vxi,
17752 + dev_t device, dev_t target, int flags, umode_t mode)
17754 + int ret = -EINVAL;
17757 + ret = __remove_mapping(vxi, device, mode);
17761 + ret = __remove_default(vxi, mode);
17771 +static inline int __user_device(const char __user *name, dev_t *dev,
17774 + struct nameidata nd;
17781 + ret = user_lpath(name, &nd.path);
17784 + if (nd.path.dentry->d_inode) {
17785 + *dev = nd.path.dentry->d_inode->i_rdev;
17786 + *mode = nd.path.dentry->d_inode->i_mode;
17788 + path_put(&nd.path);
17792 +static inline int __mapping_mode(dev_t device, dev_t target,
17793 + umode_t device_mode, umode_t target_mode, umode_t *mode)
17796 + *mode = device_mode & S_IFMT;
17798 + *mode = target_mode & S_IFMT;
17802 + /* if both given, device and target mode have to match */
17803 + if (device && target &&
17804 + ((device_mode ^ target_mode) & S_IFMT))
17810 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
17811 + const char __user *target_path, int flags, int set)
17813 + dev_t device = ~0, target = ~0;
17814 + umode_t device_mode = 0, target_mode = 0, mode;
17817 + ret = __user_device(device_path, &device, &device_mode);
17820 + ret = __user_device(target_path, &target, &target_mode);
17824 + ret = __mapping_mode(device, target,
17825 + device_mode, target_mode, &mode);
17830 + return do_set_mapping(vxi, device, target,
17833 + return do_unset_mapping(vxi, device, target,
17838 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
17840 + struct vcmd_set_mapping_v0 vc_data;
17842 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17845 + return do_mapping(vxi, vc_data.device, vc_data.target,
17846 + vc_data.flags, 1);
17849 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
17851 + struct vcmd_set_mapping_v0 vc_data;
17853 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17856 + return do_mapping(vxi, vc_data.device, vc_data.target,
17857 + vc_data.flags, 0);
17861 +#ifdef CONFIG_COMPAT
17863 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
17865 + struct vcmd_set_mapping_v0_x32 vc_data;
17867 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17870 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
17871 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
17874 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
17876 + struct vcmd_set_mapping_v0_x32 vc_data;
17878 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17881 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
17882 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
17885 +#endif /* CONFIG_COMPAT */
17888 diff -NurpP --minimal linux-3.6.9/kernel/vserver/dlimit.c linux-3.6.9-vs2.3.4.4/kernel/vserver/dlimit.c
17889 --- linux-3.6.9/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
17890 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/dlimit.c 2012-10-04 18:47:00.000000000 +0200
17893 + * linux/kernel/vserver/dlimit.c
17895 + * Virtual Server: Context Disk Limits
17897 + * Copyright (C) 2004-2009 Herbert Pötzl
17899 + * V0.01 initial version
17900 + * V0.02 compat32 splitup
17901 + * V0.03 extended interface
17905 +#include <linux/statfs.h>
17906 +#include <linux/sched.h>
17907 +#include <linux/namei.h>
17908 +#include <linux/vs_tag.h>
17909 +#include <linux/vs_dlimit.h>
17910 +#include <linux/vserver/dlimit_cmd.h>
17911 +#include <linux/slab.h>
17912 +// #include <linux/gfp.h>
17914 +#include <asm/uaccess.h>
17916 +/* __alloc_dl_info()
17918 + * allocate an initialized dl_info struct
17919 + * doesn't make it visible (hash) */
17921 +static struct dl_info *__alloc_dl_info(struct super_block *sb, vs_tag_t tag)
17923 + struct dl_info *new = NULL;
17925 + vxdprintk(VXD_CBIT(dlim, 5),
17926 + "alloc_dl_info(%p,%d)*", sb, tag);
17928 + /* would this benefit from a slab cache? */
17929 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
17933 + memset(new, 0, sizeof(struct dl_info));
17934 + new->dl_tag = tag;
17936 + // INIT_RCU_HEAD(&new->dl_rcu);
17937 + INIT_HLIST_NODE(&new->dl_hlist);
17938 + spin_lock_init(&new->dl_lock);
17939 + atomic_set(&new->dl_refcnt, 0);
17940 + atomic_set(&new->dl_usecnt, 0);
17942 + /* rest of init goes here */
17944 + vxdprintk(VXD_CBIT(dlim, 4),
17945 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
17949 +/* __dealloc_dl_info()
17951 + * final disposal of dl_info */
17953 +static void __dealloc_dl_info(struct dl_info *dli)
17955 + vxdprintk(VXD_CBIT(dlim, 4),
17956 + "dealloc_dl_info(%p)", dli);
17958 + dli->dl_hlist.next = LIST_POISON1;
17959 + dli->dl_tag = -1;
17962 + BUG_ON(atomic_read(&dli->dl_usecnt));
17963 + BUG_ON(atomic_read(&dli->dl_refcnt));
17969 +/* hash table for dl_info hash */
17971 +#define DL_HASH_SIZE 13
17973 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
17975 +static DEFINE_SPINLOCK(dl_info_hash_lock);
17978 +static inline unsigned int __hashval(struct super_block *sb, vs_tag_t tag)
17980 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
17985 +/* __hash_dl_info()
17987 + * add the dli to the global hash table
17988 + * requires the hash_lock to be held */
17990 +static inline void __hash_dl_info(struct dl_info *dli)
17992 + struct hlist_head *head;
17994 + vxdprintk(VXD_CBIT(dlim, 6),
17995 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
17996 + get_dl_info(dli);
17997 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
17998 + hlist_add_head_rcu(&dli->dl_hlist, head);
18001 +/* __unhash_dl_info()
18003 + * remove the dli from the global hash table
18004 + * requires the hash_lock to be held */
18006 +static inline void __unhash_dl_info(struct dl_info *dli)
18008 + vxdprintk(VXD_CBIT(dlim, 6),
18009 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
18010 + hlist_del_rcu(&dli->dl_hlist);
18011 + put_dl_info(dli);
18015 +/* __lookup_dl_info()
18017 + * requires the rcu_read_lock()
18018 + * doesn't increment the dl_refcnt */
18020 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, vs_tag_t tag)
18022 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
18023 + struct hlist_node *pos;
18024 + struct dl_info *dli;
18026 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
18028 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
18036 +struct dl_info *locate_dl_info(struct super_block *sb, vs_tag_t tag)
18038 + struct dl_info *dli;
18041 + dli = get_dl_info(__lookup_dl_info(sb, tag));
18042 + vxdprintk(VXD_CBIT(dlim, 7),
18043 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
18044 + rcu_read_unlock();
18048 +void rcu_free_dl_info(struct rcu_head *head)
18050 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
18051 + int usecnt, refcnt;
18053 + BUG_ON(!dli || !head);
18055 + usecnt = atomic_read(&dli->dl_usecnt);
18056 + BUG_ON(usecnt < 0);
18058 + refcnt = atomic_read(&dli->dl_refcnt);
18059 + BUG_ON(refcnt < 0);
18061 + vxdprintk(VXD_CBIT(dlim, 3),
18062 + "rcu_free_dl_info(%p)", dli);
18064 + __dealloc_dl_info(dli);
18066 + printk("!!! rcu didn't free\n");
18072 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
18073 + uint32_t flags, int add)
18075 + struct path path;
18078 + ret = user_lpath(name, &path);
18080 + struct super_block *sb;
18081 + struct dl_info *dli;
18084 + if (!path.dentry->d_inode)
18085 + goto out_release;
18086 + if (!(sb = path.dentry->d_inode->i_sb))
18087 + goto out_release;
18090 + dli = __alloc_dl_info(sb, id);
18091 + spin_lock(&dl_info_hash_lock);
18094 + if (__lookup_dl_info(sb, id))
18096 + __hash_dl_info(dli);
18099 + spin_lock(&dl_info_hash_lock);
18100 + dli = __lookup_dl_info(sb, id);
18105 + __unhash_dl_info(dli);
18109 + spin_unlock(&dl_info_hash_lock);
18111 + __dealloc_dl_info(dli);
18118 +int vc_add_dlimit(uint32_t id, void __user *data)
18120 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18122 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18125 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
18128 +int vc_rem_dlimit(uint32_t id, void __user *data)
18130 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18132 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18135 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
18138 +#ifdef CONFIG_COMPAT
18140 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
18142 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18144 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18147 + return do_addrem_dlimit(id,
18148 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
18151 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
18153 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18155 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18158 + return do_addrem_dlimit(id,
18159 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
18162 +#endif /* CONFIG_COMPAT */
18166 +int do_set_dlimit(uint32_t id, const char __user *name,
18167 + uint32_t space_used, uint32_t space_total,
18168 + uint32_t inodes_used, uint32_t inodes_total,
18169 + uint32_t reserved, uint32_t flags)
18171 + struct path path;
18174 + ret = user_lpath(name, &path);
18176 + struct super_block *sb;
18177 + struct dl_info *dli;
18180 + if (!path.dentry->d_inode)
18181 + goto out_release;
18182 + if (!(sb = path.dentry->d_inode->i_sb))
18183 + goto out_release;
18185 + /* sanity checks */
18186 + if ((reserved != CDLIM_KEEP &&
18187 + reserved > 100) ||
18188 + (inodes_used != CDLIM_KEEP &&
18189 + inodes_used > inodes_total) ||
18190 + (space_used != CDLIM_KEEP &&
18191 + space_used > space_total))
18192 + goto out_release;
18195 + dli = locate_dl_info(sb, id);
18197 + goto out_release;
18199 + spin_lock(&dli->dl_lock);
18201 + if (inodes_used != CDLIM_KEEP)
18202 + dli->dl_inodes_used = inodes_used;
18203 + if (inodes_total != CDLIM_KEEP)
18204 + dli->dl_inodes_total = inodes_total;
18205 + if (space_used != CDLIM_KEEP)
18206 + dli->dl_space_used = dlimit_space_32to64(
18207 + space_used, flags, DLIMS_USED);
18209 + if (space_total == CDLIM_INFINITY)
18210 + dli->dl_space_total = DLIM_INFINITY;
18211 + else if (space_total != CDLIM_KEEP)
18212 + dli->dl_space_total = dlimit_space_32to64(
18213 + space_total, flags, DLIMS_TOTAL);
18215 + if (reserved != CDLIM_KEEP)
18216 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
18218 + spin_unlock(&dli->dl_lock);
18220 + put_dl_info(dli);
18229 +int vc_set_dlimit(uint32_t id, void __user *data)
18231 + struct vcmd_ctx_dlimit_v0 vc_data;
18233 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18236 + return do_set_dlimit(id, vc_data.name,
18237 + vc_data.space_used, vc_data.space_total,
18238 + vc_data.inodes_used, vc_data.inodes_total,
18239 + vc_data.reserved, vc_data.flags);
18242 +#ifdef CONFIG_COMPAT
18244 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
18246 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18248 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18251 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
18252 + vc_data.space_used, vc_data.space_total,
18253 + vc_data.inodes_used, vc_data.inodes_total,
18254 + vc_data.reserved, vc_data.flags);
18257 +#endif /* CONFIG_COMPAT */
18261 +int do_get_dlimit(uint32_t id, const char __user *name,
18262 + uint32_t *space_used, uint32_t *space_total,
18263 + uint32_t *inodes_used, uint32_t *inodes_total,
18264 + uint32_t *reserved, uint32_t *flags)
18266 + struct path path;
18269 + ret = user_lpath(name, &path);
18271 + struct super_block *sb;
18272 + struct dl_info *dli;
18275 + if (!path.dentry->d_inode)
18276 + goto out_release;
18277 + if (!(sb = path.dentry->d_inode->i_sb))
18278 + goto out_release;
18281 + dli = locate_dl_info(sb, id);
18283 + goto out_release;
18285 + spin_lock(&dli->dl_lock);
18286 + *inodes_used = dli->dl_inodes_used;
18287 + *inodes_total = dli->dl_inodes_total;
18289 + *space_used = dlimit_space_64to32(
18290 + dli->dl_space_used, flags, DLIMS_USED);
18292 + if (dli->dl_space_total == DLIM_INFINITY)
18293 + *space_total = CDLIM_INFINITY;
18295 + *space_total = dlimit_space_64to32(
18296 + dli->dl_space_total, flags, DLIMS_TOTAL);
18298 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
18299 + spin_unlock(&dli->dl_lock);
18301 + put_dl_info(dli);
18312 +int vc_get_dlimit(uint32_t id, void __user *data)
18314 + struct vcmd_ctx_dlimit_v0 vc_data;
18317 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18320 + ret = do_get_dlimit(id, vc_data.name,
18321 + &vc_data.space_used, &vc_data.space_total,
18322 + &vc_data.inodes_used, &vc_data.inodes_total,
18323 + &vc_data.reserved, &vc_data.flags);
18327 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18332 +#ifdef CONFIG_COMPAT
18334 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
18336 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18339 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18342 + ret = do_get_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);
18349 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18354 +#endif /* CONFIG_COMPAT */
18357 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
18359 + struct dl_info *dli;
18360 + __u64 blimit, bfree, bavail;
18363 + dli = locate_dl_info(sb, dx_current_tag());
18367 + spin_lock(&dli->dl_lock);
18368 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
18371 + /* reduce max inodes available to limit */
18372 + if (buf->f_files > dli->dl_inodes_total)
18373 + buf->f_files = dli->dl_inodes_total;
18375 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
18376 + /* reduce free inodes to min */
18377 + if (ifree < buf->f_ffree)
18378 + buf->f_ffree = ifree;
18381 + if (dli->dl_space_total == DLIM_INFINITY)
18384 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
18386 + if (dli->dl_space_total < dli->dl_space_used)
18389 + bfree = (dli->dl_space_total - dli->dl_space_used)
18390 + >> sb->s_blocksize_bits;
18392 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
18393 + if (bavail < dli->dl_space_used)
18396 + bavail = (bavail - dli->dl_space_used)
18397 + >> sb->s_blocksize_bits;
18399 + /* reduce max space available to limit */
18400 + if (buf->f_blocks > blimit)
18401 + buf->f_blocks = blimit;
18403 + /* reduce free space to min */
18404 + if (bfree < buf->f_bfree)
18405 + buf->f_bfree = bfree;
18407 + /* reduce avail space to min */
18408 + if (bavail < buf->f_bavail)
18409 + buf->f_bavail = bavail;
18412 + spin_unlock(&dli->dl_lock);
18413 + put_dl_info(dli);
18418 +#include <linux/module.h>
18420 +EXPORT_SYMBOL_GPL(locate_dl_info);
18421 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
18423 diff -NurpP --minimal linux-3.6.9/kernel/vserver/helper.c linux-3.6.9-vs2.3.4.4/kernel/vserver/helper.c
18424 --- linux-3.6.9/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
18425 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/helper.c 2012-10-04 18:47:00.000000000 +0200
18428 + * linux/kernel/vserver/helper.c
18430 + * Virtual Context Support
18432 + * Copyright (C) 2004-2007 Herbert Pötzl
18434 + * V0.01 basic helper
18438 +#include <linux/kmod.h>
18439 +#include <linux/reboot.h>
18440 +#include <linux/vs_context.h>
18441 +#include <linux/vs_network.h>
18442 +#include <linux/vserver/signal.h>
18445 +char vshelper_path[255] = "/sbin/vshelper";
18447 +static int vshelper_init(struct subprocess_info *info, struct cred *new_cred)
18449 + current->flags &= ~PF_THREAD_BOUND;
18453 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
18457 + if ((ret = call_usermodehelper_fns(name, argv, envp,
18458 + sync ? UMH_WAIT_PROC : UMH_WAIT_EXEC,
18459 + vshelper_init, NULL, NULL))) {
18460 + printk(KERN_WARNING "%s: (%s %s) returned %s with %d\n",
18461 + name, argv[1], argv[2],
18462 + sync ? "sync" : "async", ret);
18464 + vxdprintk(VXD_CBIT(switch, 4),
18465 + "%s: (%s %s) returned %s with %d",
18466 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
18471 + * vshelper path is set via /proc/sys
18472 + * invoked by vserver sys_reboot(), with
18473 + * the following arguments
18475 + * argv [0] = vshelper_path;
18476 + * argv [1] = action: "restart", "halt", "poweroff", ...
18477 + * argv [2] = context identifier
18479 + * envp [*] = type-specific parameters
18482 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
18484 + char id_buf[8], cmd_buf[16];
18485 + char uid_buf[16], pid_buf[16];
18488 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18489 + char *envp[] = {"HOME=/", "TERM=linux",
18490 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
18491 + uid_buf, pid_buf, cmd_buf, 0};
18493 + if (vx_info_state(vxi, VXS_HELPER))
18495 + vxi->vx_state |= VXS_HELPER;
18497 + snprintf(id_buf, sizeof(id_buf), "%d", vxi->vx_id);
18499 + snprintf(cmd_buf, sizeof(cmd_buf), "VS_CMD=%08x", cmd);
18500 + snprintf(uid_buf, sizeof(uid_buf), "VS_UID=%d", current_uid());
18501 + snprintf(pid_buf, sizeof(pid_buf), "VS_PID=%d", current->pid);
18504 + case LINUX_REBOOT_CMD_RESTART:
18505 + argv[1] = "restart";
18508 + case LINUX_REBOOT_CMD_HALT:
18509 + argv[1] = "halt";
18512 + case LINUX_REBOOT_CMD_POWER_OFF:
18513 + argv[1] = "poweroff";
18516 + case LINUX_REBOOT_CMD_SW_SUSPEND:
18517 + argv[1] = "swsusp";
18520 + case LINUX_REBOOT_CMD_OOM:
18525 + vxi->vx_state &= ~VXS_HELPER;
18529 + ret = do_vshelper(vshelper_path, argv, envp, 0);
18530 + vxi->vx_state &= ~VXS_HELPER;
18531 + __wakeup_vx_info(vxi);
18532 + return (ret) ? -EPERM : 0;
18536 +long vs_reboot(unsigned int cmd, void __user *arg)
18538 + struct vx_info *vxi = current_vx_info();
18541 + vxdprintk(VXD_CBIT(misc, 5),
18542 + "vs_reboot(%p[#%d],%u)",
18543 + vxi, vxi ? vxi->vx_id : 0, cmd);
18545 + ret = vs_reboot_helper(vxi, cmd, arg);
18549 + vxi->reboot_cmd = cmd;
18550 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18552 + case LINUX_REBOOT_CMD_RESTART:
18553 + case LINUX_REBOOT_CMD_HALT:
18554 + case LINUX_REBOOT_CMD_POWER_OFF:
18555 + vx_info_kill(vxi, 0, SIGKILL);
18556 + vx_info_kill(vxi, 1, SIGKILL);
18564 +long vs_oom_action(unsigned int cmd)
18566 + struct vx_info *vxi = current_vx_info();
18569 + vxdprintk(VXD_CBIT(misc, 5),
18570 + "vs_oom_action(%p[#%d],%u)",
18571 + vxi, vxi ? vxi->vx_id : 0, cmd);
18573 + ret = vs_reboot_helper(vxi, cmd, NULL);
18577 + vxi->reboot_cmd = cmd;
18578 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18579 + vx_info_kill(vxi, 0, SIGKILL);
18580 + vx_info_kill(vxi, 1, SIGKILL);
18586 + * argv [0] = vshelper_path;
18587 + * argv [1] = action: "startup", "shutdown"
18588 + * argv [2] = context identifier
18590 + * envp [*] = type-specific parameters
18593 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
18595 + char id_buf[8], cmd_buf[16];
18596 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18597 + char *envp[] = {"HOME=/", "TERM=linux",
18598 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18600 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
18603 + snprintf(id_buf, sizeof(id_buf), "%d", vxi->vx_id);
18604 + snprintf(cmd_buf, sizeof(cmd_buf), "VS_CMD=%08x", cmd);
18607 + case VSC_STARTUP:
18608 + argv[1] = "startup";
18610 + case VSC_SHUTDOWN:
18611 + argv[1] = "shutdown";
18617 + return do_vshelper(vshelper_path, argv, envp, 1);
18622 + * argv [0] = vshelper_path;
18623 + * argv [1] = action: "netup", "netdown"
18624 + * argv [2] = context identifier
18626 + * envp [*] = type-specific parameters
18629 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
18631 + char id_buf[8], cmd_buf[16];
18632 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18633 + char *envp[] = {"HOME=/", "TERM=linux",
18634 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18636 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
18639 + snprintf(id_buf, sizeof(id_buf), "%d", nxi->nx_id);
18640 + snprintf(cmd_buf, sizeof(cmd_buf), "VS_CMD=%08x", cmd);
18644 + argv[1] = "netup";
18646 + case VSC_NETDOWN:
18647 + argv[1] = "netdown";
18653 + return do_vshelper(vshelper_path, argv, envp, 1);
18656 diff -NurpP --minimal linux-3.6.9/kernel/vserver/history.c linux-3.6.9-vs2.3.4.4/kernel/vserver/history.c
18657 --- linux-3.6.9/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
18658 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/history.c 2012-10-04 18:47:00.000000000 +0200
18661 + * kernel/vserver/history.c
18663 + * Virtual Context History Backtrace
18665 + * Copyright (C) 2004-2007 Herbert Pötzl
18667 + * V0.01 basic structure
18668 + * V0.02 hash/unhash and trace
18669 + * V0.03 preemption fixes
18673 +#include <linux/module.h>
18674 +#include <asm/uaccess.h>
18676 +#include <linux/vserver/context.h>
18677 +#include <linux/vserver/debug.h>
18678 +#include <linux/vserver/debug_cmd.h>
18679 +#include <linux/vserver/history.h>
18682 +#ifdef CONFIG_VSERVER_HISTORY
18683 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
18685 +#define VXH_SIZE 64
18688 +struct _vx_history {
18689 + unsigned int counter;
18691 + struct _vx_hist_entry entry[VXH_SIZE + 1];
18695 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
18697 +unsigned volatile int vxh_active = 1;
18699 +static atomic_t sequence = ATOMIC_INIT(0);
18704 + * requires disabled preemption */
18706 +struct _vx_hist_entry *vxh_advance(void *loc)
18708 + unsigned int cpu = smp_processor_id();
18709 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
18710 + struct _vx_hist_entry *entry;
18711 + unsigned int index;
18713 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
18714 + entry = &hist->entry[index];
18716 + entry->seq = atomic_inc_return(&sequence);
18717 + entry->loc = loc;
18721 +EXPORT_SYMBOL_GPL(vxh_advance);
18724 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
18726 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
18729 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
18731 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
18732 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
18733 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
18734 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
18736 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
18738 + switch (e->type) {
18739 + case VXH_THROW_OOPS:
18740 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
18743 + case VXH_GET_VX_INFO:
18744 + case VXH_PUT_VX_INFO:
18745 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
18747 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
18748 + VXH_VXI_ARGS(e));
18751 + case VXH_INIT_VX_INFO:
18752 + case VXH_SET_VX_INFO:
18753 + case VXH_CLR_VX_INFO:
18754 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
18756 + (e->type == VXH_INIT_VX_INFO) ? "init" :
18757 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
18758 + VXH_VXI_ARGS(e), e->sc.data);
18761 + case VXH_CLAIM_VX_INFO:
18762 + case VXH_RELEASE_VX_INFO:
18763 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
18765 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
18766 + VXH_VXI_ARGS(e), e->sc.data);
18769 + case VXH_ALLOC_VX_INFO:
18770 + case VXH_DEALLOC_VX_INFO:
18771 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
18773 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
18774 + VXH_VXI_ARGS(e));
18777 + case VXH_HASH_VX_INFO:
18778 + case VXH_UNHASH_VX_INFO:
18779 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
18781 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
18782 + VXH_VXI_ARGS(e));
18785 + case VXH_LOC_VX_INFO:
18786 + case VXH_LOOKUP_VX_INFO:
18787 + case VXH_CREATE_VX_INFO:
18788 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
18790 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
18791 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
18792 + e->ll.arg, VXH_VXI_ARGS(e));
18797 +static void __vxh_dump_history(void)
18799 + unsigned int i, cpu;
18801 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
18802 + atomic_read(&sequence), NR_CPUS);
18804 + for (i = 0; i < VXH_SIZE; i++) {
18805 + for_each_online_cpu(cpu) {
18806 + struct _vx_history *hist =
18807 + &per_cpu(vx_history_buffer, cpu);
18808 + unsigned int index = (hist->counter - i) % VXH_SIZE;
18809 + struct _vx_hist_entry *entry = &hist->entry[index];
18811 + vxh_dump_entry(entry, cpu);
18816 +void vxh_dump_history(void)
18820 + local_irq_enable();
18822 + local_irq_disable();
18824 + __vxh_dump_history();
18828 +/* vserver syscall commands below here */
18831 +int vc_dump_history(uint32_t id)
18834 + __vxh_dump_history();
18841 +int do_read_history(struct __user _vx_hist_entry *data,
18842 + int cpu, uint32_t *index, uint32_t *count)
18844 + int pos, ret = 0;
18845 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
18846 + int end = hist->counter;
18847 + int start = end - VXH_SIZE + 2;
18848 + int idx = *index;
18850 + /* special case: get current pos */
18856 + /* have we lost some data? */
18860 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
18861 + struct _vx_hist_entry *entry =
18862 + &hist->entry[idx % VXH_SIZE];
18864 + /* send entry to userspace */
18865 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
18869 + /* save new index and count */
18872 + return ret ? ret : (*index < end);
18875 +int vc_read_history(uint32_t id, void __user *data)
18877 + struct vcmd_read_history_v0 vc_data;
18880 + if (id >= NR_CPUS)
18883 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18886 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
18887 + id, &vc_data.index, &vc_data.count);
18889 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18894 +#ifdef CONFIG_COMPAT
18896 +int vc_read_history_x32(uint32_t id, void __user *data)
18898 + struct vcmd_read_history_v0_x32 vc_data;
18901 + if (id >= NR_CPUS)
18904 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18907 + ret = do_read_history((struct __user _vx_hist_entry *)
18908 + compat_ptr(vc_data.data_ptr),
18909 + id, &vc_data.index, &vc_data.count);
18911 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18916 +#endif /* CONFIG_COMPAT */
18918 diff -NurpP --minimal linux-3.6.9/kernel/vserver/inet.c linux-3.6.9-vs2.3.4.4/kernel/vserver/inet.c
18919 --- linux-3.6.9/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
18920 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/inet.c 2012-10-04 18:47:00.000000000 +0200
18923 +#include <linux/in.h>
18924 +#include <linux/inetdevice.h>
18925 +#include <linux/export.h>
18926 +#include <linux/vs_inet.h>
18927 +#include <linux/vs_inet6.h>
18928 +#include <linux/vserver/debug.h>
18929 +#include <net/route.h>
18930 +#include <net/addrconf.h>
18933 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
18937 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
18940 + struct nx_addr_v4 *ptr;
18942 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
18943 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
18950 + vxdprintk(VXD_CBIT(net, 2),
18951 + "nx_v4_addr_conflict(%p,%p): %d",
18952 + nxi1, nxi2, ret);
18958 +#ifdef CONFIG_IPV6
18960 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
18964 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
18967 + struct nx_addr_v6 *ptr;
18969 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
18970 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
18977 + vxdprintk(VXD_CBIT(net, 2),
18978 + "nx_v6_addr_conflict(%p,%p): %d",
18979 + nxi1, nxi2, ret);
18986 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
18988 + struct in_device *in_dev;
18989 + struct in_ifaddr **ifap;
18990 + struct in_ifaddr *ifa;
18995 + in_dev = in_dev_get(dev);
18999 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
19000 + ifap = &ifa->ifa_next) {
19001 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
19006 + in_dev_put(in_dev);
19012 +#ifdef CONFIG_IPV6
19014 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19016 + struct inet6_dev *in_dev;
19017 + struct inet6_ifaddr *ifa;
19022 + in_dev = in6_dev_get(dev);
19026 + // for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
19027 + list_for_each_entry(ifa, &in_dev->addr_list, if_list) {
19028 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
19033 + in6_dev_put(in_dev);
19040 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19046 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
19048 +#ifdef CONFIG_IPV6
19050 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
19055 + vxdprintk(VXD_CBIT(net, 3),
19056 + "dev_in_nx_info(%p,%p[#%d]) = %d",
19057 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
19061 +struct rtable *ip_v4_find_src(struct net *net, struct nx_info *nxi,
19062 + struct flowi4 *fl4)
19064 + struct rtable *rt;
19069 + /* FIXME: handle lback only case */
19070 + if (!NX_IPV4(nxi))
19071 + return ERR_PTR(-EPERM);
19073 + vxdprintk(VXD_CBIT(net, 4),
19074 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
19075 + nxi, nxi ? nxi->nx_id : 0,
19076 + NIPQUAD(fl4->saddr), NIPQUAD(fl4->daddr));
19078 + /* single IP is unconditional */
19079 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
19080 + (fl4->saddr == INADDR_ANY))
19081 + fl4->saddr = nxi->v4.ip[0].s_addr;
19083 + if (fl4->saddr == INADDR_ANY) {
19084 + struct nx_addr_v4 *ptr;
19085 + __be32 found = 0;
19087 + rt = __ip_route_output_key(net, fl4);
19088 + if (!IS_ERR(rt)) {
19089 + found = fl4->saddr;
19091 + vxdprintk(VXD_CBIT(net, 4),
19092 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19093 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(found));
19094 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
19098 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
19099 + __be32 primary = ptr->ip[0].s_addr;
19100 + __be32 mask = ptr->mask.s_addr;
19101 + __be32 neta = primary & mask;
19103 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
19104 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
19105 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
19106 + NIPQUAD(mask), NIPQUAD(neta));
19107 + if ((found & mask) != neta)
19110 + fl4->saddr = primary;
19111 + rt = __ip_route_output_key(net, fl4);
19112 + vxdprintk(VXD_CBIT(net, 4),
19113 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19114 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(primary));
19115 + if (!IS_ERR(rt)) {
19116 + found = fl4->saddr;
19118 + if (found == primary)
19122 + /* still no source ip? */
19123 + found = ipv4_is_loopback(fl4->daddr)
19124 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
19126 + /* assign src ip to flow */
19127 + fl4->saddr = found;
19130 + if (!v4_addr_in_nx_info(nxi, fl4->saddr, NXA_MASK_BIND))
19131 + return ERR_PTR(-EPERM);
19134 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
19135 + if (ipv4_is_loopback(fl4->daddr))
19136 + fl4->daddr = nxi->v4_lback.s_addr;
19137 + if (ipv4_is_loopback(fl4->saddr))
19138 + fl4->saddr = nxi->v4_lback.s_addr;
19139 + } else if (ipv4_is_loopback(fl4->daddr) &&
19140 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
19141 + return ERR_PTR(-EPERM);
19146 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
19148 diff -NurpP --minimal linux-3.6.9/kernel/vserver/init.c linux-3.6.9-vs2.3.4.4/kernel/vserver/init.c
19149 --- linux-3.6.9/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
19150 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/init.c 2012-10-04 18:47:00.000000000 +0200
19153 + * linux/kernel/init.c
19155 + * Virtual Server Init
19157 + * Copyright (C) 2004-2007 Herbert Pötzl
19159 + * V0.01 basic structure
19163 +#include <linux/init.h>
19165 +int vserver_register_sysctl(void);
19166 +void vserver_unregister_sysctl(void);
19169 +static int __init init_vserver(void)
19173 +#ifdef CONFIG_VSERVER_DEBUG
19174 + vserver_register_sysctl();
19180 +static void __exit exit_vserver(void)
19183 +#ifdef CONFIG_VSERVER_DEBUG
19184 + vserver_unregister_sysctl();
19189 +/* FIXME: GFP_ZONETYPES gone
19190 +long vx_slab[GFP_ZONETYPES]; */
19194 +module_init(init_vserver);
19195 +module_exit(exit_vserver);
19197 diff -NurpP --minimal linux-3.6.9/kernel/vserver/inode.c linux-3.6.9-vs2.3.4.4/kernel/vserver/inode.c
19198 --- linux-3.6.9/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
19199 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/inode.c 2012-10-04 18:47:00.000000000 +0200
19202 + * linux/kernel/vserver/inode.c
19204 + * Virtual Server: File System Support
19206 + * Copyright (C) 2004-2007 Herbert Pötzl
19208 + * V0.01 separated from vcontext V0.05
19209 + * V0.02 moved to tag (instead of xid)
19213 +#include <linux/tty.h>
19214 +#include <linux/proc_fs.h>
19215 +#include <linux/devpts_fs.h>
19216 +#include <linux/fs.h>
19217 +#include <linux/file.h>
19218 +#include <linux/mount.h>
19219 +#include <linux/parser.h>
19220 +#include <linux/namei.h>
19221 +#include <linux/vserver/inode.h>
19222 +#include <linux/vserver/inode_cmd.h>
19223 +#include <linux/vs_base.h>
19224 +#include <linux/vs_tag.h>
19226 +#include <asm/uaccess.h>
19229 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19231 + struct proc_dir_entry *entry;
19233 + if (!in || !in->i_sb)
19236 + *flags = IATTR_TAG
19237 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
19238 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
19239 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
19240 + | (IS_COW(in) ? IATTR_COW : 0);
19241 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
19243 + if (S_ISDIR(in->i_mode))
19244 + *mask |= IATTR_BARRIER;
19246 + if (IS_TAGGED(in)) {
19247 + *tag = in->i_tag;
19248 + *mask |= IATTR_TAG;
19251 + switch (in->i_sb->s_magic) {
19252 + case PROC_SUPER_MAGIC:
19253 + entry = PROC_I(in)->pde;
19255 + /* check for specific inodes? */
19257 + *mask |= IATTR_FLAGS;
19259 + *flags |= (entry->vx_flags & IATTR_FLAGS);
19261 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
19264 + case DEVPTS_SUPER_MAGIC:
19265 + *tag = in->i_tag;
19266 + *mask |= IATTR_TAG;
19275 +int vc_get_iattr(void __user *data)
19277 + struct path path;
19278 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
19281 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19284 + ret = user_lpath(vc_data.name, &path);
19286 + ret = __vc_get_iattr(path.dentry->d_inode,
19287 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19293 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19298 +#ifdef CONFIG_COMPAT
19300 +int vc_get_iattr_x32(void __user *data)
19302 + struct path path;
19303 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
19306 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19309 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19311 + ret = __vc_get_iattr(path.dentry->d_inode,
19312 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19318 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19323 +#endif /* CONFIG_COMPAT */
19326 +int vc_fget_iattr(uint32_t fd, void __user *data)
19328 + struct file *filp;
19329 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
19332 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19336 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19339 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
19340 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19344 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19350 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19352 + struct inode *in = de->d_inode;
19353 + int error = 0, is_proc = 0, has_tag = 0;
19354 + struct iattr attr = { 0 };
19356 + if (!in || !in->i_sb)
19359 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
19360 + if ((*mask & IATTR_FLAGS) && !is_proc)
19363 + has_tag = IS_TAGGED(in) ||
19364 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
19365 + if ((*mask & IATTR_TAG) && !has_tag)
19368 + mutex_lock(&in->i_mutex);
19369 + if (*mask & IATTR_TAG) {
19370 + attr.ia_tag = *tag;
19371 + attr.ia_valid |= ATTR_TAG;
19374 + if (*mask & IATTR_FLAGS) {
19375 + struct proc_dir_entry *entry = PROC_I(in)->pde;
19376 + unsigned int iflags = PROC_I(in)->vx_flags;
19378 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
19379 + | (*flags & IATTR_FLAGS);
19380 + PROC_I(in)->vx_flags = iflags;
19382 + entry->vx_flags = iflags;
19385 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
19386 + IATTR_BARRIER | IATTR_COW)) {
19387 + int iflags = in->i_flags;
19388 + int vflags = in->i_vflags;
19390 + if (*mask & IATTR_IMMUTABLE) {
19391 + if (*flags & IATTR_IMMUTABLE)
19392 + iflags |= S_IMMUTABLE;
19394 + iflags &= ~S_IMMUTABLE;
19396 + if (*mask & IATTR_IXUNLINK) {
19397 + if (*flags & IATTR_IXUNLINK)
19398 + iflags |= S_IXUNLINK;
19400 + iflags &= ~S_IXUNLINK;
19402 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
19403 + if (*flags & IATTR_BARRIER)
19404 + vflags |= V_BARRIER;
19406 + vflags &= ~V_BARRIER;
19408 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
19409 + if (*flags & IATTR_COW)
19412 + vflags &= ~V_COW;
19414 + if (in->i_op && in->i_op->sync_flags) {
19415 + error = in->i_op->sync_flags(in, iflags, vflags);
19421 + if (attr.ia_valid) {
19422 + if (in->i_op && in->i_op->setattr)
19423 + error = in->i_op->setattr(de, &attr);
19425 + error = inode_change_ok(in, &attr);
19427 + setattr_copy(in, &attr);
19428 + mark_inode_dirty(in);
19434 + mutex_unlock(&in->i_mutex);
19438 +int vc_set_iattr(void __user *data)
19440 + struct path path;
19441 + struct vcmd_ctx_iattr_v1 vc_data;
19444 + if (!capable(CAP_LINUX_IMMUTABLE))
19446 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19449 + ret = user_lpath(vc_data.name, &path);
19451 + ret = __vc_set_iattr(path.dentry,
19452 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19456 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19461 +#ifdef CONFIG_COMPAT
19463 +int vc_set_iattr_x32(void __user *data)
19465 + struct path path;
19466 + struct vcmd_ctx_iattr_v1_x32 vc_data;
19469 + if (!capable(CAP_LINUX_IMMUTABLE))
19471 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19474 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19476 + ret = __vc_set_iattr(path.dentry,
19477 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19481 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19486 +#endif /* CONFIG_COMPAT */
19488 +int vc_fset_iattr(uint32_t fd, void __user *data)
19490 + struct file *filp;
19491 + struct vcmd_ctx_fiattr_v0 vc_data;
19494 + if (!capable(CAP_LINUX_IMMUTABLE))
19496 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19500 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19503 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
19504 + &vc_data.flags, &vc_data.mask);
19508 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19514 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
19516 +static match_table_t tokens = {
19517 + {Opt_notagcheck, "notagcheck"},
19518 +#ifdef CONFIG_PROPAGATE
19519 + {Opt_notag, "notag"},
19520 + {Opt_tag, "tag"},
19521 + {Opt_tagid, "tagid=%u"},
19527 +static void __dx_parse_remove(char *string, char *opt)
19529 + char *p = strstr(string, opt);
19533 + while (*q != '\0' && *q != ',')
19542 +int dx_parse_tag(char *string, vs_tag_t *tag, int remove, int *mnt_flags,
19543 + unsigned long *flags)
19546 + substring_t args[MAX_OPT_ARGS];
19548 + char *s, *p, *opts;
19549 +#if defined(CONFIG_PROPAGATE) || defined(CONFIG_VSERVER_DEBUG)
19555 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
19560 + while ((p = strsep(&opts, ",")) != NULL) {
19561 + token = match_token(p, tokens, args);
19564 +#ifdef CONFIG_PROPAGATE
19569 + __dx_parse_remove(s, "tag");
19570 + *mnt_flags |= MNT_TAGID;
19571 + set |= MNT_TAGID;
19575 + __dx_parse_remove(s, "notag");
19576 + *mnt_flags |= MNT_NOTAG;
19577 + set |= MNT_NOTAG;
19580 + if (tag && !match_int(args, &option))
19583 + __dx_parse_remove(s, "tagid");
19584 + *mnt_flags |= MNT_TAGID;
19585 + set |= MNT_TAGID;
19587 +#endif /* CONFIG_PROPAGATE */
19588 + case Opt_notagcheck:
19590 + __dx_parse_remove(s, "notagcheck");
19591 + *flags |= MS_NOTAGCHECK;
19592 + set |= MS_NOTAGCHECK;
19595 + vxdprintk(VXD_CBIT(tag, 7),
19596 + "dx_parse_tag(" VS_Q("%s") "): %d:#%d",
19597 + p, token, option);
19600 + strcpy(string, s);
19605 +#ifdef CONFIG_PROPAGATE
19607 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
19609 + vs_tag_t new_tag = 0;
19610 + struct vfsmount *mnt;
19615 + mnt = nd->path.mnt;
19619 + propagate = (mnt->mnt_flags & MNT_TAGID);
19621 + new_tag = mnt->mnt_tag;
19623 + vxdprintk(VXD_CBIT(tag, 7),
19624 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
19625 + inode, inode->i_ino, inode->i_tag,
19626 + new_tag, (propagate) ? 1 : 0);
19629 + inode->i_tag = new_tag;
19632 +#include <linux/module.h>
19634 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
19636 +#endif /* CONFIG_PROPAGATE */
19638 diff -NurpP --minimal linux-3.6.9/kernel/vserver/limit.c linux-3.6.9-vs2.3.4.4/kernel/vserver/limit.c
19639 --- linux-3.6.9/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
19640 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/limit.c 2012-10-04 18:47:00.000000000 +0200
19643 + * linux/kernel/vserver/limit.c
19645 + * Virtual Server: Context Limits
19647 + * Copyright (C) 2004-2010 Herbert Pötzl
19649 + * V0.01 broken out from vcontext V0.05
19650 + * V0.02 changed vcmds to vxi arg
19651 + * V0.03 added memory cgroup support
19655 +#include <linux/sched.h>
19656 +#include <linux/module.h>
19657 +#include <linux/memcontrol.h>
19658 +#include <linux/res_counter.h>
19659 +#include <linux/vs_limit.h>
19660 +#include <linux/vserver/limit.h>
19661 +#include <linux/vserver/limit_cmd.h>
19663 +#include <asm/uaccess.h>
19666 +const char *vlimit_name[NUM_LIMITS] = {
19667 + [RLIMIT_CPU] = "CPU",
19668 + [RLIMIT_NPROC] = "NPROC",
19669 + [RLIMIT_NOFILE] = "NOFILE",
19670 + [RLIMIT_LOCKS] = "LOCKS",
19671 + [RLIMIT_SIGPENDING] = "SIGP",
19672 + [RLIMIT_MSGQUEUE] = "MSGQ",
19674 + [VLIMIT_NSOCK] = "NSOCK",
19675 + [VLIMIT_OPENFD] = "OPENFD",
19676 + [VLIMIT_SHMEM] = "SHMEM",
19677 + [VLIMIT_DENTRY] = "DENTRY",
19680 +EXPORT_SYMBOL_GPL(vlimit_name);
19682 +#define MASK_ENTRY(x) (1 << (x))
19684 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
19687 + , /* softlimit */
19690 + MASK_ENTRY( RLIMIT_NPROC ) |
19691 + MASK_ENTRY( RLIMIT_NOFILE ) |
19692 + MASK_ENTRY( RLIMIT_LOCKS ) |
19693 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
19695 + MASK_ENTRY( VLIMIT_NSOCK ) |
19696 + MASK_ENTRY( VLIMIT_OPENFD ) |
19697 + MASK_ENTRY( VLIMIT_SHMEM ) |
19698 + MASK_ENTRY( VLIMIT_DENTRY ) |
19701 + /* accounting only */
19702 +uint32_t account_mask =
19703 + MASK_ENTRY( VLIMIT_SEMARY ) |
19704 + MASK_ENTRY( VLIMIT_NSEMS ) |
19705 + MASK_ENTRY( VLIMIT_MAPPED ) |
19709 +static int is_valid_vlimit(int id)
19711 + uint32_t mask = vlimit_mask.minimum |
19712 + vlimit_mask.softlimit | vlimit_mask.maximum;
19713 + return mask & (1 << id);
19716 +static int is_accounted_vlimit(int id)
19718 + if (is_valid_vlimit(id))
19720 + return account_mask & (1 << id);
19724 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
19726 + rlim_t limit = __rlim_soft(&vxi->limit, id);
19727 + return VX_VLIM(limit);
19730 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
19732 + rlim_t limit = __rlim_hard(&vxi->limit, id);
19733 + return VX_VLIM(limit);
19736 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
19737 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
19739 + if (!is_valid_vlimit(id))
19743 + *minimum = CRLIM_UNSET;
19745 + *softlimit = vc_get_soft(vxi, id);
19747 + *maximum = vc_get_hard(vxi, id);
19751 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
19753 + struct vcmd_ctx_rlimit_v0 vc_data;
19756 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19759 + ret = do_get_rlimit(vxi, vc_data.id,
19760 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
19764 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19769 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
19770 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
19772 + if (!is_valid_vlimit(id))
19775 + if (maximum != CRLIM_KEEP)
19776 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
19777 + if (softlimit != CRLIM_KEEP)
19778 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
19780 + /* clamp soft limit */
19781 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
19782 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
19787 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
19789 + struct vcmd_ctx_rlimit_v0 vc_data;
19791 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19794 + return do_set_rlimit(vxi, vc_data.id,
19795 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
19798 +#ifdef CONFIG_IA32_EMULATION
19800 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
19802 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
19804 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19807 + return do_set_rlimit(vxi, vc_data.id,
19808 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
19811 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
19813 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
19816 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19819 + ret = do_get_rlimit(vxi, vc_data.id,
19820 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
19824 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19829 +#endif /* CONFIG_IA32_EMULATION */
19832 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
19834 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
19840 +static inline void vx_reset_hits(struct _vx_limit *limit)
19844 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19845 + atomic_set(&__rlim_lhit(limit, lim), 0);
19849 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
19851 + vx_reset_hits(&vxi->limit);
19855 +static inline void vx_reset_minmax(struct _vx_limit *limit)
19860 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19861 + value = __rlim_get(limit, lim);
19862 + __rlim_rmax(limit, lim) = value;
19863 + __rlim_rmin(limit, lim) = value;
19867 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
19869 + vx_reset_minmax(&vxi->limit);
19874 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
19876 + struct vcmd_rlimit_stat_v0 vc_data;
19877 + struct _vx_limit *limit = &vxi->limit;
19880 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19884 + if (!is_accounted_vlimit(id))
19887 + vx_limit_fixup(limit, id);
19888 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
19889 + vc_data.value = __rlim_get(limit, id);
19890 + vc_data.minimum = __rlim_rmin(limit, id);
19891 + vc_data.maximum = __rlim_rmax(limit, id);
19893 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19899 +void vx_vsi_meminfo(struct sysinfo *val)
19901 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
19902 + struct mem_cgroup *mcg;
19903 + u64 res_limit, res_usage;
19906 + mcg = mem_cgroup_from_task(current);
19907 + rcu_read_unlock();
19911 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
19912 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
19914 + if (res_limit != RESOURCE_MAX)
19915 + val->totalram = (res_limit >> PAGE_SHIFT);
19916 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
19917 + val->bufferram = 0;
19918 + val->totalhigh = 0;
19919 + val->freehigh = 0;
19921 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
19925 +void vx_vsi_swapinfo(struct sysinfo *val)
19927 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
19928 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
19929 + struct mem_cgroup *mcg;
19930 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
19931 + s64 swap_limit, swap_usage;
19934 + mcg = mem_cgroup_from_task(current);
19935 + rcu_read_unlock();
19939 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
19940 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
19941 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
19942 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
19944 + /* memory unlimited */
19945 + if (res_limit == RESOURCE_MAX)
19948 + swap_limit = memsw_limit - res_limit;
19949 + /* we have a swap limit? */
19950 + if (memsw_limit != RESOURCE_MAX)
19951 + val->totalswap = swap_limit >> PAGE_SHIFT;
19953 + /* calculate swap part */
19954 + swap_usage = (memsw_usage > res_usage) ?
19955 + memsw_usage - res_usage : 0;
19957 + /* total shown minus usage gives free swap */
19958 + val->freeswap = (swap_usage < swap_limit) ?
19959 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
19961 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
19962 + val->totalswap = 0;
19963 + val->freeswap = 0;
19964 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
19965 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
19969 +long vx_vsi_cached(struct sysinfo *val)
19972 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
19973 + struct mem_cgroup *mcg;
19976 + mcg = mem_cgroup_from_task(current);
19977 + rcu_read_unlock();
19981 + cache = mem_cgroup_stat_read_cache(mcg);
19987 diff -NurpP --minimal linux-3.6.9/kernel/vserver/limit_init.h linux-3.6.9-vs2.3.4.4/kernel/vserver/limit_init.h
19988 --- linux-3.6.9/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
19989 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/limit_init.h 2012-10-04 18:47:00.000000000 +0200
19993 +static inline void vx_info_init_limit(struct _vx_limit *limit)
19997 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19998 + __rlim_soft(limit, lim) = RLIM_INFINITY;
19999 + __rlim_hard(limit, lim) = RLIM_INFINITY;
20000 + __rlim_set(limit, lim, 0);
20001 + atomic_set(&__rlim_lhit(limit, lim), 0);
20002 + __rlim_rmin(limit, lim) = 0;
20003 + __rlim_rmax(limit, lim) = 0;
20007 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
20012 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20013 + if ((1 << lim) & VLIM_NOCHECK)
20015 + value = __rlim_get(limit, lim);
20016 + vxwprintk_xid(value,
20017 + "!!! limit: %p[%s,%d] = %ld on exit.",
20018 + limit, vlimit_name[lim], lim, (long)value);
20022 diff -NurpP --minimal linux-3.6.9/kernel/vserver/limit_proc.h linux-3.6.9-vs2.3.4.4/kernel/vserver/limit_proc.h
20023 --- linux-3.6.9/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
20024 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/limit_proc.h 2012-10-04 18:47:00.000000000 +0200
20026 +#ifndef _VX_LIMIT_PROC_H
20027 +#define _VX_LIMIT_PROC_H
20029 +#include <linux/vserver/limit_int.h>
20032 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
20033 +#define VX_LIMIT_TOP \
20034 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
20036 +#define VX_LIMIT_ARG(r) \
20037 + (unsigned long)__rlim_get(limit, r), \
20038 + (unsigned long)__rlim_rmin(limit, r), \
20039 + (unsigned long)__rlim_rmax(limit, r), \
20040 + VX_VLIM(__rlim_soft(limit, r)), \
20041 + VX_VLIM(__rlim_hard(limit, r)), \
20042 + atomic_read(&__rlim_lhit(limit, r))
20044 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
20046 + vx_limit_fixup(limit, -1);
20047 + return sprintf(buffer, VX_LIMIT_TOP
20048 + "PROC" VX_LIMIT_FMT
20049 + "VM" VX_LIMIT_FMT
20050 + "VML" VX_LIMIT_FMT
20051 + "RSS" VX_LIMIT_FMT
20052 + "ANON" VX_LIMIT_FMT
20053 + "RMAP" VX_LIMIT_FMT
20054 + "FILES" VX_LIMIT_FMT
20055 + "OFD" VX_LIMIT_FMT
20056 + "LOCKS" VX_LIMIT_FMT
20057 + "SOCK" VX_LIMIT_FMT
20058 + "MSGQ" VX_LIMIT_FMT
20059 + "SHM" VX_LIMIT_FMT
20060 + "SEMA" VX_LIMIT_FMT
20061 + "SEMS" VX_LIMIT_FMT
20062 + "DENT" VX_LIMIT_FMT,
20063 + VX_LIMIT_ARG(RLIMIT_NPROC),
20064 + VX_LIMIT_ARG(RLIMIT_AS),
20065 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
20066 + VX_LIMIT_ARG(RLIMIT_RSS),
20067 + VX_LIMIT_ARG(VLIMIT_ANON),
20068 + VX_LIMIT_ARG(VLIMIT_MAPPED),
20069 + VX_LIMIT_ARG(RLIMIT_NOFILE),
20070 + VX_LIMIT_ARG(VLIMIT_OPENFD),
20071 + VX_LIMIT_ARG(RLIMIT_LOCKS),
20072 + VX_LIMIT_ARG(VLIMIT_NSOCK),
20073 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
20074 + VX_LIMIT_ARG(VLIMIT_SHMEM),
20075 + VX_LIMIT_ARG(VLIMIT_SEMARY),
20076 + VX_LIMIT_ARG(VLIMIT_NSEMS),
20077 + VX_LIMIT_ARG(VLIMIT_DENTRY));
20080 +#endif /* _VX_LIMIT_PROC_H */
20083 diff -NurpP --minimal linux-3.6.9/kernel/vserver/network.c linux-3.6.9-vs2.3.4.4/kernel/vserver/network.c
20084 --- linux-3.6.9/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
20085 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/network.c 2012-10-04 18:47:00.000000000 +0200
20088 + * linux/kernel/vserver/network.c
20090 + * Virtual Server: Network Support
20092 + * Copyright (C) 2003-2007 Herbert Pötzl
20094 + * V0.01 broken out from vcontext V0.05
20095 + * V0.02 cleaned up implementation
20096 + * V0.03 added equiv nx commands
20097 + * V0.04 switch to RCU based hash
20098 + * V0.05 and back to locking again
20099 + * V0.06 changed vcmds to nxi arg
20100 + * V0.07 have __create claim() the nxi
20104 +#include <linux/err.h>
20105 +#include <linux/slab.h>
20106 +#include <linux/rcupdate.h>
20108 +#include <linux/vs_network.h>
20109 +#include <linux/vs_pid.h>
20110 +#include <linux/vserver/network_cmd.h>
20113 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
20114 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
20116 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
20117 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
20120 +static int __init init_network(void)
20122 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
20123 + sizeof(struct nx_addr_v4), 0,
20124 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20125 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
20126 + sizeof(struct nx_addr_v6), 0,
20127 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20132 +/* __alloc_nx_addr_v4() */
20134 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
20136 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
20137 + nx_addr_v4_cachep, GFP_KERNEL);
20139 + if (!IS_ERR(nxa))
20140 + memset(nxa, 0, sizeof(*nxa));
20144 +/* __dealloc_nx_addr_v4() */
20146 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
20148 + kmem_cache_free(nx_addr_v4_cachep, nxa);
20151 +/* __dealloc_nx_addr_v4_all() */
20153 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
20156 + struct nx_addr_v4 *next = nxa->next;
20158 + __dealloc_nx_addr_v4(nxa);
20164 +#ifdef CONFIG_IPV6
20166 +/* __alloc_nx_addr_v6() */
20168 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
20170 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
20171 + nx_addr_v6_cachep, GFP_KERNEL);
20173 + if (!IS_ERR(nxa))
20174 + memset(nxa, 0, sizeof(*nxa));
20178 +/* __dealloc_nx_addr_v6() */
20180 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
20182 + kmem_cache_free(nx_addr_v6_cachep, nxa);
20185 +/* __dealloc_nx_addr_v6_all() */
20187 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
20190 + struct nx_addr_v6 *next = nxa->next;
20192 + __dealloc_nx_addr_v6(nxa);
20197 +#endif /* CONFIG_IPV6 */
20199 +/* __alloc_nx_info()
20201 + * allocate an initialized nx_info struct
20202 + * doesn't make it visible (hash) */
20204 +static struct nx_info *__alloc_nx_info(nid_t nid)
20206 + struct nx_info *new = NULL;
20208 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
20210 + /* would this benefit from a slab cache? */
20211 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
20215 + memset(new, 0, sizeof(struct nx_info));
20216 + new->nx_id = nid;
20217 + INIT_HLIST_NODE(&new->nx_hlist);
20218 + atomic_set(&new->nx_usecnt, 0);
20219 + atomic_set(&new->nx_tasks, 0);
20220 + new->nx_state = 0;
20222 + new->nx_flags = NXF_INIT_SET;
20224 + /* rest of init goes here */
20226 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
20227 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
20229 + vxdprintk(VXD_CBIT(nid, 0),
20230 + "alloc_nx_info(%d) = %p", nid, new);
20231 + atomic_inc(&nx_global_ctotal);
20235 +/* __dealloc_nx_info()
20237 + * final disposal of nx_info */
20239 +static void __dealloc_nx_info(struct nx_info *nxi)
20241 + vxdprintk(VXD_CBIT(nid, 0),
20242 + "dealloc_nx_info(%p)", nxi);
20244 + nxi->nx_hlist.next = LIST_POISON1;
20247 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20248 + BUG_ON(atomic_read(&nxi->nx_tasks));
20250 + __dealloc_nx_addr_v4_all(nxi->v4.next);
20252 + nxi->nx_state |= NXS_RELEASED;
20254 + atomic_dec(&nx_global_ctotal);
20257 +static void __shutdown_nx_info(struct nx_info *nxi)
20259 + nxi->nx_state |= NXS_SHUTDOWN;
20260 + vs_net_change(nxi, VSC_NETDOWN);
20263 +/* exported stuff */
20265 +void free_nx_info(struct nx_info *nxi)
20267 + /* context shutdown is mandatory */
20268 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
20270 + /* context must not be hashed */
20271 + BUG_ON(nxi->nx_state & NXS_HASHED);
20273 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20274 + BUG_ON(atomic_read(&nxi->nx_tasks));
20276 + __dealloc_nx_info(nxi);
20280 +void __nx_set_lback(struct nx_info *nxi)
20282 + int nid = nxi->nx_id;
20283 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
20285 + nxi->v4_lback.s_addr = lback;
20288 +extern int __nx_inet_add_lback(__be32 addr);
20289 +extern int __nx_inet_del_lback(__be32 addr);
20292 +/* hash table for nx_info hash */
20294 +#define NX_HASH_SIZE 13
20296 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
20298 +static DEFINE_SPINLOCK(nx_info_hash_lock);
20301 +static inline unsigned int __hashval(nid_t nid)
20303 + return (nid % NX_HASH_SIZE);
20308 +/* __hash_nx_info()
20310 + * add the nxi to the global hash table
20311 + * requires the hash_lock to be held */
20313 +static inline void __hash_nx_info(struct nx_info *nxi)
20315 + struct hlist_head *head;
20317 + vxd_assert_lock(&nx_info_hash_lock);
20318 + vxdprintk(VXD_CBIT(nid, 4),
20319 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
20321 + /* context must not be hashed */
20322 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
20324 + nxi->nx_state |= NXS_HASHED;
20325 + head = &nx_info_hash[__hashval(nxi->nx_id)];
20326 + hlist_add_head(&nxi->nx_hlist, head);
20327 + atomic_inc(&nx_global_cactive);
20330 +/* __unhash_nx_info()
20332 + * remove the nxi from the global hash table
20333 + * requires the hash_lock to be held */
20335 +static inline void __unhash_nx_info(struct nx_info *nxi)
20337 + vxd_assert_lock(&nx_info_hash_lock);
20338 + vxdprintk(VXD_CBIT(nid, 4),
20339 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
20340 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
20342 + /* context must be hashed */
20343 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
20344 + /* but without tasks */
20345 + BUG_ON(atomic_read(&nxi->nx_tasks));
20347 + nxi->nx_state &= ~NXS_HASHED;
20348 + hlist_del(&nxi->nx_hlist);
20349 + atomic_dec(&nx_global_cactive);
20353 +/* __lookup_nx_info()
20355 + * requires the hash_lock to be held
20356 + * doesn't increment the nx_refcnt */
20358 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
20360 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
20361 + struct hlist_node *pos;
20362 + struct nx_info *nxi;
20364 + vxd_assert_lock(&nx_info_hash_lock);
20365 + hlist_for_each(pos, head) {
20366 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20368 + if (nxi->nx_id == nid)
20373 + vxdprintk(VXD_CBIT(nid, 0),
20374 + "__lookup_nx_info(#%u): %p[#%u]",
20375 + nid, nxi, nxi ? nxi->nx_id : 0);
20380 +/* __create_nx_info()
20382 + * create the requested context
20383 + * get(), claim() and hash it */
20385 +static struct nx_info *__create_nx_info(int id)
20387 + struct nx_info *new, *nxi = NULL;
20389 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
20391 + if (!(new = __alloc_nx_info(id)))
20392 + return ERR_PTR(-ENOMEM);
20394 + /* required to make dynamic xids unique */
20395 + spin_lock(&nx_info_hash_lock);
20397 + /* static context requested */
20398 + if ((nxi = __lookup_nx_info(id))) {
20399 + vxdprintk(VXD_CBIT(nid, 0),
20400 + "create_nx_info(%d) = %p (already there)", id, nxi);
20401 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20402 + nxi = ERR_PTR(-EBUSY);
20404 + nxi = ERR_PTR(-EEXIST);
20407 + /* new context */
20408 + vxdprintk(VXD_CBIT(nid, 0),
20409 + "create_nx_info(%d) = %p (new)", id, new);
20410 + claim_nx_info(new, NULL);
20411 + __nx_set_lback(new);
20412 + __hash_nx_info(get_nx_info(new));
20413 + nxi = new, new = NULL;
20416 + spin_unlock(&nx_info_hash_lock);
20418 + __dealloc_nx_info(new);
20424 +/* exported stuff */
20427 +void unhash_nx_info(struct nx_info *nxi)
20429 + __shutdown_nx_info(nxi);
20430 + spin_lock(&nx_info_hash_lock);
20431 + __unhash_nx_info(nxi);
20432 + spin_unlock(&nx_info_hash_lock);
20435 +/* lookup_nx_info()
20437 + * search for a nx_info and get() it
20438 + * negative id means current */
20440 +struct nx_info *lookup_nx_info(int id)
20442 + struct nx_info *nxi = NULL;
20445 + nxi = get_nx_info(current_nx_info());
20446 + } else if (id > 1) {
20447 + spin_lock(&nx_info_hash_lock);
20448 + nxi = get_nx_info(__lookup_nx_info(id));
20449 + spin_unlock(&nx_info_hash_lock);
20454 +/* nid_is_hashed()
20456 + * verify that nid is still hashed */
20458 +int nid_is_hashed(nid_t nid)
20462 + spin_lock(&nx_info_hash_lock);
20463 + hashed = (__lookup_nx_info(nid) != NULL);
20464 + spin_unlock(&nx_info_hash_lock);
20469 +#ifdef CONFIG_PROC_FS
20473 + * get a subset of hashed nids for proc
20474 + * assumes size is at least one */
20476 +int get_nid_list(int index, unsigned int *nids, int size)
20478 + int hindex, nr_nids = 0;
20480 + /* only show current and children */
20481 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
20484 + nids[nr_nids] = nx_current_nid();
20488 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
20489 + struct hlist_head *head = &nx_info_hash[hindex];
20490 + struct hlist_node *pos;
20492 + spin_lock(&nx_info_hash_lock);
20493 + hlist_for_each(pos, head) {
20494 + struct nx_info *nxi;
20499 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20500 + nids[nr_nids] = nxi->nx_id;
20501 + if (++nr_nids >= size) {
20502 + spin_unlock(&nx_info_hash_lock);
20506 + /* keep the lock time short */
20507 + spin_unlock(&nx_info_hash_lock);
20516 + * migrate task to new network
20517 + * gets nxi, puts old_nxi on change
20520 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
20522 + struct nx_info *old_nxi;
20528 + vxdprintk(VXD_CBIT(nid, 5),
20529 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
20530 + p, nxi, nxi->nx_id,
20531 + atomic_read(&nxi->nx_usecnt),
20532 + atomic_read(&nxi->nx_tasks));
20534 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
20535 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20538 + if (nx_info_state(nxi, NXS_SHUTDOWN))
20541 + /* maybe disallow this completely? */
20542 + old_nxi = task_get_nx_info(p);
20543 + if (old_nxi == nxi)
20548 + clr_nx_info(&p->nx_info);
20549 + claim_nx_info(nxi, p);
20550 + set_nx_info(&p->nx_info, nxi);
20551 + p->nid = nxi->nx_id;
20554 + vxdprintk(VXD_CBIT(nid, 5),
20555 + "moved task %p into nxi:%p[#%d]",
20556 + p, nxi, nxi->nx_id);
20559 + release_nx_info(old_nxi, p);
20562 + put_nx_info(old_nxi);
20567 +void nx_set_persistent(struct nx_info *nxi)
20569 + vxdprintk(VXD_CBIT(nid, 6),
20570 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
20572 + get_nx_info(nxi);
20573 + claim_nx_info(nxi, NULL);
20576 +void nx_clear_persistent(struct nx_info *nxi)
20578 + vxdprintk(VXD_CBIT(nid, 6),
20579 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
20581 + release_nx_info(nxi, NULL);
20582 + put_nx_info(nxi);
20585 +void nx_update_persistent(struct nx_info *nxi)
20587 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
20588 + nx_set_persistent(nxi);
20590 + nx_clear_persistent(nxi);
20593 +/* vserver syscall commands below here */
20595 +/* taks nid and nx_info functions */
20597 +#include <asm/uaccess.h>
20600 +int vc_task_nid(uint32_t id)
20605 + struct task_struct *tsk;
20608 + tsk = find_task_by_real_pid(id);
20609 + nid = (tsk) ? tsk->nid : -ESRCH;
20610 + rcu_read_unlock();
20612 + nid = nx_current_nid();
20617 +int vc_nx_info(struct nx_info *nxi, void __user *data)
20619 + struct vcmd_nx_info_v0 vc_data;
20621 + vc_data.nid = nxi->nx_id;
20623 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20629 +/* network functions */
20631 +int vc_net_create(uint32_t nid, void __user *data)
20633 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
20634 + struct nx_info *new_nxi;
20637 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20640 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
20643 + new_nxi = __create_nx_info(nid);
20644 + if (IS_ERR(new_nxi))
20645 + return PTR_ERR(new_nxi);
20647 + /* initial flags */
20648 + new_nxi->nx_flags = vc_data.flagword;
20651 + if (vs_net_change(new_nxi, VSC_NETUP))
20654 + ret = nx_migrate_task(current, new_nxi);
20658 + /* return context id on success */
20659 + ret = new_nxi->nx_id;
20661 + /* get a reference for persistent contexts */
20662 + if ((vc_data.flagword & NXF_PERSISTENT))
20663 + nx_set_persistent(new_nxi);
20665 + release_nx_info(new_nxi, NULL);
20666 + put_nx_info(new_nxi);
20671 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
20673 + return nx_migrate_task(current, nxi);
20678 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
20679 + uint16_t type, uint16_t flags)
20681 + struct nx_addr_v4 *nxa = &nxi->v4;
20683 + if (NX_IPV4(nxi)) {
20684 + /* locate last entry */
20685 + for (; nxa->next; nxa = nxa->next);
20686 + nxa->next = __alloc_nx_addr_v4();
20690 + return PTR_ERR(nxa);
20693 + if (nxi->v4.next)
20694 + /* remove single ip for ip list */
20695 + nxi->nx_flags &= ~NXF_SINGLE_IP;
20697 + nxa->ip[0].s_addr = ip;
20698 + nxa->ip[1].s_addr = ip2;
20699 + nxa->mask.s_addr = mask;
20700 + nxa->type = type;
20701 + nxa->flags = flags;
20705 +int do_remove_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
20706 + uint16_t type, uint16_t flags)
20708 + struct nx_addr_v4 *nxa = &nxi->v4;
20711 +/* case NXA_TYPE_ADDR:
20714 + case NXA_TYPE_ANY:
20715 + __dealloc_nx_addr_v4_all(xchg(&nxa->next, NULL));
20716 + memset(nxa, 0, sizeof(*nxa));
20726 +int vc_net_add(struct nx_info *nxi, void __user *data)
20728 + struct vcmd_net_addr_v0 vc_data;
20729 + int index, ret = 0;
20731 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20734 + switch (vc_data.type) {
20735 + case NXA_TYPE_IPV4:
20736 + if ((vc_data.count < 1) || (vc_data.count > 4))
20740 + while (index < vc_data.count) {
20741 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
20742 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
20750 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
20751 + nxi->v4_bcast = vc_data.ip[0];
20755 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
20756 + nxi->v4_lback = vc_data.ip[0];
20767 +int vc_net_remove(struct nx_info *nxi, void __user *data)
20769 + struct vcmd_net_addr_v0 vc_data;
20771 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20774 + switch (vc_data.type) {
20775 + case NXA_TYPE_ANY:
20776 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
20777 + memset(&nxi->v4, 0, sizeof(nxi->v4));
20787 +int vc_net_add_ipv4_v1(struct nx_info *nxi, void __user *data)
20789 + struct vcmd_net_addr_ipv4_v1 vc_data;
20791 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20794 + switch (vc_data.type) {
20795 + case NXA_TYPE_ADDR:
20796 + case NXA_TYPE_MASK:
20797 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
20798 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20800 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
20801 + nxi->v4_bcast = vc_data.ip;
20804 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
20805 + nxi->v4_lback = vc_data.ip;
20814 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
20816 + struct vcmd_net_addr_ipv4_v2 vc_data;
20818 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20821 + switch (vc_data.type) {
20822 + case NXA_TYPE_ADDR:
20823 + case NXA_TYPE_MASK:
20824 + case NXA_TYPE_RANGE:
20825 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
20826 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20828 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
20829 + nxi->v4_bcast = vc_data.ip;
20832 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
20833 + nxi->v4_lback = vc_data.ip;
20842 +int vc_net_rem_ipv4_v1(struct nx_info *nxi, void __user *data)
20844 + struct vcmd_net_addr_ipv4_v1 vc_data;
20846 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20849 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, 0,
20850 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20853 +int vc_net_rem_ipv4(struct nx_info *nxi, void __user *data)
20855 + struct vcmd_net_addr_ipv4_v2 vc_data;
20857 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20860 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
20861 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20864 +#ifdef CONFIG_IPV6
20866 +int do_add_v6_addr(struct nx_info *nxi,
20867 + struct in6_addr *ip, struct in6_addr *mask,
20868 + uint32_t prefix, uint16_t type, uint16_t flags)
20870 + struct nx_addr_v6 *nxa = &nxi->v6;
20872 + if (NX_IPV6(nxi)) {
20873 + /* locate last entry */
20874 + for (; nxa->next; nxa = nxa->next);
20875 + nxa->next = __alloc_nx_addr_v6();
20879 + return PTR_ERR(nxa);
20883 + nxa->mask = *mask;
20884 + nxa->prefix = prefix;
20885 + nxa->type = type;
20886 + nxa->flags = flags;
20891 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
20893 + struct vcmd_net_addr_ipv6_v1 vc_data;
20895 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20898 + switch (vc_data.type) {
20899 + case NXA_TYPE_ADDR:
20900 + memset(&vc_data.mask, ~0, sizeof(vc_data.mask));
20901 + /* fallthrough */
20902 + case NXA_TYPE_MASK:
20903 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
20904 + vc_data.prefix, vc_data.type, vc_data.flags);
20911 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
20913 + struct vcmd_net_addr_ipv6_v1 vc_data;
20915 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20918 + switch (vc_data.type) {
20919 + case NXA_TYPE_ANY:
20920 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
20921 + memset(&nxi->v6, 0, sizeof(nxi->v6));
20930 +#endif /* CONFIG_IPV6 */
20933 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
20935 + struct vcmd_net_flags_v0 vc_data;
20937 + vc_data.flagword = nxi->nx_flags;
20939 + /* special STATE flag handling */
20940 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
20942 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20947 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
20949 + struct vcmd_net_flags_v0 vc_data;
20950 + uint64_t mask, trigger;
20952 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20955 + /* special STATE flag handling */
20956 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
20957 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
20959 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
20960 + vc_data.flagword, mask);
20961 + if (trigger & NXF_PERSISTENT)
20962 + nx_update_persistent(nxi);
20967 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
20969 + struct vcmd_net_caps_v0 vc_data;
20971 + vc_data.ncaps = nxi->nx_ncaps;
20972 + vc_data.cmask = ~0ULL;
20974 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20979 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
20981 + struct vcmd_net_caps_v0 vc_data;
20983 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20986 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
20987 + vc_data.ncaps, vc_data.cmask);
20992 +#include <linux/module.h>
20994 +module_init(init_network);
20996 +EXPORT_SYMBOL_GPL(free_nx_info);
20997 +EXPORT_SYMBOL_GPL(unhash_nx_info);
20999 diff -NurpP --minimal linux-3.6.9/kernel/vserver/proc.c linux-3.6.9-vs2.3.4.4/kernel/vserver/proc.c
21000 --- linux-3.6.9/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
21001 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/proc.c 2012-10-09 14:19:59.000000000 +0200
21004 + * linux/kernel/vserver/proc.c
21006 + * Virtual Context Support
21008 + * Copyright (C) 2003-2011 Herbert Pötzl
21010 + * V0.01 basic structure
21011 + * V0.02 adaptation vs1.3.0
21012 + * V0.03 proc permissions
21013 + * V0.04 locking/generic
21014 + * V0.05 next generation procfs
21015 + * V0.06 inode validation
21016 + * V0.07 generic rewrite vid
21017 + * V0.08 remove inode type
21018 + * V0.09 added u/wmask info
21022 +#include <linux/proc_fs.h>
21023 +#include <linux/fs_struct.h>
21024 +#include <linux/mount.h>
21025 +#include <linux/namei.h>
21026 +#include <asm/unistd.h>
21028 +#include <linux/vs_context.h>
21029 +#include <linux/vs_network.h>
21030 +#include <linux/vs_cvirt.h>
21032 +#include <linux/in.h>
21033 +#include <linux/inetdevice.h>
21034 +#include <linux/vs_inet.h>
21035 +#include <linux/vs_inet6.h>
21037 +#include <linux/vserver/global.h>
21039 +#include "cvirt_proc.h"
21040 +#include "cacct_proc.h"
21041 +#include "limit_proc.h"
21042 +#include "sched_proc.h"
21043 +#include "vci_config.h"
21046 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
21050 + CAP_FOR_EACH_U32(__capi) {
21051 + buffer += sprintf(buffer, "%08x",
21052 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
21058 +static struct proc_dir_entry *proc_virtual;
21060 +static struct proc_dir_entry *proc_virtnet;
21063 +/* first the actual feeds */
21066 +static int proc_vci(char *buffer)
21068 + return sprintf(buffer,
21069 + "VCIVersion:\t%04x:%04x\n"
21070 + "VCISyscall:\t%d\n"
21071 + "VCIKernel:\t%08x\n",
21072 + VCI_VERSION >> 16,
21073 + VCI_VERSION & 0xFFFF,
21075 + vci_kernel_config());
21078 +static int proc_virtual_info(char *buffer)
21080 + return proc_vci(buffer);
21083 +static int proc_virtual_status(char *buffer)
21085 + return sprintf(buffer,
21087 + "#CActive:\t%d\n"
21088 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
21089 + "#InitTask:\t%d\t%d %d\n",
21090 + atomic_read(&vx_global_ctotal),
21091 + atomic_read(&vx_global_cactive),
21092 + atomic_read(&vs_global_nsproxy),
21093 + atomic_read(&vs_global_fs),
21094 + atomic_read(&vs_global_mnt_ns),
21095 + atomic_read(&vs_global_uts_ns),
21096 + atomic_read(&nr_ipc_ns),
21097 + atomic_read(&vs_global_user_ns),
21098 + atomic_read(&vs_global_pid_ns),
21099 + atomic_read(&init_task.usage),
21100 + atomic_read(&init_task.nsproxy->count),
21101 + init_task.fs->users);
21105 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
21109 + length = sprintf(buffer,
21117 + vxi->vx_badness_bias);
21121 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
21123 + char *orig = buffer;
21125 + buffer += sprintf(buffer,
21128 + "Flags:\t%016llx\n",
21129 + atomic_read(&vxi->vx_usecnt),
21130 + atomic_read(&vxi->vx_tasks),
21131 + (unsigned long long)vxi->vx_flags);
21133 + buffer += sprintf(buffer, "BCaps:\t");
21134 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
21135 + buffer += sprintf(buffer, "\n");
21137 + buffer += sprintf(buffer,
21138 + "CCaps:\t%016llx\n"
21139 + "Umask:\t%16llx\n"
21140 + "Wmask:\t%16llx\n"
21141 + "Spaces:\t%08lx %08lx\n",
21142 + (unsigned long long)vxi->vx_ccaps,
21143 + (unsigned long long)vxi->vx_umask,
21144 + (unsigned long long)vxi->vx_wmask,
21145 + vxi->space[0].vx_nsmask, vxi->space[1].vx_nsmask);
21146 + return buffer - orig;
21149 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
21151 + return vx_info_proc_limit(&vxi->limit, buffer);
21154 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
21158 + length = vx_info_proc_sched(&vxi->sched, buffer);
21159 + for_each_online_cpu(cpu) {
21160 + length += vx_info_proc_sched_pc(
21161 + &vx_per_cpu(vxi, sched_pc, cpu),
21162 + buffer + length, cpu);
21167 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
21169 + return vx_info_proc_nsproxy(vxi->space[0].vx_nsproxy, buffer);
21172 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
21174 + return vx_info_proc_nsproxy(vxi->space[1].vx_nsproxy, buffer);
21177 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
21181 + vx_update_load(vxi);
21182 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
21183 + for_each_online_cpu(cpu) {
21184 + length += vx_info_proc_cvirt_pc(
21185 + &vx_per_cpu(vxi, cvirt_pc, cpu),
21186 + buffer + length, cpu);
21191 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
21193 + return vx_info_proc_cacct(&vxi->cacct, buffer);
21197 +static int proc_virtnet_info(char *buffer)
21199 + return proc_vci(buffer);
21202 +static int proc_virtnet_status(char *buffer)
21204 + return sprintf(buffer,
21206 + "#CActive:\t%d\n",
21207 + atomic_read(&nx_global_ctotal),
21208 + atomic_read(&nx_global_cactive));
21211 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
21213 + struct nx_addr_v4 *v4a;
21214 +#ifdef CONFIG_IPV6
21215 + struct nx_addr_v6 *v6a;
21219 + length = sprintf(buffer,
21222 + "Bcast:\t" NIPQUAD_FMT "\n"
21223 + "Lback:\t" NIPQUAD_FMT "\n",
21226 + NIPQUAD(nxi->v4_bcast.s_addr),
21227 + NIPQUAD(nxi->v4_lback.s_addr));
21229 + if (!NX_IPV4(nxi))
21231 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
21232 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
21235 +#ifdef CONFIG_IPV6
21236 + if (!NX_IPV6(nxi))
21238 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
21239 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
21246 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
21250 + length = sprintf(buffer,
21253 + "Flags:\t%016llx\n"
21254 + "NCaps:\t%016llx\n",
21255 + atomic_read(&nxi->nx_usecnt),
21256 + atomic_read(&nxi->nx_tasks),
21257 + (unsigned long long)nxi->nx_flags,
21258 + (unsigned long long)nxi->nx_ncaps);
21264 +/* here the inode helpers */
21270 + struct inode_operations *iop;
21271 + struct file_operations *fop;
21272 + union proc_op op;
21275 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
21277 + struct inode *inode = new_inode(sb);
21282 + inode->i_mode = p->mode;
21284 + inode->i_op = p->iop;
21286 + inode->i_fop = p->fop;
21288 + set_nlink(inode, (p->mode & S_IFDIR) ? 2 : 1);
21289 + inode->i_flags |= S_IMMUTABLE;
21291 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
21293 + inode->i_uid = 0;
21294 + inode->i_gid = 0;
21295 + inode->i_tag = 0;
21300 +static struct dentry *vs_proc_instantiate(struct inode *dir,
21301 + struct dentry *dentry, int id, void *ptr)
21303 + struct vs_entry *p = ptr;
21304 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
21305 + struct dentry *error = ERR_PTR(-EINVAL);
21310 + PROC_I(inode)->op = p->op;
21311 + PROC_I(inode)->fd = id;
21312 + d_add(dentry, inode);
21320 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
21323 + * Fill a directory entry.
21325 + * If possible create the dcache entry and derive our inode number and
21326 + * file type from dcache entry.
21328 + * Since all of the proc inode numbers are dynamically generated, the inode
21329 + * numbers do not exist until the inode is cache. This means creating the
21330 + * the dcache entry in readdir is necessary to keep the inode numbers
21331 + * reported by readdir in sync with the inode numbers reported
21334 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
21335 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
21337 + struct dentry *child, *dir = filp->f_dentry;
21338 + struct inode *inode;
21339 + struct qstr qname;
21341 + unsigned type = DT_UNKNOWN;
21343 + qname.name = name;
21345 + qname.hash = full_name_hash(name, len);
21347 + child = d_lookup(dir, &qname);
21349 + struct dentry *new;
21350 + new = d_alloc(dir, &qname);
21352 + child = instantiate(dir->d_inode, new, id, ptr);
21359 + if (!child || IS_ERR(child) || !child->d_inode)
21360 + goto end_instantiate;
21361 + inode = child->d_inode;
21363 + ino = inode->i_ino;
21364 + type = inode->i_mode >> 12;
21369 + ino = find_inode_number(dir, &qname);
21372 + return filldir(dirent, name, len, filp->f_pos, ino, type);
21377 +/* get and revalidate vx_info/xid */
21380 +struct vx_info *get_proc_vx_info(struct inode *inode)
21382 + return lookup_vx_info(PROC_I(inode)->fd);
21385 +static int proc_xid_revalidate(struct dentry *dentry, unsigned int flags)
21387 + struct inode *inode = dentry->d_inode;
21388 + xid_t xid = PROC_I(inode)->fd;
21390 + if (flags & LOOKUP_RCU) /* FIXME: can be dropped? */
21393 + if (!xid || xid_is_hashed(xid))
21400 +/* get and revalidate nx_info/nid */
21402 +static int proc_nid_revalidate(struct dentry *dentry, unsigned int flags)
21404 + struct inode *inode = dentry->d_inode;
21405 + nid_t nid = PROC_I(inode)->fd;
21407 + if (flags & LOOKUP_RCU) /* FIXME: can be dropped? */
21410 + if (!nid || nid_is_hashed(nid))
21418 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
21420 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
21421 + size_t count, loff_t *ppos)
21423 + struct inode *inode = file->f_dentry->d_inode;
21424 + unsigned long page;
21425 + ssize_t length = 0;
21427 + if (count > PROC_BLOCK_SIZE)
21428 + count = PROC_BLOCK_SIZE;
21430 + /* fade that out as soon as stable */
21431 + WARN_ON(PROC_I(inode)->fd);
21433 + if (!(page = __get_free_page(GFP_KERNEL)))
21436 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
21437 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
21440 + length = simple_read_from_buffer(buf, count, ppos,
21441 + (char *)page, length);
21447 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
21448 + size_t count, loff_t *ppos)
21450 + struct inode *inode = file->f_dentry->d_inode;
21451 + struct vx_info *vxi = NULL;
21452 + xid_t xid = PROC_I(inode)->fd;
21453 + unsigned long page;
21454 + ssize_t length = 0;
21456 + if (count > PROC_BLOCK_SIZE)
21457 + count = PROC_BLOCK_SIZE;
21459 + /* fade that out as soon as stable */
21461 + vxi = lookup_vx_info(xid);
21465 + length = -ENOMEM;
21466 + if (!(page = __get_free_page(GFP_KERNEL)))
21469 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
21470 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
21473 + length = simple_read_from_buffer(buf, count, ppos,
21474 + (char *)page, length);
21478 + put_vx_info(vxi);
21483 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
21484 + size_t count, loff_t *ppos)
21486 + struct inode *inode = file->f_dentry->d_inode;
21487 + struct nx_info *nxi = NULL;
21488 + nid_t nid = PROC_I(inode)->fd;
21489 + unsigned long page;
21490 + ssize_t length = 0;
21492 + if (count > PROC_BLOCK_SIZE)
21493 + count = PROC_BLOCK_SIZE;
21495 + /* fade that out as soon as stable */
21497 + nxi = lookup_nx_info(nid);
21501 + length = -ENOMEM;
21502 + if (!(page = __get_free_page(GFP_KERNEL)))
21505 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
21506 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
21509 + length = simple_read_from_buffer(buf, count, ppos,
21510 + (char *)page, length);
21514 + put_nx_info(nxi);
21521 +/* here comes the lower level */
21524 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
21525 + .len = sizeof(NAME) - 1, \
21526 + .name = (NAME), \
21534 +#define DIR(NAME, MODE, OTYPE) \
21535 + NOD(NAME, (S_IFDIR | (MODE)), \
21536 + &proc_ ## OTYPE ## _inode_operations, \
21537 + &proc_ ## OTYPE ## _file_operations, { } )
21539 +#define INF(NAME, MODE, OTYPE) \
21540 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21541 + &proc_vs_info_file_operations, \
21542 + { .proc_vs_read = &proc_##OTYPE } )
21544 +#define VINF(NAME, MODE, OTYPE) \
21545 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21546 + &proc_vx_info_file_operations, \
21547 + { .proc_vxi_read = &proc_##OTYPE } )
21549 +#define NINF(NAME, MODE, OTYPE) \
21550 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21551 + &proc_nx_info_file_operations, \
21552 + { .proc_nxi_read = &proc_##OTYPE } )
21555 +static struct file_operations proc_vs_info_file_operations = {
21556 + .read = proc_vs_info_read,
21559 +static struct file_operations proc_vx_info_file_operations = {
21560 + .read = proc_vx_info_read,
21563 +static struct dentry_operations proc_xid_dentry_operations = {
21564 + .d_revalidate = proc_xid_revalidate,
21567 +static struct vs_entry vx_base_stuff[] = {
21568 + VINF("info", S_IRUGO, vxi_info),
21569 + VINF("status", S_IRUGO, vxi_status),
21570 + VINF("limit", S_IRUGO, vxi_limit),
21571 + VINF("sched", S_IRUGO, vxi_sched),
21572 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
21573 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
21574 + VINF("cvirt", S_IRUGO, vxi_cvirt),
21575 + VINF("cacct", S_IRUGO, vxi_cacct),
21582 +static struct dentry *proc_xid_instantiate(struct inode *dir,
21583 + struct dentry *dentry, int id, void *ptr)
21585 + dentry->d_op = &proc_xid_dentry_operations;
21586 + return vs_proc_instantiate(dir, dentry, id, ptr);
21589 +static struct dentry *proc_xid_lookup(struct inode *dir,
21590 + struct dentry *dentry, unsigned int flags)
21592 + struct vs_entry *p = vx_base_stuff;
21593 + struct dentry *error = ERR_PTR(-ENOENT);
21595 + for (; p->name; p++) {
21596 + if (p->len != dentry->d_name.len)
21598 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21604 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
21609 +static int proc_xid_readdir(struct file *filp,
21610 + void *dirent, filldir_t filldir)
21612 + struct dentry *dentry = filp->f_dentry;
21613 + struct inode *inode = dentry->d_inode;
21614 + struct vs_entry *p = vx_base_stuff;
21615 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
21619 + pos = filp->f_pos;
21622 + ino = inode->i_ino;
21623 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21626 + /* fall through */
21628 + ino = parent_ino(dentry);
21629 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21632 + /* fall through */
21635 + if (index >= size)
21637 + for (p += index; p->name; p++) {
21638 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21639 + vs_proc_instantiate, PROC_I(inode)->fd, p))
21645 + filp->f_pos = pos;
21651 +static struct file_operations proc_nx_info_file_operations = {
21652 + .read = proc_nx_info_read,
21655 +static struct dentry_operations proc_nid_dentry_operations = {
21656 + .d_revalidate = proc_nid_revalidate,
21659 +static struct vs_entry nx_base_stuff[] = {
21660 + NINF("info", S_IRUGO, nxi_info),
21661 + NINF("status", S_IRUGO, nxi_status),
21666 +static struct dentry *proc_nid_instantiate(struct inode *dir,
21667 + struct dentry *dentry, int id, void *ptr)
21669 + dentry->d_op = &proc_nid_dentry_operations;
21670 + return vs_proc_instantiate(dir, dentry, id, ptr);
21673 +static struct dentry *proc_nid_lookup(struct inode *dir,
21674 + struct dentry *dentry, unsigned int flags)
21676 + struct vs_entry *p = nx_base_stuff;
21677 + struct dentry *error = ERR_PTR(-ENOENT);
21679 + for (; p->name; p++) {
21680 + if (p->len != dentry->d_name.len)
21682 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21688 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
21693 +static int proc_nid_readdir(struct file *filp,
21694 + void *dirent, filldir_t filldir)
21696 + struct dentry *dentry = filp->f_dentry;
21697 + struct inode *inode = dentry->d_inode;
21698 + struct vs_entry *p = nx_base_stuff;
21699 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
21703 + pos = filp->f_pos;
21706 + ino = inode->i_ino;
21707 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21710 + /* fall through */
21712 + ino = parent_ino(dentry);
21713 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21716 + /* fall through */
21719 + if (index >= size)
21721 + for (p += index; p->name; p++) {
21722 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21723 + vs_proc_instantiate, PROC_I(inode)->fd, p))
21729 + filp->f_pos = pos;
21734 +#define MAX_MULBY10 ((~0U - 9) / 10)
21736 +static inline int atovid(const char *str, int len)
21741 + while (len-- > 0) {
21746 + if (vid >= MAX_MULBY10)
21756 +/* now the upper level (virtual) */
21759 +static struct file_operations proc_xid_file_operations = {
21760 + .read = generic_read_dir,
21761 + .readdir = proc_xid_readdir,
21764 +static struct inode_operations proc_xid_inode_operations = {
21765 + .lookup = proc_xid_lookup,
21768 +static struct vs_entry vx_virtual_stuff[] = {
21769 + INF("info", S_IRUGO, virtual_info),
21770 + INF("status", S_IRUGO, virtual_status),
21771 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
21775 +static struct dentry *proc_virtual_lookup(struct inode *dir,
21776 + struct dentry *dentry, unsigned int flags)
21778 + struct vs_entry *p = vx_virtual_stuff;
21779 + struct dentry *error = ERR_PTR(-ENOENT);
21782 + for (; p->name; p++) {
21783 + if (p->len != dentry->d_name.len)
21785 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21789 + goto instantiate;
21791 + id = atovid(dentry->d_name.name, dentry->d_name.len);
21792 + if ((id < 0) || !xid_is_hashed(id))
21796 + error = proc_xid_instantiate(dir, dentry, id, p);
21801 +static struct file_operations proc_nid_file_operations = {
21802 + .read = generic_read_dir,
21803 + .readdir = proc_nid_readdir,
21806 +static struct inode_operations proc_nid_inode_operations = {
21807 + .lookup = proc_nid_lookup,
21810 +static struct vs_entry nx_virtnet_stuff[] = {
21811 + INF("info", S_IRUGO, virtnet_info),
21812 + INF("status", S_IRUGO, virtnet_status),
21813 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
21817 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
21818 + struct dentry *dentry, unsigned int flags)
21820 + struct vs_entry *p = nx_virtnet_stuff;
21821 + struct dentry *error = ERR_PTR(-ENOENT);
21824 + for (; p->name; p++) {
21825 + if (p->len != dentry->d_name.len)
21827 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21831 + goto instantiate;
21833 + id = atovid(dentry->d_name.name, dentry->d_name.len);
21834 + if ((id < 0) || !nid_is_hashed(id))
21838 + error = proc_nid_instantiate(dir, dentry, id, p);
21844 +#define PROC_MAXVIDS 32
21846 +int proc_virtual_readdir(struct file *filp,
21847 + void *dirent, filldir_t filldir)
21849 + struct dentry *dentry = filp->f_dentry;
21850 + struct inode *inode = dentry->d_inode;
21851 + struct vs_entry *p = vx_virtual_stuff;
21852 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
21854 + unsigned int xid_array[PROC_MAXVIDS];
21855 + char buf[PROC_NUMBUF];
21856 + unsigned int nr_xids, i;
21859 + pos = filp->f_pos;
21862 + ino = inode->i_ino;
21863 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21866 + /* fall through */
21868 + ino = parent_ino(dentry);
21869 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21872 + /* fall through */
21875 + if (index >= size)
21877 + for (p += index; p->name; p++) {
21878 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21879 + vs_proc_instantiate, 0, p))
21884 + index = pos - size;
21885 + p = &vx_virtual_stuff[size - 1];
21886 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
21887 + for (i = 0; i < nr_xids; i++) {
21888 + int n, xid = xid_array[i];
21889 + unsigned int j = PROC_NUMBUF;
21893 + buf[--j] = '0' + (n % 10);
21896 + if (proc_fill_cache(filp, dirent, filldir,
21897 + buf + j, PROC_NUMBUF - j,
21898 + vs_proc_instantiate, xid, p))
21904 + filp->f_pos = pos;
21908 +static int proc_virtual_getattr(struct vfsmount *mnt,
21909 + struct dentry *dentry, struct kstat *stat)
21911 + struct inode *inode = dentry->d_inode;
21913 + generic_fillattr(inode, stat);
21914 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
21918 +static struct file_operations proc_virtual_dir_operations = {
21919 + .read = generic_read_dir,
21920 + .readdir = proc_virtual_readdir,
21923 +static struct inode_operations proc_virtual_dir_inode_operations = {
21924 + .getattr = proc_virtual_getattr,
21925 + .lookup = proc_virtual_lookup,
21932 +int proc_virtnet_readdir(struct file *filp,
21933 + void *dirent, filldir_t filldir)
21935 + struct dentry *dentry = filp->f_dentry;
21936 + struct inode *inode = dentry->d_inode;
21937 + struct vs_entry *p = nx_virtnet_stuff;
21938 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
21940 + unsigned int nid_array[PROC_MAXVIDS];
21941 + char buf[PROC_NUMBUF];
21942 + unsigned int nr_nids, i;
21945 + pos = filp->f_pos;
21948 + ino = inode->i_ino;
21949 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21952 + /* fall through */
21954 + ino = parent_ino(dentry);
21955 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21958 + /* fall through */
21961 + if (index >= size)
21963 + for (p += index; p->name; p++) {
21964 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21965 + vs_proc_instantiate, 0, p))
21970 + index = pos - size;
21971 + p = &nx_virtnet_stuff[size - 1];
21972 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
21973 + for (i = 0; i < nr_nids; i++) {
21974 + int n, nid = nid_array[i];
21975 + unsigned int j = PROC_NUMBUF;
21979 + buf[--j] = '0' + (n % 10);
21982 + if (proc_fill_cache(filp, dirent, filldir,
21983 + buf + j, PROC_NUMBUF - j,
21984 + vs_proc_instantiate, nid, p))
21990 + filp->f_pos = pos;
21994 +static int proc_virtnet_getattr(struct vfsmount *mnt,
21995 + struct dentry *dentry, struct kstat *stat)
21997 + struct inode *inode = dentry->d_inode;
21999 + generic_fillattr(inode, stat);
22000 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
22004 +static struct file_operations proc_virtnet_dir_operations = {
22005 + .read = generic_read_dir,
22006 + .readdir = proc_virtnet_readdir,
22009 +static struct inode_operations proc_virtnet_dir_inode_operations = {
22010 + .getattr = proc_virtnet_getattr,
22011 + .lookup = proc_virtnet_lookup,
22016 +void proc_vx_init(void)
22018 + struct proc_dir_entry *ent;
22020 + ent = proc_mkdir("virtual", 0);
22022 + ent->proc_fops = &proc_virtual_dir_operations;
22023 + ent->proc_iops = &proc_virtual_dir_inode_operations;
22025 + proc_virtual = ent;
22027 + ent = proc_mkdir("virtnet", 0);
22029 + ent->proc_fops = &proc_virtnet_dir_operations;
22030 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
22032 + proc_virtnet = ent;
22038 +/* per pid info */
22041 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
22043 + struct vx_info *vxi;
22044 + char *orig = buffer;
22046 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
22048 + vxi = task_get_vx_info(p);
22052 + buffer += sprintf(buffer, "BCaps:\t");
22053 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
22054 + buffer += sprintf(buffer, "\n");
22055 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
22056 + (unsigned long long)vxi->vx_ccaps);
22057 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
22058 + (unsigned long long)vxi->vx_flags);
22059 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
22061 + put_vx_info(vxi);
22063 + return buffer - orig;
22067 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
22069 + struct nx_info *nxi;
22070 + struct nx_addr_v4 *v4a;
22071 +#ifdef CONFIG_IPV6
22072 + struct nx_addr_v6 *v6a;
22074 + char *orig = buffer;
22077 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
22079 + nxi = task_get_nx_info(p);
22083 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
22084 + (unsigned long long)nxi->nx_ncaps);
22085 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
22086 + (unsigned long long)nxi->nx_flags);
22088 + buffer += sprintf(buffer,
22089 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
22090 + NIPQUAD(nxi->v4_bcast.s_addr));
22091 + buffer += sprintf (buffer,
22092 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
22093 + NIPQUAD(nxi->v4_lback.s_addr));
22094 + if (!NX_IPV4(nxi))
22096 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
22097 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
22100 +#ifdef CONFIG_IPV6
22101 + if (!NX_IPV6(nxi))
22103 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
22104 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
22108 + put_nx_info(nxi);
22110 + return buffer - orig;
22113 diff -NurpP --minimal linux-3.6.9/kernel/vserver/sched.c linux-3.6.9-vs2.3.4.4/kernel/vserver/sched.c
22114 --- linux-3.6.9/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
22115 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/sched.c 2012-10-04 18:47:00.000000000 +0200
22118 + * linux/kernel/vserver/sched.c
22120 + * Virtual Server: Scheduler Support
22122 + * Copyright (C) 2004-2010 Herbert Pötzl
22124 + * V0.01 adapted Sam Vilains version to 2.6.3
22125 + * V0.02 removed legacy interface
22126 + * V0.03 changed vcmds to vxi arg
22127 + * V0.04 removed older and legacy interfaces
22128 + * V0.05 removed scheduler code/commands
22132 +#include <linux/vs_context.h>
22133 +#include <linux/vs_sched.h>
22134 +#include <linux/cpumask.h>
22135 +#include <linux/vserver/sched_cmd.h>
22137 +#include <asm/uaccess.h>
22140 +void vx_update_sched_param(struct _vx_sched *sched,
22141 + struct _vx_sched_pc *sched_pc)
22143 + sched_pc->prio_bias = sched->prio_bias;
22146 +static int do_set_prio_bias(struct vx_info *vxi, struct vcmd_prio_bias *data)
22150 + if (data->prio_bias > MAX_PRIO_BIAS)
22151 + data->prio_bias = MAX_PRIO_BIAS;
22152 + if (data->prio_bias < MIN_PRIO_BIAS)
22153 + data->prio_bias = MIN_PRIO_BIAS;
22155 + if (data->cpu_id != ~0) {
22156 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
22157 + cpumask_and(&vxi->sched.update, &vxi->sched.update,
22158 + cpu_online_mask);
22160 + cpumask_copy(&vxi->sched.update, cpu_online_mask);
22162 + for_each_cpu_mask(cpu, vxi->sched.update)
22163 + vx_update_sched_param(&vxi->sched,
22164 + &vx_per_cpu(vxi, sched_pc, cpu));
22168 +int vc_set_prio_bias(struct vx_info *vxi, void __user *data)
22170 + struct vcmd_prio_bias vc_data;
22172 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22175 + return do_set_prio_bias(vxi, &vc_data);
22178 +int vc_get_prio_bias(struct vx_info *vxi, void __user *data)
22180 + struct vcmd_prio_bias vc_data;
22181 + struct _vx_sched_pc *pcd;
22184 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22187 + cpu = vc_data.cpu_id;
22189 + if (!cpu_possible(cpu))
22192 + pcd = &vx_per_cpu(vxi, sched_pc, cpu);
22193 + vc_data.prio_bias = pcd->prio_bias;
22195 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22200 diff -NurpP --minimal linux-3.6.9/kernel/vserver/sched_init.h linux-3.6.9-vs2.3.4.4/kernel/vserver/sched_init.h
22201 --- linux-3.6.9/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
22202 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/sched_init.h 2012-10-04 18:47:00.000000000 +0200
22205 +static inline void vx_info_init_sched(struct _vx_sched *sched)
22207 + /* scheduling; hard code starting values as constants */
22208 + sched->prio_bias = 0;
22212 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22214 + sched_pc->prio_bias = 0;
22216 + sched_pc->user_ticks = 0;
22217 + sched_pc->sys_ticks = 0;
22218 + sched_pc->hold_ticks = 0;
22221 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
22227 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22231 diff -NurpP --minimal linux-3.6.9/kernel/vserver/sched_proc.h linux-3.6.9-vs2.3.4.4/kernel/vserver/sched_proc.h
22232 --- linux-3.6.9/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
22233 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/sched_proc.h 2012-10-04 18:47:00.000000000 +0200
22235 +#ifndef _VX_SCHED_PROC_H
22236 +#define _VX_SCHED_PROC_H
22240 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
22244 + length += sprintf(buffer,
22245 + "PrioBias:\t%8d\n",
22246 + sched->prio_bias);
22251 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
22252 + char *buffer, int cpu)
22256 + length += sprintf(buffer + length,
22257 + "cpu %d: %lld %lld %lld", cpu,
22258 + (unsigned long long)sched_pc->user_ticks,
22259 + (unsigned long long)sched_pc->sys_ticks,
22260 + (unsigned long long)sched_pc->hold_ticks);
22261 + length += sprintf(buffer + length,
22262 + " %d\n", sched_pc->prio_bias);
22266 +#endif /* _VX_SCHED_PROC_H */
22267 diff -NurpP --minimal linux-3.6.9/kernel/vserver/signal.c linux-3.6.9-vs2.3.4.4/kernel/vserver/signal.c
22268 --- linux-3.6.9/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
22269 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/signal.c 2012-10-04 18:47:00.000000000 +0200
22272 + * linux/kernel/vserver/signal.c
22274 + * Virtual Server: Signal Support
22276 + * Copyright (C) 2003-2007 Herbert Pötzl
22278 + * V0.01 broken out from vcontext V0.05
22279 + * V0.02 changed vcmds to vxi arg
22280 + * V0.03 adjusted siginfo for kill
22284 +#include <asm/uaccess.h>
22286 +#include <linux/vs_context.h>
22287 +#include <linux/vs_pid.h>
22288 +#include <linux/vserver/signal_cmd.h>
22291 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
22293 + int retval, count = 0;
22294 + struct task_struct *p;
22295 + struct siginfo *sip = SEND_SIG_PRIV;
22298 + vxdprintk(VXD_CBIT(misc, 4),
22299 + "vx_info_kill(%p[#%d],%d,%d)*",
22300 + vxi, vxi->vx_id, pid, sig);
22301 + read_lock(&tasklist_lock);
22305 + for_each_process(p) {
22308 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
22309 + (pid && vxi->vx_initpid == p->pid))
22312 + err = group_send_sig_info(sig, sip, p);
22314 + if (err != -EPERM)
22320 + if (vxi->vx_initpid) {
22321 + pid = vxi->vx_initpid;
22322 + /* for now, only SIGINT to private init ... */
22323 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22324 + /* ... as long as there are tasks left */
22325 + (atomic_read(&vxi->vx_tasks) > 1))
22328 + /* fallthrough */
22331 + p = find_task_by_real_pid(pid);
22332 + rcu_read_unlock();
22334 + if (vx_task_xid(p) == vxi->vx_id)
22335 + retval = group_send_sig_info(sig, sip, p);
22339 + read_unlock(&tasklist_lock);
22340 + vxdprintk(VXD_CBIT(misc, 4),
22341 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
22342 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
22346 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
22348 + struct vcmd_ctx_kill_v0 vc_data;
22350 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22353 + /* special check to allow guest shutdown */
22354 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22355 + /* forbid killall pid=0 when init is present */
22356 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
22357 + (vc_data.pid > 1)))
22360 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
22364 +static int __wait_exit(struct vx_info *vxi)
22366 + DECLARE_WAITQUEUE(wait, current);
22369 + add_wait_queue(&vxi->vx_wait, &wait);
22370 + set_current_state(TASK_INTERRUPTIBLE);
22373 + if (vx_info_state(vxi,
22374 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
22376 + if (signal_pending(current)) {
22377 + ret = -ERESTARTSYS;
22384 + set_current_state(TASK_RUNNING);
22385 + remove_wait_queue(&vxi->vx_wait, &wait);
22391 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
22393 + struct vcmd_wait_exit_v0 vc_data;
22396 + ret = __wait_exit(vxi);
22397 + vc_data.reboot_cmd = vxi->reboot_cmd;
22398 + vc_data.exit_code = vxi->exit_code;
22400 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22405 diff -NurpP --minimal linux-3.6.9/kernel/vserver/space.c linux-3.6.9-vs2.3.4.4/kernel/vserver/space.c
22406 --- linux-3.6.9/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
22407 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/space.c 2012-10-04 18:47:00.000000000 +0200
22410 + * linux/kernel/vserver/space.c
22412 + * Virtual Server: Context Space Support
22414 + * Copyright (C) 2003-2010 Herbert Pötzl
22416 + * V0.01 broken out from context.c 0.07
22417 + * V0.02 added task locking for namespace
22418 + * V0.03 broken out vx_enter_namespace
22419 + * V0.04 added *space support and commands
22420 + * V0.05 added credential support
22424 +#include <linux/utsname.h>
22425 +#include <linux/nsproxy.h>
22426 +#include <linux/err.h>
22427 +#include <linux/fs_struct.h>
22428 +#include <linux/cred.h>
22429 +#include <asm/uaccess.h>
22431 +#include <linux/vs_context.h>
22432 +#include <linux/vserver/space.h>
22433 +#include <linux/vserver/space_cmd.h>
22435 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
22436 +atomic_t vs_global_fs = ATOMIC_INIT(0);
22437 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
22438 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
22439 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
22440 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
22443 +/* namespace functions */
22445 +#include <linux/mnt_namespace.h>
22446 +#include <linux/user_namespace.h>
22447 +#include <linux/pid_namespace.h>
22448 +#include <linux/ipc_namespace.h>
22449 +#include <net/net_namespace.h>
22450 +#include "../fs/mount.h"
22453 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
22454 + .mask = CLONE_FS |
22456 +#ifdef CONFIG_UTS_NS
22459 +#ifdef CONFIG_IPC_NS
22462 +#ifdef CONFIG_USER_NS
22468 +static const struct vcmd_space_mask_v1 space_mask = {
22469 + .mask = CLONE_FS |
22471 +#ifdef CONFIG_UTS_NS
22474 +#ifdef CONFIG_IPC_NS
22477 +#ifdef CONFIG_USER_NS
22480 +#ifdef CONFIG_PID_NS
22483 +#ifdef CONFIG_NET_NS
22489 +static const struct vcmd_space_mask_v1 default_space_mask = {
22490 + .mask = CLONE_FS |
22492 +#ifdef CONFIG_UTS_NS
22495 +#ifdef CONFIG_IPC_NS
22498 +#ifdef CONFIG_USER_NS
22501 +#ifdef CONFIG_PID_NS
22508 + * build a new nsproxy mix
22509 + * assumes that both proxies are 'const'
22510 + * does not touch nsproxy refcounts
22511 + * will hold a reference on the result.
22514 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
22515 + struct nsproxy *new_nsproxy, unsigned long mask)
22517 + struct mnt_namespace *old_ns;
22518 + struct uts_namespace *old_uts;
22519 + struct ipc_namespace *old_ipc;
22520 +#ifdef CONFIG_PID_NS
22521 + struct pid_namespace *old_pid;
22523 +#ifdef CONFIG_NET_NS
22524 + struct net *old_net;
22526 + struct nsproxy *nsproxy;
22528 + nsproxy = copy_nsproxy(old_nsproxy);
22532 + if (mask & CLONE_NEWNS) {
22533 + old_ns = nsproxy->mnt_ns;
22534 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
22535 + if (nsproxy->mnt_ns)
22536 + get_mnt_ns(nsproxy->mnt_ns);
22540 + if (mask & CLONE_NEWUTS) {
22541 + old_uts = nsproxy->uts_ns;
22542 + nsproxy->uts_ns = new_nsproxy->uts_ns;
22543 + if (nsproxy->uts_ns)
22544 + get_uts_ns(nsproxy->uts_ns);
22548 + if (mask & CLONE_NEWIPC) {
22549 + old_ipc = nsproxy->ipc_ns;
22550 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
22551 + if (nsproxy->ipc_ns)
22552 + get_ipc_ns(nsproxy->ipc_ns);
22556 +#ifdef CONFIG_PID_NS
22557 + if (mask & CLONE_NEWPID) {
22558 + old_pid = nsproxy->pid_ns;
22559 + nsproxy->pid_ns = new_nsproxy->pid_ns;
22560 + if (nsproxy->pid_ns)
22561 + get_pid_ns(nsproxy->pid_ns);
22565 +#ifdef CONFIG_NET_NS
22566 + if (mask & CLONE_NEWNET) {
22567 + old_net = nsproxy->net_ns;
22568 + nsproxy->net_ns = new_nsproxy->net_ns;
22569 + if (nsproxy->net_ns)
22570 + get_net(nsproxy->net_ns);
22575 + put_mnt_ns(old_ns);
22577 + put_uts_ns(old_uts);
22579 + put_ipc_ns(old_ipc);
22580 +#ifdef CONFIG_PID_NS
22582 + put_pid_ns(old_pid);
22584 +#ifdef CONFIG_NET_NS
22586 + put_net(old_net);
22594 + * merge two nsproxy structs into a new one.
22595 + * will hold a reference on the result.
22599 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
22600 + struct nsproxy *proxy, unsigned long mask)
22602 + struct nsproxy null_proxy = { .mnt_ns = NULL };
22608 + /* vs_mix_nsproxy returns with reference */
22609 + return vs_mix_nsproxy(old ? old : &null_proxy,
22612 + get_nsproxy(proxy);
22617 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
22619 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
22620 + struct fs_struct *fs_cur, *fs = NULL;
22621 + struct _vx_space *space;
22622 + int ret, kill = 0;
22624 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
22625 + vxi, vxi->vx_id, mask, index);
22627 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
22630 + if (index >= VX_SPACES)
22633 + space = &vxi->space[index];
22636 + mask = space->vx_nsmask;
22638 + if ((mask & space->vx_nsmask) != mask)
22641 + if (mask & CLONE_FS) {
22642 + fs = copy_fs_struct(space->vx_fs);
22646 + proxy = space->vx_nsproxy;
22648 + vxdprintk(VXD_CBIT(space, 9),
22649 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
22650 + vxi, vxi->vx_id, mask, index, proxy, fs);
22652 + task_lock(current);
22653 + fs_cur = current->fs;
22655 + if (mask & CLONE_FS) {
22656 + spin_lock(&fs_cur->lock);
22657 + current->fs = fs;
22658 + kill = !--fs_cur->users;
22659 + spin_unlock(&fs_cur->lock);
22662 + proxy_cur = current->nsproxy;
22663 + get_nsproxy(proxy_cur);
22664 + task_unlock(current);
22667 + free_fs_struct(fs_cur);
22669 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
22670 + if (IS_ERR(proxy_new)) {
22671 + ret = PTR_ERR(proxy_new);
22675 + proxy_new = xchg(¤t->nsproxy, proxy_new);
22677 + if (mask & CLONE_NEWUSER) {
22678 + struct cred *cred;
22680 + vxdprintk(VXD_CBIT(space, 10),
22681 + "vx_enter_space(%p[#%u],%p) cred (%p,%p)",
22682 + vxi, vxi->vx_id, space->vx_cred,
22683 + current->real_cred, current->cred);
22685 + if (space->vx_cred) {
22686 + cred = __prepare_creds(space->vx_cred);
22688 + commit_creds(cred);
22695 + put_nsproxy(proxy_new);
22698 + put_nsproxy(proxy_cur);
22703 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
22705 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
22706 + struct fs_struct *fs_vxi, *fs;
22707 + struct _vx_space *space;
22708 + int ret, kill = 0;
22710 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
22711 + vxi, vxi->vx_id, mask, index);
22713 + if ((mask & space_mask.mask) != mask)
22716 + if (index >= VX_SPACES)
22719 + space = &vxi->space[index];
22721 + proxy_vxi = space->vx_nsproxy;
22722 + fs_vxi = space->vx_fs;
22724 + if (mask & CLONE_FS) {
22725 + fs = copy_fs_struct(current->fs);
22730 + task_lock(current);
22732 + if (mask & CLONE_FS) {
22733 + spin_lock(&fs_vxi->lock);
22734 + space->vx_fs = fs;
22735 + kill = !--fs_vxi->users;
22736 + spin_unlock(&fs_vxi->lock);
22739 + proxy_cur = current->nsproxy;
22740 + get_nsproxy(proxy_cur);
22741 + task_unlock(current);
22744 + free_fs_struct(fs_vxi);
22746 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
22747 + if (IS_ERR(proxy_new)) {
22748 + ret = PTR_ERR(proxy_new);
22752 + proxy_new = xchg(&space->vx_nsproxy, proxy_new);
22753 + space->vx_nsmask |= mask;
22755 + if (mask & CLONE_NEWUSER) {
22756 + struct cred *cred;
22758 + vxdprintk(VXD_CBIT(space, 10),
22759 + "vx_set_space(%p[#%u],%p) cred (%p,%p)",
22760 + vxi, vxi->vx_id, space->vx_cred,
22761 + current->real_cred, current->cred);
22763 + cred = prepare_creds();
22764 + cred = (struct cred *)xchg(&space->vx_cred, cred);
22766 + abort_creds(cred);
22772 + put_nsproxy(proxy_new);
22775 + put_nsproxy(proxy_cur);
22780 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
22782 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
22784 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22787 + return vx_enter_space(vxi, vc_data.mask, 0);
22790 +int vc_enter_space(struct vx_info *vxi, void __user *data)
22792 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
22794 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22797 + if (vc_data.index >= VX_SPACES)
22800 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
22803 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
22805 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
22807 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22810 + return vx_set_space(vxi, vc_data.mask, 0);
22813 +int vc_set_space(struct vx_info *vxi, void __user *data)
22815 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
22817 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22820 + if (vc_data.index >= VX_SPACES)
22823 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
22826 +int vc_get_space_mask(void __user *data, int type)
22828 + const struct vcmd_space_mask_v1 *mask;
22831 + mask = &space_mask_v0;
22832 + else if (type == 1)
22833 + mask = &space_mask;
22835 + mask = &default_space_mask;
22837 + vxdprintk(VXD_CBIT(space, 10),
22838 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
22840 + if (copy_to_user(data, mask, sizeof(*mask)))
22845 diff -NurpP --minimal linux-3.6.9/kernel/vserver/switch.c linux-3.6.9-vs2.3.4.4/kernel/vserver/switch.c
22846 --- linux-3.6.9/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
22847 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/switch.c 2012-10-04 18:47:00.000000000 +0200
22850 + * linux/kernel/vserver/switch.c
22852 + * Virtual Server: Syscall Switch
22854 + * Copyright (C) 2003-2011 Herbert Pötzl
22856 + * V0.01 syscall switch
22857 + * V0.02 added signal to context
22858 + * V0.03 added rlimit functions
22859 + * V0.04 added iattr, task/xid functions
22860 + * V0.05 added debug/history stuff
22861 + * V0.06 added compat32 layer
22862 + * V0.07 vcmd args and perms
22863 + * V0.08 added status commands
22864 + * V0.09 added tag commands
22865 + * V0.10 added oom bias
22866 + * V0.11 added device commands
22867 + * V0.12 added warn mask
22871 +#include <linux/vs_context.h>
22872 +#include <linux/vs_network.h>
22873 +#include <linux/vserver/switch.h>
22875 +#include "vci_config.h"
22879 +int vc_get_version(uint32_t id)
22881 + return VCI_VERSION;
22885 +int vc_get_vci(uint32_t id)
22887 + return vci_kernel_config();
22890 +#include <linux/vserver/context_cmd.h>
22891 +#include <linux/vserver/cvirt_cmd.h>
22892 +#include <linux/vserver/cacct_cmd.h>
22893 +#include <linux/vserver/limit_cmd.h>
22894 +#include <linux/vserver/network_cmd.h>
22895 +#include <linux/vserver/sched_cmd.h>
22896 +#include <linux/vserver/debug_cmd.h>
22897 +#include <linux/vserver/inode_cmd.h>
22898 +#include <linux/vserver/dlimit_cmd.h>
22899 +#include <linux/vserver/signal_cmd.h>
22900 +#include <linux/vserver/space_cmd.h>
22901 +#include <linux/vserver/tag_cmd.h>
22902 +#include <linux/vserver/device_cmd.h>
22904 +#include <linux/vserver/inode.h>
22905 +#include <linux/vserver/dlimit.h>
22908 +#ifdef CONFIG_COMPAT
22909 +#define __COMPAT(name, id, data, compat) \
22910 + (compat) ? name ## _x32(id, data) : name(id, data)
22911 +#define __COMPAT_NO_ID(name, data, compat) \
22912 + (compat) ? name ## _x32(data) : name(data)
22914 +#define __COMPAT(name, id, data, compat) \
22916 +#define __COMPAT_NO_ID(name, data, compat) \
22922 +long do_vcmd(uint32_t cmd, uint32_t id,
22923 + struct vx_info *vxi, struct nx_info *nxi,
22924 + void __user *data, int compat)
22928 + case VCMD_get_version:
22929 + return vc_get_version(id);
22930 + case VCMD_get_vci:
22931 + return vc_get_vci(id);
22933 + case VCMD_task_xid:
22934 + return vc_task_xid(id);
22935 + case VCMD_vx_info:
22936 + return vc_vx_info(vxi, data);
22938 + case VCMD_task_nid:
22939 + return vc_task_nid(id);
22940 + case VCMD_nx_info:
22941 + return vc_nx_info(nxi, data);
22943 + case VCMD_task_tag:
22944 + return vc_task_tag(id);
22946 + case VCMD_set_space_v1:
22947 + return vc_set_space_v1(vxi, data);
22948 + /* this is version 2 */
22949 + case VCMD_set_space:
22950 + return vc_set_space(vxi, data);
22952 + case VCMD_get_space_mask_v0:
22953 + return vc_get_space_mask(data, 0);
22954 + /* this is version 1 */
22955 + case VCMD_get_space_mask:
22956 + return vc_get_space_mask(data, 1);
22958 + case VCMD_get_space_default:
22959 + return vc_get_space_mask(data, -1);
22961 + case VCMD_set_umask:
22962 + return vc_set_umask(vxi, data);
22964 + case VCMD_get_umask:
22965 + return vc_get_umask(vxi, data);
22967 + case VCMD_set_wmask:
22968 + return vc_set_wmask(vxi, data);
22970 + case VCMD_get_wmask:
22971 + return vc_get_wmask(vxi, data);
22972 +#ifdef CONFIG_IA32_EMULATION
22973 + case VCMD_get_rlimit:
22974 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
22975 + case VCMD_set_rlimit:
22976 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
22978 + case VCMD_get_rlimit:
22979 + return vc_get_rlimit(vxi, data);
22980 + case VCMD_set_rlimit:
22981 + return vc_set_rlimit(vxi, data);
22983 + case VCMD_get_rlimit_mask:
22984 + return vc_get_rlimit_mask(id, data);
22985 + case VCMD_reset_hits:
22986 + return vc_reset_hits(vxi, data);
22987 + case VCMD_reset_minmax:
22988 + return vc_reset_minmax(vxi, data);
22990 + case VCMD_get_vhi_name:
22991 + return vc_get_vhi_name(vxi, data);
22992 + case VCMD_set_vhi_name:
22993 + return vc_set_vhi_name(vxi, data);
22995 + case VCMD_ctx_stat:
22996 + return vc_ctx_stat(vxi, data);
22997 + case VCMD_virt_stat:
22998 + return vc_virt_stat(vxi, data);
22999 + case VCMD_sock_stat:
23000 + return vc_sock_stat(vxi, data);
23001 + case VCMD_rlimit_stat:
23002 + return vc_rlimit_stat(vxi, data);
23004 + case VCMD_set_cflags:
23005 + return vc_set_cflags(vxi, data);
23006 + case VCMD_get_cflags:
23007 + return vc_get_cflags(vxi, data);
23009 + /* this is version 1 */
23010 + case VCMD_set_ccaps:
23011 + return vc_set_ccaps(vxi, data);
23012 + /* this is version 1 */
23013 + case VCMD_get_ccaps:
23014 + return vc_get_ccaps(vxi, data);
23015 + case VCMD_set_bcaps:
23016 + return vc_set_bcaps(vxi, data);
23017 + case VCMD_get_bcaps:
23018 + return vc_get_bcaps(vxi, data);
23020 + case VCMD_set_badness:
23021 + return vc_set_badness(vxi, data);
23022 + case VCMD_get_badness:
23023 + return vc_get_badness(vxi, data);
23025 + case VCMD_set_nflags:
23026 + return vc_set_nflags(nxi, data);
23027 + case VCMD_get_nflags:
23028 + return vc_get_nflags(nxi, data);
23030 + case VCMD_set_ncaps:
23031 + return vc_set_ncaps(nxi, data);
23032 + case VCMD_get_ncaps:
23033 + return vc_get_ncaps(nxi, data);
23035 + case VCMD_set_prio_bias:
23036 + return vc_set_prio_bias(vxi, data);
23037 + case VCMD_get_prio_bias:
23038 + return vc_get_prio_bias(vxi, data);
23039 + case VCMD_add_dlimit:
23040 + return __COMPAT(vc_add_dlimit, id, data, compat);
23041 + case VCMD_rem_dlimit:
23042 + return __COMPAT(vc_rem_dlimit, id, data, compat);
23043 + case VCMD_set_dlimit:
23044 + return __COMPAT(vc_set_dlimit, id, data, compat);
23045 + case VCMD_get_dlimit:
23046 + return __COMPAT(vc_get_dlimit, id, data, compat);
23048 + case VCMD_ctx_kill:
23049 + return vc_ctx_kill(vxi, data);
23051 + case VCMD_wait_exit:
23052 + return vc_wait_exit(vxi, data);
23054 + case VCMD_get_iattr:
23055 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
23056 + case VCMD_set_iattr:
23057 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
23059 + case VCMD_fget_iattr:
23060 + return vc_fget_iattr(id, data);
23061 + case VCMD_fset_iattr:
23062 + return vc_fset_iattr(id, data);
23064 + case VCMD_enter_space_v0:
23065 + return vc_enter_space_v1(vxi, NULL);
23066 + case VCMD_enter_space_v1:
23067 + return vc_enter_space_v1(vxi, data);
23068 + /* this is version 2 */
23069 + case VCMD_enter_space:
23070 + return vc_enter_space(vxi, data);
23072 + case VCMD_ctx_create_v0:
23073 + return vc_ctx_create(id, NULL);
23074 + case VCMD_ctx_create:
23075 + return vc_ctx_create(id, data);
23076 + case VCMD_ctx_migrate_v0:
23077 + return vc_ctx_migrate(vxi, NULL);
23078 + case VCMD_ctx_migrate:
23079 + return vc_ctx_migrate(vxi, data);
23081 + case VCMD_net_create_v0:
23082 + return vc_net_create(id, NULL);
23083 + case VCMD_net_create:
23084 + return vc_net_create(id, data);
23085 + case VCMD_net_migrate:
23086 + return vc_net_migrate(nxi, data);
23088 + case VCMD_tag_migrate:
23089 + return vc_tag_migrate(id);
23091 + case VCMD_net_add:
23092 + return vc_net_add(nxi, data);
23093 + case VCMD_net_remove:
23094 + return vc_net_remove(nxi, data);
23096 + case VCMD_net_add_ipv4_v1:
23097 + return vc_net_add_ipv4_v1(nxi, data);
23098 + /* this is version 2 */
23099 + case VCMD_net_add_ipv4:
23100 + return vc_net_add_ipv4(nxi, data);
23102 + case VCMD_net_rem_ipv4_v1:
23103 + return vc_net_rem_ipv4_v1(nxi, data);
23104 + /* this is version 2 */
23105 + case VCMD_net_rem_ipv4:
23106 + return vc_net_rem_ipv4(nxi, data);
23107 +#ifdef CONFIG_IPV6
23108 + case VCMD_net_add_ipv6:
23109 + return vc_net_add_ipv6(nxi, data);
23110 + case VCMD_net_remove_ipv6:
23111 + return vc_net_remove_ipv6(nxi, data);
23113 +/* case VCMD_add_match_ipv4:
23114 + return vc_add_match_ipv4(nxi, data);
23115 + case VCMD_get_match_ipv4:
23116 + return vc_get_match_ipv4(nxi, data);
23117 +#ifdef CONFIG_IPV6
23118 + case VCMD_add_match_ipv6:
23119 + return vc_add_match_ipv6(nxi, data);
23120 + case VCMD_get_match_ipv6:
23121 + return vc_get_match_ipv6(nxi, data);
23124 +#ifdef CONFIG_VSERVER_DEVICE
23125 + case VCMD_set_mapping:
23126 + return __COMPAT(vc_set_mapping, vxi, data, compat);
23127 + case VCMD_unset_mapping:
23128 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
23130 +#ifdef CONFIG_VSERVER_HISTORY
23131 + case VCMD_dump_history:
23132 + return vc_dump_history(id);
23133 + case VCMD_read_history:
23134 + return __COMPAT(vc_read_history, id, data, compat);
23137 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
23138 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
23144 +#define __VCMD(vcmd, _perm, _args, _flags) \
23145 + case VCMD_ ## vcmd: perm = _perm; \
23146 + args = _args; flags = _flags; break
23149 +#define VCA_NONE 0x00
23150 +#define VCA_VXI 0x01
23151 +#define VCA_NXI 0x02
23153 +#define VCF_NONE 0x00
23154 +#define VCF_INFO 0x01
23155 +#define VCF_ADMIN 0x02
23156 +#define VCF_ARES 0x06 /* includes admin */
23157 +#define VCF_SETUP 0x08
23159 +#define VCF_ZIDOK 0x10 /* zero id okay */
23163 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
23166 + int permit = -1, state = 0;
23167 + int perm = -1, args = 0, flags = 0;
23168 + struct vx_info *vxi = NULL;
23169 + struct nx_info *nxi = NULL;
23172 + /* unpriviledged commands */
23173 + __VCMD(get_version, 0, VCA_NONE, 0);
23174 + __VCMD(get_vci, 0, VCA_NONE, 0);
23175 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
23176 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
23177 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
23178 + __VCMD(get_space_default,0, VCA_NONE, 0);
23180 + /* info commands */
23181 + __VCMD(task_xid, 2, VCA_NONE, 0);
23182 + __VCMD(reset_hits, 2, VCA_VXI, 0);
23183 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
23184 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
23185 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
23186 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
23187 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
23188 + __VCMD(get_umask, 3, VCA_VXI, VCF_INFO);
23189 + __VCMD(get_wmask, 3, VCA_VXI, VCF_INFO);
23190 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
23191 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
23192 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
23194 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
23195 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
23196 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
23197 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
23199 + __VCMD(task_nid, 2, VCA_NONE, 0);
23200 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
23201 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
23202 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
23204 + __VCMD(task_tag, 2, VCA_NONE, 0);
23206 + __VCMD(get_iattr, 2, VCA_NONE, 0);
23207 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
23208 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
23209 + __VCMD(get_prio_bias, 3, VCA_VXI, VCF_INFO);
23211 + /* lower admin commands */
23212 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
23213 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
23214 + __VCMD(ctx_create, 5, VCA_NONE, 0);
23215 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
23216 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
23217 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
23218 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
23219 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
23221 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
23222 + __VCMD(net_create, 5, VCA_NONE, 0);
23223 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
23225 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
23227 + /* higher admin commands */
23228 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
23229 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23230 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23232 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23233 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23234 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23235 + __VCMD(set_umask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23236 + __VCMD(set_wmask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23237 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23239 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23240 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23241 + __VCMD(set_prio_bias, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23243 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23244 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23245 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23246 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23247 + __VCMD(net_add_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23248 + __VCMD(net_rem_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23249 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23250 + __VCMD(net_rem_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23251 +#ifdef CONFIG_IPV6
23252 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23253 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23255 + __VCMD(set_iattr, 7, VCA_NONE, 0);
23256 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
23257 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
23258 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
23259 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
23261 +#ifdef CONFIG_VSERVER_DEVICE
23262 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23263 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23265 + /* debug level admin commands */
23266 +#ifdef CONFIG_VSERVER_HISTORY
23267 + __VCMD(dump_history, 9, VCA_NONE, 0);
23268 + __VCMD(read_history, 9, VCA_NONE, 0);
23275 + vxdprintk(VXD_CBIT(switch, 0),
23276 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
23277 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23278 + VC_VERSION(cmd), id, data, compat,
23279 + perm, args, flags);
23286 + if (!capable(CAP_CONTEXT))
23290 + /* moved here from the individual commands */
23292 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
23296 + /* vcmd involves resource management */
23298 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
23302 + /* various legacy exceptions */
23304 + /* will go away when spectator is a cap */
23305 + case VCMD_ctx_migrate_v0:
23306 + case VCMD_ctx_migrate:
23308 + current->xid = 1;
23314 + /* will go away when spectator is a cap */
23315 + case VCMD_net_migrate:
23317 + current->nid = 1;
23324 + /* vcmds are fine by default */
23327 + /* admin type vcmds require admin ... */
23328 + if (flags & VCF_ADMIN)
23329 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
23331 + /* ... but setup type vcmds override that */
23332 + if (!permit && (flags & VCF_SETUP))
23333 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
23341 + if (!id && (flags & VCF_ZIDOK))
23345 + if (args & VCA_VXI) {
23346 + vxi = lookup_vx_info(id);
23350 + if ((flags & VCF_ADMIN) &&
23351 + /* special case kill for shutdown */
23352 + (cmd != VCMD_ctx_kill) &&
23353 + /* can context be administrated? */
23354 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
23360 + if (args & VCA_NXI) {
23361 + nxi = lookup_nx_info(id);
23365 + if ((flags & VCF_ADMIN) &&
23366 + /* can context be administrated? */
23367 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
23374 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
23377 + if ((args & VCA_NXI) && nxi)
23378 + put_nx_info(nxi);
23380 + if ((args & VCA_VXI) && vxi)
23381 + put_vx_info(vxi);
23383 + vxdprintk(VXD_CBIT(switch, 1),
23384 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
23385 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23386 + VC_VERSION(cmd), ret, ret, state, permit);
23391 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
23393 + return do_vserver(cmd, id, data, 0);
23396 +#ifdef CONFIG_COMPAT
23399 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
23401 + return do_vserver(cmd, id, data, 1);
23404 +#endif /* CONFIG_COMPAT */
23405 diff -NurpP --minimal linux-3.6.9/kernel/vserver/sysctl.c linux-3.6.9-vs2.3.4.4/kernel/vserver/sysctl.c
23406 --- linux-3.6.9/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
23407 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/sysctl.c 2012-10-04 18:47:00.000000000 +0200
23410 + * kernel/vserver/sysctl.c
23412 + * Virtual Context Support
23414 + * Copyright (C) 2004-2007 Herbert Pötzl
23416 + * V0.01 basic structure
23420 +#include <linux/module.h>
23421 +#include <linux/ctype.h>
23422 +#include <linux/sysctl.h>
23423 +#include <linux/parser.h>
23424 +#include <asm/uaccess.h>
23427 + CTL_DEBUG_ERROR = 0,
23428 + CTL_DEBUG_SWITCH = 1,
23444 +unsigned int vs_debug_switch = 0;
23445 +unsigned int vs_debug_xid = 0;
23446 +unsigned int vs_debug_nid = 0;
23447 +unsigned int vs_debug_tag = 0;
23448 +unsigned int vs_debug_net = 0;
23449 +unsigned int vs_debug_limit = 0;
23450 +unsigned int vs_debug_cres = 0;
23451 +unsigned int vs_debug_dlim = 0;
23452 +unsigned int vs_debug_quota = 0;
23453 +unsigned int vs_debug_cvirt = 0;
23454 +unsigned int vs_debug_space = 0;
23455 +unsigned int vs_debug_perm = 0;
23456 +unsigned int vs_debug_misc = 0;
23459 +static struct ctl_table_header *vserver_table_header;
23460 +static ctl_table vserver_root_table[];
23463 +void vserver_register_sysctl(void)
23465 + if (!vserver_table_header) {
23466 + vserver_table_header = register_sysctl_table(vserver_root_table);
23471 +void vserver_unregister_sysctl(void)
23473 + if (vserver_table_header) {
23474 + unregister_sysctl_table(vserver_table_header);
23475 + vserver_table_header = NULL;
23480 +static int proc_dodebug(ctl_table *table, int write,
23481 + void __user *buffer, size_t *lenp, loff_t *ppos)
23483 + char tmpbuf[20], *p, c;
23484 + unsigned int value;
23485 + size_t left, len;
23487 + if ((*ppos && !write) || !*lenp) {
23495 + if (!access_ok(VERIFY_READ, buffer, left))
23497 + p = (char *)buffer;
23498 + while (left && __get_user(c, p) >= 0 && isspace(c))
23503 + if (left > sizeof(tmpbuf) - 1)
23505 + if (copy_from_user(tmpbuf, p, left))
23507 + tmpbuf[left] = '\0';
23509 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
23510 + value = 10 * value + (*p - '0');
23511 + if (*p && !isspace(*p))
23513 + while (left && isspace(*p))
23515 + *(unsigned int *)table->data = value;
23517 + if (!access_ok(VERIFY_WRITE, buffer, left))
23519 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
23522 + if (__copy_to_user(buffer, tmpbuf, len))
23524 + if ((left -= len) > 0) {
23525 + if (put_user('\n', (char *)buffer + len))
23539 +#define CTL_ENTRY(ctl, name) \
23541 + .procname = #name, \
23542 + .data = &vs_ ## name, \
23543 + .maxlen = sizeof(int), \
23545 + .proc_handler = &proc_dodebug, \
23546 + .extra1 = &zero, \
23547 + .extra2 = &zero, \
23550 +static ctl_table vserver_debug_table[] = {
23551 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
23552 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
23553 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
23554 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
23555 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
23556 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
23557 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
23558 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
23559 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
23560 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
23561 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
23562 + CTL_ENTRY(CTL_DEBUG_PERM, debug_perm),
23563 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
23567 +static ctl_table vserver_root_table[] = {
23569 + .procname = "vserver",
23571 + .child = vserver_debug_table
23577 +static match_table_t tokens = {
23578 + { CTL_DEBUG_SWITCH, "switch=%x" },
23579 + { CTL_DEBUG_XID, "xid=%x" },
23580 + { CTL_DEBUG_NID, "nid=%x" },
23581 + { CTL_DEBUG_TAG, "tag=%x" },
23582 + { CTL_DEBUG_NET, "net=%x" },
23583 + { CTL_DEBUG_LIMIT, "limit=%x" },
23584 + { CTL_DEBUG_CRES, "cres=%x" },
23585 + { CTL_DEBUG_DLIM, "dlim=%x" },
23586 + { CTL_DEBUG_QUOTA, "quota=%x" },
23587 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
23588 + { CTL_DEBUG_SPACE, "space=%x" },
23589 + { CTL_DEBUG_PERM, "perm=%x" },
23590 + { CTL_DEBUG_MISC, "misc=%x" },
23591 + { CTL_DEBUG_ERROR, NULL }
23594 +#define HANDLE_CASE(id, name, val) \
23595 + case CTL_DEBUG_ ## id: \
23596 + vs_debug_ ## name = val; \
23597 + printk("vs_debug_" #name "=0x%x\n", val); \
23601 +static int __init vs_debug_setup(char *str)
23606 + printk("vs_debug_setup(%s)\n", str);
23607 + while ((p = strsep(&str, ",")) != NULL) {
23608 + substring_t args[MAX_OPT_ARGS];
23609 + unsigned int value;
23614 + token = match_token(p, tokens, args);
23615 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
23618 + HANDLE_CASE(SWITCH, switch, value);
23619 + HANDLE_CASE(XID, xid, value);
23620 + HANDLE_CASE(NID, nid, value);
23621 + HANDLE_CASE(TAG, tag, value);
23622 + HANDLE_CASE(NET, net, value);
23623 + HANDLE_CASE(LIMIT, limit, value);
23624 + HANDLE_CASE(CRES, cres, value);
23625 + HANDLE_CASE(DLIM, dlim, value);
23626 + HANDLE_CASE(QUOTA, quota, value);
23627 + HANDLE_CASE(CVIRT, cvirt, value);
23628 + HANDLE_CASE(SPACE, space, value);
23629 + HANDLE_CASE(PERM, perm, value);
23630 + HANDLE_CASE(MISC, misc, value);
23639 +__setup("vsdebug=", vs_debug_setup);
23643 +EXPORT_SYMBOL_GPL(vs_debug_switch);
23644 +EXPORT_SYMBOL_GPL(vs_debug_xid);
23645 +EXPORT_SYMBOL_GPL(vs_debug_nid);
23646 +EXPORT_SYMBOL_GPL(vs_debug_net);
23647 +EXPORT_SYMBOL_GPL(vs_debug_limit);
23648 +EXPORT_SYMBOL_GPL(vs_debug_cres);
23649 +EXPORT_SYMBOL_GPL(vs_debug_dlim);
23650 +EXPORT_SYMBOL_GPL(vs_debug_quota);
23651 +EXPORT_SYMBOL_GPL(vs_debug_cvirt);
23652 +EXPORT_SYMBOL_GPL(vs_debug_space);
23653 +EXPORT_SYMBOL_GPL(vs_debug_perm);
23654 +EXPORT_SYMBOL_GPL(vs_debug_misc);
23656 diff -NurpP --minimal linux-3.6.9/kernel/vserver/tag.c linux-3.6.9-vs2.3.4.4/kernel/vserver/tag.c
23657 --- linux-3.6.9/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
23658 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/tag.c 2012-10-04 18:47:00.000000000 +0200
23661 + * linux/kernel/vserver/tag.c
23663 + * Virtual Server: Shallow Tag Space
23665 + * Copyright (C) 2007 Herbert Pötzl
23667 + * V0.01 basic implementation
23671 +#include <linux/sched.h>
23672 +#include <linux/vserver/debug.h>
23673 +#include <linux/vs_pid.h>
23674 +#include <linux/vs_tag.h>
23676 +#include <linux/vserver/tag_cmd.h>
23679 +int dx_migrate_task(struct task_struct *p, vs_tag_t tag)
23684 + vxdprintk(VXD_CBIT(tag, 5),
23685 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
23691 + vxdprintk(VXD_CBIT(tag, 5),
23692 + "moved task %p into [#%d]", p, tag);
23696 +/* vserver syscall commands below here */
23698 +/* taks xid and vx_info functions */
23701 +int vc_task_tag(uint32_t id)
23706 + struct task_struct *tsk;
23708 + tsk = find_task_by_real_pid(id);
23709 + tag = (tsk) ? tsk->tag : -ESRCH;
23710 + rcu_read_unlock();
23712 + tag = dx_current_tag();
23717 +int vc_tag_migrate(uint32_t tag)
23719 + return dx_migrate_task(current, tag & 0xFFFF);
23723 diff -NurpP --minimal linux-3.6.9/kernel/vserver/vci_config.h linux-3.6.9-vs2.3.4.4/kernel/vserver/vci_config.h
23724 --- linux-3.6.9/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
23725 +++ linux-3.6.9-vs2.3.4.4/kernel/vserver/vci_config.h 2012-10-04 18:47:00.000000000 +0200
23728 +/* interface version */
23730 +#define VCI_VERSION 0x00020308
23734 + VCI_KCBIT_NO_DYNAMIC = 0,
23736 + VCI_KCBIT_PROC_SECURE = 4,
23737 + /* VCI_KCBIT_HARDCPU = 5, */
23738 + /* VCI_KCBIT_IDLELIMIT = 6, */
23739 + /* VCI_KCBIT_IDLETIME = 7, */
23741 + VCI_KCBIT_COWBL = 8,
23742 + VCI_KCBIT_FULLCOWBL = 9,
23743 + VCI_KCBIT_SPACES = 10,
23744 + VCI_KCBIT_NETV2 = 11,
23745 + VCI_KCBIT_MEMCG = 12,
23747 + VCI_KCBIT_DEBUG = 16,
23748 + VCI_KCBIT_HISTORY = 20,
23749 + VCI_KCBIT_TAGGED = 24,
23750 + VCI_KCBIT_PPTAG = 28,
23752 + VCI_KCBIT_MORE = 31,
23756 +static inline uint32_t vci_kernel_config(void)
23759 + (1 << VCI_KCBIT_NO_DYNAMIC) |
23761 + /* configured features */
23762 +#ifdef CONFIG_VSERVER_PROC_SECURE
23763 + (1 << VCI_KCBIT_PROC_SECURE) |
23765 +#ifdef CONFIG_VSERVER_COWBL
23766 + (1 << VCI_KCBIT_COWBL) |
23767 + (1 << VCI_KCBIT_FULLCOWBL) |
23769 + (1 << VCI_KCBIT_SPACES) |
23770 + (1 << VCI_KCBIT_NETV2) |
23771 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
23772 + (1 << VCI_KCBIT_MEMCG) |
23775 + /* debug options */
23776 +#ifdef CONFIG_VSERVER_DEBUG
23777 + (1 << VCI_KCBIT_DEBUG) |
23779 +#ifdef CONFIG_VSERVER_HISTORY
23780 + (1 << VCI_KCBIT_HISTORY) |
23783 + /* inode context tagging */
23784 +#if defined(CONFIG_TAGGING_NONE)
23785 + (0 << VCI_KCBIT_TAGGED) |
23786 +#elif defined(CONFIG_TAGGING_UID16)
23787 + (1 << VCI_KCBIT_TAGGED) |
23788 +#elif defined(CONFIG_TAGGING_GID16)
23789 + (2 << VCI_KCBIT_TAGGED) |
23790 +#elif defined(CONFIG_TAGGING_ID24)
23791 + (3 << VCI_KCBIT_TAGGED) |
23792 +#elif defined(CONFIG_TAGGING_INTERN)
23793 + (4 << VCI_KCBIT_TAGGED) |
23794 +#elif defined(CONFIG_TAGGING_RUNTIME)
23795 + (5 << VCI_KCBIT_TAGGED) |
23797 + (7 << VCI_KCBIT_TAGGED) |
23799 + (1 << VCI_KCBIT_PPTAG) |
23803 diff -NurpP --minimal linux-3.6.9/mm/memcontrol.c linux-3.6.9-vs2.3.4.4/mm/memcontrol.c
23804 --- linux-3.6.9/mm/memcontrol.c 2012-12-08 01:34:15.000000000 +0100
23805 +++ linux-3.6.9-vs2.3.4.4/mm/memcontrol.c 2012-12-08 01:36:33.000000000 +0100
23806 @@ -885,6 +885,31 @@ struct mem_cgroup *mem_cgroup_from_task(
23807 return mem_cgroup_from_css(task_subsys_state(p, mem_cgroup_subsys_id));
23810 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
23812 + return res_counter_read_u64(&mem->res, member);
23815 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
23817 + return res_counter_read_u64(&mem->memsw, member);
23820 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
23822 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE);
23825 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
23827 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS);
23830 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
23832 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_FILE_MAPPED);
23835 struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
23837 struct mem_cgroup *memcg = NULL;
23838 diff -NurpP --minimal linux-3.6.9/mm/oom_kill.c linux-3.6.9-vs2.3.4.4/mm/oom_kill.c
23839 --- linux-3.6.9/mm/oom_kill.c 2012-10-04 15:27:48.000000000 +0200
23840 +++ linux-3.6.9-vs2.3.4.4/mm/oom_kill.c 2012-10-04 18:53:46.000000000 +0200
23842 #include <linux/freezer.h>
23843 #include <linux/ftrace.h>
23844 #include <linux/ratelimit.h>
23845 +#include <linux/reboot.h>
23846 +#include <linux/vs_context.h>
23848 #define CREATE_TRACE_POINTS
23849 #include <trace/events/oom.h>
23850 @@ -155,11 +157,18 @@ struct task_struct *find_lock_task_mm(st
23851 static bool oom_unkillable_task(struct task_struct *p,
23852 const struct mem_cgroup *memcg, const nodemask_t *nodemask)
23854 - if (is_global_init(p))
23855 + unsigned xid = vx_current_xid();
23857 + /* skip the init task, global and per guest */
23858 + if (task_is_init(p))
23860 if (p->flags & PF_KTHREAD)
23863 + /* skip other guest and host processes if oom in guest */
23864 + if (xid && vx_task_xid(p) != xid)
23867 /* When mem_cgroup_out_of_memory() and p is not member of the group */
23868 if (memcg && !task_in_mem_cgroup(p, memcg))
23870 @@ -472,8 +481,8 @@ void oom_kill_process(struct task_struct
23871 dump_header(p, gfp_mask, order, memcg, nodemask);
23874 - pr_err("%s: Kill process %d (%s) score %d or sacrifice child\n",
23875 - message, task_pid_nr(p), p->comm, points);
23876 + pr_err("%s: Kill process %d:#%u (%s) score %d or sacrifice child\n",
23877 + message, task_pid_nr(p), p->xid, p->comm, points);
23881 @@ -518,8 +527,8 @@ void oom_kill_process(struct task_struct
23883 /* mm cannot safely be dereferenced after task_unlock(victim) */
23885 - pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
23886 - task_pid_nr(victim), victim->comm, K(victim->mm->total_vm),
23887 + pr_err("Killed process %d:#%u (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
23888 + task_pid_nr(victim), victim->xid, victim->comm, K(victim->mm->total_vm),
23889 K(get_mm_counter(victim->mm, MM_ANONPAGES)),
23890 K(get_mm_counter(victim->mm, MM_FILEPAGES)));
23891 task_unlock(victim);
23892 @@ -589,6 +598,8 @@ int unregister_oom_notifier(struct notif
23894 EXPORT_SYMBOL_GPL(unregister_oom_notifier);
23896 +long vs_oom_action(unsigned int);
23899 * Try to acquire the OOM killer lock for the zones in zonelist. Returns zero
23900 * if a parallel OOM killing is already taking place that includes a zone in
23901 @@ -738,7 +749,12 @@ void out_of_memory(struct zonelist *zone
23902 /* Found nothing?!?! Either we hang forever, or we panic. */
23904 dump_header(NULL, gfp_mask, order, NULL, mpol_mask);
23905 - panic("Out of memory and no killable processes...\n");
23907 + /* avoid panic for guest OOM */
23908 + if (current->xid)
23909 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
23911 + panic("Out of memory and no killable processes...\n");
23913 if (PTR_ERR(p) != -1UL) {
23914 oom_kill_process(p, gfp_mask, order, points, totalpages, NULL,
23915 diff -NurpP --minimal linux-3.6.9/mm/page_alloc.c linux-3.6.9-vs2.3.4.4/mm/page_alloc.c
23916 --- linux-3.6.9/mm/page_alloc.c 2012-12-08 01:34:15.000000000 +0100
23917 +++ linux-3.6.9-vs2.3.4.4/mm/page_alloc.c 2012-12-08 01:36:33.000000000 +0100
23919 #include <linux/prefetch.h>
23920 #include <linux/migrate.h>
23921 #include <linux/page-debug-flags.h>
23922 +#include <linux/vs_base.h>
23923 +#include <linux/vs_limit.h>
23925 #include <asm/tlbflush.h>
23926 #include <asm/div64.h>
23927 @@ -2773,6 +2775,9 @@ void si_meminfo(struct sysinfo *val)
23928 val->totalhigh = totalhigh_pages;
23929 val->freehigh = nr_free_highpages();
23930 val->mem_unit = PAGE_SIZE;
23932 + if (vx_flags(VXF_VIRT_MEM, 0))
23933 + vx_vsi_meminfo(val);
23936 EXPORT_SYMBOL(si_meminfo);
23937 @@ -2793,6 +2798,9 @@ void si_meminfo_node(struct sysinfo *val
23940 val->mem_unit = PAGE_SIZE;
23942 + if (vx_flags(VXF_VIRT_MEM, 0))
23943 + vx_vsi_meminfo(val);
23947 diff -NurpP --minimal linux-3.6.9/mm/pgtable-generic.c linux-3.6.9-vs2.3.4.4/mm/pgtable-generic.c
23948 --- linux-3.6.9/mm/pgtable-generic.c 2012-07-22 23:39:47.000000000 +0200
23949 +++ linux-3.6.9-vs2.3.4.4/mm/pgtable-generic.c 2012-10-04 18:47:00.000000000 +0200
23951 * Copyright (C) 2010 Linus Torvalds
23954 +#include <linux/mm.h>
23956 #include <linux/pagemap.h>
23957 #include <asm/tlb.h>
23958 #include <asm-generic/pgtable.h>
23959 diff -NurpP --minimal linux-3.6.9/mm/shmem.c linux-3.6.9-vs2.3.4.4/mm/shmem.c
23960 --- linux-3.6.9/mm/shmem.c 2012-12-08 01:34:15.000000000 +0100
23961 +++ linux-3.6.9-vs2.3.4.4/mm/shmem.c 2012-12-08 01:36:33.000000000 +0100
23962 @@ -1826,7 +1826,7 @@ static int shmem_statfs(struct dentry *d
23964 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
23966 - buf->f_type = TMPFS_MAGIC;
23967 + buf->f_type = TMPFS_SUPER_MAGIC;
23968 buf->f_bsize = PAGE_CACHE_SIZE;
23969 buf->f_namelen = NAME_MAX;
23970 if (sbinfo->max_blocks) {
23971 @@ -2644,7 +2644,7 @@ int shmem_fill_super(struct super_block
23972 sb->s_maxbytes = MAX_LFS_FILESIZE;
23973 sb->s_blocksize = PAGE_CACHE_SIZE;
23974 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
23975 - sb->s_magic = TMPFS_MAGIC;
23976 + sb->s_magic = TMPFS_SUPER_MAGIC;
23977 sb->s_op = &shmem_ops;
23978 sb->s_time_gran = 1;
23979 #ifdef CONFIG_TMPFS_XATTR
23980 diff -NurpP --minimal linux-3.6.9/mm/slab.c linux-3.6.9-vs2.3.4.4/mm/slab.c
23981 --- linux-3.6.9/mm/slab.c 2012-12-08 01:34:15.000000000 +0100
23982 +++ linux-3.6.9-vs2.3.4.4/mm/slab.c 2012-11-06 18:43:41.000000000 +0100
23983 @@ -445,6 +445,8 @@ static void kmem_list3_init(struct kmem_
23984 #define STATS_INC_FREEMISS(x) do { } while (0)
23987 +#include "slab_vs.h"
23992 @@ -3539,6 +3541,7 @@ retry:
23994 obj = slab_get_obj(cachep, slabp, nodeid);
23995 check_slabp(cachep, slabp);
23996 + vx_slab_alloc(cachep, flags);
23997 l3->free_objects--;
23998 /* move slabp to correct slabp list: */
23999 list_del(&slabp->list);
24000 @@ -3616,6 +3619,7 @@ __cache_alloc_node(struct kmem_cache *ca
24001 /* ___cache_alloc_node can fall back to other nodes */
24002 ptr = ____cache_alloc_node(cachep, flags, nodeid);
24004 + vx_slab_alloc(cachep, flags);
24005 local_irq_restore(save_flags);
24006 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
24007 kmemleak_alloc_recursive(ptr, cachep->object_size, 1, cachep->flags,
24008 @@ -3806,6 +3810,7 @@ static inline void __cache_free(struct k
24010 kmemleak_free_recursive(objp, cachep->flags);
24011 objp = cache_free_debugcheck(cachep, objp, caller);
24012 + vx_slab_free(cachep);
24014 kmemcheck_slab_free(cachep, objp, cachep->object_size);
24016 diff -NurpP --minimal linux-3.6.9/mm/slab_vs.h linux-3.6.9-vs2.3.4.4/mm/slab_vs.h
24017 --- linux-3.6.9/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
24018 +++ linux-3.6.9-vs2.3.4.4/mm/slab_vs.h 2012-10-09 16:28:11.000000000 +0200
24021 +#include <linux/vserver/context.h>
24023 +#include <linux/vs_context.h>
24026 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
24028 + int what = gfp_zone(cachep->allocflags);
24029 + struct vx_info *vxi = current_vx_info();
24034 + atomic_add(cachep->size, &vxi->cacct.slab[what]);
24038 +void vx_slab_free(struct kmem_cache *cachep)
24040 + int what = gfp_zone(cachep->allocflags);
24041 + struct vx_info *vxi = current_vx_info();
24046 + atomic_sub(cachep->size, &vxi->cacct.slab[what]);
24049 diff -NurpP --minimal linux-3.6.9/mm/swapfile.c linux-3.6.9-vs2.3.4.4/mm/swapfile.c
24050 --- linux-3.6.9/mm/swapfile.c 2012-10-04 15:27:48.000000000 +0200
24051 +++ linux-3.6.9-vs2.3.4.4/mm/swapfile.c 2012-10-04 18:47:00.000000000 +0200
24053 #include <asm/tlbflush.h>
24054 #include <linux/swapops.h>
24055 #include <linux/page_cgroup.h>
24056 +#include <linux/vs_base.h>
24058 static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
24060 @@ -1686,6 +1687,16 @@ static int swap_show(struct seq_file *sw
24062 if (si == SEQ_START_TOKEN) {
24063 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
24064 + if (vx_flags(VXF_VIRT_MEM, 0)) {
24065 + struct sysinfo si;
24067 + vx_vsi_swapinfo(&si);
24068 + if (si.totalswap < (1 << 10))
24070 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
24071 + "hdv0", "partition", si.totalswap >> 10,
24072 + (si.totalswap - si.freeswap) >> 10, -1);
24077 @@ -2113,6 +2124,8 @@ void si_swapinfo(struct sysinfo *val)
24078 val->freeswap = nr_swap_pages + nr_to_be_unused;
24079 val->totalswap = total_swap_pages + nr_to_be_unused;
24080 spin_unlock(&swap_lock);
24081 + if (vx_flags(VXF_VIRT_MEM, 0))
24082 + vx_vsi_swapinfo(val);
24086 diff -NurpP --minimal linux-3.6.9/net/bridge/br_multicast.c linux-3.6.9-vs2.3.4.4/net/bridge/br_multicast.c
24087 --- linux-3.6.9/net/bridge/br_multicast.c 2012-10-04 15:27:49.000000000 +0200
24088 +++ linux-3.6.9-vs2.3.4.4/net/bridge/br_multicast.c 2012-10-04 18:47:00.000000000 +0200
24089 @@ -447,7 +447,7 @@ static struct sk_buff *br_ip6_multicast_
24090 ip6h->hop_limit = 1;
24091 ipv6_addr_set(&ip6h->daddr, htonl(0xff020000), 0, 0, htonl(1));
24092 if (ipv6_dev_get_saddr(dev_net(br->dev), br->dev, &ip6h->daddr, 0,
24094 + &ip6h->saddr, NULL)) {
24098 diff -NurpP --minimal linux-3.6.9/net/core/dev.c linux-3.6.9-vs2.3.4.4/net/core/dev.c
24099 --- linux-3.6.9/net/core/dev.c 2012-12-08 01:34:15.000000000 +0100
24100 +++ linux-3.6.9-vs2.3.4.4/net/core/dev.c 2012-12-08 01:36:33.000000000 +0100
24101 @@ -126,6 +126,7 @@
24102 #include <linux/in.h>
24103 #include <linux/jhash.h>
24104 #include <linux/random.h>
24105 +#include <linux/vs_inet.h>
24106 #include <trace/events/napi.h>
24107 #include <trace/events/net.h>
24108 #include <trace/events/skb.h>
24109 @@ -620,7 +621,8 @@ struct net_device *__dev_get_by_name(str
24110 struct hlist_head *head = dev_name_hash(net, name);
24112 hlist_for_each_entry(dev, p, head, name_hlist)
24113 - if (!strncmp(dev->name, name, IFNAMSIZ))
24114 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24115 + nx_dev_visible(current_nx_info(), dev))
24119 @@ -646,7 +648,8 @@ struct net_device *dev_get_by_name_rcu(s
24120 struct hlist_head *head = dev_name_hash(net, name);
24122 hlist_for_each_entry_rcu(dev, p, head, name_hlist)
24123 - if (!strncmp(dev->name, name, IFNAMSIZ))
24124 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24125 + nx_dev_visible(current_nx_info(), dev))
24129 @@ -697,7 +700,8 @@ struct net_device *__dev_get_by_index(st
24130 struct hlist_head *head = dev_index_hash(net, ifindex);
24132 hlist_for_each_entry(dev, p, head, index_hlist)
24133 - if (dev->ifindex == ifindex)
24134 + if ((dev->ifindex == ifindex) &&
24135 + nx_dev_visible(current_nx_info(), dev))
24139 @@ -715,7 +719,7 @@ EXPORT_SYMBOL(__dev_get_by_index);
24140 * about locking. The caller must hold RCU lock.
24143 -struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
24144 +struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex)
24146 struct hlist_node *p;
24147 struct net_device *dev;
24148 @@ -727,6 +731,16 @@ struct net_device *dev_get_by_index_rcu(
24152 +EXPORT_SYMBOL(dev_get_by_index_real_rcu);
24154 +struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
24156 + struct net_device *dev = dev_get_by_index_real_rcu(net, ifindex);
24158 + if (nx_dev_visible(current_nx_info(), dev))
24162 EXPORT_SYMBOL(dev_get_by_index_rcu);
24165 @@ -775,7 +789,8 @@ struct net_device *dev_getbyhwaddr_rcu(s
24167 for_each_netdev_rcu(net, dev)
24168 if (dev->type == type &&
24169 - !memcmp(dev->dev_addr, ha, dev->addr_len))
24170 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
24171 + nx_dev_visible(current_nx_info(), dev))
24175 @@ -787,9 +802,11 @@ struct net_device *__dev_getfirstbyhwtyp
24176 struct net_device *dev;
24179 - for_each_netdev(net, dev)
24180 - if (dev->type == type)
24181 + for_each_netdev(net, dev) {
24182 + if ((dev->type == type) &&
24183 + nx_dev_visible(current_nx_info(), dev))
24189 @@ -907,6 +924,8 @@ static int __dev_alloc_name(struct net *
24191 if (i < 0 || i >= max_netdevices)
24193 + if (!nx_dev_visible(current_nx_info(), d))
24196 /* avoid cases where sscanf is not exact inverse of printf */
24197 snprintf(buf, IFNAMSIZ, name, i);
24198 @@ -4076,6 +4095,8 @@ static int dev_ifconf(struct net *net, c
24201 for_each_netdev(net, dev) {
24202 + if (!nx_dev_visible(current_nx_info(), dev))
24204 for (i = 0; i < NPROTO; i++) {
24205 if (gifconf_list[i]) {
24207 @@ -4178,6 +4199,10 @@ static void dev_seq_printf_stats(struct
24208 struct rtnl_link_stats64 temp;
24209 const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
24211 + /* device visible inside network context? */
24212 + if (!nx_dev_visible(current_nx_info(), dev))
24215 seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
24216 "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
24217 dev->name, stats->rx_bytes, stats->rx_packets,
24218 diff -NurpP --minimal linux-3.6.9/net/core/rtnetlink.c linux-3.6.9-vs2.3.4.4/net/core/rtnetlink.c
24219 --- linux-3.6.9/net/core/rtnetlink.c 2012-10-04 15:27:49.000000000 +0200
24220 +++ linux-3.6.9-vs2.3.4.4/net/core/rtnetlink.c 2012-10-04 18:47:00.000000000 +0200
24221 @@ -1080,6 +1080,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
24222 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
24225 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
24227 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
24228 NETLINK_CB(cb->skb).pid,
24229 cb->nlh->nlmsg_seq, 0,
24230 @@ -1969,6 +1971,9 @@ void rtmsg_ifinfo(int type, struct net_d
24231 int err = -ENOBUFS;
24232 size_t if_info_size;
24234 + if (!nx_dev_visible(current_nx_info(), dev))
24237 skb = nlmsg_new((if_info_size = if_nlmsg_size(dev, 0)), GFP_KERNEL);
24240 diff -NurpP --minimal linux-3.6.9/net/core/sock.c linux-3.6.9-vs2.3.4.4/net/core/sock.c
24241 --- linux-3.6.9/net/core/sock.c 2012-10-04 15:27:49.000000000 +0200
24242 +++ linux-3.6.9-vs2.3.4.4/net/core/sock.c 2012-10-04 18:47:00.000000000 +0200
24243 @@ -132,6 +132,10 @@
24244 #include <net/netprio_cgroup.h>
24246 #include <linux/filter.h>
24247 +#include <linux/vs_socket.h>
24248 +#include <linux/vs_limit.h>
24249 +#include <linux/vs_context.h>
24250 +#include <linux/vs_network.h>
24252 #include <trace/events/sock.h>
24254 @@ -1194,6 +1198,8 @@ static struct sock *sk_prot_alloc(struct
24256 sk_tx_queue_clear(sk);
24258 + sock_vx_init(sk);
24259 + sock_nx_init(sk);
24263 @@ -1302,6 +1308,11 @@ static void __sk_free(struct sock *sk)
24264 put_cred(sk->sk_peer_cred);
24265 put_pid(sk->sk_peer_pid);
24266 put_net(sock_net(sk));
24268 + clr_vx_info(&sk->sk_vx_info);
24270 + clr_nx_info(&sk->sk_nx_info);
24272 sk_prot_free(sk->sk_prot_creator, sk);
24275 @@ -1362,6 +1373,8 @@ struct sock *sk_clone_lock(const struct
24278 get_net(sock_net(newsk));
24279 + sock_vx_init(newsk);
24280 + sock_nx_init(newsk);
24281 sk_node_init(&newsk->sk_node);
24282 sock_lock_init(newsk);
24283 bh_lock_sock(newsk);
24284 @@ -1418,6 +1431,12 @@ struct sock *sk_clone_lock(const struct
24286 atomic_set(&newsk->sk_refcnt, 2);
24288 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
24289 + newsk->sk_xid = sk->sk_xid;
24290 + vx_sock_inc(newsk);
24291 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
24292 + newsk->sk_nid = sk->sk_nid;
24295 * Increment the counter in the same struct proto as the master
24296 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
24297 @@ -2187,6 +2206,12 @@ void sock_init_data(struct socket *sock,
24299 sk->sk_stamp = ktime_set(-1L, 0);
24301 + set_vx_info(&sk->sk_vx_info, current_vx_info());
24302 + sk->sk_xid = vx_current_xid();
24304 + set_nx_info(&sk->sk_nx_info, current_nx_info());
24305 + sk->sk_nid = nx_current_nid();
24308 * Before updating sk_refcnt, we must commit prior changes to memory
24309 * (Documentation/RCU/rculist_nulls.txt for details)
24310 diff -NurpP --minimal linux-3.6.9/net/ipv4/af_inet.c linux-3.6.9-vs2.3.4.4/net/ipv4/af_inet.c
24311 --- linux-3.6.9/net/ipv4/af_inet.c 2012-10-04 15:27:49.000000000 +0200
24312 +++ linux-3.6.9-vs2.3.4.4/net/ipv4/af_inet.c 2012-10-04 18:47:00.000000000 +0200
24313 @@ -118,6 +118,7 @@
24314 #ifdef CONFIG_IP_MROUTE
24315 #include <linux/mroute.h>
24317 +#include <linux/vs_limit.h>
24320 /* The inetsw table contains everything that inet_create needs to
24321 @@ -326,9 +327,13 @@ lookup_protocol:
24325 + if ((protocol == IPPROTO_ICMP) &&
24326 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
24329 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
24330 goto out_rcu_unlock;
24333 err = -EAFNOSUPPORT;
24334 if (!inet_netns_ok(net, protocol))
24335 goto out_rcu_unlock;
24336 @@ -453,6 +458,7 @@ int inet_bind(struct socket *sock, struc
24337 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
24338 struct sock *sk = sock->sk;
24339 struct inet_sock *inet = inet_sk(sk);
24340 + struct nx_v4_sock_addr nsa;
24341 unsigned short snum;
24344 @@ -476,7 +482,11 @@ int inet_bind(struct socket *sock, struc
24348 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
24349 + err = v4_map_sock_addr(inet, addr, &nsa);
24353 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
24355 /* Not specified by any standard per-se, however it breaks too
24356 * many applications when removed. It is unfortunate since
24357 @@ -488,7 +498,7 @@ int inet_bind(struct socket *sock, struc
24358 err = -EADDRNOTAVAIL;
24359 if (!sysctl_ip_nonlocal_bind &&
24360 !(inet->freebind || inet->transparent) &&
24361 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
24362 + nsa.saddr != htonl(INADDR_ANY) &&
24363 chk_addr_ret != RTN_LOCAL &&
24364 chk_addr_ret != RTN_MULTICAST &&
24365 chk_addr_ret != RTN_BROADCAST)
24366 @@ -513,7 +523,7 @@ int inet_bind(struct socket *sock, struc
24367 if (sk->sk_state != TCP_CLOSE || inet->inet_num)
24368 goto out_release_sock;
24370 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24371 + v4_set_sock_addr(inet, &nsa);
24372 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24373 inet->inet_saddr = 0; /* Use device */
24375 @@ -731,11 +741,13 @@ int inet_getname(struct socket *sock, st
24378 sin->sin_port = inet->inet_dport;
24379 - sin->sin_addr.s_addr = inet->inet_daddr;
24380 + sin->sin_addr.s_addr =
24381 + nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
24383 __be32 addr = inet->inet_rcv_saddr;
24385 addr = inet->inet_saddr;
24386 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
24387 sin->sin_port = inet->inet_sport;
24388 sin->sin_addr.s_addr = addr;
24390 diff -NurpP --minimal linux-3.6.9/net/ipv4/arp.c linux-3.6.9-vs2.3.4.4/net/ipv4/arp.c
24391 --- linux-3.6.9/net/ipv4/arp.c 2012-10-04 15:27:49.000000000 +0200
24392 +++ linux-3.6.9-vs2.3.4.4/net/ipv4/arp.c 2012-10-04 18:47:00.000000000 +0200
24393 @@ -1318,6 +1318,7 @@ static void arp_format_neigh_entry(struc
24394 struct net_device *dev = n->dev;
24395 int hatype = dev->type;
24397 + /* FIXME: check for network context */
24398 read_lock(&n->lock);
24399 /* Convert hardware address to XX:XX:XX:XX ... form. */
24400 #if IS_ENABLED(CONFIG_AX25)
24401 @@ -1349,6 +1350,7 @@ static void arp_format_pneigh_entry(stru
24402 int hatype = dev ? dev->type : 0;
24405 + /* FIXME: check for network context */
24406 sprintf(tbuf, "%pI4", n->key);
24407 seq_printf(seq, "%-16s 0x%-10x0x%-10x%s * %s\n",
24408 tbuf, hatype, ATF_PUBL | ATF_PERM, "00:00:00:00:00:00",
24409 diff -NurpP --minimal linux-3.6.9/net/ipv4/devinet.c linux-3.6.9-vs2.3.4.4/net/ipv4/devinet.c
24410 --- linux-3.6.9/net/ipv4/devinet.c 2012-10-04 15:27:49.000000000 +0200
24411 +++ linux-3.6.9-vs2.3.4.4/net/ipv4/devinet.c 2012-10-04 18:47:00.000000000 +0200
24412 @@ -516,6 +516,7 @@ struct in_device *inetdev_by_index(struc
24414 EXPORT_SYMBOL(inetdev_by_index);
24417 /* Called only from RTNL semaphored context. No locks. */
24419 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
24420 @@ -757,6 +758,8 @@ int devinet_ioctl(struct net *net, unsig
24422 in_dev = __in_dev_get_rtnl(dev);
24424 + struct nx_info *nxi = current_nx_info();
24426 if (tryaddrmatch) {
24427 /* Matthias Andree */
24428 /* compare label and address (4.4BSD style) */
24429 @@ -765,6 +768,8 @@ int devinet_ioctl(struct net *net, unsig
24430 This is checked above. */
24431 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24432 ifap = &ifa->ifa_next) {
24433 + if (!nx_v4_ifa_visible(nxi, ifa))
24435 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
24436 sin_orig.sin_addr.s_addr ==
24438 @@ -777,9 +782,12 @@ int devinet_ioctl(struct net *net, unsig
24439 comparing just the label */
24441 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24442 - ifap = &ifa->ifa_next)
24443 + ifap = &ifa->ifa_next) {
24444 + if (!nx_v4_ifa_visible(nxi, ifa))
24446 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
24452 @@ -932,6 +940,8 @@ static int inet_gifconf(struct net_devic
24455 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
24456 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
24459 done += sizeof(ifr);
24461 @@ -1291,6 +1301,7 @@ static int inet_dump_ifaddr(struct sk_bu
24462 struct net_device *dev;
24463 struct in_device *in_dev;
24464 struct in_ifaddr *ifa;
24465 + struct sock *sk = skb->sk;
24466 struct hlist_head *head;
24467 struct hlist_node *node;
24469 @@ -1313,6 +1324,8 @@ static int inet_dump_ifaddr(struct sk_bu
24471 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
24472 ifa = ifa->ifa_next, ip_idx++) {
24473 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
24475 if (ip_idx < s_ip_idx)
24477 if (inet_fill_ifaddr(skb, ifa,
24478 diff -NurpP --minimal linux-3.6.9/net/ipv4/fib_trie.c linux-3.6.9-vs2.3.4.4/net/ipv4/fib_trie.c
24479 --- linux-3.6.9/net/ipv4/fib_trie.c 2012-10-04 15:27:49.000000000 +0200
24480 +++ linux-3.6.9-vs2.3.4.4/net/ipv4/fib_trie.c 2012-10-04 18:47:00.000000000 +0200
24481 @@ -2554,6 +2554,7 @@ static int fib_route_seq_show(struct seq
24482 || fa->fa_type == RTN_MULTICAST)
24485 + /* FIXME: check for network context? */
24488 "%s\t%08X\t%08X\t%04X\t%d\t%u\t"
24489 diff -NurpP --minimal linux-3.6.9/net/ipv4/inet_connection_sock.c linux-3.6.9-vs2.3.4.4/net/ipv4/inet_connection_sock.c
24490 --- linux-3.6.9/net/ipv4/inet_connection_sock.c 2012-12-08 01:34:15.000000000 +0100
24491 +++ linux-3.6.9-vs2.3.4.4/net/ipv4/inet_connection_sock.c 2012-11-06 18:43:41.000000000 +0100
24492 @@ -53,6 +53,37 @@ void inet_get_local_port_range(int *low,
24494 EXPORT_SYMBOL(inet_get_local_port_range);
24496 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
24498 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1),
24499 + sk2_rcv_saddr = sk_rcv_saddr(sk2);
24501 + if (inet_v6_ipv6only(sk2))
24504 + if (sk1_rcv_saddr &&
24506 + sk1_rcv_saddr == sk2_rcv_saddr)
24509 + if (sk1_rcv_saddr &&
24510 + !sk2_rcv_saddr &&
24511 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
24514 + if (sk2_rcv_saddr &&
24515 + !sk1_rcv_saddr &&
24516 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
24519 + if (!sk1_rcv_saddr &&
24520 + !sk2_rcv_saddr &&
24521 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
24527 int inet_csk_bind_conflict(const struct sock *sk,
24528 const struct inet_bind_bucket *tb, bool relax)
24530 @@ -75,9 +106,7 @@ int inet_csk_bind_conflict(const struct
24531 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
24532 if (!reuse || !sk2->sk_reuse ||
24533 sk2->sk_state == TCP_LISTEN) {
24534 - const __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
24535 - if (!sk2_rcv_saddr || !sk_rcv_saddr(sk) ||
24536 - sk2_rcv_saddr == sk_rcv_saddr(sk))
24537 + if (ipv4_rcv_saddr_equal(sk, sk2))
24540 if (!relax && reuse && sk2->sk_reuse &&
24541 diff -NurpP --minimal linux-3.6.9/net/ipv4/inet_diag.c linux-3.6.9-vs2.3.4.4/net/ipv4/inet_diag.c
24542 --- linux-3.6.9/net/ipv4/inet_diag.c 2012-12-08 01:34:15.000000000 +0100
24543 +++ linux-3.6.9-vs2.3.4.4/net/ipv4/inet_diag.c 2012-12-08 01:36:33.000000000 +0100
24546 #include <linux/inet.h>
24547 #include <linux/stddef.h>
24548 +#include <linux/vs_network.h>
24549 +#include <linux/vs_inet.h>
24551 #include <linux/inet_diag.h>
24552 #include <linux/sock_diag.h>
24553 @@ -101,8 +103,10 @@ int inet_sk_diag_fill(struct sock *sk, s
24555 r->id.idiag_sport = inet->inet_sport;
24556 r->id.idiag_dport = inet->inet_dport;
24557 - r->id.idiag_src[0] = inet->inet_rcv_saddr;
24558 - r->id.idiag_dst[0] = inet->inet_daddr;
24559 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
24560 + inet->inet_rcv_saddr);
24561 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
24562 + inet->inet_daddr);
24564 /* IPv6 dual-stack sockets use inet->tos for IPv4 connections,
24565 * hence this needs to be included regardless of socket family.
24566 @@ -233,8 +237,8 @@ static int inet_twsk_diag_fill(struct in
24567 sock_diag_save_cookie(tw, r->id.idiag_cookie);
24568 r->id.idiag_sport = tw->tw_sport;
24569 r->id.idiag_dport = tw->tw_dport;
24570 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
24571 - r->id.idiag_dst[0] = tw->tw_daddr;
24572 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
24573 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
24574 r->idiag_state = tw->tw_substate;
24575 r->idiag_timer = 3;
24576 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
24577 @@ -276,12 +280,14 @@ int inet_diag_dump_one_icsk(struct inet_
24580 if (req->sdiag_family == AF_INET) {
24581 + /* TODO: lback */
24582 sk = inet_lookup(net, hashinfo, req->id.idiag_dst[0],
24583 req->id.idiag_dport, req->id.idiag_src[0],
24584 req->id.idiag_sport, req->id.idiag_if);
24586 #if IS_ENABLED(CONFIG_IPV6)
24587 else if (req->sdiag_family == AF_INET6) {
24588 + /* TODO: lback */
24589 sk = inet6_lookup(net, hashinfo,
24590 (struct in6_addr *)req->id.idiag_dst,
24591 req->id.idiag_dport,
24592 @@ -476,6 +482,7 @@ int inet_diag_bc_sk(const struct nlattr
24596 + /* TODO: lback */
24597 entry.saddr = &inet->inet_rcv_saddr;
24598 entry.daddr = &inet->inet_daddr;
24600 @@ -574,6 +581,7 @@ static int inet_twsk_diag_dump(struct in
24604 + /* TODO: lback */
24605 entry.saddr = &tw->tw_rcv_saddr;
24606 entry.daddr = &tw->tw_daddr;
24608 @@ -620,8 +628,8 @@ static int inet_diag_fill_req(struct sk_
24610 r->id.idiag_sport = inet->inet_sport;
24611 r->id.idiag_dport = ireq->rmt_port;
24612 - r->id.idiag_src[0] = ireq->loc_addr;
24613 - r->id.idiag_dst[0] = ireq->rmt_addr;
24614 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
24615 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
24616 r->idiag_expires = jiffies_to_msecs(tmo);
24617 r->idiag_rqueue = 0;
24618 r->idiag_wqueue = 0;
24619 @@ -683,6 +691,7 @@ static int inet_diag_dump_reqs(struct sk
24623 + /* TODO: lback */
24625 #if IS_ENABLED(CONFIG_IPV6)
24626 (entry.family == AF_INET6) ?
24627 @@ -748,6 +757,8 @@ void inet_diag_dump_icsk(struct inet_has
24628 if (!net_eq(sock_net(sk), net))
24631 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24636 @@ -820,6 +831,8 @@ skip_listen_ht:
24638 if (!net_eq(sock_net(sk), net))
24640 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24644 if (!(r->idiag_states & (1 << sk->sk_state)))
24645 @@ -848,7 +861,8 @@ next_normal:
24647 if (!net_eq(twsk_net(tw), net))
24650 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
24654 if (r->sdiag_family != AF_UNSPEC &&
24655 diff -NurpP --minimal linux-3.6.9/net/ipv4/inet_hashtables.c linux-3.6.9-vs2.3.4.4/net/ipv4/inet_hashtables.c
24656 --- linux-3.6.9/net/ipv4/inet_hashtables.c 2012-07-22 23:39:48.000000000 +0200
24657 +++ linux-3.6.9-vs2.3.4.4/net/ipv4/inet_hashtables.c 2012-10-04 18:47:00.000000000 +0200
24659 #include <net/inet_connection_sock.h>
24660 #include <net/inet_hashtables.h>
24661 #include <net/secure_seq.h>
24662 +#include <net/route.h>
24663 #include <net/ip.h>
24666 @@ -156,6 +157,11 @@ static inline int compute_score(struct s
24667 if (rcv_saddr != daddr)
24671 + /* block non nx_info ips */
24672 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
24673 + daddr, NXA_MASK_BIND))
24676 if (sk->sk_bound_dev_if) {
24677 if (sk->sk_bound_dev_if != dif)
24678 @@ -173,7 +179,6 @@ static inline int compute_score(struct s
24679 * wildcarded during the search since they can never be otherwise.
24683 struct sock *__inet_lookup_listener(struct net *net,
24684 struct inet_hashinfo *hashinfo,
24685 const __be32 daddr, const unsigned short hnum,
24686 @@ -196,6 +201,7 @@ begin:
24692 * if the nulls value we got at the end of this lookup is
24693 * not the expected one, we must restart lookup.
24694 diff -NurpP --minimal linux-3.6.9/net/ipv4/netfilter/nf_nat_helper.c linux-3.6.9-vs2.3.4.4/net/ipv4/netfilter/nf_nat_helper.c
24695 --- linux-3.6.9/net/ipv4/netfilter/nf_nat_helper.c 2012-10-04 15:27:50.000000000 +0200
24696 +++ linux-3.6.9-vs2.3.4.4/net/ipv4/netfilter/nf_nat_helper.c 2012-10-04 18:47:00.000000000 +0200
24698 #include <net/route.h>
24700 #include <linux/netfilter_ipv4.h>
24701 +#include <net/route.h>
24702 #include <net/netfilter/nf_conntrack.h>
24703 #include <net/netfilter/nf_conntrack_helper.h>
24704 #include <net/netfilter/nf_conntrack_ecache.h>
24705 diff -NurpP --minimal linux-3.6.9/net/ipv4/netfilter.c linux-3.6.9-vs2.3.4.4/net/ipv4/netfilter.c
24706 --- linux-3.6.9/net/ipv4/netfilter.c 2012-07-22 23:39:48.000000000 +0200
24707 +++ linux-3.6.9-vs2.3.4.4/net/ipv4/netfilter.c 2012-10-04 18:47:00.000000000 +0200
24709 #include <linux/skbuff.h>
24710 #include <linux/gfp.h>
24711 #include <linux/export.h>
24712 -#include <net/route.h>
24713 +// #include <net/route.h>
24714 #include <net/xfrm.h>
24715 #include <net/ip.h>
24716 #include <net/netfilter/nf_queue.h>
24717 diff -NurpP --minimal linux-3.6.9/net/ipv4/raw.c linux-3.6.9-vs2.3.4.4/net/ipv4/raw.c
24718 --- linux-3.6.9/net/ipv4/raw.c 2012-10-04 15:27:50.000000000 +0200
24719 +++ linux-3.6.9-vs2.3.4.4/net/ipv4/raw.c 2012-10-04 18:47:00.000000000 +0200
24720 @@ -118,7 +118,7 @@ static struct sock *__raw_v4_lookup(stru
24722 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
24723 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
24724 - !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
24725 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
24726 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
24727 goto found; /* gotcha */
24729 @@ -397,6 +397,12 @@ static int raw_send_hdrinc(struct sock *
24730 icmp_out_count(net, ((struct icmphdr *)
24731 skb_transport_header(skb))->type);
24734 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
24735 + sk->sk_nx_info &&
24736 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
24739 err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL,
24740 rt->dst.dev, dst_output);
24742 @@ -582,6 +588,16 @@ static int raw_sendmsg(struct kiocb *ioc
24746 + if (sk->sk_nx_info) {
24747 + rt = ip_v4_find_src(sock_net(sk), sk->sk_nx_info, &fl4);
24748 + if (IS_ERR(rt)) {
24749 + err = PTR_ERR(rt);
24756 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4));
24757 rt = ip_route_output_flow(sock_net(sk), &fl4, sk);
24759 @@ -658,17 +674,19 @@ static int raw_bind(struct sock *sk, str
24761 struct inet_sock *inet = inet_sk(sk);
24762 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
24763 + struct nx_v4_sock_addr nsa = { 0 };
24767 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
24769 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
24770 + v4_map_sock_addr(inet, addr, &nsa);
24771 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
24772 ret = -EADDRNOTAVAIL;
24773 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
24774 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
24775 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
24777 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24778 + v4_set_sock_addr(inet, &nsa);
24779 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24780 inet->inet_saddr = 0; /* Use device */
24782 @@ -720,7 +738,8 @@ static int raw_recvmsg(struct kiocb *ioc
24783 /* Copy the address. */
24785 sin->sin_family = AF_INET;
24786 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
24787 + sin->sin_addr.s_addr =
24788 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
24790 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
24792 @@ -916,7 +935,8 @@ static struct sock *raw_get_first(struct
24793 struct hlist_node *node;
24795 sk_for_each(sk, node, &state->h->ht[state->bucket])
24796 - if (sock_net(sk) == seq_file_net(seq))
24797 + if ((sock_net(sk) == seq_file_net(seq)) &&
24798 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24802 @@ -932,7 +952,8 @@ static struct sock *raw_get_next(struct
24806 - } while (sk && sock_net(sk) != seq_file_net(seq));
24807 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
24808 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
24810 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
24811 sk = sk_head(&state->h->ht[state->bucket]);
24812 diff -NurpP --minimal linux-3.6.9/net/ipv4/route.c linux-3.6.9-vs2.3.4.4/net/ipv4/route.c
24813 --- linux-3.6.9/net/ipv4/route.c 2012-12-08 01:34:15.000000000 +0100
24814 +++ linux-3.6.9-vs2.3.4.4/net/ipv4/route.c 2012-12-08 01:36:33.000000000 +0100
24815 @@ -1949,7 +1949,7 @@ struct rtable *__ip_route_output_key(str
24818 if (fl4->flowi4_oif) {
24819 - dev_out = dev_get_by_index_rcu(net, fl4->flowi4_oif);
24820 + dev_out = dev_get_by_index_real_rcu(net, fl4->flowi4_oif);
24821 rth = ERR_PTR(-ENODEV);
24822 if (dev_out == NULL)
24824 diff -NurpP --minimal linux-3.6.9/net/ipv4/tcp.c linux-3.6.9-vs2.3.4.4/net/ipv4/tcp.c
24825 --- linux-3.6.9/net/ipv4/tcp.c 2012-12-08 01:34:16.000000000 +0100
24826 +++ linux-3.6.9-vs2.3.4.4/net/ipv4/tcp.c 2012-12-08 01:36:33.000000000 +0100
24827 @@ -268,6 +268,7 @@
24828 #include <linux/crypto.h>
24829 #include <linux/time.h>
24830 #include <linux/slab.h>
24831 +#include <linux/in.h>
24833 #include <net/icmp.h>
24834 #include <net/inet_common.h>
24835 diff -NurpP --minimal linux-3.6.9/net/ipv4/tcp_ipv4.c linux-3.6.9-vs2.3.4.4/net/ipv4/tcp_ipv4.c
24836 --- linux-3.6.9/net/ipv4/tcp_ipv4.c 2012-12-08 01:34:16.000000000 +0100
24837 +++ linux-3.6.9-vs2.3.4.4/net/ipv4/tcp_ipv4.c 2012-11-06 18:43:41.000000000 +0100
24838 @@ -2034,6 +2034,12 @@ static void *listening_get_next(struct s
24839 req = req->dl_next;
24842 + vxdprintk(VXD_CBIT(net, 6),
24843 + "sk,req: %p [#%d] (from %d)", req->sk,
24844 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
24846 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
24848 if (req->rsk_ops->family == st->family) {
24851 @@ -2058,6 +2064,10 @@ get_req:
24854 sk_nulls_for_each_from(sk, node) {
24855 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
24856 + sk, sk->sk_nid, nx_current_nid());
24857 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24859 if (!net_eq(sock_net(sk), net))
24861 if (sk->sk_family == st->family) {
24862 @@ -2134,6 +2144,11 @@ static void *established_get_first(struc
24864 spin_lock_bh(lock);
24865 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
24866 + vxdprintk(VXD_CBIT(net, 6),
24867 + "sk,egf: %p [#%d] (from %d)",
24868 + sk, sk->sk_nid, nx_current_nid());
24869 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24871 if (sk->sk_family != st->family ||
24872 !net_eq(sock_net(sk), net)) {
24874 @@ -2144,6 +2159,11 @@ static void *established_get_first(struc
24875 st->state = TCP_SEQ_STATE_TIME_WAIT;
24876 inet_twsk_for_each(tw, node,
24877 &tcp_hashinfo.ehash[st->bucket].twchain) {
24878 + vxdprintk(VXD_CBIT(net, 6),
24879 + "tw: %p [#%d] (from %d)",
24880 + tw, tw->tw_nid, nx_current_nid());
24881 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
24883 if (tw->tw_family != st->family ||
24884 !net_eq(twsk_net(tw), net)) {
24886 @@ -2173,7 +2193,9 @@ static void *established_get_next(struct
24890 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
24891 + while (tw && (tw->tw_family != st->family ||
24892 + !net_eq(twsk_net(tw), net) ||
24893 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
24897 @@ -2197,6 +2219,11 @@ get_tw:
24898 sk = sk_nulls_next(sk);
24900 sk_nulls_for_each_from(sk, node) {
24901 + vxdprintk(VXD_CBIT(net, 6),
24902 + "sk,egn: %p [#%d] (from %d)",
24903 + sk, sk->sk_nid, nx_current_nid());
24904 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24906 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
24909 @@ -2402,9 +2429,9 @@ static void get_openreq4(const struct so
24910 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
24911 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %pK%n",
24914 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
24915 ntohs(inet_sk(sk)->inet_sport),
24917 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
24918 ntohs(ireq->rmt_port),
24920 0, 0, /* could print option size, but that is af dependent. */
24921 @@ -2426,8 +2453,8 @@ static void get_tcp4_sock(struct sock *s
24922 const struct tcp_sock *tp = tcp_sk(sk);
24923 const struct inet_connection_sock *icsk = inet_csk(sk);
24924 const struct inet_sock *inet = inet_sk(sk);
24925 - __be32 dest = inet->inet_daddr;
24926 - __be32 src = inet->inet_rcv_saddr;
24927 + __be32 dest = nx_map_sock_lback(current_nx_info(), inet->inet_daddr);
24928 + __be32 src = nx_map_sock_lback(current_nx_info(), inet->inet_rcv_saddr);
24929 __u16 destp = ntohs(inet->inet_dport);
24930 __u16 srcp = ntohs(inet->inet_sport);
24932 @@ -2484,8 +2511,8 @@ static void get_timewait4_sock(const str
24936 - dest = tw->tw_daddr;
24937 - src = tw->tw_rcv_saddr;
24938 + dest = nx_map_sock_lback(current_nx_info(), tw->tw_daddr);
24939 + src = nx_map_sock_lback(current_nx_info(), tw->tw_rcv_saddr);
24940 destp = ntohs(tw->tw_dport);
24941 srcp = ntohs(tw->tw_sport);
24943 diff -NurpP --minimal linux-3.6.9/net/ipv4/tcp_minisocks.c linux-3.6.9-vs2.3.4.4/net/ipv4/tcp_minisocks.c
24944 --- linux-3.6.9/net/ipv4/tcp_minisocks.c 2012-10-04 15:27:50.000000000 +0200
24945 +++ linux-3.6.9-vs2.3.4.4/net/ipv4/tcp_minisocks.c 2012-10-04 18:47:00.000000000 +0200
24947 #include <linux/slab.h>
24948 #include <linux/sysctl.h>
24949 #include <linux/workqueue.h>
24950 +#include <linux/vs_limit.h>
24951 +#include <linux/vs_socket.h>
24952 +#include <linux/vs_context.h>
24953 #include <net/tcp.h>
24954 #include <net/inet_common.h>
24955 #include <net/xfrm.h>
24956 @@ -287,6 +290,11 @@ void tcp_time_wait(struct sock *sk, int
24957 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
24958 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
24960 + tw->tw_xid = sk->sk_xid;
24961 + tw->tw_vx_info = NULL;
24962 + tw->tw_nid = sk->sk_nid;
24963 + tw->tw_nx_info = NULL;
24965 #if IS_ENABLED(CONFIG_IPV6)
24966 if (tw->tw_family == PF_INET6) {
24967 struct ipv6_pinfo *np = inet6_sk(sk);
24968 diff -NurpP --minimal linux-3.6.9/net/ipv4/udp.c linux-3.6.9-vs2.3.4.4/net/ipv4/udp.c
24969 --- linux-3.6.9/net/ipv4/udp.c 2012-10-04 15:27:50.000000000 +0200
24970 +++ linux-3.6.9-vs2.3.4.4/net/ipv4/udp.c 2012-10-04 18:47:00.000000000 +0200
24971 @@ -300,14 +300,7 @@ fail:
24973 EXPORT_SYMBOL(udp_lib_get_port);
24975 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
24977 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
24979 - return (!ipv6_only_sock(sk2) &&
24980 - (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
24981 - inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
24983 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
24985 static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
24987 @@ -342,6 +335,11 @@ static inline int compute_score(struct s
24988 if (inet->inet_rcv_saddr != daddr)
24992 + /* block non nx_info ips */
24993 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
24994 + daddr, NXA_MASK_BIND))
24997 if (inet->inet_daddr) {
24998 if (inet->inet_daddr != saddr)
24999 @@ -445,6 +443,7 @@ exact_match:
25004 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
25005 * harder than this. -DaveM
25007 @@ -490,6 +489,11 @@ begin:
25008 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
25009 score = compute_score(sk, net, saddr, hnum, sport,
25010 daddr, dport, dif);
25011 + /* FIXME: disabled?
25012 + if (score == 9) {
25016 if (score > badness) {
25019 @@ -503,6 +507,7 @@ begin:
25020 if (get_nulls_value(node) != slot)
25025 if (unlikely(!atomic_inc_not_zero_hint(&result->sk_refcnt, 2)))
25027 @@ -512,6 +517,7 @@ begin:
25035 @@ -555,8 +561,7 @@ static inline struct sock *udp_v4_mcast_
25036 udp_sk(s)->udp_port_hash != hnum ||
25037 (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
25038 (inet->inet_dport != rmt_port && inet->inet_dport) ||
25039 - (inet->inet_rcv_saddr &&
25040 - inet->inet_rcv_saddr != loc_addr) ||
25041 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
25042 ipv6_only_sock(s) ||
25043 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
25045 @@ -939,6 +944,16 @@ int udp_sendmsg(struct kiocb *iocb, stru
25046 inet_sk_flowi_flags(sk)|FLOWI_FLAG_CAN_SLEEP,
25047 faddr, saddr, dport, inet->inet_sport);
25049 + if (sk->sk_nx_info) {
25050 + rt = ip_v4_find_src(net, sk->sk_nx_info, fl4);
25051 + if (IS_ERR(rt)) {
25052 + err = PTR_ERR(rt);
25059 security_sk_classify_flow(sk, flowi4_to_flowi(fl4));
25060 rt = ip_route_output_flow(net, fl4, sk);
25062 @@ -1244,7 +1259,8 @@ try_again:
25064 sin->sin_family = AF_INET;
25065 sin->sin_port = udp_hdr(skb)->source;
25066 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25067 + sin->sin_addr.s_addr = nx_map_sock_lback(
25068 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
25069 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
25071 if (inet->cmsg_flags)
25072 @@ -1992,6 +2008,8 @@ static struct sock *udp_get_first(struct
25073 sk_nulls_for_each(sk, node, &hslot->head) {
25074 if (!net_eq(sock_net(sk), net))
25076 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25078 if (sk->sk_family == state->family)
25081 @@ -2009,7 +2027,9 @@ static struct sock *udp_get_next(struct
25084 sk = sk_nulls_next(sk);
25085 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
25086 + } while (sk && (!net_eq(sock_net(sk), net) ||
25087 + sk->sk_family != state->family ||
25088 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25091 if (state->bucket <= state->udp_table->mask)
25092 @@ -2105,8 +2125,8 @@ static void udp4_format_sock(struct sock
25093 int bucket, int *len)
25095 struct inet_sock *inet = inet_sk(sp);
25096 - __be32 dest = inet->inet_daddr;
25097 - __be32 src = inet->inet_rcv_saddr;
25098 + __be32 dest = nx_map_sock_lback(current_nx_info(), inet->inet_daddr);
25099 + __be32 src = nx_map_sock_lback(current_nx_info(), inet->inet_rcv_saddr);
25100 __u16 destp = ntohs(inet->inet_dport);
25101 __u16 srcp = ntohs(inet->inet_sport);
25103 diff -NurpP --minimal linux-3.6.9/net/ipv6/Kconfig linux-3.6.9-vs2.3.4.4/net/ipv6/Kconfig
25104 --- linux-3.6.9/net/ipv6/Kconfig 2012-07-22 23:39:48.000000000 +0200
25105 +++ linux-3.6.9-vs2.3.4.4/net/ipv6/Kconfig 2012-10-04 18:47:00.000000000 +0200
25108 # IPv6 as module will cause a CRASH if you try to unload it
25110 - tristate "The IPv6 protocol"
25112 + bool "The IPv6 protocol"
25115 This is complemental support for the IP version 6.
25116 You will still be able to do traditional IPv4 networking as well.
25117 diff -NurpP --minimal linux-3.6.9/net/ipv6/addrconf.c linux-3.6.9-vs2.3.4.4/net/ipv6/addrconf.c
25118 --- linux-3.6.9/net/ipv6/addrconf.c 2012-12-08 01:34:16.000000000 +0100
25119 +++ linux-3.6.9-vs2.3.4.4/net/ipv6/addrconf.c 2012-11-06 18:43:41.000000000 +0100
25121 #include <linux/proc_fs.h>
25122 #include <linux/seq_file.h>
25123 #include <linux/export.h>
25124 +#include <linux/vs_network.h>
25125 +#include <linux/vs_inet6.h>
25127 /* Set to 3 to get tracing... */
25128 #define ACONF_DEBUG 2
25129 @@ -1101,7 +1103,7 @@ out:
25131 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
25132 const struct in6_addr *daddr, unsigned int prefs,
25133 - struct in6_addr *saddr)
25134 + struct in6_addr *saddr, struct nx_info *nxi)
25136 struct ipv6_saddr_score scores[2],
25137 *score = &scores[0], *hiscore = &scores[1];
25138 @@ -1173,6 +1175,8 @@ int ipv6_dev_get_saddr(struct net *net,
25142 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
25146 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
25147 @@ -3159,7 +3163,10 @@ static void if6_seq_stop(struct seq_file
25148 static int if6_seq_show(struct seq_file *seq, void *v)
25150 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
25151 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25153 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
25154 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
25155 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25157 ifp->idev->dev->ifindex,
25159 @@ -3665,6 +3672,11 @@ static int in6_dump_addrs(struct inet6_d
25160 struct ifacaddr6 *ifaca;
25162 int ip_idx = *p_ip_idx;
25163 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25165 + /* disable ipv6 on non v6 guests */
25166 + if (nxi && !nx_info_has_v6(nxi))
25169 read_lock_bh(&idev->lock);
25171 @@ -3675,6 +3687,8 @@ static int in6_dump_addrs(struct inet6_d
25172 list_for_each_entry(ifa, &idev->addr_list, if_list) {
25173 if (++ip_idx < s_ip_idx)
25175 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
25177 err = inet6_fill_ifaddr(skb, ifa,
25178 NETLINK_CB(cb->skb).pid,
25179 cb->nlh->nlmsg_seq,
25180 @@ -3691,6 +3705,8 @@ static int in6_dump_addrs(struct inet6_d
25181 ifmca = ifmca->next, ip_idx++) {
25182 if (ip_idx < s_ip_idx)
25184 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
25186 err = inet6_fill_ifmcaddr(skb, ifmca,
25187 NETLINK_CB(cb->skb).pid,
25188 cb->nlh->nlmsg_seq,
25189 @@ -3706,6 +3722,8 @@ static int in6_dump_addrs(struct inet6_d
25190 ifaca = ifaca->aca_next, ip_idx++) {
25191 if (ip_idx < s_ip_idx)
25193 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
25195 err = inet6_fill_ifacaddr(skb, ifaca,
25196 NETLINK_CB(cb->skb).pid,
25197 cb->nlh->nlmsg_seq,
25198 @@ -4089,6 +4107,11 @@ static int inet6_dump_ifinfo(struct sk_b
25199 struct inet6_dev *idev;
25200 struct hlist_head *head;
25201 struct hlist_node *node;
25202 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25204 + /* FIXME: maybe disable ipv6 on non v6 guests?
25205 + if (skb->sk && skb->sk->sk_vx_info)
25206 + return skb->len; */
25209 s_idx = cb->args[1];
25210 @@ -4100,6 +4123,8 @@ static int inet6_dump_ifinfo(struct sk_b
25211 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
25214 + if (!v6_dev_in_nx_info(dev, nxi))
25216 idev = __in6_dev_get(dev);
25219 diff -NurpP --minimal linux-3.6.9/net/ipv6/af_inet6.c linux-3.6.9-vs2.3.4.4/net/ipv6/af_inet6.c
25220 --- linux-3.6.9/net/ipv6/af_inet6.c 2012-12-08 01:34:16.000000000 +0100
25221 +++ linux-3.6.9-vs2.3.4.4/net/ipv6/af_inet6.c 2012-11-06 18:43:41.000000000 +0100
25223 #include <linux/netdevice.h>
25224 #include <linux/icmpv6.h>
25225 #include <linux/netfilter_ipv6.h>
25226 +#include <linux/vs_inet.h>
25227 +#include <linux/vs_inet6.h>
25229 #include <net/ip.h>
25230 #include <net/ipv6.h>
25231 @@ -160,9 +162,12 @@ lookup_protocol:
25235 + if ((protocol == IPPROTO_ICMPV6) &&
25236 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
25238 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
25239 goto out_rcu_unlock;
25242 sock->ops = answer->ops;
25243 answer_prot = answer->prot;
25244 answer_no_check = answer->no_check;
25245 @@ -262,6 +267,7 @@ int inet6_bind(struct socket *sock, stru
25246 struct inet_sock *inet = inet_sk(sk);
25247 struct ipv6_pinfo *np = inet6_sk(sk);
25248 struct net *net = sock_net(sk);
25249 + struct nx_v6_sock_addr nsa;
25251 unsigned short snum;
25253 @@ -277,6 +283,10 @@ int inet6_bind(struct socket *sock, stru
25254 if (addr->sin6_family != AF_INET6)
25255 return -EAFNOSUPPORT;
25257 + err = v6_map_sock_addr(inet, addr, &nsa);
25261 addr_type = ipv6_addr_type(&addr->sin6_addr);
25262 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
25264 @@ -308,6 +318,7 @@ int inet6_bind(struct socket *sock, stru
25265 /* Reproduce AF_INET checks to make the bindings consistent */
25266 v4addr = addr->sin6_addr.s6_addr32[3];
25267 chk_addr_ret = inet_addr_type(net, v4addr);
25269 if (!sysctl_ip_nonlocal_bind &&
25270 !(inet->freebind || inet->transparent) &&
25271 v4addr != htonl(INADDR_ANY) &&
25272 @@ -317,6 +328,10 @@ int inet6_bind(struct socket *sock, stru
25273 err = -EADDRNOTAVAIL;
25276 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
25277 + err = -EADDRNOTAVAIL;
25281 if (addr_type != IPV6_ADDR_ANY) {
25282 struct net_device *dev = NULL;
25283 @@ -343,6 +358,11 @@ int inet6_bind(struct socket *sock, stru
25287 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25288 + err = -EADDRNOTAVAIL;
25292 /* ipv4 addr of the socket is invalid. Only the
25293 * unspecified and mapped address have a v4 equivalent.
25295 @@ -359,6 +379,9 @@ int inet6_bind(struct socket *sock, stru
25299 + /* what's that for? */
25300 + v6_set_sock_addr(inet, &nsa);
25302 inet->inet_rcv_saddr = v4addr;
25303 inet->inet_saddr = v4addr;
25305 @@ -460,9 +483,11 @@ int inet6_getname(struct socket *sock, s
25307 sin->sin6_port = inet->inet_dport;
25308 sin->sin6_addr = np->daddr;
25309 + /* FIXME: remap lback? */
25311 sin->sin6_flowinfo = np->flow_label;
25313 + /* FIXME: remap lback? */
25314 if (ipv6_addr_any(&np->rcv_saddr))
25315 sin->sin6_addr = np->saddr;
25317 diff -NurpP --minimal linux-3.6.9/net/ipv6/datagram.c linux-3.6.9-vs2.3.4.4/net/ipv6/datagram.c
25318 --- linux-3.6.9/net/ipv6/datagram.c 2012-07-22 23:39:48.000000000 +0200
25319 +++ linux-3.6.9-vs2.3.4.4/net/ipv6/datagram.c 2012-10-04 18:47:00.000000000 +0200
25320 @@ -645,7 +645,7 @@ int datagram_send_ctl(struct net *net, s
25323 if (fl6->flowi6_oif) {
25324 - dev = dev_get_by_index_rcu(net, fl6->flowi6_oif);
25325 + dev = dev_get_by_index_real_rcu(net, fl6->flowi6_oif);
25329 diff -NurpP --minimal linux-3.6.9/net/ipv6/fib6_rules.c linux-3.6.9-vs2.3.4.4/net/ipv6/fib6_rules.c
25330 --- linux-3.6.9/net/ipv6/fib6_rules.c 2012-07-22 23:39:48.000000000 +0200
25331 +++ linux-3.6.9-vs2.3.4.4/net/ipv6/fib6_rules.c 2012-10-04 18:47:00.000000000 +0200
25332 @@ -90,7 +90,7 @@ static int fib6_rule_action(struct fib_r
25333 ip6_dst_idev(&rt->dst)->dev,
25335 rt6_flags2srcprefs(flags),
25339 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
25341 diff -NurpP --minimal linux-3.6.9/net/ipv6/inet6_hashtables.c linux-3.6.9-vs2.3.4.4/net/ipv6/inet6_hashtables.c
25342 --- linux-3.6.9/net/ipv6/inet6_hashtables.c 2011-10-24 18:45:34.000000000 +0200
25343 +++ linux-3.6.9-vs2.3.4.4/net/ipv6/inet6_hashtables.c 2012-10-04 18:47:00.000000000 +0200
25346 #include <linux/module.h>
25347 #include <linux/random.h>
25348 +#include <linux/vs_inet6.h>
25350 #include <net/inet_connection_sock.h>
25351 #include <net/inet_hashtables.h>
25352 @@ -83,7 +84,6 @@ struct sock *__inet6_lookup_established(
25353 unsigned int slot = hash & hashinfo->ehash_mask;
25354 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
25359 sk_nulls_for_each_rcu(sk, node, &head->chain) {
25360 @@ -95,7 +95,7 @@ begin:
25368 if (get_nulls_value(node) != slot)
25369 @@ -141,6 +141,9 @@ static inline int compute_score(struct s
25370 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25374 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25377 if (sk->sk_bound_dev_if) {
25378 if (sk->sk_bound_dev_if != dif)
25379 diff -NurpP --minimal linux-3.6.9/net/ipv6/ip6_output.c linux-3.6.9-vs2.3.4.4/net/ipv6/ip6_output.c
25380 --- linux-3.6.9/net/ipv6/ip6_output.c 2012-10-04 15:27:50.000000000 +0200
25381 +++ linux-3.6.9-vs2.3.4.4/net/ipv6/ip6_output.c 2012-10-04 18:47:00.000000000 +0200
25382 @@ -966,7 +966,8 @@ static int ip6_dst_lookup_tail(struct so
25383 struct rt6_info *rt = (struct rt6_info *) *dst;
25384 err = ip6_route_get_saddr(net, rt, &fl6->daddr,
25385 sk ? inet6_sk(sk)->srcprefs : 0,
25388 + sk ? sk->sk_nx_info : NULL);
25390 goto out_err_release;
25392 diff -NurpP --minimal linux-3.6.9/net/ipv6/ndisc.c linux-3.6.9-vs2.3.4.4/net/ipv6/ndisc.c
25393 --- linux-3.6.9/net/ipv6/ndisc.c 2012-12-08 01:34:16.000000000 +0100
25394 +++ linux-3.6.9-vs2.3.4.4/net/ipv6/ndisc.c 2012-12-08 01:36:33.000000000 +0100
25395 @@ -517,7 +517,7 @@ static void ndisc_send_na(struct net_dev
25397 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
25398 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
25402 src_addr = &tmpaddr;
25404 diff -NurpP --minimal linux-3.6.9/net/ipv6/raw.c linux-3.6.9-vs2.3.4.4/net/ipv6/raw.c
25405 --- linux-3.6.9/net/ipv6/raw.c 2012-10-04 15:27:50.000000000 +0200
25406 +++ linux-3.6.9-vs2.3.4.4/net/ipv6/raw.c 2012-10-04 18:47:00.000000000 +0200
25408 #include <linux/icmpv6.h>
25409 #include <linux/netfilter.h>
25410 #include <linux/netfilter_ipv6.h>
25411 +#include <linux/vs_inet6.h>
25412 #include <linux/skbuff.h>
25413 #include <linux/compat.h>
25414 #include <asm/uaccess.h>
25415 @@ -284,6 +285,13 @@ static int rawv6_bind(struct sock *sk, s
25419 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25420 + err = -EADDRNOTAVAIL;
25426 /* ipv4 addr of the socket is invalid. Only the
25427 * unspecified and mapped address have a v4 equivalent.
25429 diff -NurpP --minimal linux-3.6.9/net/ipv6/route.c linux-3.6.9-vs2.3.4.4/net/ipv6/route.c
25430 --- linux-3.6.9/net/ipv6/route.c 2012-12-08 01:34:16.000000000 +0100
25431 +++ linux-3.6.9-vs2.3.4.4/net/ipv6/route.c 2012-12-08 01:36:33.000000000 +0100
25433 #include <net/xfrm.h>
25434 #include <net/netevent.h>
25435 #include <net/netlink.h>
25436 +#include <linux/vs_inet6.h>
25438 #include <asm/uaccess.h>
25440 @@ -2112,15 +2113,17 @@ int ip6_route_get_saddr(struct net *net,
25441 struct rt6_info *rt,
25442 const struct in6_addr *daddr,
25443 unsigned int prefs,
25444 - struct in6_addr *saddr)
25445 + struct in6_addr *saddr,
25446 + struct nx_info *nxi)
25448 struct inet6_dev *idev = ip6_dst_idev((struct dst_entry*)rt);
25450 - if (rt->rt6i_prefsrc.plen)
25451 + if (rt->rt6i_prefsrc.plen && (!nxi ||
25452 + v6_addr_in_nx_info(nxi, &rt->rt6i_prefsrc.addr, NXA_TYPE_ADDR)))
25453 *saddr = rt->rt6i_prefsrc.addr;
25455 err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
25456 - daddr, prefs, saddr);
25457 + daddr, prefs, saddr, nxi);
25461 @@ -2456,7 +2459,8 @@ static int rt6_fill_node(struct net *net
25462 goto nla_put_failure;
25464 struct in6_addr saddr_buf;
25465 - if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf) == 0 &&
25466 + if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf,
25467 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0 &&
25468 nla_put(skb, RTA_PREFSRC, 16, &saddr_buf))
25469 goto nla_put_failure;
25471 @@ -2674,6 +2678,7 @@ static int rt6_info_route(struct rt6_inf
25472 struct seq_file *m = p_arg;
25473 struct neighbour *n;
25475 + /* FIXME: check for network context? */
25476 seq_printf(m, "%pi6 %02x ", &rt->rt6i_dst.addr, rt->rt6i_dst.plen);
25478 #ifdef CONFIG_IPV6_SUBTREES
25479 diff -NurpP --minimal linux-3.6.9/net/ipv6/tcp_ipv6.c linux-3.6.9-vs2.3.4.4/net/ipv6/tcp_ipv6.c
25480 --- linux-3.6.9/net/ipv6/tcp_ipv6.c 2012-12-08 01:34:17.000000000 +0100
25481 +++ linux-3.6.9-vs2.3.4.4/net/ipv6/tcp_ipv6.c 2012-11-06 18:43:41.000000000 +0100
25484 #include <linux/crypto.h>
25485 #include <linux/scatterlist.h>
25486 +#include <linux/vs_inet6.h>
25488 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
25489 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
25490 @@ -175,8 +176,15 @@ static int tcp_v6_connect(struct sock *s
25491 * connect() to INADDR_ANY means loopback (BSD'ism).
25494 - if(ipv6_addr_any(&usin->sin6_addr))
25495 - usin->sin6_addr.s6_addr[15] = 0x1;
25496 + if(ipv6_addr_any(&usin->sin6_addr)) {
25497 + struct nx_info *nxi = sk->sk_nx_info;
25499 + if (nxi && nx_info_has_v6(nxi))
25500 + /* FIXME: remap lback? */
25501 + usin->sin6_addr = nxi->v6.ip;
25503 + usin->sin6_addr.s6_addr[15] = 0x1;
25506 addr_type = ipv6_addr_type(&usin->sin6_addr);
25508 diff -NurpP --minimal linux-3.6.9/net/ipv6/udp.c linux-3.6.9-vs2.3.4.4/net/ipv6/udp.c
25509 --- linux-3.6.9/net/ipv6/udp.c 2012-10-04 15:27:50.000000000 +0200
25510 +++ linux-3.6.9-vs2.3.4.4/net/ipv6/udp.c 2012-10-04 18:56:03.000000000 +0200
25511 @@ -45,42 +45,68 @@
25512 #include <net/tcp_states.h>
25513 #include <net/ip6_checksum.h>
25514 #include <net/xfrm.h>
25515 +#include <linux/vs_inet6.h>
25517 #include <linux/proc_fs.h>
25518 #include <linux/seq_file.h>
25519 #include <trace/events/skb.h>
25520 #include "udp_impl.h"
25522 -int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
25523 +int ipv6_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25525 - const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
25526 + const struct in6_addr *sk1_rcv_saddr6 = &inet6_sk(sk1)->rcv_saddr;
25527 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
25528 - __be32 sk1_rcv_saddr = sk_rcv_saddr(sk);
25529 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1);
25530 __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
25531 - int sk_ipv6only = ipv6_only_sock(sk);
25532 + int sk1_ipv6only = ipv6_only_sock(sk1);
25533 int sk2_ipv6only = inet_v6_ipv6only(sk2);
25534 - int addr_type = ipv6_addr_type(sk_rcv_saddr6);
25535 + int addr_type = ipv6_addr_type(sk1_rcv_saddr6);
25536 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
25538 /* if both are mapped, treat as IPv4 */
25539 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
25540 - return (!sk2_ipv6only &&
25541 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
25542 + if (!sk2_ipv6only &&
25543 (!sk1_rcv_saddr || !sk2_rcv_saddr ||
25544 - sk1_rcv_saddr == sk2_rcv_saddr));
25545 + sk1_rcv_saddr == sk2_rcv_saddr))
25551 if (addr_type2 == IPV6_ADDR_ANY &&
25552 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
25556 if (addr_type == IPV6_ADDR_ANY &&
25557 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
25559 + !(sk1_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
25562 if (sk2_rcv_saddr6 &&
25563 - ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
25565 + ipv6_addr_equal(sk1_rcv_saddr6, sk2_rcv_saddr6))
25571 + if (!sk1_rcv_saddr && !sk2_rcv_saddr)
25572 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25573 + if (!sk2_rcv_saddr)
25574 + return v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, -1);
25575 + if (!sk1_rcv_saddr)
25576 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, -1);
25579 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
25580 + return nx_v6_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25581 + else if (addr_type2 == IPV6_ADDR_ANY)
25582 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr6, -1);
25583 + else if (addr_type == IPV6_ADDR_ANY) {
25584 + if (addr_type2 == IPV6_ADDR_MAPPED)
25585 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25587 + return v6_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr6, -1);
25592 static unsigned int udp6_portaddr_hash(struct net *net,
25593 @@ -144,6 +170,10 @@ static inline int compute_score(struct s
25594 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25598 + /* block non nx_info ips */
25599 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25602 if (!ipv6_addr_any(&np->daddr)) {
25603 if (!ipv6_addr_equal(&np->daddr, saddr))
25604 diff -NurpP --minimal linux-3.6.9/net/ipv6/xfrm6_policy.c linux-3.6.9-vs2.3.4.4/net/ipv6/xfrm6_policy.c
25605 --- linux-3.6.9/net/ipv6/xfrm6_policy.c 2012-10-04 15:27:50.000000000 +0200
25606 +++ linux-3.6.9-vs2.3.4.4/net/ipv6/xfrm6_policy.c 2012-10-04 18:47:00.000000000 +0200
25607 @@ -63,7 +63,7 @@ static int xfrm6_get_saddr(struct net *n
25608 dev = ip6_dst_idev(dst)->dev;
25609 ipv6_dev_get_saddr(dev_net(dev), dev,
25610 (struct in6_addr *)&daddr->a6, 0,
25611 - (struct in6_addr *)&saddr->a6);
25612 + (struct in6_addr *)&saddr->a6, NULL);
25616 diff -NurpP --minimal linux-3.6.9/net/netfilter/ipvs/ip_vs_xmit.c linux-3.6.9-vs2.3.4.4/net/netfilter/ipvs/ip_vs_xmit.c
25617 --- linux-3.6.9/net/netfilter/ipvs/ip_vs_xmit.c 2012-12-08 01:34:19.000000000 +0100
25618 +++ linux-3.6.9-vs2.3.4.4/net/netfilter/ipvs/ip_vs_xmit.c 2012-11-06 18:43:41.000000000 +0100
25619 @@ -231,7 +231,7 @@ __ip_vs_route_output_v6(struct net *net,
25621 if (ipv6_addr_any(&fl6.saddr) &&
25622 ipv6_dev_get_saddr(net, ip6_dst_idev(dst)->dev,
25623 - &fl6.daddr, 0, &fl6.saddr) < 0)
25624 + &fl6.daddr, 0, &fl6.saddr, NULL) < 0)
25627 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
25628 diff -NurpP --minimal linux-3.6.9/net/netlink/af_netlink.c linux-3.6.9-vs2.3.4.4/net/netlink/af_netlink.c
25629 --- linux-3.6.9/net/netlink/af_netlink.c 2012-12-08 01:34:19.000000000 +0100
25630 +++ linux-3.6.9-vs2.3.4.4/net/netlink/af_netlink.c 2012-12-08 01:36:33.000000000 +0100
25632 #include <linux/types.h>
25633 #include <linux/audit.h>
25634 #include <linux/mutex.h>
25635 +#include <linux/vs_context.h>
25636 +#include <linux/vs_network.h>
25637 +#include <linux/vs_limit.h>
25639 #include <net/net_namespace.h>
25640 #include <net/sock.h>
25641 @@ -1983,6 +1986,8 @@ static struct sock *netlink_seq_socket_i
25642 sk_for_each(s, node, &hash->table[j]) {
25643 if (sock_net(s) != seq_file_net(seq))
25645 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
25649 iter->hash_idx = j;
25650 @@ -2017,7 +2022,8 @@ static void *netlink_seq_next(struct seq
25654 - } while (s && sock_net(s) != seq_file_net(seq));
25655 + } while (s && (sock_net(s) != seq_file_net(seq) ||
25656 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
25660 @@ -2029,7 +2035,8 @@ static void *netlink_seq_next(struct seq
25662 for (; j <= hash->mask; j++) {
25663 s = sk_head(&hash->table[j]);
25664 - while (s && sock_net(s) != seq_file_net(seq))
25665 + while (s && (sock_net(s) != seq_file_net(seq) ||
25666 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
25670 diff -NurpP --minimal linux-3.6.9/net/socket.c linux-3.6.9-vs2.3.4.4/net/socket.c
25671 --- linux-3.6.9/net/socket.c 2012-10-04 15:27:51.000000000 +0200
25672 +++ linux-3.6.9-vs2.3.4.4/net/socket.c 2012-10-04 18:47:00.000000000 +0200
25675 #include <net/sock.h>
25676 #include <linux/netfilter.h>
25677 +#include <linux/vs_base.h>
25678 +#include <linux/vs_socket.h>
25679 +#include <linux/vs_inet.h>
25680 +#include <linux/vs_inet6.h>
25682 #include <linux/if_tun.h>
25683 #include <linux/ipv6_route.h>
25684 @@ -552,6 +556,7 @@ static inline int __sock_sendmsg_nosec(s
25685 struct msghdr *msg, size_t size)
25687 struct sock_iocb *si = kiocb_to_siocb(iocb);
25690 sock_update_classid(sock->sk);
25692 @@ -560,7 +565,22 @@ static inline int __sock_sendmsg_nosec(s
25696 - return sock->ops->sendmsg(iocb, sock, msg, size);
25697 + len = sock->ops->sendmsg(iocb, sock, msg, size);
25700 + vx_sock_send(sock->sk, size);
25702 + vx_sock_fail(sock->sk, size);
25704 + vxdprintk(VXD_CBIT(net, 7),
25705 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%zu",
25707 + (sock->sk)?sock->sk->sk_nx_info:0,
25708 + (sock->sk)?sock->sk->sk_vx_info:0,
25709 + (sock->sk)?sock->sk->sk_xid:0,
25710 + (sock->sk)?sock->sk->sk_nid:0,
25711 + (unsigned int)size, len);
25715 static inline int __sock_sendmsg(struct kiocb *iocb, struct socket *sock,
25716 @@ -716,6 +736,7 @@ static inline int __sock_recvmsg_nosec(s
25717 struct msghdr *msg, size_t size, int flags)
25719 struct sock_iocb *si = kiocb_to_siocb(iocb);
25722 sock_update_classid(sock->sk);
25724 @@ -725,7 +746,18 @@ static inline int __sock_recvmsg_nosec(s
25728 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
25729 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
25730 + if ((len >= 0) && sock->sk)
25731 + vx_sock_recv(sock->sk, len);
25732 + vxdprintk(VXD_CBIT(net, 7),
25733 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
25735 + (sock->sk)?sock->sk->sk_nx_info:0,
25736 + (sock->sk)?sock->sk->sk_vx_info:0,
25737 + (sock->sk)?sock->sk->sk_xid:0,
25738 + (sock->sk)?sock->sk->sk_nid:0,
25739 + (unsigned int)size, len);
25743 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
25744 @@ -1210,6 +1242,13 @@ int __sock_create(struct net *net, int f
25745 if (type < 0 || type >= SOCK_MAX)
25748 + if (!nx_check(0, VS_ADMIN)) {
25749 + if (family == PF_INET && !current_nx_info_has_v4())
25750 + return -EAFNOSUPPORT;
25751 + if (family == PF_INET6 && !current_nx_info_has_v6())
25752 + return -EAFNOSUPPORT;
25757 This uglymoron is moved from INET layer to here to avoid
25758 @@ -1344,6 +1383,7 @@ SYSCALL_DEFINE3(socket, int, family, int
25762 + set_bit(SOCK_USER_SOCKET, &sock->flags);
25763 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
25766 @@ -1385,10 +1425,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
25767 err = sock_create(family, type, protocol, &sock1);
25770 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
25772 err = sock_create(family, type, protocol, &sock2);
25774 goto out_release_1;
25775 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
25777 err = sock1->ops->socketpair(sock1, sock2);
25779 diff -NurpP --minimal linux-3.6.9/net/sunrpc/auth.c linux-3.6.9-vs2.3.4.4/net/sunrpc/auth.c
25780 --- linux-3.6.9/net/sunrpc/auth.c 2012-10-04 15:27:51.000000000 +0200
25781 +++ linux-3.6.9-vs2.3.4.4/net/sunrpc/auth.c 2012-10-04 18:47:00.000000000 +0200
25783 #include <linux/sunrpc/clnt.h>
25784 #include <linux/sunrpc/gss_api.h>
25785 #include <linux/spinlock.h>
25786 +#include <linux/vs_tag.h>
25789 # define RPCDBG_FACILITY RPCDBG_AUTH
25790 @@ -481,6 +482,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
25791 memset(&acred, 0, sizeof(acred));
25792 acred.uid = cred->fsuid;
25793 acred.gid = cred->fsgid;
25794 + acred.tag = dx_current_tag();
25795 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
25797 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
25798 @@ -521,6 +523,7 @@ rpcauth_bind_root_cred(struct rpc_task *
25799 struct auth_cred acred = {
25802 + .tag = dx_current_tag(),
25805 dprintk("RPC: %5u looking up %s cred\n",
25806 diff -NurpP --minimal linux-3.6.9/net/sunrpc/auth_unix.c linux-3.6.9-vs2.3.4.4/net/sunrpc/auth_unix.c
25807 --- linux-3.6.9/net/sunrpc/auth_unix.c 2012-07-22 23:39:49.000000000 +0200
25808 +++ linux-3.6.9-vs2.3.4.4/net/sunrpc/auth_unix.c 2012-10-04 18:47:00.000000000 +0200
25809 @@ -13,11 +13,13 @@
25810 #include <linux/sunrpc/clnt.h>
25811 #include <linux/sunrpc/auth.h>
25812 #include <linux/user_namespace.h>
25813 +#include <linux/vs_tag.h>
25815 #define NFS_NGROUPS 16
25818 struct rpc_cred uc_base;
25821 gid_t uc_gids[NFS_NGROUPS];
25823 @@ -79,6 +81,7 @@ unx_create_cred(struct rpc_auth *auth, s
25824 groups = NFS_NGROUPS;
25826 cred->uc_gid = acred->gid;
25827 + cred->uc_tag = acred->tag;
25828 for (i = 0; i < groups; i++) {
25830 gid = from_kgid(&init_user_ns, GROUP_AT(acred->group_info, i));
25831 @@ -123,7 +126,9 @@ unx_match(struct auth_cred *acred, struc
25835 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
25836 + if (cred->uc_uid != acred->uid ||
25837 + cred->uc_gid != acred->gid ||
25838 + cred->uc_tag != acred->tag)
25841 if (acred->group_info != NULL)
25842 @@ -152,7 +157,7 @@ unx_marshal(struct rpc_task *task, __be3
25843 struct rpc_clnt *clnt = task->tk_client;
25844 struct unx_cred *cred = container_of(task->tk_rqstp->rq_cred, struct unx_cred, uc_base);
25845 __be32 *base, *hold;
25849 *p++ = htonl(RPC_AUTH_UNIX);
25851 @@ -162,9 +167,12 @@ unx_marshal(struct rpc_task *task, __be3
25852 * Copy the UTS nodename captured when the client was created.
25854 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
25855 + tag = task->tk_client->cl_tag;
25857 - *p++ = htonl((u32) cred->uc_uid);
25858 - *p++ = htonl((u32) cred->uc_gid);
25859 + *p++ = htonl((u32) TAGINO_UID(tag,
25860 + cred->uc_uid, cred->uc_tag));
25861 + *p++ = htonl((u32) TAGINO_GID(tag,
25862 + cred->uc_gid, cred->uc_tag));
25864 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
25865 *p++ = htonl((u32) cred->uc_gids[i]);
25866 diff -NurpP --minimal linux-3.6.9/net/sunrpc/clnt.c linux-3.6.9-vs2.3.4.4/net/sunrpc/clnt.c
25867 --- linux-3.6.9/net/sunrpc/clnt.c 2012-10-04 15:27:51.000000000 +0200
25868 +++ linux-3.6.9-vs2.3.4.4/net/sunrpc/clnt.c 2012-10-04 18:47:00.000000000 +0200
25870 #include <linux/in6.h>
25871 #include <linux/un.h>
25872 #include <linux/rcupdate.h>
25873 +#include <linux/vs_cvirt.h>
25875 #include <linux/sunrpc/clnt.h>
25876 #include <linux/sunrpc/rpc_pipe_fs.h>
25877 @@ -481,6 +482,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
25878 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
25879 clnt->cl_chatty = 1;
25881 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
25882 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
25883 + clnt->cl_tag = 1; */
25886 EXPORT_SYMBOL_GPL(rpc_create);
25887 diff -NurpP --minimal linux-3.6.9/net/unix/af_unix.c linux-3.6.9-vs2.3.4.4/net/unix/af_unix.c
25888 --- linux-3.6.9/net/unix/af_unix.c 2012-10-04 15:27:51.000000000 +0200
25889 +++ linux-3.6.9-vs2.3.4.4/net/unix/af_unix.c 2012-10-04 18:59:36.000000000 +0200
25890 @@ -114,6 +114,8 @@
25891 #include <linux/mount.h>
25892 #include <net/checksum.h>
25893 #include <linux/security.h>
25894 +#include <linux/vs_context.h>
25895 +#include <linux/vs_limit.h>
25897 struct hlist_head unix_socket_table[2 * UNIX_HASH_SIZE];
25898 EXPORT_SYMBOL_GPL(unix_socket_table);
25899 @@ -271,6 +273,8 @@ static struct sock *__unix_find_socket_b
25900 if (!net_eq(sock_net(s), net))
25903 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
25905 if (u->addr->len == len &&
25906 !memcmp(u->addr->name, sunname, len))
25908 @@ -2258,6 +2262,8 @@ static struct sock *unix_from_bucket(str
25909 for (sk = sk_head(&unix_socket_table[bucket]); sk; sk = sk_next(sk)) {
25910 if (sock_net(sk) != seq_file_net(seq))
25912 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25914 if (++count == offset)
25917 @@ -2275,6 +2281,8 @@ static struct sock *unix_next_socket(str
25921 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25923 if (sock_net(sk) == seq_file_net(seq))
25926 diff -NurpP --minimal linux-3.6.9/scripts/checksyscalls.sh linux-3.6.9-vs2.3.4.4/scripts/checksyscalls.sh
25927 --- linux-3.6.9/scripts/checksyscalls.sh 2012-10-04 15:27:51.000000000 +0200
25928 +++ linux-3.6.9-vs2.3.4.4/scripts/checksyscalls.sh 2012-10-04 18:47:00.000000000 +0200
25929 @@ -193,7 +193,6 @@ cat << EOF
25930 #define __IGNORE_afs_syscall
25931 #define __IGNORE_getpmsg
25932 #define __IGNORE_putpmsg
25933 -#define __IGNORE_vserver
25937 diff -NurpP --minimal linux-3.6.9/security/commoncap.c linux-3.6.9-vs2.3.4.4/security/commoncap.c
25938 --- linux-3.6.9/security/commoncap.c 2012-07-22 23:39:51.000000000 +0200
25939 +++ linux-3.6.9-vs2.3.4.4/security/commoncap.c 2012-10-04 18:47:00.000000000 +0200
25940 @@ -76,14 +76,20 @@ int cap_netlink_send(struct sock *sk, st
25941 int cap_capable(const struct cred *cred, struct user_namespace *targ_ns,
25942 int cap, int audit)
25944 + struct vx_info *vxi = current_vx_info(); /* FIXME: get vxi from cred? */
25947 /* The owner of the user namespace has all caps. */
25948 if (targ_ns != &init_user_ns && uid_eq(targ_ns->owner, cred->euid))
25951 /* Do we have the necessary capabilities? */
25952 - if (targ_ns == cred->user_ns)
25953 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
25954 + if (targ_ns == cred->user_ns) {
25955 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
25956 + cap_raised(cred->cap_effective, cap))
25958 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
25961 /* Have we tried all of the parent namespaces? */
25962 if (targ_ns == &init_user_ns)
25963 @@ -619,7 +625,7 @@ int cap_inode_setxattr(struct dentry *de
25965 if (!strncmp(name, XATTR_SECURITY_PREFIX,
25966 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
25967 - !capable(CAP_SYS_ADMIN))
25968 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
25972 @@ -645,7 +651,7 @@ int cap_inode_removexattr(struct dentry
25974 if (!strncmp(name, XATTR_SECURITY_PREFIX,
25975 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
25976 - !capable(CAP_SYS_ADMIN))
25977 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
25981 diff -NurpP --minimal linux-3.6.9/security/selinux/hooks.c linux-3.6.9-vs2.3.4.4/security/selinux/hooks.c
25982 --- linux-3.6.9/security/selinux/hooks.c 2012-10-04 15:27:53.000000000 +0200
25983 +++ linux-3.6.9-vs2.3.4.4/security/selinux/hooks.c 2012-10-04 18:47:00.000000000 +0200
25985 #include <linux/dccp.h>
25986 #include <linux/quota.h>
25987 #include <linux/un.h> /* for Unix socket types */
25988 -#include <net/af_unix.h> /* for Unix socket types */
25989 #include <linux/parser.h>
25990 #include <linux/nfs_mount.h>
25991 #include <net/ipv6.h>