1 diff -NurpP --minimal linux-3.6.10/Documentation/vserver/debug.txt linux-3.6.10-vs2.3.4.5/Documentation/vserver/debug.txt
2 --- linux-3.6.10/Documentation/vserver/debug.txt 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/alpha/Kconfig linux-3.6.10-vs2.3.4.5/arch/alpha/Kconfig
160 --- linux-3.6.10/arch/alpha/Kconfig 2012-10-04 15:26:43.000000000 +0200
161 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/alpha/kernel/ptrace.c linux-3.6.10-vs2.3.4.5/arch/alpha/kernel/ptrace.c
172 --- linux-3.6.10/arch/alpha/kernel/ptrace.c 2012-05-21 18:06:12.000000000 +0200
173 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/alpha/kernel/systbls.S linux-3.6.10-vs2.3.4.5/arch/alpha/kernel/systbls.S
183 --- linux-3.6.10/arch/alpha/kernel/systbls.S 2012-10-04 15:26:43.000000000 +0200
184 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/alpha/kernel/traps.c linux-3.6.10-vs2.3.4.5/arch/alpha/kernel/traps.c
195 --- linux-3.6.10/arch/alpha/kernel/traps.c 2012-05-21 18:06:12.000000000 +0200
196 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/arm/Kconfig linux-3.6.10-vs2.3.4.5/arch/arm/Kconfig
208 --- linux-3.6.10/arch/arm/Kconfig 2012-12-11 12:36:49.000000000 +0100
209 +++ linux-3.6.10-vs2.3.4.5/arch/arm/Kconfig 2012-12-11 12:45:19.000000000 +0100
210 @@ -2342,6 +2342,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.10/arch/arm/kernel/calls.S linux-3.6.10-vs2.3.4.5/arch/arm/kernel/calls.S
220 --- linux-3.6.10/arch/arm/kernel/calls.S 2012-10-04 15:26:43.000000000 +0200
221 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/arm/kernel/process.c linux-3.6.10-vs2.3.4.5/arch/arm/kernel/process.c
232 --- linux-3.6.10/arch/arm/kernel/process.c 2012-10-04 15:26:43.000000000 +0200
233 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/arm/kernel/traps.c linux-3.6.10-vs2.3.4.5/arch/arm/kernel/traps.c
245 --- linux-3.6.10/arch/arm/kernel/traps.c 2012-10-04 15:26:44.000000000 +0200
246 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/cris/Kconfig linux-3.6.10-vs2.3.4.5/arch/cris/Kconfig
259 --- linux-3.6.10/arch/cris/Kconfig 2012-10-04 15:26:51.000000000 +0200
260 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/frv/kernel/kernel_thread.S linux-3.6.10-vs2.3.4.5/arch/frv/kernel/kernel_thread.S
271 --- linux-3.6.10/arch/frv/kernel/kernel_thread.S 2012-10-04 15:26:51.000000000 +0200
272 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/h8300/Kconfig linux-3.6.10-vs2.3.4.5/arch/h8300/Kconfig
283 --- linux-3.6.10/arch/h8300/Kconfig 2012-10-04 15:26:51.000000000 +0200
284 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/ia64/Kconfig linux-3.6.10-vs2.3.4.5/arch/ia64/Kconfig
295 --- linux-3.6.10/arch/ia64/Kconfig 2012-10-04 15:26:51.000000000 +0200
296 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/ia64/kernel/entry.S linux-3.6.10-vs2.3.4.5/arch/ia64/kernel/entry.S
307 --- linux-3.6.10/arch/ia64/kernel/entry.S 2012-03-19 19:46:40.000000000 +0100
308 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/ia64/kernel/process.c linux-3.6.10-vs2.3.4.5/arch/ia64/kernel/process.c
319 --- linux-3.6.10/arch/ia64/kernel/process.c 2012-12-11 12:36:49.000000000 +0100
320 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/ia64/kernel/ptrace.c linux-3.6.10-vs2.3.4.5/arch/ia64/kernel/ptrace.c
333 --- linux-3.6.10/arch/ia64/kernel/ptrace.c 2012-05-21 18:06:26.000000000 +0200
334 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/ia64/kernel/traps.c linux-3.6.10-vs2.3.4.5/arch/ia64/kernel/traps.c
344 --- linux-3.6.10/arch/ia64/kernel/traps.c 2012-05-21 18:06:26.000000000 +0200
345 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/m32r/kernel/traps.c linux-3.6.10-vs2.3.4.5/arch/m32r/kernel/traps.c
371 --- linux-3.6.10/arch/m32r/kernel/traps.c 2012-05-21 18:06:26.000000000 +0200
372 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/m68k/Kconfig linux-3.6.10-vs2.3.4.5/arch/m68k/Kconfig
386 --- linux-3.6.10/arch/m68k/Kconfig 2012-10-04 15:26:51.000000000 +0200
387 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/mips/Kconfig linux-3.6.10-vs2.3.4.5/arch/mips/Kconfig
398 --- linux-3.6.10/arch/mips/Kconfig 2012-10-04 15:26:52.000000000 +0200
399 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/mips/kernel/ptrace.c linux-3.6.10-vs2.3.4.5/arch/mips/kernel/ptrace.c
410 --- linux-3.6.10/arch/mips/kernel/ptrace.c 2012-07-22 23:38:52.000000000 +0200
411 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/mips/kernel/scall32-o32.S linux-3.6.10-vs2.3.4.5/arch/mips/kernel/scall32-o32.S
431 --- linux-3.6.10/arch/mips/kernel/scall32-o32.S 2012-01-09 16:14:05.000000000 +0100
432 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/mips/kernel/scall64-64.S linux-3.6.10-vs2.3.4.5/arch/mips/kernel/scall64-64.S
443 --- linux-3.6.10/arch/mips/kernel/scall64-64.S 2012-01-09 16:14:05.000000000 +0100
444 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/mips/kernel/scall64-n32.S linux-3.6.10-vs2.3.4.5/arch/mips/kernel/scall64-n32.S
455 --- linux-3.6.10/arch/mips/kernel/scall64-n32.S 2012-01-09 16:14:05.000000000 +0100
456 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/mips/kernel/scall64-o32.S linux-3.6.10-vs2.3.4.5/arch/mips/kernel/scall64-o32.S
467 --- linux-3.6.10/arch/mips/kernel/scall64-o32.S 2012-01-09 16:14:05.000000000 +0100
468 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/mips/kernel/traps.c linux-3.6.10-vs2.3.4.5/arch/mips/kernel/traps.c
479 --- linux-3.6.10/arch/mips/kernel/traps.c 2012-10-04 15:26:53.000000000 +0200
480 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/parisc/Kconfig linux-3.6.10-vs2.3.4.5/arch/parisc/Kconfig
496 --- linux-3.6.10/arch/parisc/Kconfig 2012-07-22 23:38:52.000000000 +0200
497 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/parisc/kernel/syscall_table.S linux-3.6.10-vs2.3.4.5/arch/parisc/kernel/syscall_table.S
508 --- linux-3.6.10/arch/parisc/kernel/syscall_table.S 2011-10-24 18:45:00.000000000 +0200
509 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/parisc/kernel/traps.c linux-3.6.10-vs2.3.4.5/arch/parisc/kernel/traps.c
520 --- linux-3.6.10/arch/parisc/kernel/traps.c 2012-05-21 18:06:28.000000000 +0200
521 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/parisc/mm/fault.c linux-3.6.10-vs2.3.4.5/arch/parisc/mm/fault.c
546 --- linux-3.6.10/arch/parisc/mm/fault.c 2010-08-02 16:52:06.000000000 +0200
547 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/powerpc/Kconfig linux-3.6.10-vs2.3.4.5/arch/powerpc/Kconfig
561 --- linux-3.6.10/arch/powerpc/Kconfig 2012-10-04 15:26:53.000000000 +0200
562 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/powerpc/include/asm/unistd.h linux-3.6.10-vs2.3.4.5/arch/powerpc/include/asm/unistd.h
573 --- linux-3.6.10/arch/powerpc/include/asm/unistd.h 2012-10-04 15:26:53.000000000 +0200
574 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/powerpc/kernel/process.c linux-3.6.10-vs2.3.4.5/arch/powerpc/kernel/process.c
585 --- linux-3.6.10/arch/powerpc/kernel/process.c 2012-10-04 15:26:54.000000000 +0200
586 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/powerpc/kernel/traps.c linux-3.6.10-vs2.3.4.5/arch/powerpc/kernel/traps.c
600 --- linux-3.6.10/arch/powerpc/kernel/traps.c 2012-10-04 15:26:54.000000000 +0200
601 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/s390/Kconfig linux-3.6.10-vs2.3.4.5/arch/s390/Kconfig
615 --- linux-3.6.10/arch/s390/Kconfig 2012-10-04 15:26:54.000000000 +0200
616 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/s390/include/asm/tlb.h linux-3.6.10-vs2.3.4.5/arch/s390/include/asm/tlb.h
627 --- linux-3.6.10/arch/s390/include/asm/tlb.h 2012-07-22 23:38:59.000000000 +0200
628 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/s390/include/asm/unistd.h linux-3.6.10-vs2.3.4.5/arch/s390/include/asm/unistd.h
638 --- linux-3.6.10/arch/s390/include/asm/unistd.h 2012-10-04 15:26:55.000000000 +0200
639 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/s390/kernel/ptrace.c linux-3.6.10-vs2.3.4.5/arch/s390/kernel/ptrace.c
650 --- linux-3.6.10/arch/s390/kernel/ptrace.c 2012-10-04 15:26:55.000000000 +0200
651 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/s390/kernel/syscalls.S linux-3.6.10-vs2.3.4.5/arch/s390/kernel/syscalls.S
661 --- linux-3.6.10/arch/s390/kernel/syscalls.S 2012-01-09 16:14:06.000000000 +0100
662 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/sh/Kconfig linux-3.6.10-vs2.3.4.5/arch/sh/Kconfig
673 --- linux-3.6.10/arch/sh/Kconfig 2012-10-04 15:26:55.000000000 +0200
674 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/sh/kernel/irq.c linux-3.6.10-vs2.3.4.5/arch/sh/kernel/irq.c
685 --- linux-3.6.10/arch/sh/kernel/irq.c 2012-10-04 15:26:56.000000000 +0200
686 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/sparc/Kconfig linux-3.6.10-vs2.3.4.5/arch/sparc/Kconfig
696 --- linux-3.6.10/arch/sparc/Kconfig 2012-10-04 15:26:58.000000000 +0200
697 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/sparc/include/asm/unistd.h linux-3.6.10-vs2.3.4.5/arch/sparc/include/asm/unistd.h
708 --- linux-3.6.10/arch/sparc/include/asm/unistd.h 2012-10-04 15:26:59.000000000 +0200
709 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/sparc/kernel/systbls_32.S linux-3.6.10-vs2.3.4.5/arch/sparc/kernel/systbls_32.S
720 --- linux-3.6.10/arch/sparc/kernel/systbls_32.S 2012-01-09 16:14:09.000000000 +0100
721 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/sparc/kernel/systbls_64.S linux-3.6.10-vs2.3.4.5/arch/sparc/kernel/systbls_64.S
732 --- linux-3.6.10/arch/sparc/kernel/systbls_64.S 2012-07-22 23:39:00.000000000 +0200
733 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/um/Kconfig.rest linux-3.6.10-vs2.3.4.5/arch/um/Kconfig.rest
753 --- linux-3.6.10/arch/um/Kconfig.rest 2012-01-09 16:14:09.000000000 +0100
754 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/um/include/shared/kern_constants.h linux-3.6.10-vs2.3.4.5/arch/um/include/shared/kern_constants.h
765 --- linux-3.6.10/arch/um/include/shared/kern_constants.h 1970-01-01 01:00:00.000000000 +0100
766 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/um/include/shared/user_constants.h linux-3.6.10-vs2.3.4.5/arch/um/include/shared/user_constants.h
770 --- linux-3.6.10/arch/um/include/shared/user_constants.h 1970-01-01 01:00:00.000000000 +0100
771 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/x86/Kconfig linux-3.6.10-vs2.3.4.5/arch/x86/Kconfig
814 --- linux-3.6.10/arch/x86/Kconfig 2012-10-04 15:27:00.000000000 +0200
815 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/x86/syscalls/syscall_32.tbl linux-3.6.10-vs2.3.4.5/arch/x86/syscalls/syscall_32.tbl
826 --- linux-3.6.10/arch/x86/syscalls/syscall_32.tbl 2012-07-22 23:39:02.000000000 +0200
827 +++ linux-3.6.10-vs2.3.4.5/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.10/arch/x86/syscalls/syscall_64.tbl linux-3.6.10-vs2.3.4.5/arch/x86/syscalls/syscall_64.tbl
838 --- linux-3.6.10/arch/x86/syscalls/syscall_64.tbl 2012-10-04 15:27:01.000000000 +0200
839 +++ linux-3.6.10-vs2.3.4.5/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.10/drivers/block/Kconfig linux-3.6.10-vs2.3.4.5/drivers/block/Kconfig
850 --- linux-3.6.10/drivers/block/Kconfig 2012-05-21 18:06:43.000000000 +0200
851 +++ linux-3.6.10-vs2.3.4.5/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.10/drivers/block/Makefile linux-3.6.10-vs2.3.4.5/drivers/block/Makefile
867 --- linux-3.6.10/drivers/block/Makefile 2012-03-19 19:46:52.000000000 +0100
868 +++ linux-3.6.10-vs2.3.4.5/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.10/drivers/block/loop.c linux-3.6.10-vs2.3.4.5/drivers/block/loop.c
878 --- linux-3.6.10/drivers/block/loop.c 2012-07-22 23:39:02.000000000 +0200
879 +++ linux-3.6.10-vs2.3.4.5/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.10/drivers/block/vroot.c linux-3.6.10-vs2.3.4.5/drivers/block/vroot.c
936 --- linux-3.6.10/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100
937 +++ linux-3.6.10-vs2.3.4.5/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.10/drivers/infiniband/Kconfig linux-3.6.10-vs2.3.4.5/drivers/infiniband/Kconfig
1231 --- linux-3.6.10/drivers/infiniband/Kconfig 2012-07-22 23:39:06.000000000 +0200
1232 +++ linux-3.6.10-vs2.3.4.5/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.10/drivers/infiniband/core/addr.c linux-3.6.10-vs2.3.4.5/drivers/infiniband/core/addr.c
1243 --- linux-3.6.10/drivers/infiniband/core/addr.c 2012-10-04 15:27:10.000000000 +0200
1244 +++ linux-3.6.10-vs2.3.4.5/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.10/drivers/md/dm-ioctl.c linux-3.6.10-vs2.3.4.5/drivers/md/dm-ioctl.c
1255 --- linux-3.6.10/drivers/md/dm-ioctl.c 2012-10-04 15:27:11.000000000 +0200
1256 +++ linux-3.6.10-vs2.3.4.5/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.10/drivers/md/dm.c linux-3.6.10-vs2.3.4.5/drivers/md/dm.c
1343 --- linux-3.6.10/drivers/md/dm.c 2012-12-11 12:36:52.000000000 +0100
1344 +++ linux-3.6.10-vs2.3.4.5/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.10/drivers/md/dm.h linux-3.6.10-vs2.3.4.5/drivers/md/dm.h
1419 --- linux-3.6.10/drivers/md/dm.h 2012-10-04 15:27:11.000000000 +0200
1420 +++ linux-3.6.10-vs2.3.4.5/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.10/drivers/net/tun.c linux-3.6.10-vs2.3.4.5/drivers/net/tun.c
1431 --- linux-3.6.10/drivers/net/tun.c 2012-10-04 15:27:20.000000000 +0200
1432 +++ linux-3.6.10-vs2.3.4.5/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.10/drivers/staging/csr/csr_wifi_hip_xbv.c linux-3.6.10-vs2.3.4.5/drivers/staging/csr/csr_wifi_hip_xbv.c
1503 --- linux-3.6.10/drivers/staging/csr/csr_wifi_hip_xbv.c 2012-10-04 15:27:30.000000000 +0200
1504 +++ linux-3.6.10-vs2.3.4.5/drivers/staging/csr/csr_wifi_hip_xbv.c 2012-12-10 17:33:14.000000000 +0100
1505 @@ -55,7 +55,7 @@ typedef struct
1513 #define TAG_EQ(i, v) (((i)[0] == (v)[0]) && \
1514 @@ -90,7 +90,7 @@ typedef struct
1518 -static s32 read_tag(card_t *card, ct_t *ct, tag_t *tag);
1519 +static s32 read_tag(card_t *card, ct_t *ct, ctag_t *tag);
1520 static s32 read_bytes(card_t *card, ct_t *ct, void *buf, u32 len);
1521 static s32 read_uint(card_t *card, ct_t *ct, u32 *u, u32 len);
1522 static s32 xbv_check(xbv1_t *fwinfo, const xbv_stack_t *stack,
1523 @@ -160,7 +160,7 @@ static u32 write_fwdl_to_ptdl(void *buf,
1524 CsrResult xbv1_parse(card_t *card, fwreadfn_t readfn, void *dlpriv, xbv1_t *fwinfo)
1532 @@ -505,7 +505,7 @@ static u32 xbv2uint(u8 *ptr, s32 len)
1536 -static s32 read_tag(card_t *card, ct_t *ct, tag_t *tag)
1537 +static s32 read_tag(card_t *card, ct_t *ct, ctag_t *tag)
1541 diff -NurpP --minimal linux-3.6.10/drivers/tty/sysrq.c linux-3.6.10-vs2.3.4.5/drivers/tty/sysrq.c
1542 --- linux-3.6.10/drivers/tty/sysrq.c 2012-05-21 18:07:16.000000000 +0200
1543 +++ linux-3.6.10-vs2.3.4.5/drivers/tty/sysrq.c 2012-10-04 18:47:00.000000000 +0200
1545 #include <linux/slab.h>
1546 #include <linux/input.h>
1547 #include <linux/uaccess.h>
1548 +#include <linux/vserver/debug.h>
1550 #include <asm/ptrace.h>
1551 #include <asm/irq_regs.h>
1552 @@ -398,6 +399,21 @@ static struct sysrq_key_op sysrq_unrt_op
1553 .enable_mask = SYSRQ_ENABLE_RTNICE,
1557 +#ifdef CONFIG_VSERVER_DEBUG
1558 +static void sysrq_handle_vxinfo(int key)
1560 + dump_vx_info_inactive((key == 'x') ? 0 : 1);
1563 +static struct sysrq_key_op sysrq_showvxinfo_op = {
1564 + .handler = sysrq_handle_vxinfo,
1565 + .help_msg = "conteXt",
1566 + .action_msg = "Show Context Info",
1567 + .enable_mask = SYSRQ_ENABLE_DUMP,
1571 /* Key Operations table and lock */
1572 static DEFINE_SPINLOCK(sysrq_key_table_lock);
1574 @@ -452,7 +468,11 @@ static struct sysrq_key_op *sysrq_key_ta
1576 &sysrq_showstate_blocked_op, /* w */
1577 /* x: May be registered on ppc/powerpc for xmon */
1578 +#ifdef CONFIG_VSERVER_DEBUG
1579 + &sysrq_showvxinfo_op, /* x */
1583 /* y: May be registered on sparc64 for global register dump */
1585 &sysrq_ftrace_dump_op, /* z */
1586 @@ -467,6 +487,8 @@ static int sysrq_key_table_key2index(int
1588 else if ((key >= 'a') && (key <= 'z'))
1589 retval = key + 10 - 'a';
1590 + else if ((key >= 'A') && (key <= 'Z'))
1591 + retval = key + 10 - 'A';
1595 diff -NurpP --minimal linux-3.6.10/drivers/tty/tty_io.c linux-3.6.10-vs2.3.4.5/drivers/tty/tty_io.c
1596 --- linux-3.6.10/drivers/tty/tty_io.c 2012-07-22 23:39:32.000000000 +0200
1597 +++ linux-3.6.10-vs2.3.4.5/drivers/tty/tty_io.c 2012-10-04 18:47:00.000000000 +0200
1600 #include <linux/kmod.h>
1601 #include <linux/nsproxy.h>
1602 +#include <linux/vs_pid.h>
1604 #undef TTY_DEBUG_HANGUP
1606 @@ -2123,7 +2124,8 @@ static int tiocsti(struct tty_struct *tt
1608 struct tty_ldisc *ld;
1610 - if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
1611 + if (((current->signal->tty != tty) &&
1612 + !vx_capable(CAP_SYS_ADMIN, VXC_TIOCSTI)))
1614 if (get_user(ch, p))
1616 @@ -2411,6 +2413,7 @@ static int tiocspgrp(struct tty_struct *
1618 if (get_user(pgrp_nr, p))
1620 + pgrp_nr = vx_rmap_pid(pgrp_nr);
1624 diff -NurpP --minimal linux-3.6.10/fs/attr.c linux-3.6.10-vs2.3.4.5/fs/attr.c
1625 --- linux-3.6.10/fs/attr.c 2012-10-04 15:27:39.000000000 +0200
1626 +++ linux-3.6.10-vs2.3.4.5/fs/attr.c 2012-10-04 18:47:00.000000000 +0200
1628 #include <linux/fcntl.h>
1629 #include <linux/security.h>
1630 #include <linux/evm.h>
1631 +#include <linux/proc_fs.h>
1632 +#include <linux/devpts_fs.h>
1633 +#include <linux/vs_tag.h>
1636 * inode_change_ok - check if attribute changes to an inode are allowed
1637 @@ -74,6 +77,10 @@ int inode_change_ok(const struct inode *
1641 + /* check for inode tag permission */
1642 + if (dx_permission(inode, MAY_WRITE))
1647 EXPORT_SYMBOL(inode_change_ok);
1648 @@ -144,6 +151,8 @@ void setattr_copy(struct inode *inode, c
1649 inode->i_uid = attr->ia_uid;
1650 if (ia_valid & ATTR_GID)
1651 inode->i_gid = attr->ia_gid;
1652 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
1653 + inode->i_tag = attr->ia_tag;
1654 if (ia_valid & ATTR_ATIME)
1655 inode->i_atime = timespec_trunc(attr->ia_atime,
1656 inode->i_sb->s_time_gran);
1657 @@ -173,7 +182,8 @@ int notify_change(struct dentry * dentry
1659 WARN_ON_ONCE(!mutex_is_locked(&inode->i_mutex));
1661 - if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
1662 + if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
1663 + ATTR_TAG | ATTR_TIMES_SET)) {
1664 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1667 diff -NurpP --minimal linux-3.6.10/fs/block_dev.c linux-3.6.10-vs2.3.4.5/fs/block_dev.c
1668 --- linux-3.6.10/fs/block_dev.c 2012-10-04 15:27:39.000000000 +0200
1669 +++ linux-3.6.10-vs2.3.4.5/fs/block_dev.c 2012-10-04 18:47:00.000000000 +0200
1671 #include <linux/namei.h>
1672 #include <linux/log2.h>
1673 #include <linux/cleancache.h>
1674 +#include <linux/vs_device.h>
1675 #include <asm/uaccess.h>
1676 #include "internal.h"
1678 @@ -581,6 +582,7 @@ struct block_device *bdget(dev_t dev)
1679 bdev->bd_invalidated = 0;
1680 inode->i_mode = S_IFBLK;
1681 inode->i_rdev = dev;
1682 + inode->i_mdev = dev;
1683 inode->i_bdev = bdev;
1684 inode->i_data.a_ops = &def_blk_aops;
1685 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
1686 @@ -627,6 +629,11 @@ EXPORT_SYMBOL(bdput);
1687 static struct block_device *bd_acquire(struct inode *inode)
1689 struct block_device *bdev;
1692 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
1694 + inode->i_mdev = mdev;
1696 spin_lock(&bdev_lock);
1697 bdev = inode->i_bdev;
1698 @@ -637,7 +644,7 @@ static struct block_device *bd_acquire(s
1700 spin_unlock(&bdev_lock);
1702 - bdev = bdget(inode->i_rdev);
1703 + bdev = bdget(mdev);
1705 spin_lock(&bdev_lock);
1706 if (!inode->i_bdev) {
1707 diff -NurpP --minimal linux-3.6.10/fs/btrfs/ctree.h linux-3.6.10-vs2.3.4.5/fs/btrfs/ctree.h
1708 --- linux-3.6.10/fs/btrfs/ctree.h 2012-10-04 15:27:39.000000000 +0200
1709 +++ linux-3.6.10-vs2.3.4.5/fs/btrfs/ctree.h 2012-10-04 18:47:00.000000000 +0200
1710 @@ -674,11 +674,14 @@ struct btrfs_inode_item {
1711 /* modification sequence number for NFS */
1716 * a little future expansion, for more than this we can
1717 * just grow the inode item and version it
1719 - __le64 reserved[4];
1720 + __le16 reserved16;
1721 + __le32 reserved32;
1722 + __le64 reserved[3];
1723 struct btrfs_timespec atime;
1724 struct btrfs_timespec ctime;
1725 struct btrfs_timespec mtime;
1726 @@ -1727,6 +1730,8 @@ struct btrfs_ioctl_defrag_range_args {
1727 #define BTRFS_MOUNT_CHECK_INTEGRITY_INCLUDING_EXTENT_DATA (1 << 21)
1728 #define BTRFS_MOUNT_PANIC_ON_FATAL_ERROR (1 << 22)
1730 +#define BTRFS_MOUNT_TAGGED (1 << 24)
1732 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
1733 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
1734 #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \
1735 @@ -1988,6 +1993,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
1736 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
1737 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
1738 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
1739 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
1740 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
1741 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
1742 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
1743 @@ -2041,6 +2047,10 @@ BTRFS_SETGET_FUNCS(extent_flags, struct
1745 BTRFS_SETGET_FUNCS(extent_refs_v0, struct btrfs_extent_item_v0, refs, 32);
1747 +#define BTRFS_INODE_IXUNLINK (1 << 24)
1748 +#define BTRFS_INODE_BARRIER (1 << 25)
1749 +#define BTRFS_INODE_COW (1 << 26)
1752 BTRFS_SETGET_FUNCS(tree_block_level, struct btrfs_tree_block_info, level, 8);
1754 @@ -3305,6 +3315,7 @@ extern const struct dentry_operations bt
1755 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1756 void btrfs_update_iflags(struct inode *inode);
1757 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
1758 +int btrfs_sync_flags(struct inode *inode, int, int);
1759 int btrfs_defrag_file(struct inode *inode, struct file *file,
1760 struct btrfs_ioctl_defrag_range_args *range,
1761 u64 newer_than, unsigned long max_pages);
1762 diff -NurpP --minimal linux-3.6.10/fs/btrfs/disk-io.c linux-3.6.10-vs2.3.4.5/fs/btrfs/disk-io.c
1763 --- linux-3.6.10/fs/btrfs/disk-io.c 2012-10-04 15:27:39.000000000 +0200
1764 +++ linux-3.6.10-vs2.3.4.5/fs/btrfs/disk-io.c 2012-10-04 18:47:00.000000000 +0200
1765 @@ -2187,6 +2187,9 @@ int open_ctree(struct super_block *sb,
1769 + if (btrfs_test_opt(tree_root, TAGGED))
1770 + sb->s_flags |= MS_TAGGED;
1772 features = btrfs_super_incompat_flags(disk_super) &
1773 ~BTRFS_FEATURE_INCOMPAT_SUPP;
1775 diff -NurpP --minimal linux-3.6.10/fs/btrfs/inode.c linux-3.6.10-vs2.3.4.5/fs/btrfs/inode.c
1776 --- linux-3.6.10/fs/btrfs/inode.c 2012-10-04 15:27:39.000000000 +0200
1777 +++ linux-3.6.10-vs2.3.4.5/fs/btrfs/inode.c 2012-10-04 18:47:00.000000000 +0200
1779 #include <linux/slab.h>
1780 #include <linux/ratelimit.h>
1781 #include <linux/mount.h>
1782 +#include <linux/vs_tag.h>
1785 #include "disk-io.h"
1786 @@ -2545,6 +2546,8 @@ static void btrfs_read_locked_inode(stru
1787 struct btrfs_key location;
1793 bool filled = false;
1795 @@ -2572,8 +2575,13 @@ static void btrfs_read_locked_inode(stru
1796 struct btrfs_inode_item);
1797 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
1798 set_nlink(inode, btrfs_inode_nlink(leaf, inode_item));
1799 - inode->i_uid = btrfs_inode_uid(leaf, inode_item);
1800 - inode->i_gid = btrfs_inode_gid(leaf, inode_item);
1802 + uid = btrfs_inode_uid(leaf, inode_item);
1803 + gid = btrfs_inode_gid(leaf, inode_item);
1804 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
1805 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
1806 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
1807 + btrfs_inode_tag(leaf, inode_item));
1808 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
1810 tspec = btrfs_inode_atime(inode_item);
1811 @@ -2651,8 +2659,14 @@ static void fill_inode_item(struct btrfs
1812 struct btrfs_inode_item *item,
1813 struct inode *inode)
1815 - btrfs_set_inode_uid(leaf, item, inode->i_uid);
1816 - btrfs_set_inode_gid(leaf, item, inode->i_gid);
1817 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
1818 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
1820 + btrfs_set_inode_uid(leaf, item, uid);
1821 + btrfs_set_inode_gid(leaf, item, gid);
1822 +#ifdef CONFIG_TAGGING_INTERN
1823 + btrfs_set_inode_tag(leaf, item, inode->i_tag);
1825 btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
1826 btrfs_set_inode_mode(leaf, item, inode->i_mode);
1827 btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
1828 @@ -7636,11 +7650,13 @@ static const struct inode_operations btr
1829 .listxattr = btrfs_listxattr,
1830 .removexattr = btrfs_removexattr,
1831 .permission = btrfs_permission,
1832 + .sync_flags = btrfs_sync_flags,
1833 .get_acl = btrfs_get_acl,
1835 static const struct inode_operations btrfs_dir_ro_inode_operations = {
1836 .lookup = btrfs_lookup,
1837 .permission = btrfs_permission,
1838 + .sync_flags = btrfs_sync_flags,
1839 .get_acl = btrfs_get_acl,
1842 diff -NurpP --minimal linux-3.6.10/fs/btrfs/ioctl.c linux-3.6.10-vs2.3.4.5/fs/btrfs/ioctl.c
1843 --- linux-3.6.10/fs/btrfs/ioctl.c 2012-10-04 15:27:39.000000000 +0200
1844 +++ linux-3.6.10-vs2.3.4.5/fs/btrfs/ioctl.c 2012-10-04 18:47:00.000000000 +0200
1845 @@ -74,10 +74,13 @@ static unsigned int btrfs_flags_to_ioctl
1847 unsigned int iflags = 0;
1849 - if (flags & BTRFS_INODE_SYNC)
1850 - iflags |= FS_SYNC_FL;
1851 if (flags & BTRFS_INODE_IMMUTABLE)
1852 iflags |= FS_IMMUTABLE_FL;
1853 + if (flags & BTRFS_INODE_IXUNLINK)
1854 + iflags |= FS_IXUNLINK_FL;
1856 + if (flags & BTRFS_INODE_SYNC)
1857 + iflags |= FS_SYNC_FL;
1858 if (flags & BTRFS_INODE_APPEND)
1859 iflags |= FS_APPEND_FL;
1860 if (flags & BTRFS_INODE_NODUMP)
1861 @@ -94,28 +97,78 @@ static unsigned int btrfs_flags_to_ioctl
1862 else if (flags & BTRFS_INODE_NOCOMPRESS)
1863 iflags |= FS_NOCOMP_FL;
1865 + if (flags & BTRFS_INODE_BARRIER)
1866 + iflags |= FS_BARRIER_FL;
1867 + if (flags & BTRFS_INODE_COW)
1868 + iflags |= FS_COW_FL;
1873 - * Update inode->i_flags based on the btrfs internal flags.
1874 + * Update inode->i_(v)flags based on the btrfs internal flags.
1876 void btrfs_update_iflags(struct inode *inode)
1878 struct btrfs_inode *ip = BTRFS_I(inode);
1880 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
1881 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
1882 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
1884 - if (ip->flags & BTRFS_INODE_SYNC)
1885 - inode->i_flags |= S_SYNC;
1886 if (ip->flags & BTRFS_INODE_IMMUTABLE)
1887 inode->i_flags |= S_IMMUTABLE;
1888 + if (ip->flags & BTRFS_INODE_IXUNLINK)
1889 + inode->i_flags |= S_IXUNLINK;
1891 + if (ip->flags & BTRFS_INODE_SYNC)
1892 + inode->i_flags |= S_SYNC;
1893 if (ip->flags & BTRFS_INODE_APPEND)
1894 inode->i_flags |= S_APPEND;
1895 if (ip->flags & BTRFS_INODE_NOATIME)
1896 inode->i_flags |= S_NOATIME;
1897 if (ip->flags & BTRFS_INODE_DIRSYNC)
1898 inode->i_flags |= S_DIRSYNC;
1900 + inode->i_vflags &= ~(V_BARRIER | V_COW);
1902 + if (ip->flags & BTRFS_INODE_BARRIER)
1903 + inode->i_vflags |= V_BARRIER;
1904 + if (ip->flags & BTRFS_INODE_COW)
1905 + inode->i_vflags |= V_COW;
1909 + * Update btrfs internal flags from inode->i_(v)flags.
1911 +void btrfs_update_flags(struct inode *inode)
1913 + struct btrfs_inode *ip = BTRFS_I(inode);
1915 + unsigned int flags = inode->i_flags;
1916 + unsigned int vflags = inode->i_vflags;
1918 + ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
1919 + BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
1920 + BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
1921 + BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
1923 + if (flags & S_IMMUTABLE)
1924 + ip->flags |= BTRFS_INODE_IMMUTABLE;
1925 + if (flags & S_IXUNLINK)
1926 + ip->flags |= BTRFS_INODE_IXUNLINK;
1928 + if (flags & S_SYNC)
1929 + ip->flags |= BTRFS_INODE_SYNC;
1930 + if (flags & S_APPEND)
1931 + ip->flags |= BTRFS_INODE_APPEND;
1932 + if (flags & S_NOATIME)
1933 + ip->flags |= BTRFS_INODE_NOATIME;
1934 + if (flags & S_DIRSYNC)
1935 + ip->flags |= BTRFS_INODE_DIRSYNC;
1937 + if (vflags & V_BARRIER)
1938 + ip->flags |= BTRFS_INODE_BARRIER;
1939 + if (vflags & V_COW)
1940 + ip->flags |= BTRFS_INODE_COW;
1944 @@ -131,6 +184,7 @@ void btrfs_inherit_iflags(struct inode *
1947 flags = BTRFS_I(dir)->flags;
1948 + flags &= ~BTRFS_INODE_BARRIER;
1950 if (flags & BTRFS_INODE_NOCOMPRESS) {
1951 BTRFS_I(inode)->flags &= ~BTRFS_INODE_COMPRESS;
1952 @@ -146,6 +200,30 @@ void btrfs_inherit_iflags(struct inode *
1953 btrfs_update_iflags(inode);
1956 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
1958 + struct btrfs_inode *ip = BTRFS_I(inode);
1959 + struct btrfs_root *root = ip->root;
1960 + struct btrfs_trans_handle *trans;
1963 + trans = btrfs_join_transaction(root);
1966 + inode->i_flags = flags;
1967 + inode->i_vflags = vflags;
1968 + btrfs_update_flags(inode);
1970 + ret = btrfs_update_inode(trans, root, inode);
1973 + btrfs_update_iflags(inode);
1974 + inode->i_ctime = CURRENT_TIME;
1975 + btrfs_end_transaction(trans, root);
1980 static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
1982 struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
1983 @@ -206,21 +284,27 @@ static int btrfs_ioctl_setflags(struct f
1985 flags = btrfs_mask_flags(inode->i_mode, flags);
1986 oldflags = btrfs_flags_to_ioctl(ip->flags);
1987 - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
1988 + if ((flags ^ oldflags) & (FS_APPEND_FL |
1989 + FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
1990 if (!capable(CAP_LINUX_IMMUTABLE)) {
1996 - if (flags & FS_SYNC_FL)
1997 - ip->flags |= BTRFS_INODE_SYNC;
1999 - ip->flags &= ~BTRFS_INODE_SYNC;
2000 if (flags & FS_IMMUTABLE_FL)
2001 ip->flags |= BTRFS_INODE_IMMUTABLE;
2003 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
2004 + if (flags & FS_IXUNLINK_FL)
2005 + ip->flags |= BTRFS_INODE_IXUNLINK;
2007 + ip->flags &= ~BTRFS_INODE_IXUNLINK;
2009 + if (flags & FS_SYNC_FL)
2010 + ip->flags |= BTRFS_INODE_SYNC;
2012 + ip->flags &= ~BTRFS_INODE_SYNC;
2013 if (flags & FS_APPEND_FL)
2014 ip->flags |= BTRFS_INODE_APPEND;
2016 diff -NurpP --minimal linux-3.6.10/fs/btrfs/super.c linux-3.6.10-vs2.3.4.5/fs/btrfs/super.c
2017 --- linux-3.6.10/fs/btrfs/super.c 2012-10-04 15:27:39.000000000 +0200
2018 +++ linux-3.6.10-vs2.3.4.5/fs/btrfs/super.c 2012-10-04 18:47:00.000000000 +0200
2019 @@ -306,7 +306,7 @@ enum {
2020 Opt_no_space_cache, Opt_recovery, Opt_skip_balance,
2021 Opt_check_integrity, Opt_check_integrity_including_extent_data,
2022 Opt_check_integrity_print_mask, Opt_fatal_errors,
2024 + Opt_tag, Opt_notag, Opt_tagid, Opt_err,
2027 static match_table_t tokens = {
2028 @@ -346,6 +346,9 @@ static match_table_t tokens = {
2029 {Opt_check_integrity_including_extent_data, "check_int_data"},
2030 {Opt_check_integrity_print_mask, "check_int_print_mask=%d"},
2031 {Opt_fatal_errors, "fatal_errors=%s"},
2033 + {Opt_notag, "notag"},
2034 + {Opt_tagid, "tagid=%u"},
2038 @@ -596,6 +599,22 @@ int btrfs_parse_options(struct btrfs_roo
2042 +#ifndef CONFIG_TAGGING_NONE
2044 + printk(KERN_INFO "btrfs: use tagging\n");
2045 + btrfs_set_opt(info->mount_opt, TAGGED);
2048 + printk(KERN_INFO "btrfs: disabled tagging\n");
2049 + btrfs_clear_opt(info->mount_opt, TAGGED);
2052 +#ifdef CONFIG_PROPAGATE
2055 + btrfs_set_opt(info->mount_opt, TAGGED);
2059 printk(KERN_INFO "btrfs: unrecognized mount option "
2061 @@ -1196,6 +1215,12 @@ static int btrfs_remount(struct super_bl
2062 btrfs_resize_thread_pool(fs_info,
2063 fs_info->thread_pool_size, old_thread_pool_size);
2065 + if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
2066 + printk("btrfs: %s: tagging not permitted on remount.\n",
2071 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
2074 diff -NurpP --minimal linux-3.6.10/fs/char_dev.c linux-3.6.10-vs2.3.4.5/fs/char_dev.c
2075 --- linux-3.6.10/fs/char_dev.c 2012-03-19 19:47:25.000000000 +0100
2076 +++ linux-3.6.10-vs2.3.4.5/fs/char_dev.c 2012-10-04 18:47:00.000000000 +0200
2078 #include <linux/mutex.h>
2079 #include <linux/backing-dev.h>
2080 #include <linux/tty.h>
2081 +#include <linux/vs_context.h>
2082 +#include <linux/vs_device.h>
2084 #include "internal.h"
2086 @@ -371,14 +373,21 @@ static int chrdev_open(struct inode *ino
2088 struct cdev *new = NULL;
2092 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2094 + inode->i_mdev = mdev;
2096 spin_lock(&cdev_lock);
2099 struct kobject *kobj;
2102 spin_unlock(&cdev_lock);
2103 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2105 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2108 new = container_of(kobj, struct cdev, kobj);
2109 diff -NurpP --minimal linux-3.6.10/fs/dcache.c linux-3.6.10-vs2.3.4.5/fs/dcache.c
2110 --- linux-3.6.10/fs/dcache.c 2012-10-04 15:27:39.000000000 +0200
2111 +++ linux-3.6.10-vs2.3.4.5/fs/dcache.c 2012-12-07 22:49:54.000000000 +0100
2113 #include <linux/rculist_bl.h>
2114 #include <linux/prefetch.h>
2115 #include <linux/ratelimit.h>
2116 +#include <linux/vs_limit.h>
2117 #include "internal.h"
2120 @@ -617,6 +618,8 @@ int d_invalidate(struct dentry * dentry)
2121 spin_lock(&dentry->d_lock);
2124 + vx_dentry_dec(dentry);
2127 * Somebody else still using it?
2129 @@ -646,6 +649,7 @@ EXPORT_SYMBOL(d_invalidate);
2130 static inline void __dget_dlock(struct dentry *dentry)
2133 + vx_dentry_inc(dentry);
2136 static inline void __dget(struct dentry *dentry)
2137 @@ -1276,6 +1280,9 @@ struct dentry *__d_alloc(struct super_bl
2138 struct dentry *dentry;
2141 + if (!vx_dentry_avail(1))
2144 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
2147 @@ -1308,6 +1315,7 @@ struct dentry *__d_alloc(struct super_bl
2149 dentry->d_count = 1;
2150 dentry->d_flags = 0;
2151 + vx_dentry_inc(dentry);
2152 spin_lock_init(&dentry->d_lock);
2153 seqcount_init(&dentry->d_seq);
2154 dentry->d_inode = NULL;
2155 @@ -2012,6 +2020,7 @@ struct dentry *__d_lookup(struct dentry
2159 + vx_dentry_inc(dentry);
2161 spin_unlock(&dentry->d_lock);
2163 diff -NurpP --minimal linux-3.6.10/fs/devpts/inode.c linux-3.6.10-vs2.3.4.5/fs/devpts/inode.c
2164 --- linux-3.6.10/fs/devpts/inode.c 2012-10-04 15:27:39.000000000 +0200
2165 +++ linux-3.6.10-vs2.3.4.5/fs/devpts/inode.c 2012-10-04 18:47:00.000000000 +0200
2167 #include <linux/parser.h>
2168 #include <linux/fsnotify.h>
2169 #include <linux/seq_file.h>
2170 +#include <linux/vs_base.h>
2172 #define DEVPTS_DEFAULT_MODE 0600
2175 #define DEVPTS_DEFAULT_PTMX_MODE 0000
2176 #define PTMX_MINOR 2
2178 +static int devpts_permission(struct inode *inode, int mask)
2180 + int ret = -EACCES;
2182 + /* devpts is xid tagged */
2183 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
2184 + ret = generic_permission(inode, mask);
2188 +static struct inode_operations devpts_file_inode_operations = {
2189 + .permission = devpts_permission,
2194 * sysctl support for setting limits on the number of Unix98 ptys allocated.
2195 * Otherwise one can eat up all kernel memory by opening /dev/ptmx repeatedly.
2196 @@ -336,6 +352,34 @@ static int devpts_show_options(struct se
2200 +static int devpts_filter(struct dentry *de)
2204 + /* devpts is xid tagged */
2205 + if (de && de->d_inode)
2206 + xid = (xid_t)de->d_inode->i_tag;
2207 +#ifdef CONFIG_VSERVER_WARN_DEVPTS
2209 + vxwprintk_task(1, "devpts " VS_Q("%.*s") " without inode.",
2210 + de->d_name.len, de->d_name.name);
2212 + return vx_check(xid, VS_WATCH_P | VS_IDENT);
2215 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2217 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2220 +static struct file_operations devpts_dir_operations = {
2221 + .open = dcache_dir_open,
2222 + .release = dcache_dir_close,
2223 + .llseek = dcache_dir_lseek,
2224 + .read = generic_read_dir,
2225 + .readdir = devpts_readdir,
2228 static const struct super_operations devpts_sops = {
2229 .statfs = simple_statfs,
2230 .remount_fs = devpts_remount,
2231 @@ -379,8 +423,10 @@ devpts_fill_super(struct super_block *s,
2232 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2233 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2234 inode->i_op = &simple_dir_inode_operations;
2235 - inode->i_fop = &simple_dir_operations;
2236 + inode->i_fop = &devpts_dir_operations;
2237 set_nlink(inode, 2);
2238 + /* devpts is xid tagged */
2239 + inode->i_tag = (tag_t)vx_current_xid();
2241 s->s_root = d_make_root(inode);
2243 @@ -572,6 +618,9 @@ int devpts_pty_new(struct inode *ptmx_in
2244 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
2245 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2246 init_special_inode(inode, S_IFCHR|opts->mode, device);
2247 + /* devpts is xid tagged */
2248 + inode->i_tag = (tag_t)vx_current_xid();
2249 + inode->i_op = &devpts_file_inode_operations;
2250 inode->i_private = tty;
2251 tty->driver_data = inode;
2253 diff -NurpP --minimal linux-3.6.10/fs/ext2/balloc.c linux-3.6.10-vs2.3.4.5/fs/ext2/balloc.c
2254 --- linux-3.6.10/fs/ext2/balloc.c 2012-10-04 15:27:39.000000000 +0200
2255 +++ linux-3.6.10-vs2.3.4.5/fs/ext2/balloc.c 2012-10-04 18:47:00.000000000 +0200
2256 @@ -699,7 +699,6 @@ ext2_try_to_allocate(struct super_block
2258 end = EXT2_BLOCKS_PER_GROUP(sb);
2261 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2264 diff -NurpP --minimal linux-3.6.10/fs/ext2/ext2.h linux-3.6.10-vs2.3.4.5/fs/ext2/ext2.h
2265 --- linux-3.6.10/fs/ext2/ext2.h 2012-07-22 23:39:39.000000000 +0200
2266 +++ linux-3.6.10-vs2.3.4.5/fs/ext2/ext2.h 2012-10-04 18:47:00.000000000 +0200
2267 @@ -244,8 +244,12 @@ struct ext2_group_desc
2268 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
2269 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
2270 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
2271 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
2272 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
2274 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
2275 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
2277 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
2278 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
2280 @@ -329,7 +333,8 @@ struct ext2_inode {
2282 __le16 l_i_uid_high; /* these 2 fields */
2283 __le16 l_i_gid_high; /* were reserved2[0] */
2284 - __u32 l_i_reserved2;
2285 + __le16 l_i_tag; /* Context Tag */
2286 + __u16 l_i_reserved2;
2289 __u8 h_i_frag; /* Fragment number */
2290 @@ -357,6 +362,7 @@ struct ext2_inode {
2291 #define i_gid_low i_gid
2292 #define i_uid_high osd2.linux2.l_i_uid_high
2293 #define i_gid_high osd2.linux2.l_i_gid_high
2294 +#define i_raw_tag osd2.linux2.l_i_tag
2295 #define i_reserved2 osd2.linux2.l_i_reserved2
2298 @@ -384,6 +390,7 @@ struct ext2_inode {
2299 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
2300 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
2301 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
2302 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
2305 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
2306 @@ -757,6 +764,7 @@ extern void ext2_set_inode_flags(struct
2307 extern void ext2_get_inode_flags(struct ext2_inode_info *);
2308 extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2309 u64 start, u64 len);
2310 +extern int ext2_sync_flags(struct inode *, int, int);
2313 extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
2314 diff -NurpP --minimal linux-3.6.10/fs/ext2/file.c linux-3.6.10-vs2.3.4.5/fs/ext2/file.c
2315 --- linux-3.6.10/fs/ext2/file.c 2011-10-24 18:45:27.000000000 +0200
2316 +++ linux-3.6.10-vs2.3.4.5/fs/ext2/file.c 2012-10-04 18:47:00.000000000 +0200
2317 @@ -104,4 +104,5 @@ const struct inode_operations ext2_file_
2318 .setattr = ext2_setattr,
2319 .get_acl = ext2_get_acl,
2320 .fiemap = ext2_fiemap,
2321 + .sync_flags = ext2_sync_flags,
2323 diff -NurpP --minimal linux-3.6.10/fs/ext2/ialloc.c linux-3.6.10-vs2.3.4.5/fs/ext2/ialloc.c
2324 --- linux-3.6.10/fs/ext2/ialloc.c 2012-10-04 15:27:39.000000000 +0200
2325 +++ linux-3.6.10-vs2.3.4.5/fs/ext2/ialloc.c 2012-10-04 18:47:00.000000000 +0200
2327 #include <linux/backing-dev.h>
2328 #include <linux/buffer_head.h>
2329 #include <linux/random.h>
2330 +#include <linux/vs_tag.h>
2334 @@ -547,6 +548,7 @@ got:
2335 inode->i_mode = mode;
2336 inode->i_uid = current_fsuid();
2337 inode->i_gid = dir->i_gid;
2338 + inode->i_tag = dx_current_fstag(sb);
2340 inode_init_owner(inode, dir, mode);
2342 diff -NurpP --minimal linux-3.6.10/fs/ext2/inode.c linux-3.6.10-vs2.3.4.5/fs/ext2/inode.c
2343 --- linux-3.6.10/fs/ext2/inode.c 2012-10-04 15:27:39.000000000 +0200
2344 +++ linux-3.6.10-vs2.3.4.5/fs/ext2/inode.c 2012-10-04 18:47:00.000000000 +0200
2346 #include <linux/mpage.h>
2347 #include <linux/fiemap.h>
2348 #include <linux/namei.h>
2349 +#include <linux/vs_tag.h>
2353 @@ -1165,7 +1166,7 @@ static void ext2_truncate_blocks(struct
2355 if (ext2_inode_is_fast_symlink(inode))
2357 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2358 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2360 __ext2_truncate_blocks(inode, offset);
2362 @@ -1256,36 +1257,61 @@ void ext2_set_inode_flags(struct inode *
2364 unsigned int flags = EXT2_I(inode)->i_flags;
2366 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2367 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2368 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2371 + if (flags & EXT2_IMMUTABLE_FL)
2372 + inode->i_flags |= S_IMMUTABLE;
2373 + if (flags & EXT2_IXUNLINK_FL)
2374 + inode->i_flags |= S_IXUNLINK;
2376 if (flags & EXT2_SYNC_FL)
2377 inode->i_flags |= S_SYNC;
2378 if (flags & EXT2_APPEND_FL)
2379 inode->i_flags |= S_APPEND;
2380 - if (flags & EXT2_IMMUTABLE_FL)
2381 - inode->i_flags |= S_IMMUTABLE;
2382 if (flags & EXT2_NOATIME_FL)
2383 inode->i_flags |= S_NOATIME;
2384 if (flags & EXT2_DIRSYNC_FL)
2385 inode->i_flags |= S_DIRSYNC;
2387 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2389 + if (flags & EXT2_BARRIER_FL)
2390 + inode->i_vflags |= V_BARRIER;
2391 + if (flags & EXT2_COW_FL)
2392 + inode->i_vflags |= V_COW;
2395 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
2396 void ext2_get_inode_flags(struct ext2_inode_info *ei)
2398 unsigned int flags = ei->vfs_inode.i_flags;
2399 + unsigned int vflags = ei->vfs_inode.i_vflags;
2401 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
2402 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
2403 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
2404 + EXT2_BARRIER_FL | EXT2_COW_FL);
2406 + if (flags & S_IMMUTABLE)
2407 + ei->i_flags |= EXT2_IMMUTABLE_FL;
2408 + if (flags & S_IXUNLINK)
2409 + ei->i_flags |= EXT2_IXUNLINK_FL;
2411 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
2412 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
2414 ei->i_flags |= EXT2_SYNC_FL;
2415 if (flags & S_APPEND)
2416 ei->i_flags |= EXT2_APPEND_FL;
2417 - if (flags & S_IMMUTABLE)
2418 - ei->i_flags |= EXT2_IMMUTABLE_FL;
2419 if (flags & S_NOATIME)
2420 ei->i_flags |= EXT2_NOATIME_FL;
2421 if (flags & S_DIRSYNC)
2422 ei->i_flags |= EXT2_DIRSYNC_FL;
2424 + if (vflags & V_BARRIER)
2425 + ei->i_flags |= EXT2_BARRIER_FL;
2426 + if (vflags & V_COW)
2427 + ei->i_flags |= EXT2_COW_FL;
2430 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
2431 @@ -1321,8 +1347,10 @@ struct inode *ext2_iget (struct super_bl
2432 i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2433 i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2435 - i_uid_write(inode, i_uid);
2436 - i_gid_write(inode, i_gid);
2437 + i_uid_write(inode, INOTAG_UID(DX_TAG(inode), i_uid, i_gid));
2438 + i_gid_write(inode, INOTAG_GID(DX_TAG(inode), i_uid, i_gid));
2439 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), i_uid, i_gid,
2440 + le16_to_cpu(raw_inode->i_raw_tag));
2441 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
2442 inode->i_size = le32_to_cpu(raw_inode->i_size);
2443 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2444 @@ -1420,8 +1448,8 @@ static int __ext2_write_inode(struct ino
2445 struct ext2_inode_info *ei = EXT2_I(inode);
2446 struct super_block *sb = inode->i_sb;
2447 ino_t ino = inode->i_ino;
2448 - uid_t uid = i_uid_read(inode);
2449 - gid_t gid = i_gid_read(inode);
2450 + uid_t uid = TAGINO_UID(DX_TAG(inode), i_uid_read(inode), inode->i_tag);
2451 + gid_t gid = TAGINO_GID(DX_TAG(inode), i_gid_read(inode), inode->i_tag);
2452 struct buffer_head * bh;
2453 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2455 @@ -1457,6 +1485,9 @@ static int __ext2_write_inode(struct ino
2456 raw_inode->i_uid_high = 0;
2457 raw_inode->i_gid_high = 0;
2459 +#ifdef CONFIG_TAGGING_INTERN
2460 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2462 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2463 raw_inode->i_size = cpu_to_le32(inode->i_size);
2464 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2465 @@ -1537,7 +1568,8 @@ int ext2_setattr(struct dentry *dentry,
2466 if (is_quota_modification(inode, iattr))
2467 dquot_initialize(inode);
2468 if ((iattr->ia_valid & ATTR_UID && !uid_eq(iattr->ia_uid, inode->i_uid)) ||
2469 - (iattr->ia_valid & ATTR_GID && !gid_eq(iattr->ia_gid, inode->i_gid))) {
2470 + (iattr->ia_valid & ATTR_GID && !gid_eq(iattr->ia_gid, inode->i_gid)) ||
2471 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
2472 error = dquot_transfer(inode, iattr);
2475 diff -NurpP --minimal linux-3.6.10/fs/ext2/ioctl.c linux-3.6.10-vs2.3.4.5/fs/ext2/ioctl.c
2476 --- linux-3.6.10/fs/ext2/ioctl.c 2012-03-19 19:47:25.000000000 +0100
2477 +++ linux-3.6.10-vs2.3.4.5/fs/ext2/ioctl.c 2012-10-04 18:47:00.000000000 +0200
2479 #include <asm/uaccess.h>
2482 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
2484 + inode->i_flags = flags;
2485 + inode->i_vflags = vflags;
2486 + ext2_get_inode_flags(EXT2_I(inode));
2487 + inode->i_ctime = CURRENT_TIME_SEC;
2488 + mark_inode_dirty(inode);
2492 long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2494 struct inode *inode = filp->f_dentry->d_inode;
2495 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
2497 flags = ext2_mask_flags(inode->i_mode, flags);
2499 + if (IS_BARRIER(inode)) {
2500 + vxwprintk_task(1, "messing with the barrier.");
2504 mutex_lock(&inode->i_mutex);
2505 /* Is it quota file? Do not allow user to mess with it */
2506 if (IS_NOQUOTA(inode)) {
2507 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
2509 * This test looks nicer. Thanks to Pauline Middelink
2511 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
2512 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
2513 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
2514 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
2515 if (!capable(CAP_LINUX_IMMUTABLE)) {
2516 mutex_unlock(&inode->i_mutex);
2518 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
2522 - flags = flags & EXT2_FL_USER_MODIFIABLE;
2523 + flags &= EXT2_FL_USER_MODIFIABLE;
2524 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
2525 ei->i_flags = flags;
2527 diff -NurpP --minimal linux-3.6.10/fs/ext2/namei.c linux-3.6.10-vs2.3.4.5/fs/ext2/namei.c
2528 --- linux-3.6.10/fs/ext2/namei.c 2012-10-04 15:27:39.000000000 +0200
2529 +++ linux-3.6.10-vs2.3.4.5/fs/ext2/namei.c 2012-10-04 18:47:00.000000000 +0200
2532 #include <linux/pagemap.h>
2533 #include <linux/quotaops.h>
2534 +#include <linux/vs_tag.h>
2538 @@ -73,6 +74,7 @@ static struct dentry *ext2_lookup(struct
2539 (unsigned long) ino);
2540 return ERR_PTR(-EIO);
2542 + dx_propagate_tag(nd, inode);
2544 return d_splice_alias(inode, dentry);
2546 @@ -397,6 +399,7 @@ const struct inode_operations ext2_dir_i
2547 .removexattr = generic_removexattr,
2549 .setattr = ext2_setattr,
2550 + .sync_flags = ext2_sync_flags,
2551 .get_acl = ext2_get_acl,
2554 diff -NurpP --minimal linux-3.6.10/fs/ext2/super.c linux-3.6.10-vs2.3.4.5/fs/ext2/super.c
2555 --- linux-3.6.10/fs/ext2/super.c 2012-10-04 15:27:39.000000000 +0200
2556 +++ linux-3.6.10-vs2.3.4.5/fs/ext2/super.c 2012-10-04 18:47:00.000000000 +0200
2557 @@ -390,7 +390,8 @@ enum {
2558 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
2559 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
2560 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
2561 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
2562 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
2563 + Opt_tag, Opt_notag, Opt_tagid
2566 static const match_table_t tokens = {
2567 @@ -418,6 +419,9 @@ static const match_table_t tokens = {
2569 {Opt_noacl, "noacl"},
2572 + {Opt_notag, "notag"},
2573 + {Opt_tagid, "tagid=%u"},
2574 {Opt_grpquota, "grpquota"},
2575 {Opt_ignore, "noquota"},
2576 {Opt_quota, "quota"},
2577 @@ -501,6 +505,20 @@ static int parse_options(char *options,
2579 set_opt (sbi->s_mount_opt, NO_UID32);
2581 +#ifndef CONFIG_TAGGING_NONE
2583 + set_opt (sbi->s_mount_opt, TAGGED);
2586 + clear_opt (sbi->s_mount_opt, TAGGED);
2589 +#ifdef CONFIG_PROPAGATE
2592 + set_opt (sbi->s_mount_opt, TAGGED);
2596 clear_opt (sbi->s_mount_opt, CHECK);
2598 @@ -859,6 +877,8 @@ static int ext2_fill_super(struct super_
2599 if (!parse_options((char *) data, sb))
2602 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
2603 + sb->s_flags |= MS_TAGGED;
2604 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2605 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
2607 @@ -1265,6 +1285,14 @@ static int ext2_remount (struct super_bl
2611 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
2612 + !(sb->s_flags & MS_TAGGED)) {
2613 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
2616 + goto restore_opts;
2619 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2620 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
2622 diff -NurpP --minimal linux-3.6.10/fs/ext3/ext3.h linux-3.6.10-vs2.3.4.5/fs/ext3/ext3.h
2623 --- linux-3.6.10/fs/ext3/ext3.h 2012-07-22 23:39:39.000000000 +0200
2624 +++ linux-3.6.10-vs2.3.4.5/fs/ext3/ext3.h 2012-10-04 18:47:00.000000000 +0200
2625 @@ -151,10 +151,14 @@ struct ext3_group_desc
2626 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
2627 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
2628 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
2629 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
2630 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
2632 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
2633 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
2634 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
2635 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
2637 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
2638 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
2640 /* Flags that should be inherited by new inodes from their parent. */
2641 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
2642 @@ -290,7 +294,8 @@ struct ext3_inode {
2644 __le16 l_i_uid_high; /* these 2 fields */
2645 __le16 l_i_gid_high; /* were reserved2[0] */
2646 - __u32 l_i_reserved2;
2647 + __le16 l_i_tag; /* Context Tag */
2648 + __u16 l_i_reserved2;
2651 __u8 h_i_frag; /* Fragment number */
2652 @@ -320,6 +325,7 @@ struct ext3_inode {
2653 #define i_gid_low i_gid
2654 #define i_uid_high osd2.linux2.l_i_uid_high
2655 #define i_gid_high osd2.linux2.l_i_gid_high
2656 +#define i_raw_tag osd2.linux2.l_i_tag
2657 #define i_reserved2 osd2.linux2.l_i_reserved2
2660 @@ -364,6 +370,7 @@ struct ext3_inode {
2661 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
2662 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
2663 * error in ordered mode */
2664 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
2666 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
2667 #ifndef _LINUX_EXT2_FS_H
2668 @@ -1061,6 +1068,7 @@ extern void ext3_get_inode_flags(struct
2669 extern void ext3_set_aops(struct inode *inode);
2670 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2671 u64 start, u64 len);
2672 +extern int ext3_sync_flags(struct inode *, int, int);
2675 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
2676 diff -NurpP --minimal linux-3.6.10/fs/ext3/file.c linux-3.6.10-vs2.3.4.5/fs/ext3/file.c
2677 --- linux-3.6.10/fs/ext3/file.c 2012-05-21 18:07:20.000000000 +0200
2678 +++ linux-3.6.10-vs2.3.4.5/fs/ext3/file.c 2012-10-04 18:47:00.000000000 +0200
2679 @@ -76,5 +76,6 @@ const struct inode_operations ext3_file_
2681 .get_acl = ext3_get_acl,
2682 .fiemap = ext3_fiemap,
2683 + .sync_flags = ext3_sync_flags,
2686 diff -NurpP --minimal linux-3.6.10/fs/ext3/ialloc.c linux-3.6.10-vs2.3.4.5/fs/ext3/ialloc.c
2687 --- linux-3.6.10/fs/ext3/ialloc.c 2012-07-22 23:39:39.000000000 +0200
2688 +++ linux-3.6.10-vs2.3.4.5/fs/ext3/ialloc.c 2012-10-04 18:47:00.000000000 +0200
2691 #include <linux/quotaops.h>
2692 #include <linux/random.h>
2693 +#include <linux/vs_tag.h>
2697 @@ -469,6 +470,7 @@ got:
2698 inode->i_mode = mode;
2699 inode->i_uid = current_fsuid();
2700 inode->i_gid = dir->i_gid;
2701 + inode->i_tag = dx_current_fstag(sb);
2703 inode_init_owner(inode, dir, mode);
2705 diff -NurpP --minimal linux-3.6.10/fs/ext3/inode.c linux-3.6.10-vs2.3.4.5/fs/ext3/inode.c
2706 --- linux-3.6.10/fs/ext3/inode.c 2012-10-04 15:27:39.000000000 +0200
2707 +++ linux-3.6.10-vs2.3.4.5/fs/ext3/inode.c 2012-10-04 18:47:00.000000000 +0200
2709 #include <linux/writeback.h>
2710 #include <linux/mpage.h>
2711 #include <linux/namei.h>
2712 +#include <linux/vs_tag.h>
2717 @@ -2848,36 +2850,60 @@ void ext3_set_inode_flags(struct inode *
2719 unsigned int flags = EXT3_I(inode)->i_flags;
2721 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2722 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2723 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2725 + if (flags & EXT3_IMMUTABLE_FL)
2726 + inode->i_flags |= S_IMMUTABLE;
2727 + if (flags & EXT3_IXUNLINK_FL)
2728 + inode->i_flags |= S_IXUNLINK;
2730 if (flags & EXT3_SYNC_FL)
2731 inode->i_flags |= S_SYNC;
2732 if (flags & EXT3_APPEND_FL)
2733 inode->i_flags |= S_APPEND;
2734 - if (flags & EXT3_IMMUTABLE_FL)
2735 - inode->i_flags |= S_IMMUTABLE;
2736 if (flags & EXT3_NOATIME_FL)
2737 inode->i_flags |= S_NOATIME;
2738 if (flags & EXT3_DIRSYNC_FL)
2739 inode->i_flags |= S_DIRSYNC;
2741 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2743 + if (flags & EXT3_BARRIER_FL)
2744 + inode->i_vflags |= V_BARRIER;
2745 + if (flags & EXT3_COW_FL)
2746 + inode->i_vflags |= V_COW;
2749 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
2750 void ext3_get_inode_flags(struct ext3_inode_info *ei)
2752 unsigned int flags = ei->vfs_inode.i_flags;
2753 + unsigned int vflags = ei->vfs_inode.i_vflags;
2755 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
2756 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
2757 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
2758 + EXT3_BARRIER_FL | EXT3_COW_FL);
2760 + if (flags & S_IMMUTABLE)
2761 + ei->i_flags |= EXT3_IMMUTABLE_FL;
2762 + if (flags & S_IXUNLINK)
2763 + ei->i_flags |= EXT3_IXUNLINK_FL;
2765 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
2766 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
2768 ei->i_flags |= EXT3_SYNC_FL;
2769 if (flags & S_APPEND)
2770 ei->i_flags |= EXT3_APPEND_FL;
2771 - if (flags & S_IMMUTABLE)
2772 - ei->i_flags |= EXT3_IMMUTABLE_FL;
2773 if (flags & S_NOATIME)
2774 ei->i_flags |= EXT3_NOATIME_FL;
2775 if (flags & S_DIRSYNC)
2776 ei->i_flags |= EXT3_DIRSYNC_FL;
2778 + if (vflags & V_BARRIER)
2779 + ei->i_flags |= EXT3_BARRIER_FL;
2780 + if (vflags & V_COW)
2781 + ei->i_flags |= EXT3_COW_FL;
2784 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
2785 @@ -2915,8 +2941,10 @@ struct inode *ext3_iget(struct super_blo
2786 i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2787 i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2789 - i_uid_write(inode, i_uid);
2790 - i_gid_write(inode, i_gid);
2791 + i_uid_write(inode, INOTAG_UID(DX_TAG(inode), i_uid, i_gid));
2792 + i_gid_write(inode, INOTAG_GID(DX_TAG(inode), i_uid, i_gid));
2793 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), i_uid, i_gid,
2794 + le16_to_cpu(raw_inode->i_raw_tag));
2795 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
2796 inode->i_size = le32_to_cpu(raw_inode->i_size);
2797 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2798 @@ -3088,8 +3116,8 @@ again:
2800 ext3_get_inode_flags(ei);
2801 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
2802 - i_uid = i_uid_read(inode);
2803 - i_gid = i_gid_read(inode);
2804 + i_uid = TAGINO_UID(DX_TAG(inode), i_uid_read(inode), inode->i_tag);
2805 + i_gid = TAGINO_GID(DX_TAG(inode), i_gid_read(inode), inode->i_tag);
2806 if(!(test_opt(inode->i_sb, NO_UID32))) {
2807 raw_inode->i_uid_low = cpu_to_le16(low_16_bits(i_uid));
2808 raw_inode->i_gid_low = cpu_to_le16(low_16_bits(i_gid));
2809 @@ -3114,6 +3142,9 @@ again:
2810 raw_inode->i_uid_high = 0;
2811 raw_inode->i_gid_high = 0;
2813 +#ifdef CONFIG_TAGGING_INTERN
2814 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2816 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2817 disksize = cpu_to_le32(ei->i_disksize);
2818 if (disksize != raw_inode->i_size) {
2819 @@ -3282,7 +3313,8 @@ int ext3_setattr(struct dentry *dentry,
2820 if (is_quota_modification(inode, attr))
2821 dquot_initialize(inode);
2822 if ((ia_valid & ATTR_UID && !uid_eq(attr->ia_uid, inode->i_uid)) ||
2823 - (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid))) {
2824 + (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid)) ||
2825 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
2828 /* (user+group)*(old+new) structure, inode write (sb,
2829 @@ -3304,6 +3336,8 @@ int ext3_setattr(struct dentry *dentry,
2830 inode->i_uid = attr->ia_uid;
2831 if (attr->ia_valid & ATTR_GID)
2832 inode->i_gid = attr->ia_gid;
2833 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2834 + inode->i_tag = attr->ia_tag;
2835 error = ext3_mark_inode_dirty(handle, inode);
2836 ext3_journal_stop(handle);
2838 diff -NurpP --minimal linux-3.6.10/fs/ext3/ioctl.c linux-3.6.10-vs2.3.4.5/fs/ext3/ioctl.c
2839 --- linux-3.6.10/fs/ext3/ioctl.c 2012-05-21 18:07:20.000000000 +0200
2840 +++ linux-3.6.10-vs2.3.4.5/fs/ext3/ioctl.c 2012-10-04 18:47:00.000000000 +0200
2842 #include <asm/uaccess.h>
2846 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
2848 + handle_t *handle = NULL;
2849 + struct ext3_iloc iloc;
2852 + handle = ext3_journal_start(inode, 1);
2853 + if (IS_ERR(handle))
2854 + return PTR_ERR(handle);
2856 + if (IS_SYNC(inode))
2857 + handle->h_sync = 1;
2858 + err = ext3_reserve_inode_write(handle, inode, &iloc);
2862 + inode->i_flags = flags;
2863 + inode->i_vflags = vflags;
2864 + ext3_get_inode_flags(EXT3_I(inode));
2865 + inode->i_ctime = CURRENT_TIME_SEC;
2867 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
2869 + ext3_journal_stop(handle);
2873 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2875 struct inode *inode = filp->f_dentry->d_inode;
2876 @@ -45,6 +73,11 @@ long ext3_ioctl(struct file *filp, unsig
2878 flags = ext3_mask_flags(inode->i_mode, flags);
2880 + if (IS_BARRIER(inode)) {
2881 + vxwprintk_task(1, "messing with the barrier.");
2885 mutex_lock(&inode->i_mutex);
2887 /* Is it quota file? Do not allow user to mess with it */
2888 @@ -63,7 +96,9 @@ long ext3_ioctl(struct file *filp, unsig
2890 * This test looks nicer. Thanks to Pauline Middelink
2892 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
2893 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
2894 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
2895 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
2896 if (!capable(CAP_LINUX_IMMUTABLE))
2899 @@ -88,7 +123,7 @@ long ext3_ioctl(struct file *filp, unsig
2903 - flags = flags & EXT3_FL_USER_MODIFIABLE;
2904 + flags &= EXT3_FL_USER_MODIFIABLE;
2905 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
2906 ei->i_flags = flags;
2908 diff -NurpP --minimal linux-3.6.10/fs/ext3/namei.c linux-3.6.10-vs2.3.4.5/fs/ext3/namei.c
2909 --- linux-3.6.10/fs/ext3/namei.c 2012-10-04 15:27:39.000000000 +0200
2910 +++ linux-3.6.10-vs2.3.4.5/fs/ext3/namei.c 2012-10-04 18:47:00.000000000 +0200
2914 #include <linux/quotaops.h>
2915 +#include <linux/vs_tag.h>
2920 @@ -915,6 +917,7 @@ restart:
2921 submit_bh(READ | REQ_META | REQ_PRIO,
2924 + dx_propagate_tag(nd, inode);
2927 if ((bh = bh_use[ra_ptr++]) == NULL)
2928 @@ -2526,6 +2529,7 @@ const struct inode_operations ext3_dir_i
2929 .listxattr = ext3_listxattr,
2930 .removexattr = generic_removexattr,
2932 + .sync_flags = ext3_sync_flags,
2933 .get_acl = ext3_get_acl,
2936 diff -NurpP --minimal linux-3.6.10/fs/ext3/super.c linux-3.6.10-vs2.3.4.5/fs/ext3/super.c
2937 --- linux-3.6.10/fs/ext3/super.c 2012-10-04 15:27:39.000000000 +0200
2938 +++ linux-3.6.10-vs2.3.4.5/fs/ext3/super.c 2012-10-04 18:47:00.000000000 +0200
2939 @@ -811,7 +811,8 @@ enum {
2940 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
2941 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
2942 Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
2943 - Opt_resize, Opt_usrquota, Opt_grpquota
2944 + Opt_resize, Opt_usrquota, Opt_grpquota,
2945 + Opt_tag, Opt_notag, Opt_tagid
2948 static const match_table_t tokens = {
2949 @@ -868,6 +869,9 @@ static const match_table_t tokens = {
2950 {Opt_barrier, "barrier"},
2951 {Opt_nobarrier, "nobarrier"},
2952 {Opt_resize, "resize"},
2954 + {Opt_notag, "notag"},
2955 + {Opt_tagid, "tagid=%u"},
2959 @@ -1033,6 +1037,20 @@ static int parse_options (char *options,
2961 set_opt (sbi->s_mount_opt, NO_UID32);
2963 +#ifndef CONFIG_TAGGING_NONE
2965 + set_opt (sbi->s_mount_opt, TAGGED);
2968 + clear_opt (sbi->s_mount_opt, TAGGED);
2971 +#ifdef CONFIG_PROPAGATE
2974 + set_opt (sbi->s_mount_opt, TAGGED);
2978 clear_opt (sbi->s_mount_opt, CHECK);
2980 @@ -1731,6 +1749,9 @@ static int ext3_fill_super (struct super
2984 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
2985 + sb->s_flags |= MS_TAGGED;
2987 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2988 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
2990 @@ -2618,6 +2639,14 @@ static int ext3_remount (struct super_bl
2991 if (test_opt(sb, ABORT))
2992 ext3_abort(sb, __func__, "Abort forced by user");
2994 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
2995 + !(sb->s_flags & MS_TAGGED)) {
2996 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
2999 + goto restore_opts;
3002 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3003 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3005 diff -NurpP --minimal linux-3.6.10/fs/ext4/ext4.h linux-3.6.10-vs2.3.4.5/fs/ext4/ext4.h
3006 --- linux-3.6.10/fs/ext4/ext4.h 2012-12-11 12:36:57.000000000 +0100
3007 +++ linux-3.6.10-vs2.3.4.5/fs/ext4/ext4.h 2012-12-08 01:36:33.000000000 +0100
3008 @@ -393,8 +393,12 @@ struct flex_groups {
3009 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
3010 #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
3011 #define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
3012 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3013 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
3015 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3016 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
3018 #define EXT4_FL_USER_VISIBLE 0x004BDFFF /* User visible flags */
3019 #define EXT4_FL_USER_MODIFIABLE 0x004B80FF /* User modifiable flags */
3021 @@ -666,7 +670,7 @@ struct ext4_inode {
3022 __le16 l_i_uid_high; /* these 2 fields */
3023 __le16 l_i_gid_high; /* were reserved2[0] */
3024 __le16 l_i_checksum_lo;/* crc32c(uuid+inum+inode) LE */
3025 - __le16 l_i_reserved;
3026 + __le16 l_i_tag; /* Context Tag */
3029 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
3030 @@ -784,6 +788,7 @@ do { \
3031 #define i_gid_low i_gid
3032 #define i_uid_high osd2.linux2.l_i_uid_high
3033 #define i_gid_high osd2.linux2.l_i_gid_high
3034 +#define i_raw_tag osd2.linux2.l_i_tag
3035 #define i_checksum_lo osd2.linux2.l_i_checksum_lo
3037 #elif defined(__GNU__)
3038 @@ -964,6 +969,7 @@ struct ext4_inode_info {
3039 #define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
3040 #define EXT4_MOUNT_NO_AUTO_DA_ALLOC 0x10000 /* No auto delalloc mapping */
3041 #define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */
3042 +#define EXT4_MOUNT_TAGGED 0x40000 /* Enable Context Tags */
3043 #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
3044 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
3045 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
3046 @@ -2392,6 +2398,7 @@ extern int ext4_map_blocks(handle_t *han
3047 struct ext4_map_blocks *map, int flags);
3048 extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
3049 __u64 start, __u64 len);
3050 +extern int ext4_sync_flags(struct inode *, int, int);
3052 extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
3053 __u64 start_orig, __u64 start_donor,
3054 diff -NurpP --minimal linux-3.6.10/fs/ext4/file.c linux-3.6.10-vs2.3.4.5/fs/ext4/file.c
3055 --- linux-3.6.10/fs/ext4/file.c 2012-10-04 15:27:39.000000000 +0200
3056 +++ linux-3.6.10-vs2.3.4.5/fs/ext4/file.c 2012-10-04 18:47:00.000000000 +0200
3057 @@ -334,5 +334,6 @@ const struct inode_operations ext4_file_
3059 .get_acl = ext4_get_acl,
3060 .fiemap = ext4_fiemap,
3061 + .sync_flags = ext4_sync_flags,
3064 diff -NurpP --minimal linux-3.6.10/fs/ext4/ialloc.c linux-3.6.10-vs2.3.4.5/fs/ext4/ialloc.c
3065 --- linux-3.6.10/fs/ext4/ialloc.c 2012-12-11 12:36:57.000000000 +0100
3066 +++ linux-3.6.10-vs2.3.4.5/fs/ext4/ialloc.c 2012-11-06 18:43:41.000000000 +0100
3068 #include <linux/random.h>
3069 #include <linux/bitops.h>
3070 #include <linux/blkdev.h>
3071 +#include <linux/vs_tag.h>
3072 #include <asm/byteorder.h>
3075 @@ -839,6 +840,7 @@ got:
3076 inode->i_mode = mode;
3077 inode->i_uid = current_fsuid();
3078 inode->i_gid = dir->i_gid;
3079 + inode->i_tag = dx_current_fstag(sb);
3081 inode_init_owner(inode, dir, mode);
3083 diff -NurpP --minimal linux-3.6.10/fs/ext4/inode.c linux-3.6.10-vs2.3.4.5/fs/ext4/inode.c
3084 --- linux-3.6.10/fs/ext4/inode.c 2012-12-11 12:36:57.000000000 +0100
3085 +++ linux-3.6.10-vs2.3.4.5/fs/ext4/inode.c 2012-11-06 18:43:41.000000000 +0100
3087 #include <linux/printk.h>
3088 #include <linux/slab.h>
3089 #include <linux/ratelimit.h>
3090 +#include <linux/vs_tag.h>
3092 #include "ext4_jbd2.h"
3094 @@ -3715,41 +3716,64 @@ void ext4_set_inode_flags(struct inode *
3096 unsigned int flags = EXT4_I(inode)->i_flags;
3098 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
3099 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3100 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3102 + if (flags & EXT4_IMMUTABLE_FL)
3103 + inode->i_flags |= S_IMMUTABLE;
3104 + if (flags & EXT4_IXUNLINK_FL)
3105 + inode->i_flags |= S_IXUNLINK;
3107 if (flags & EXT4_SYNC_FL)
3108 inode->i_flags |= S_SYNC;
3109 if (flags & EXT4_APPEND_FL)
3110 inode->i_flags |= S_APPEND;
3111 - if (flags & EXT4_IMMUTABLE_FL)
3112 - inode->i_flags |= S_IMMUTABLE;
3113 if (flags & EXT4_NOATIME_FL)
3114 inode->i_flags |= S_NOATIME;
3115 if (flags & EXT4_DIRSYNC_FL)
3116 inode->i_flags |= S_DIRSYNC;
3118 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3120 + if (flags & EXT4_BARRIER_FL)
3121 + inode->i_vflags |= V_BARRIER;
3122 + if (flags & EXT4_COW_FL)
3123 + inode->i_vflags |= V_COW;
3126 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3127 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3129 - unsigned int vfs_fl;
3130 + unsigned int vfs_fl, vfs_vf;
3131 unsigned long old_fl, new_fl;
3134 vfs_fl = ei->vfs_inode.i_flags;
3135 + vfs_vf = ei->vfs_inode.i_vflags;
3136 old_fl = ei->i_flags;
3137 new_fl = old_fl & ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3138 EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|
3140 + EXT4_DIRSYNC_FL|EXT4_BARRIER_FL|
3143 + if (vfs_fl & S_IMMUTABLE)
3144 + new_fl |= EXT4_IMMUTABLE_FL;
3145 + if (vfs_fl & S_IXUNLINK)
3146 + new_fl |= EXT4_IXUNLINK_FL;
3148 if (vfs_fl & S_SYNC)
3149 new_fl |= EXT4_SYNC_FL;
3150 if (vfs_fl & S_APPEND)
3151 new_fl |= EXT4_APPEND_FL;
3152 - if (vfs_fl & S_IMMUTABLE)
3153 - new_fl |= EXT4_IMMUTABLE_FL;
3154 if (vfs_fl & S_NOATIME)
3155 new_fl |= EXT4_NOATIME_FL;
3156 if (vfs_fl & S_DIRSYNC)
3157 new_fl |= EXT4_DIRSYNC_FL;
3159 + if (vfs_vf & V_BARRIER)
3160 + new_fl |= EXT4_BARRIER_FL;
3161 + if (vfs_vf & V_COW)
3162 + new_fl |= EXT4_COW_FL;
3163 } while (cmpxchg(&ei->i_flags, old_fl, new_fl) != old_fl);
3166 @@ -3841,8 +3865,10 @@ struct inode *ext4_iget(struct super_blo
3167 i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3168 i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3170 - i_uid_write(inode, i_uid);
3171 - i_gid_write(inode, i_gid);
3172 + i_uid_write(inode, INOTAG_UID(DX_TAG(inode), i_uid, i_gid));
3173 + i_gid_write(inode, INOTAG_GID(DX_TAG(inode), i_uid, i_gid));
3174 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), i_uid, i_gid,
3175 + le16_to_cpu(raw_inode->i_raw_tag));
3176 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
3178 ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */
3179 @@ -4066,8 +4092,8 @@ static int ext4_do_update_inode(handle_t
3181 ext4_get_inode_flags(ei);
3182 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3183 - i_uid = i_uid_read(inode);
3184 - i_gid = i_gid_read(inode);
3185 + i_uid = TAGINO_UID(DX_TAG(inode), i_uid_read(inode), inode->i_tag);
3186 + i_gid = TAGINO_GID(DX_TAG(inode), i_gid_read(inode), inode->i_tag);
3187 if (!(test_opt(inode->i_sb, NO_UID32))) {
3188 raw_inode->i_uid_low = cpu_to_le16(low_16_bits(i_uid));
3189 raw_inode->i_gid_low = cpu_to_le16(low_16_bits(i_gid));
3190 @@ -4090,6 +4116,9 @@ static int ext4_do_update_inode(handle_t
3191 raw_inode->i_uid_high = 0;
3192 raw_inode->i_gid_high = 0;
3194 +#ifdef CONFIG_TAGGING_INTERN
3195 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3197 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3199 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3200 @@ -4278,7 +4307,8 @@ int ext4_setattr(struct dentry *dentry,
3201 if (is_quota_modification(inode, attr))
3202 dquot_initialize(inode);
3203 if ((ia_valid & ATTR_UID && !uid_eq(attr->ia_uid, inode->i_uid)) ||
3204 - (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid))) {
3205 + (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid)) ||
3206 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3209 /* (user+group)*(old+new) structure, inode write (sb,
3210 @@ -4300,6 +4330,8 @@ int ext4_setattr(struct dentry *dentry,
3211 inode->i_uid = attr->ia_uid;
3212 if (attr->ia_valid & ATTR_GID)
3213 inode->i_gid = attr->ia_gid;
3214 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3215 + inode->i_tag = attr->ia_tag;
3216 error = ext4_mark_inode_dirty(handle, inode);
3217 ext4_journal_stop(handle);
3219 diff -NurpP --minimal linux-3.6.10/fs/ext4/ioctl.c linux-3.6.10-vs2.3.4.5/fs/ext4/ioctl.c
3220 --- linux-3.6.10/fs/ext4/ioctl.c 2012-10-04 15:27:39.000000000 +0200
3221 +++ linux-3.6.10-vs2.3.4.5/fs/ext4/ioctl.c 2012-10-04 18:47:00.000000000 +0200
3223 #include <linux/compat.h>
3224 #include <linux/mount.h>
3225 #include <linux/file.h>
3226 +#include <linux/vs_tag.h>
3227 #include <asm/uaccess.h>
3228 #include "ext4_jbd2.h"
3231 #define MAX_32_NUM ((((unsigned long long) 1) << 32) - 1)
3233 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
3235 + handle_t *handle = NULL;
3236 + struct ext4_iloc iloc;
3239 + handle = ext4_journal_start(inode, 1);
3240 + if (IS_ERR(handle))
3241 + return PTR_ERR(handle);
3243 + if (IS_SYNC(inode))
3244 + ext4_handle_sync(handle);
3245 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3249 + inode->i_flags = flags;
3250 + inode->i_vflags = vflags;
3251 + ext4_get_inode_flags(EXT4_I(inode));
3252 + inode->i_ctime = ext4_current_time(inode);
3254 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3256 + ext4_journal_stop(handle);
3260 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3262 struct inode *inode = filp->f_dentry->d_inode;
3263 @@ -53,6 +81,11 @@ long ext4_ioctl(struct file *filp, unsig
3265 flags = ext4_mask_flags(inode->i_mode, flags);
3267 + if (IS_BARRIER(inode)) {
3268 + vxwprintk_task(1, "messing with the barrier.");
3273 mutex_lock(&inode->i_mutex);
3274 /* Is it quota file? Do not allow user to mess with it */
3275 @@ -70,7 +103,9 @@ long ext4_ioctl(struct file *filp, unsig
3277 * This test looks nicer. Thanks to Pauline Middelink
3279 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3280 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3281 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3282 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3283 if (!capable(CAP_LINUX_IMMUTABLE))
3286 diff -NurpP --minimal linux-3.6.10/fs/ext4/namei.c linux-3.6.10-vs2.3.4.5/fs/ext4/namei.c
3287 --- linux-3.6.10/fs/ext4/namei.c 2012-12-11 12:36:57.000000000 +0100
3288 +++ linux-3.6.10-vs2.3.4.5/fs/ext4/namei.c 2012-11-06 18:43:41.000000000 +0100
3290 #include <linux/quotaops.h>
3291 #include <linux/buffer_head.h>
3292 #include <linux/bio.h>
3293 +#include <linux/vs_tag.h>
3295 #include "ext4_jbd2.h"
3297 @@ -1199,6 +1200,7 @@ restart:
3298 ll_rw_block(READ | REQ_META | REQ_PRIO,
3301 + dx_propagate_tag(nd, inode);
3303 if ((bh = bh_use[ra_ptr++]) == NULL)
3305 @@ -2982,6 +2984,7 @@ const struct inode_operations ext4_dir_i
3307 .get_acl = ext4_get_acl,
3308 .fiemap = ext4_fiemap,
3309 + .sync_flags = ext4_sync_flags,
3312 const struct inode_operations ext4_special_inode_operations = {
3313 diff -NurpP --minimal linux-3.6.10/fs/ext4/super.c linux-3.6.10-vs2.3.4.5/fs/ext4/super.c
3314 --- linux-3.6.10/fs/ext4/super.c 2012-12-11 12:36:57.000000000 +0100
3315 +++ linux-3.6.10-vs2.3.4.5/fs/ext4/super.c 2012-12-08 01:36:33.000000000 +0100
3316 @@ -1220,6 +1220,7 @@ enum {
3317 Opt_inode_readahead_blks, Opt_journal_ioprio,
3318 Opt_dioread_nolock, Opt_dioread_lock,
3319 Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable,
3320 + Opt_tag, Opt_notag, Opt_tagid
3323 static const match_table_t tokens = {
3324 @@ -1298,6 +1299,9 @@ static const match_table_t tokens = {
3325 {Opt_removed, "reservation"}, /* mount option from ext2/3 */
3326 {Opt_removed, "noreservation"}, /* mount option from ext2/3 */
3327 {Opt_removed, "journal=%u"}, /* mount option from ext2/3 */
3329 + {Opt_notag, "notag"},
3330 + {Opt_tagid, "tagid=%u"},
3334 @@ -1544,6 +1548,20 @@ static int handle_mount_opt(struct super
3336 *journal_ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, arg);
3338 +#ifndef CONFIG_TAGGING_NONE
3340 + set_opt(sb, TAGGED);
3343 + clear_opt(sb, TAGGED);
3346 +#ifdef CONFIG_PROPAGATE
3349 + set_opt(sb, TAGGED);
3354 for (m = ext4_mount_opts; m->token != Opt_err; m++) {
3355 @@ -3418,6 +3436,9 @@ static int ext4_fill_super(struct super_
3359 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3360 + sb->s_flags |= MS_TAGGED;
3362 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3363 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3365 @@ -4583,6 +4604,14 @@ static int ext4_remount(struct super_blo
3366 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
3367 ext4_abort(sb, "Abort forced by user");
3369 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3370 + !(sb->s_flags & MS_TAGGED)) {
3371 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3374 + goto restore_opts;
3377 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3378 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3380 diff -NurpP --minimal linux-3.6.10/fs/fcntl.c linux-3.6.10-vs2.3.4.5/fs/fcntl.c
3381 --- linux-3.6.10/fs/fcntl.c 2012-10-04 15:27:39.000000000 +0200
3382 +++ linux-3.6.10-vs2.3.4.5/fs/fcntl.c 2012-10-04 19:05:02.000000000 +0200
3384 #include <linux/rcupdate.h>
3385 #include <linux/pid_namespace.h>
3386 #include <linux/user_namespace.h>
3387 +#include <linux/vs_limit.h>
3389 #include <asm/poll.h>
3390 #include <asm/siginfo.h>
3391 @@ -104,6 +105,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
3394 filp_close(tofree, files);
3396 + vx_openfd_inc(newfd); /* fd was unused */
3400 @@ -477,6 +480,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
3401 filp = fget_raw_light(fd, &fput_needed);
3404 + if (!vx_files_avail(1))
3407 if (unlikely(filp->f_mode & FMODE_PATH)) {
3408 if (!check_fcntl_cmd(cmd))
3409 diff -NurpP --minimal linux-3.6.10/fs/file.c linux-3.6.10-vs2.3.4.5/fs/file.c
3410 --- linux-3.6.10/fs/file.c 2012-05-21 18:07:20.000000000 +0200
3411 +++ linux-3.6.10-vs2.3.4.5/fs/file.c 2012-10-04 18:47:00.000000000 +0200
3413 #include <linux/spinlock.h>
3414 #include <linux/rcupdate.h>
3415 #include <linux/workqueue.h>
3416 +#include <linux/vs_limit.h>
3418 struct fdtable_defer {
3420 @@ -358,6 +359,8 @@ struct files_struct *dup_fd(struct files
3421 struct file *f = *old_fds++;
3424 + /* TODO: sum it first for check and performance */
3425 + vx_openfd_inc(open_files - i);
3428 * The fd may be claimed in the fd bitmap but not yet
3429 @@ -464,6 +467,7 @@ repeat:
3431 __clear_close_on_exec(fd, fdt);
3433 + vx_openfd_inc(fd);
3436 if (rcu_dereference_raw(fdt->fd[fd]) != NULL) {
3437 diff -NurpP --minimal linux-3.6.10/fs/file_table.c linux-3.6.10-vs2.3.4.5/fs/file_table.c
3438 --- linux-3.6.10/fs/file_table.c 2012-10-04 15:27:39.000000000 +0200
3439 +++ linux-3.6.10-vs2.3.4.5/fs/file_table.c 2012-11-17 14:36:19.000000000 +0100
3441 #include <linux/hardirq.h>
3442 #include <linux/task_work.h>
3443 #include <linux/ima.h>
3444 +#include <linux/vs_limit.h>
3445 +#include <linux/vs_context.h>
3447 #include <linux/atomic.h>
3449 @@ -136,6 +138,8 @@ struct file *get_empty_filp(void)
3450 spin_lock_init(&f->f_lock);
3451 eventpoll_init_file(f);
3452 /* f->f_version: 0 */
3453 + f->f_xid = vx_current_xid();
3458 @@ -257,6 +261,8 @@ static void __fput(struct file *file)
3459 i_readcount_dec(inode);
3460 if (file->f_mode & FMODE_WRITE)
3461 drop_file_write_access(file);
3462 + vx_files_dec(file);
3464 file->f_path.dentry = NULL;
3465 file->f_path.mnt = NULL;
3467 @@ -449,6 +455,8 @@ void put_filp(struct file *file)
3469 if (atomic_long_dec_and_test(&file->f_count)) {
3470 security_file_free(file);
3471 + vx_files_dec(file);
3473 file_sb_list_del(file);
3476 diff -NurpP --minimal linux-3.6.10/fs/fs_struct.c linux-3.6.10-vs2.3.4.5/fs/fs_struct.c
3477 --- linux-3.6.10/fs/fs_struct.c 2012-10-04 15:27:39.000000000 +0200
3478 +++ linux-3.6.10-vs2.3.4.5/fs/fs_struct.c 2012-10-04 19:08:56.000000000 +0200
3480 #include <linux/path.h>
3481 #include <linux/slab.h>
3482 #include <linux/fs_struct.h>
3483 +#include <linux/vserver/global.h>
3484 #include "internal.h"
3487 @@ -87,6 +88,7 @@ void free_fs_struct(struct fs_struct *fs
3489 path_put(&fs->root);
3491 + atomic_dec(&vs_global_fs);
3492 kmem_cache_free(fs_cachep, fs);
3495 @@ -124,6 +126,7 @@ struct fs_struct *copy_fs_struct(struct
3498 spin_unlock(&old->lock);
3499 + atomic_inc(&vs_global_fs);
3503 diff -NurpP --minimal linux-3.6.10/fs/gfs2/file.c linux-3.6.10-vs2.3.4.5/fs/gfs2/file.c
3504 --- linux-3.6.10/fs/gfs2/file.c 2012-12-11 12:36:57.000000000 +0100
3505 +++ linux-3.6.10-vs2.3.4.5/fs/gfs2/file.c 2012-12-08 01:36:33.000000000 +0100
3506 @@ -143,6 +143,9 @@ static const u32 fsflags_to_gfs2[32] = {
3507 [12] = GFS2_DIF_EXHASH,
3508 [14] = GFS2_DIF_INHERIT_JDATA,
3509 [17] = GFS2_DIF_TOPDIR,
3510 + [27] = GFS2_DIF_IXUNLINK,
3511 + [26] = GFS2_DIF_BARRIER,
3512 + [29] = GFS2_DIF_COW,
3515 static const u32 gfs2_to_fsflags[32] = {
3516 @@ -153,6 +156,9 @@ static const u32 gfs2_to_fsflags[32] = {
3517 [gfs2fl_ExHash] = FS_INDEX_FL,
3518 [gfs2fl_TopLevel] = FS_TOPDIR_FL,
3519 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
3520 + [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
3521 + [gfs2fl_Barrier] = FS_BARRIER_FL,
3522 + [gfs2fl_Cow] = FS_COW_FL,
3525 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
3526 @@ -183,12 +189,18 @@ void gfs2_set_inode_flags(struct inode *
3528 struct gfs2_inode *ip = GFS2_I(inode);
3529 unsigned int flags = inode->i_flags;
3530 + unsigned int vflags = inode->i_vflags;
3532 + flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3533 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC | S_NOSEC);
3535 - flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|S_NOSEC);
3536 if ((ip->i_eattr == 0) && !is_sxid(inode->i_mode))
3537 inode->i_flags |= S_NOSEC;
3538 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
3539 flags |= S_IMMUTABLE;
3540 + if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
3541 + flags |= S_IXUNLINK;
3543 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
3545 if (ip->i_diskflags & GFS2_DIF_NOATIME)
3546 @@ -196,6 +208,43 @@ void gfs2_set_inode_flags(struct inode *
3547 if (ip->i_diskflags & GFS2_DIF_SYNC)
3549 inode->i_flags = flags;
3551 + vflags &= ~(V_BARRIER | V_COW);
3553 + if (ip->i_diskflags & GFS2_DIF_BARRIER)
3554 + vflags |= V_BARRIER;
3555 + if (ip->i_diskflags & GFS2_DIF_COW)
3557 + inode->i_vflags = vflags;
3560 +void gfs2_get_inode_flags(struct inode *inode)
3562 + struct gfs2_inode *ip = GFS2_I(inode);
3563 + unsigned int flags = inode->i_flags;
3564 + unsigned int vflags = inode->i_vflags;
3566 + ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
3567 + GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
3568 + GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
3569 + GFS2_DIF_BARRIER | GFS2_DIF_COW);
3571 + if (flags & S_IMMUTABLE)
3572 + ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
3573 + if (flags & S_IXUNLINK)
3574 + ip->i_diskflags |= GFS2_DIF_IXUNLINK;
3576 + if (flags & S_APPEND)
3577 + ip->i_diskflags |= GFS2_DIF_APPENDONLY;
3578 + if (flags & S_NOATIME)
3579 + ip->i_diskflags |= GFS2_DIF_NOATIME;
3580 + if (flags & S_SYNC)
3581 + ip->i_diskflags |= GFS2_DIF_SYNC;
3583 + if (vflags & V_BARRIER)
3584 + ip->i_diskflags |= GFS2_DIF_BARRIER;
3585 + if (vflags & V_COW)
3586 + ip->i_diskflags |= GFS2_DIF_COW;
3589 /* Flags that can be set by user space */
3590 @@ -309,6 +358,37 @@ static int gfs2_set_flags(struct file *f
3591 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
3594 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
3596 + struct gfs2_inode *ip = GFS2_I(inode);
3597 + struct gfs2_sbd *sdp = GFS2_SB(inode);
3598 + struct buffer_head *bh;
3599 + struct gfs2_holder gh;
3602 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
3605 + error = gfs2_trans_begin(sdp, RES_DINODE, 0);
3608 + error = gfs2_meta_inode_buffer(ip, &bh);
3610 + goto out_trans_end;
3611 + gfs2_trans_add_bh(ip->i_gl, bh, 1);
3612 + inode->i_flags = flags;
3613 + inode->i_vflags = vflags;
3614 + gfs2_get_inode_flags(inode);
3615 + gfs2_dinode_out(ip, bh->b_data);
3617 + gfs2_set_aops(inode);
3619 + gfs2_trans_end(sdp);
3621 + gfs2_glock_dq_uninit(&gh);
3625 static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3628 diff -NurpP --minimal linux-3.6.10/fs/gfs2/inode.h linux-3.6.10-vs2.3.4.5/fs/gfs2/inode.h
3629 --- linux-3.6.10/fs/gfs2/inode.h 2012-07-22 23:39:40.000000000 +0200
3630 +++ linux-3.6.10-vs2.3.4.5/fs/gfs2/inode.h 2012-10-04 18:47:00.000000000 +0200
3631 @@ -117,6 +117,7 @@ extern const struct file_operations gfs2
3632 extern const struct file_operations gfs2_dir_fops_nolock;
3634 extern void gfs2_set_inode_flags(struct inode *inode);
3635 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
3637 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
3638 extern const struct file_operations gfs2_file_fops;
3639 diff -NurpP --minimal linux-3.6.10/fs/inode.c linux-3.6.10-vs2.3.4.5/fs/inode.c
3640 --- linux-3.6.10/fs/inode.c 2012-12-11 12:36:58.000000000 +0100
3641 +++ linux-3.6.10-vs2.3.4.5/fs/inode.c 2012-12-08 01:36:33.000000000 +0100
3643 #include <linux/prefetch.h>
3644 #include <linux/buffer_head.h> /* for inode_has_buffers */
3645 #include <linux/ratelimit.h>
3646 +#include <linux/vs_tag.h>
3647 #include "internal.h"
3650 @@ -128,6 +129,9 @@ int inode_init_always(struct super_block
3651 struct address_space *const mapping = &inode->i_data;
3655 + /* essential because of inode slab reuse */
3657 inode->i_blkbits = sb->s_blocksize_bits;
3659 atomic_set(&inode->i_count, 1);
3660 @@ -149,6 +153,7 @@ int inode_init_always(struct super_block
3661 inode->i_bdev = NULL;
3662 inode->i_cdev = NULL;
3664 + inode->i_mdev = 0;
3665 inode->dirtied_when = 0;
3667 if (security_inode_alloc(inode))
3668 @@ -483,6 +488,8 @@ void __insert_inode_hash(struct inode *i
3670 EXPORT_SYMBOL(__insert_inode_hash);
3672 +EXPORT_SYMBOL_GPL(__iget);
3675 * __remove_inode_hash - remove an inode from the hash
3676 * @inode: inode to unhash
3677 @@ -1804,9 +1811,11 @@ void init_special_inode(struct inode *in
3678 if (S_ISCHR(mode)) {
3679 inode->i_fop = &def_chr_fops;
3680 inode->i_rdev = rdev;
3681 + inode->i_mdev = rdev;
3682 } else if (S_ISBLK(mode)) {
3683 inode->i_fop = &def_blk_fops;
3684 inode->i_rdev = rdev;
3685 + inode->i_mdev = rdev;
3686 } else if (S_ISFIFO(mode))
3687 inode->i_fop = &def_fifo_fops;
3688 else if (S_ISSOCK(mode))
3689 @@ -1835,6 +1844,7 @@ void inode_init_owner(struct inode *inod
3691 inode->i_gid = current_fsgid();
3692 inode->i_mode = mode;
3693 + inode->i_tag = dx_current_fstag(inode->i_sb);
3695 EXPORT_SYMBOL(inode_init_owner);
3697 diff -NurpP --minimal linux-3.6.10/fs/ioctl.c linux-3.6.10-vs2.3.4.5/fs/ioctl.c
3698 --- linux-3.6.10/fs/ioctl.c 2012-05-21 18:07:24.000000000 +0200
3699 +++ linux-3.6.10-vs2.3.4.5/fs/ioctl.c 2012-10-04 18:47:00.000000000 +0200
3701 #include <linux/writeback.h>
3702 #include <linux/buffer_head.h>
3703 #include <linux/falloc.h>
3704 +#include <linux/proc_fs.h>
3705 +#include <linux/vserver/inode.h>
3706 +#include <linux/vs_tag.h>
3708 #include <asm/ioctls.h>
3710 diff -NurpP --minimal linux-3.6.10/fs/ioprio.c linux-3.6.10-vs2.3.4.5/fs/ioprio.c
3711 --- linux-3.6.10/fs/ioprio.c 2012-07-22 23:39:40.000000000 +0200
3712 +++ linux-3.6.10-vs2.3.4.5/fs/ioprio.c 2012-10-04 18:47:00.000000000 +0200
3714 #include <linux/syscalls.h>
3715 #include <linux/security.h>
3716 #include <linux/pid_namespace.h>
3717 +#include <linux/vs_base.h>
3719 int set_task_ioprio(struct task_struct *task, int ioprio)
3721 @@ -105,6 +106,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
3723 pgrp = find_vpid(who);
3724 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3725 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3727 ret = set_task_ioprio(p, ioprio);
3730 @@ -198,6 +201,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
3732 pgrp = find_vpid(who);
3733 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3734 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3736 tmpio = get_task_ioprio(p);
3739 diff -NurpP --minimal linux-3.6.10/fs/jfs/file.c linux-3.6.10-vs2.3.4.5/fs/jfs/file.c
3740 --- linux-3.6.10/fs/jfs/file.c 2011-10-24 18:45:27.000000000 +0200
3741 +++ linux-3.6.10-vs2.3.4.5/fs/jfs/file.c 2012-10-04 18:47:00.000000000 +0200
3742 @@ -109,7 +109,8 @@ int jfs_setattr(struct dentry *dentry, s
3743 if (is_quota_modification(inode, iattr))
3744 dquot_initialize(inode);
3745 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
3746 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
3747 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
3748 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
3749 rc = dquot_transfer(inode, iattr);
3752 @@ -142,6 +143,7 @@ const struct inode_operations jfs_file_i
3753 #ifdef CONFIG_JFS_POSIX_ACL
3754 .get_acl = jfs_get_acl,
3756 + .sync_flags = jfs_sync_flags,
3759 const struct file_operations jfs_file_operations = {
3760 diff -NurpP --minimal linux-3.6.10/fs/jfs/ioctl.c linux-3.6.10-vs2.3.4.5/fs/jfs/ioctl.c
3761 --- linux-3.6.10/fs/jfs/ioctl.c 2012-03-19 19:47:25.000000000 +0100
3762 +++ linux-3.6.10-vs2.3.4.5/fs/jfs/ioctl.c 2012-10-04 18:47:00.000000000 +0200
3764 #include <linux/mount.h>
3765 #include <linux/time.h>
3766 #include <linux/sched.h>
3767 +#include <linux/mount.h>
3768 #include <asm/current.h>
3769 #include <asm/uaccess.h>
3771 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
3775 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
3777 + inode->i_flags = flags;
3778 + inode->i_vflags = vflags;
3779 + jfs_get_inode_flags(JFS_IP(inode));
3780 + inode->i_ctime = CURRENT_TIME_SEC;
3781 + mark_inode_dirty(inode);
3785 long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3787 struct inode *inode = filp->f_dentry->d_inode;
3788 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
3789 if (!S_ISDIR(inode->i_mode))
3790 flags &= ~JFS_DIRSYNC_FL;
3792 + if (IS_BARRIER(inode)) {
3793 + vxwprintk_task(1, "messing with the barrier.");
3797 /* Is it quota file? Do not allow user to mess with it */
3798 if (IS_NOQUOTA(inode)) {
3800 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
3801 * the relevant capability.
3803 if ((oldflags & JFS_IMMUTABLE_FL) ||
3804 - ((flags ^ oldflags) &
3805 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
3806 + ((flags ^ oldflags) & (JFS_APPEND_FL |
3807 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
3808 if (!capable(CAP_LINUX_IMMUTABLE)) {
3809 mutex_unlock(&inode->i_mutex);
3811 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
3815 - flags = flags & JFS_FL_USER_MODIFIABLE;
3816 + flags &= JFS_FL_USER_MODIFIABLE;
3817 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
3818 jfs_inode->mode2 = flags;
3820 diff -NurpP --minimal linux-3.6.10/fs/jfs/jfs_dinode.h linux-3.6.10-vs2.3.4.5/fs/jfs/jfs_dinode.h
3821 --- linux-3.6.10/fs/jfs/jfs_dinode.h 2008-12-25 00:26:37.000000000 +0100
3822 +++ linux-3.6.10-vs2.3.4.5/fs/jfs/jfs_dinode.h 2012-10-04 18:47:00.000000000 +0200
3823 @@ -161,9 +161,13 @@ struct dinode {
3825 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
3826 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
3827 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3829 -#define JFS_FL_USER_VISIBLE 0x03F80000
3830 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
3831 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3832 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
3834 +#define JFS_FL_USER_VISIBLE 0x07F80000
3835 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
3836 #define JFS_FL_INHERIT 0x03C80000
3838 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
3839 diff -NurpP --minimal linux-3.6.10/fs/jfs/jfs_filsys.h linux-3.6.10-vs2.3.4.5/fs/jfs/jfs_filsys.h
3840 --- linux-3.6.10/fs/jfs/jfs_filsys.h 2008-12-25 00:26:37.000000000 +0100
3841 +++ linux-3.6.10-vs2.3.4.5/fs/jfs/jfs_filsys.h 2012-10-04 18:47:00.000000000 +0200
3843 #define JFS_NAME_MAX 255
3844 #define JFS_PATH_MAX BPSIZE
3846 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
3849 * file system state (superblock state)
3850 diff -NurpP --minimal linux-3.6.10/fs/jfs/jfs_imap.c linux-3.6.10-vs2.3.4.5/fs/jfs/jfs_imap.c
3851 --- linux-3.6.10/fs/jfs/jfs_imap.c 2012-01-09 16:14:54.000000000 +0100
3852 +++ linux-3.6.10-vs2.3.4.5/fs/jfs/jfs_imap.c 2012-10-04 18:47:00.000000000 +0200
3854 #include <linux/pagemap.h>
3855 #include <linux/quotaops.h>
3856 #include <linux/slab.h>
3857 +#include <linux/vs_tag.h>
3859 #include "jfs_incore.h"
3860 #include "jfs_inode.h"
3861 @@ -3058,6 +3059,8 @@ static int copy_from_dinode(struct dinod
3863 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
3864 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
3868 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
3869 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
3870 @@ -3078,14 +3081,18 @@ static int copy_from_dinode(struct dinod
3872 set_nlink(ip, le32_to_cpu(dip->di_nlink));
3874 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
3875 + uid = le32_to_cpu(dip->di_uid);
3876 + gid = le32_to_cpu(dip->di_gid);
3877 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
3879 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
3881 ip->i_uid = jfs_ip->saved_uid;
3883 ip->i_uid = sbi->uid;
3886 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
3887 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
3889 ip->i_gid = jfs_ip->saved_gid;
3891 @@ -3150,14 +3157,12 @@ static void copy_to_dinode(struct dinode
3892 dip->di_size = cpu_to_le64(ip->i_size);
3893 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
3894 dip->di_nlink = cpu_to_le32(ip->i_nlink);
3895 - if (sbi->uid == -1)
3896 - dip->di_uid = cpu_to_le32(ip->i_uid);
3898 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
3899 - if (sbi->gid == -1)
3900 - dip->di_gid = cpu_to_le32(ip->i_gid);
3902 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
3904 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
3905 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
3906 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
3907 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
3909 jfs_get_inode_flags(jfs_ip);
3911 * mode2 is only needed for storing the higher order bits.
3912 diff -NurpP --minimal linux-3.6.10/fs/jfs/jfs_inode.c linux-3.6.10-vs2.3.4.5/fs/jfs/jfs_inode.c
3913 --- linux-3.6.10/fs/jfs/jfs_inode.c 2012-01-09 16:14:54.000000000 +0100
3914 +++ linux-3.6.10-vs2.3.4.5/fs/jfs/jfs_inode.c 2012-10-04 18:47:00.000000000 +0200
3917 #include <linux/fs.h>
3918 #include <linux/quotaops.h>
3919 +#include <linux/vs_tag.h>
3920 #include "jfs_incore.h"
3921 #include "jfs_inode.h"
3922 #include "jfs_filsys.h"
3923 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
3925 unsigned int flags = JFS_IP(inode)->mode2;
3927 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
3928 - S_NOATIME | S_DIRSYNC | S_SYNC);
3929 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3930 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3932 if (flags & JFS_IMMUTABLE_FL)
3933 inode->i_flags |= S_IMMUTABLE;
3934 + if (flags & JFS_IXUNLINK_FL)
3935 + inode->i_flags |= S_IXUNLINK;
3937 + if (flags & JFS_SYNC_FL)
3938 + inode->i_flags |= S_SYNC;
3939 if (flags & JFS_APPEND_FL)
3940 inode->i_flags |= S_APPEND;
3941 if (flags & JFS_NOATIME_FL)
3942 inode->i_flags |= S_NOATIME;
3943 if (flags & JFS_DIRSYNC_FL)
3944 inode->i_flags |= S_DIRSYNC;
3945 - if (flags & JFS_SYNC_FL)
3946 - inode->i_flags |= S_SYNC;
3948 + inode->i_vflags &= ~(V_BARRIER | V_COW);
3950 + if (flags & JFS_BARRIER_FL)
3951 + inode->i_vflags |= V_BARRIER;
3952 + if (flags & JFS_COW_FL)
3953 + inode->i_vflags |= V_COW;
3956 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
3958 unsigned int flags = jfs_ip->vfs_inode.i_flags;
3959 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
3961 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
3962 + JFS_APPEND_FL | JFS_NOATIME_FL |
3963 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
3964 + JFS_BARRIER_FL | JFS_COW_FL);
3966 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
3967 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
3968 if (flags & S_IMMUTABLE)
3969 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
3970 + if (flags & S_IXUNLINK)
3971 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
3973 if (flags & S_APPEND)
3974 jfs_ip->mode2 |= JFS_APPEND_FL;
3975 if (flags & S_NOATIME)
3976 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
3977 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
3979 jfs_ip->mode2 |= JFS_SYNC_FL;
3981 + if (vflags & V_BARRIER)
3982 + jfs_ip->mode2 |= JFS_BARRIER_FL;
3983 + if (vflags & V_COW)
3984 + jfs_ip->mode2 |= JFS_COW_FL;
3988 diff -NurpP --minimal linux-3.6.10/fs/jfs/jfs_inode.h linux-3.6.10-vs2.3.4.5/fs/jfs/jfs_inode.h
3989 --- linux-3.6.10/fs/jfs/jfs_inode.h 2011-10-24 18:45:27.000000000 +0200
3990 +++ linux-3.6.10-vs2.3.4.5/fs/jfs/jfs_inode.h 2012-10-04 18:47:00.000000000 +0200
3991 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
3992 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
3993 int fh_len, int fh_type);
3994 extern void jfs_set_inode_flags(struct inode *);
3995 +extern int jfs_sync_flags(struct inode *, int, int);
3996 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
3997 extern int jfs_setattr(struct dentry *, struct iattr *);
3999 diff -NurpP --minimal linux-3.6.10/fs/jfs/namei.c linux-3.6.10-vs2.3.4.5/fs/jfs/namei.c
4000 --- linux-3.6.10/fs/jfs/namei.c 2012-10-04 15:27:40.000000000 +0200
4001 +++ linux-3.6.10-vs2.3.4.5/fs/jfs/namei.c 2012-10-04 18:47:00.000000000 +0200
4003 #include <linux/ctype.h>
4004 #include <linux/quotaops.h>
4005 #include <linux/exportfs.h>
4006 +#include <linux/vs_tag.h>
4007 #include "jfs_incore.h"
4008 #include "jfs_superblock.h"
4009 #include "jfs_inode.h"
4010 @@ -1461,6 +1462,7 @@ static struct dentry *jfs_lookup(struct
4011 jfs_err("jfs_lookup: iget failed on inum %d", (uint)inum);
4014 + dx_propagate_tag(nd, ip);
4015 return d_splice_alias(ip, dentry);
4018 @@ -1525,6 +1527,7 @@ const struct inode_operations jfs_dir_in
4019 #ifdef CONFIG_JFS_POSIX_ACL
4020 .get_acl = jfs_get_acl,
4022 + .sync_flags = jfs_sync_flags,
4025 const struct file_operations jfs_dir_operations = {
4026 diff -NurpP --minimal linux-3.6.10/fs/jfs/super.c linux-3.6.10-vs2.3.4.5/fs/jfs/super.c
4027 --- linux-3.6.10/fs/jfs/super.c 2012-10-04 15:27:40.000000000 +0200
4028 +++ linux-3.6.10-vs2.3.4.5/fs/jfs/super.c 2012-10-04 18:47:00.000000000 +0200
4029 @@ -197,7 +197,8 @@ static void jfs_put_super(struct super_b
4031 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
4032 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
4033 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
4034 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
4035 + Opt_tag, Opt_notag, Opt_tagid
4038 static const match_table_t tokens = {
4039 @@ -207,6 +208,10 @@ static const match_table_t tokens = {
4040 {Opt_resize, "resize=%u"},
4041 {Opt_resize_nosize, "resize"},
4042 {Opt_errors, "errors=%s"},
4044 + {Opt_notag, "notag"},
4045 + {Opt_tagid, "tagid=%u"},
4046 + {Opt_tag, "tagxid"},
4047 {Opt_ignore, "noquota"},
4048 {Opt_ignore, "quota"},
4049 {Opt_usrquota, "usrquota"},
4050 @@ -341,6 +346,20 @@ static int parse_options(char *options,
4054 +#ifndef CONFIG_TAGGING_NONE
4056 + *flag |= JFS_TAGGED;
4059 + *flag &= JFS_TAGGED;
4062 +#ifdef CONFIG_PROPAGATE
4065 + *flag |= JFS_TAGGED;
4069 printk("jfs: Unrecognized mount option \"%s\" "
4070 " or missing value\n", p);
4071 @@ -372,6 +391,12 @@ static int jfs_remount(struct super_bloc
4075 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4076 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4082 if (sb->s_flags & MS_RDONLY) {
4084 @@ -455,6 +480,9 @@ static int jfs_fill_super(struct super_b
4085 #ifdef CONFIG_JFS_POSIX_ACL
4086 sb->s_flags |= MS_POSIXACL;
4088 + /* map mount option tagxid */
4089 + if (sbi->flag & JFS_TAGGED)
4090 + sb->s_flags |= MS_TAGGED;
4093 printk(KERN_ERR "resize option for remount only\n");
4094 diff -NurpP --minimal linux-3.6.10/fs/libfs.c linux-3.6.10-vs2.3.4.5/fs/libfs.c
4095 --- linux-3.6.10/fs/libfs.c 2012-10-04 15:27:40.000000000 +0200
4096 +++ linux-3.6.10-vs2.3.4.5/fs/libfs.c 2012-10-04 18:47:00.000000000 +0200
4097 @@ -135,7 +135,8 @@ static inline unsigned char dt_type(stru
4098 * both impossible due to the lock on directory.
4101 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4102 +static inline int do_dcache_readdir_filter(struct file *filp,
4103 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4105 struct dentry *dentry = filp->f_path.dentry;
4106 struct dentry *cursor = filp->private_data;
4107 @@ -166,6 +167,8 @@ int dcache_readdir(struct file * filp, v
4108 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
4109 struct dentry *next;
4110 next = list_entry(p, struct dentry, d_u.d_child);
4111 + if (filter && !filter(next))
4113 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
4114 if (!simple_positive(next)) {
4115 spin_unlock(&next->d_lock);
4116 @@ -192,6 +195,17 @@ int dcache_readdir(struct file * filp, v
4120 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4122 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4125 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4126 + int (*filter)(struct dentry *))
4128 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4131 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4134 @@ -983,6 +997,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4135 EXPORT_SYMBOL(dcache_dir_lseek);
4136 EXPORT_SYMBOL(dcache_dir_open);
4137 EXPORT_SYMBOL(dcache_readdir);
4138 +EXPORT_SYMBOL(dcache_readdir_filter);
4139 EXPORT_SYMBOL(generic_read_dir);
4140 EXPORT_SYMBOL(mount_pseudo);
4141 EXPORT_SYMBOL(simple_write_begin);
4142 diff -NurpP --minimal linux-3.6.10/fs/locks.c linux-3.6.10-vs2.3.4.5/fs/locks.c
4143 --- linux-3.6.10/fs/locks.c 2012-10-04 15:27:40.000000000 +0200
4144 +++ linux-3.6.10-vs2.3.4.5/fs/locks.c 2012-10-04 18:47:00.000000000 +0200
4146 #include <linux/time.h>
4147 #include <linux/rcupdate.h>
4148 #include <linux/pid_namespace.h>
4149 +#include <linux/vs_base.h>
4150 +#include <linux/vs_limit.h>
4152 #include <asm/uaccess.h>
4154 @@ -184,11 +186,17 @@ static void locks_init_lock_heads(struct
4155 /* Allocate an empty lock structure. */
4156 struct file_lock *locks_alloc_lock(void)
4158 - struct file_lock *fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL);
4159 + struct file_lock *fl;
4162 - locks_init_lock_heads(fl);
4163 + if (!vx_locks_avail(1))
4166 + fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL);
4169 + locks_init_lock_heads(fl);
4174 EXPORT_SYMBOL_GPL(locks_alloc_lock);
4175 @@ -212,6 +220,7 @@ void locks_free_lock(struct file_lock *f
4176 BUG_ON(!list_empty(&fl->fl_block));
4177 BUG_ON(!list_empty(&fl->fl_link));
4180 locks_release_private(fl);
4181 kmem_cache_free(filelock_cache, fl);
4183 @@ -221,6 +230,7 @@ void locks_init_lock(struct file_lock *f
4185 memset(fl, 0, sizeof(struct file_lock));
4186 locks_init_lock_heads(fl);
4190 EXPORT_SYMBOL(locks_init_lock);
4191 @@ -261,6 +271,7 @@ void locks_copy_lock(struct file_lock *n
4192 new->fl_file = fl->fl_file;
4193 new->fl_ops = fl->fl_ops;
4194 new->fl_lmops = fl->fl_lmops;
4195 + new->fl_xid = fl->fl_xid;
4197 locks_copy_private(new, fl);
4199 @@ -299,6 +310,11 @@ static int flock_make_lock(struct file *
4200 fl->fl_flags = FL_FLOCK;
4202 fl->fl_end = OFFSET_MAX;
4204 + vxd_assert(filp->f_xid == vx_current_xid(),
4205 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4206 + fl->fl_xid = filp->f_xid;
4211 @@ -438,6 +454,7 @@ static int lease_init(struct file *filp,
4213 fl->fl_owner = current->files;
4214 fl->fl_pid = current->tgid;
4215 + fl->fl_xid = vx_current_xid();
4218 fl->fl_flags = FL_LEASE;
4219 @@ -457,6 +474,11 @@ static struct file_lock *lease_alloc(str
4221 return ERR_PTR(error);
4223 + fl->fl_xid = vx_current_xid();
4225 + vxd_assert(filp->f_xid == fl->fl_xid,
4226 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4228 error = lease_init(filp, type, fl);
4230 locks_free_lock(fl);
4231 @@ -753,6 +775,7 @@ static int flock_lock_file(struct file *
4235 + new_fl->fl_xid = -1;
4237 for_each_lock(inode, before) {
4238 struct file_lock *fl = *before;
4239 @@ -773,6 +796,7 @@ find_conflict:
4241 locks_copy_lock(new_fl, request);
4242 locks_insert_lock(before, new_fl);
4243 + vx_locks_inc(new_fl);
4247 @@ -783,7 +807,8 @@ out:
4251 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4252 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4253 + struct file_lock *conflock, xid_t xid)
4255 struct file_lock *fl;
4256 struct file_lock *new_fl = NULL;
4257 @@ -793,6 +818,8 @@ static int __posix_lock_file(struct inod
4258 struct file_lock **before;
4259 int error, added = 0;
4261 + vxd_assert(xid == vx_current_xid(),
4262 + "xid(%d) == current(%d)", xid, vx_current_xid());
4264 * We may need two file_lock structures for this operation,
4265 * so we get them in advance to avoid races.
4266 @@ -803,7 +830,11 @@ static int __posix_lock_file(struct inod
4267 (request->fl_type != F_UNLCK ||
4268 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4269 new_fl = locks_alloc_lock();
4270 + new_fl->fl_xid = xid;
4271 + vx_locks_inc(new_fl);
4272 new_fl2 = locks_alloc_lock();
4273 + new_fl2->fl_xid = xid;
4274 + vx_locks_inc(new_fl2);
4278 @@ -1002,7 +1033,8 @@ static int __posix_lock_file(struct inod
4279 int posix_lock_file(struct file *filp, struct file_lock *fl,
4280 struct file_lock *conflock)
4282 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
4283 + return __posix_lock_file(filp->f_path.dentry->d_inode,
4284 + fl, conflock, filp->f_xid);
4286 EXPORT_SYMBOL(posix_lock_file);
4288 @@ -1092,7 +1124,7 @@ int locks_mandatory_area(int read_write,
4289 fl.fl_end = offset + count - 1;
4292 - error = __posix_lock_file(inode, &fl, NULL);
4293 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
4294 if (error != FILE_LOCK_DEFERRED)
4296 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
4297 @@ -1397,6 +1429,7 @@ int generic_add_lease(struct file *filp,
4300 locks_insert_lock(before, lease);
4301 + vx_locks_inc(lease);
4305 @@ -1838,6 +1871,11 @@ int fcntl_setlk(unsigned int fd, struct
4306 if (file_lock == NULL)
4309 + vxd_assert(filp->f_xid == vx_current_xid(),
4310 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4311 + file_lock->fl_xid = filp->f_xid;
4312 + vx_locks_inc(file_lock);
4315 * This might block, so we do it before checking the inode.
4317 @@ -1956,6 +1994,11 @@ int fcntl_setlk64(unsigned int fd, struc
4318 if (file_lock == NULL)
4321 + vxd_assert(filp->f_xid == vx_current_xid(),
4322 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4323 + file_lock->fl_xid = filp->f_xid;
4324 + vx_locks_inc(file_lock);
4327 * This might block, so we do it before checking the inode.
4329 @@ -2221,8 +2264,11 @@ static int locks_show(struct seq_file *f
4331 lock_get_status(f, fl, *((loff_t *)f->private), "");
4333 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
4334 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
4335 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
4337 lock_get_status(f, bfl, *((loff_t *)f->private), " ->");
4342 diff -NurpP --minimal linux-3.6.10/fs/mount.h linux-3.6.10-vs2.3.4.5/fs/mount.h
4343 --- linux-3.6.10/fs/mount.h 2012-10-04 15:27:40.000000000 +0200
4344 +++ linux-3.6.10-vs2.3.4.5/fs/mount.h 2012-10-04 18:47:00.000000000 +0200
4345 @@ -46,6 +46,7 @@ struct mount {
4346 int mnt_expiry_mark; /* true if marked for expiry */
4349 + tag_t mnt_tag; /* tagging used for vfsmount */
4352 #define MNT_NS_INTERNAL ERR_PTR(-EINVAL) /* distinct from any mnt_namespace */
4353 diff -NurpP --minimal linux-3.6.10/fs/namei.c linux-3.6.10-vs2.3.4.5/fs/namei.c
4354 --- linux-3.6.10/fs/namei.c 2012-12-11 12:36:58.000000000 +0100
4355 +++ linux-3.6.10-vs2.3.4.5/fs/namei.c 2012-12-08 01:08:53.000000000 +0100
4357 #include <linux/device_cgroup.h>
4358 #include <linux/fs_struct.h>
4359 #include <linux/posix_acl.h>
4360 +#include <linux/proc_fs.h>
4361 +#include <linux/vserver/inode.h>
4362 +#include <linux/vs_base.h>
4363 +#include <linux/vs_tag.h>
4364 +#include <linux/vs_cowbl.h>
4365 +#include <linux/vs_device.h>
4366 +#include <linux/vs_context.h>
4367 +#include <linux/pid_namespace.h>
4368 #include <asm/uaccess.h>
4370 #include "internal.h"
4371 @@ -212,6 +220,89 @@ static int check_acl(struct inode *inode
4375 +static inline int dx_barrier(const struct inode *inode)
4377 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
4378 + vxwprintk_task(1, "did hit the barrier.");
4384 +static int __dx_permission(const struct inode *inode, int mask)
4386 + if (dx_barrier(inode))
4389 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
4390 + /* devpts is xid tagged */
4391 + if (S_ISDIR(inode->i_mode) ||
4392 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
4395 + /* just pretend we didn't find anything */
4398 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
4399 + struct proc_dir_entry *de = PDE(inode);
4401 + if (de && !vx_hide_check(0, de->vx_flags))
4404 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
4406 + struct task_struct *tsk;
4408 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
4409 + vx_flags(VXF_STATE_SETUP, 0))
4412 + pid = PROC_I(inode)->pid;
4417 + tsk = pid_task(pid, PIDTYPE_PID);
4418 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
4419 + tsk, (tsk ? vx_task_xid(tsk) : 0));
4421 + vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P)) {
4422 + rcu_read_unlock();
4425 + rcu_read_unlock();
4428 + /* FIXME: Should we block some entries here? */
4433 + if (dx_notagcheck(inode->i_sb) ||
4434 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
4443 +int dx_permission(const struct inode *inode, int mask)
4445 + int ret = __dx_permission(inode, mask);
4446 + if (unlikely(ret)) {
4447 +#ifndef CONFIG_VSERVER_WARN_DEVPTS
4448 + if (inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC)
4451 + "denied [0x%x] access to inode %s:%p[#%d,%lu]",
4452 + mask, inode->i_sb->s_id, inode, inode->i_tag,
4459 * This does the basic permission checking
4461 @@ -334,10 +425,14 @@ int __inode_permission(struct inode *ino
4463 * Nobody gets write access to an immutable file.
4465 - if (IS_IMMUTABLE(inode))
4466 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
4470 + retval = dx_permission(inode, mask);
4474 retval = do_inode_permission(inode, mask);
4477 @@ -1189,7 +1284,8 @@ static void follow_dotdot(struct nameida
4479 if (nd->path.dentry == nd->root.dentry &&
4480 nd->path.mnt == nd->root.mnt) {
4482 + /* for sane '/' avoid follow_mount() */
4485 if (nd->path.dentry != nd->path.mnt->mnt_root) {
4486 /* rare case of legitimate dget_parent()... */
4487 @@ -1338,6 +1434,9 @@ static int lookup_fast(struct nameidata
4492 + /* FIXME: check dx permission */
4495 path->dentry = dentry;
4496 if (unlikely(!__follow_mount_rcu(nd, path, inode)))
4497 @@ -1373,6 +1472,8 @@ unlazy:
4501 + /* FIXME: check dx permission */
4504 path->dentry = dentry;
4505 err = follow_managed(path, nd->flags);
4506 @@ -2192,7 +2293,7 @@ static int may_delete(struct inode *dir,
4509 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
4510 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4511 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4514 if (!S_ISDIR(victim->d_inode->i_mode))
4515 @@ -2271,19 +2372,25 @@ int vfs_create(struct inode *dir, struct
4518 int error = may_create(dir, dentry);
4522 + vxdprintk(VXD_CBIT(misc, 3), "may_create failed with %d", error);
4526 if (!dir->i_op->create)
4527 return -EACCES; /* shouldn't it be ENOSYS? */
4530 error = security_inode_create(dir, dentry, mode);
4534 + vxdprintk(VXD_CBIT(misc, 3), "security_inode_create failed with %d", error);
4537 error = dir->i_op->create(dir, dentry, mode, want_excl);
4539 fsnotify_create(dir, dentry);
4541 + vxdprintk(VXD_CBIT(misc, 3), "i_op->create failed with %d", error);
4545 @@ -2318,6 +2425,15 @@ static int may_open(struct path *path, i
4549 +#ifdef CONFIG_VSERVER_COWBL
4550 + if (IS_COW(inode) &&
4551 + ((flag & O_ACCMODE) != O_RDONLY)) {
4552 + if (IS_COW_LINK(inode))
4554 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
4555 + mark_inode_dirty(inode);
4558 error = inode_permission(inode, acc_mode);
4561 @@ -2820,6 +2936,16 @@ finish_open:
4563 finish_open_created:
4564 error = may_open(&nd->path, acc_mode, open_flag);
4565 +#ifdef CONFIG_VSERVER_COWBL
4566 + if (error == -EMLINK) {
4567 + struct dentry *dentry;
4568 + dentry = cow_break_link(pathname);
4569 + if (IS_ERR(dentry))
4570 + error = PTR_ERR(dentry);
4577 file->f_path.mnt = nd->path.mnt;
4578 @@ -2884,6 +3010,7 @@ static struct file *path_openat(int dfd,
4583 file = get_empty_filp();
4585 return ERR_PTR(-ENFILE);
4586 @@ -2920,6 +3047,16 @@ static struct file *path_openat(int dfd,
4587 error = do_last(nd, &path, file, op, &opened, pathname);
4588 put_link(nd, &link, cookie);
4591 +#ifdef CONFIG_VSERVER_COWBL
4592 + if (error == -EMLINK) {
4593 + if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
4594 + path_put(&nd->root);
4601 if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
4602 path_put(&nd->root);
4603 @@ -3023,6 +3160,11 @@ struct dentry *kern_path_create(int dfd,
4607 + vxdprintk(VXD_CBIT(misc, 3), "kern_path_create path.dentry = %p (%.*s), dentry = %p (%.*s), d_inode = %p",
4608 + path->dentry, path->dentry->d_name.len,
4609 + path->dentry->d_name.name, dentry,
4610 + dentry->d_name.len, dentry->d_name.name,
4611 + path->dentry->d_inode);
4615 @@ -3489,7 +3631,7 @@ int vfs_link(struct dentry *old_dentry,
4617 * A link to an append-only or immutable file cannot be created.
4619 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4620 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4622 if (!dir->i_op->link)
4624 @@ -3874,6 +4016,275 @@ int vfs_follow_link(struct nameidata *nd
4625 return __vfs_follow_link(nd, link);
4629 +#ifdef CONFIG_VSERVER_COWBL
4632 +long do_cow_splice(struct file *in, struct file *out, size_t len)
4636 + return do_splice_direct(in, &ppos, out, len, 0);
4639 +struct dentry *cow_break_link(const char *pathname)
4641 + int ret, mode, pathlen, redo = 0;
4642 + struct nameidata old_nd, dir_nd;
4643 + struct path dir_path, *old_path, *new_path;
4644 + struct dentry *dir, *old_dentry, *new_dentry = NULL;
4645 + struct file *old_file;
4646 + struct file *new_file;
4647 + char *to, *path, pad='\251';
4650 + vxdprintk(VXD_CBIT(misc, 1),
4651 + "cow_break_link(" VS_Q("%s") ")", pathname);
4653 + path = kmalloc(PATH_MAX, GFP_KERNEL);
4658 + /* old_nd.path will have refs to dentry and mnt */
4659 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
4660 + vxdprintk(VXD_CBIT(misc, 2),
4661 + "do_path_lookup(old): %d", ret);
4663 + goto out_free_path;
4665 + /* dentry/mnt refs handed over to old_path */
4666 + old_path = &old_nd.path;
4667 + /* no explicit reference for old_dentry here */
4668 + old_dentry = old_path->dentry;
4670 + mode = old_dentry->d_inode->i_mode;
4671 + to = d_path(old_path, path, PATH_MAX-2);
4672 + pathlen = strlen(to);
4673 + vxdprintk(VXD_CBIT(misc, 2),
4674 + "old path " VS_Q("%s") " [%p:" VS_Q("%.*s") ":%d]", to,
4676 + old_dentry->d_name.len, old_dentry->d_name.name,
4677 + old_dentry->d_name.len);
4679 + to[pathlen + 1] = 0;
4681 + new_dentry = NULL;
4682 + to[pathlen] = pad--;
4684 + if (pad <= '\240')
4687 + vxdprintk(VXD_CBIT(misc, 1), "temp copy " VS_Q("%s"), to);
4689 + /* dir_nd.path will have refs to dentry and mnt */
4690 + ret = do_path_lookup(AT_FDCWD, to,
4691 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
4692 + vxdprintk(VXD_CBIT(misc, 2), "do_path_lookup(new): %d", ret);
4696 + /* this puppy downs the dir inode mutex if successful.
4697 + dir_path will hold refs to dentry and mnt and
4698 + we'll have get write access to the mnt */
4699 + new_dentry = kern_path_create(AT_FDCWD, to, &dir_path, 0);
4700 + if (!new_dentry || IS_ERR(new_dentry)) {
4701 + path_put(&dir_nd.path);
4702 + vxdprintk(VXD_CBIT(misc, 2),
4703 + "kern_path_create(new) failed with %ld",
4704 + PTR_ERR(new_dentry));
4707 + vxdprintk(VXD_CBIT(misc, 2),
4708 + "kern_path_create(new): %p [" VS_Q("%.*s") ":%d]",
4710 + new_dentry->d_name.len, new_dentry->d_name.name,
4711 + new_dentry->d_name.len);
4713 + /* take a reference on new_dentry */
4716 + /* dentry/mnt refs handed over to new_path */
4717 + new_path = &dir_path;
4719 + /* dentry for old/new dir */
4720 + dir = dir_nd.path.dentry;
4722 + /* give up reference on dir */
4723 + dput(new_path->dentry);
4725 + /* new_dentry already has a reference */
4726 + new_path->dentry = new_dentry;
4728 + ret = vfs_create(dir->d_inode, new_dentry, mode, 1);
4729 + vxdprintk(VXD_CBIT(misc, 2),
4730 + "vfs_create(new): %d", ret);
4731 + if (ret == -EEXIST) {
4732 + mutex_unlock(&dir->d_inode->i_mutex);
4733 + path_put(&dir_nd.path);
4734 + mnt_drop_write(new_path->mnt);
4735 + path_put(new_path);
4736 + new_dentry = NULL;
4740 + goto out_unlock_new;
4742 + /* drop out early, ret passes ENOENT */
4744 + if ((redo = d_unhashed(old_dentry)))
4745 + goto out_unlock_new;
4747 + /* doesn't change refs for old_path */
4748 + old_file = dentry_open(old_path, O_RDONLY, current_cred());
4749 + vxdprintk(VXD_CBIT(misc, 2),
4750 + "dentry_open(old): %p", old_file);
4751 + if (IS_ERR(old_file)) {
4752 + ret = PTR_ERR(old_file);
4753 + goto out_unlock_new;
4756 + /* doesn't change refs for new_path */
4757 + new_file = dentry_open(new_path, O_WRONLY, current_cred());
4758 + vxdprintk(VXD_CBIT(misc, 2),
4759 + "dentry_open(new): %p", new_file);
4760 + if (IS_ERR(new_file)) {
4761 + ret = PTR_ERR(new_file);
4762 + goto out_fput_old;
4765 + size = i_size_read(old_file->f_dentry->d_inode);
4766 + ret = do_cow_splice(old_file, new_file, size);
4767 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
4769 + goto out_fput_both;
4770 + } else if (ret < size) {
4772 + goto out_fput_both;
4774 + struct inode *old_inode = old_dentry->d_inode;
4775 + struct inode *new_inode = new_dentry->d_inode;
4776 + struct iattr attr = {
4777 + .ia_uid = old_inode->i_uid,
4778 + .ia_gid = old_inode->i_gid,
4779 + .ia_valid = ATTR_UID | ATTR_GID
4782 + setattr_copy(new_inode, &attr);
4783 + mark_inode_dirty(new_inode);
4786 + /* lock rename mutex */
4787 + mutex_lock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
4789 + /* drop out late */
4791 + if ((redo = d_unhashed(old_dentry)))
4794 + vxdprintk(VXD_CBIT(misc, 2),
4795 + "vfs_rename: [" VS_Q("%*s") ":%d] -> [" VS_Q("%*s") ":%d]",
4796 + new_dentry->d_name.len, new_dentry->d_name.name,
4797 + new_dentry->d_name.len,
4798 + old_dentry->d_name.len, old_dentry->d_name.name,
4799 + old_dentry->d_name.len);
4800 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_dentry,
4801 + old_dentry->d_parent->d_inode, old_dentry);
4802 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
4805 + mutex_unlock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
4808 + vxdprintk(VXD_CBIT(misc, 3),
4809 + "fput(new_file=%p[#%ld])", new_file,
4810 + atomic_long_read(&new_file->f_count));
4814 + vxdprintk(VXD_CBIT(misc, 3),
4815 + "fput(old_file=%p[#%ld])", old_file,
4816 + atomic_long_read(&old_file->f_count));
4820 + /* drop references from dir_nd.path */
4821 + path_put(&dir_nd.path);
4823 + /* drop write access to mnt */
4824 + mnt_drop_write(new_path->mnt);
4826 + /* unlock the inode mutex from kern_path_create() */
4827 + mutex_unlock(&dir->d_inode->i_mutex);
4831 + /* error path cleanup */
4832 + vfs_unlink(dir->d_inode, new_dentry);
4836 + goto out_rel_both;
4838 + /* lookup dentry once again
4839 + old_nd.path will be freed as old_path in out_rel_old */
4840 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
4842 + goto out_rel_both;
4844 + /* drop reference on new_dentry */
4846 + new_dentry = old_path->dentry;
4848 + vxdprintk(VXD_CBIT(misc, 2),
4849 + "do_path_lookup(redo): %p [" VS_Q("%.*s") ":%d]",
4851 + new_dentry->d_name.len, new_dentry->d_name.name,
4852 + new_dentry->d_name.len);
4856 + path_put(new_path);
4858 + path_put(old_path);
4864 + new_dentry = ERR_PTR(ret);
4866 + vxdprintk(VXD_CBIT(misc, 3),
4867 + "cow_break_link returning with %p", new_dentry);
4868 + return new_dentry;
4873 +int vx_info_mnt_namespace(struct mnt_namespace *ns, char *buffer)
4876 + struct vfsmount *vmnt;
4877 + char *pstr, *root;
4880 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
4884 + vmnt = &ns->root->mnt;
4886 + path.dentry = vmnt->mnt_root;
4887 + root = d_path(&path, pstr, PATH_MAX - 2);
4888 + length = sprintf(buffer + length,
4889 + "Namespace:\t%p [#%u]\n"
4890 + "RootPath:\t%s\n",
4891 + ns, atomic_read(&ns->count),
4897 /* get the link contents into pagecache */
4898 static char *page_getlink(struct dentry * dentry, struct page **ppage)
4900 @@ -3998,3 +4409,4 @@ EXPORT_SYMBOL(vfs_symlink);
4901 EXPORT_SYMBOL(vfs_unlink);
4902 EXPORT_SYMBOL(dentry_unhash);
4903 EXPORT_SYMBOL(generic_readlink);
4904 +EXPORT_SYMBOL(vx_info_mnt_namespace);
4905 diff -NurpP --minimal linux-3.6.10/fs/namespace.c linux-3.6.10-vs2.3.4.5/fs/namespace.c
4906 --- linux-3.6.10/fs/namespace.c 2012-10-04 15:27:40.000000000 +0200
4907 +++ linux-3.6.10-vs2.3.4.5/fs/namespace.c 2012-12-08 01:10:23.000000000 +0100
4909 #include <linux/fs_struct.h> /* get_fs_root et.al. */
4910 #include <linux/fsnotify.h> /* fsnotify_vfsmount_delete */
4911 #include <linux/uaccess.h>
4912 +#include <linux/vs_base.h>
4913 +#include <linux/vs_context.h>
4914 +#include <linux/vs_tag.h>
4915 +#include <linux/vserver/space.h>
4916 +#include <linux/vserver/global.h>
4918 #include "internal.h"
4920 @@ -749,6 +754,10 @@ vfs_kern_mount(struct file_system_type *
4922 return ERR_PTR(-ENODEV);
4924 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
4925 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
4926 + return ERR_PTR(-EPERM);
4928 mnt = alloc_vfsmnt(name);
4930 return ERR_PTR(-ENOMEM);
4931 @@ -801,6 +810,7 @@ static struct mount *clone_mnt(struct mo
4932 mnt->mnt.mnt_root = dget(root);
4933 mnt->mnt_mountpoint = mnt->mnt.mnt_root;
4934 mnt->mnt_parent = mnt;
4935 + mnt->mnt_tag = old->mnt_tag;
4936 br_write_lock(&vfsmount_lock);
4937 list_add_tail(&mnt->mnt_instance, &sb->s_mounts);
4938 br_write_unlock(&vfsmount_lock);
4939 @@ -1266,7 +1276,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
4943 - if (!capable(CAP_SYS_ADMIN))
4944 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
4947 retval = do_umount(mnt, flags);
4948 @@ -1292,7 +1302,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
4950 static int mount_is_safe(struct path *path)
4952 - if (capable(CAP_SYS_ADMIN))
4953 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
4957 @@ -1610,7 +1620,7 @@ static int do_change_type(struct path *p
4961 - if (!capable(CAP_SYS_ADMIN))
4962 + if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
4965 if (path->dentry != path->mnt->mnt_root)
4966 @@ -1626,6 +1636,7 @@ static int do_change_type(struct path *p
4970 + // mnt->mnt_flags = mnt_flags;
4972 br_write_lock(&vfsmount_lock);
4973 for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL))
4974 @@ -1641,12 +1652,14 @@ static int do_change_type(struct path *p
4975 * do loopback mount.
4977 static int do_loopback(struct path *path, char *old_name,
4979 + tag_t tag, unsigned long flags, int mnt_flags)
4981 LIST_HEAD(umount_list);
4982 struct path old_path;
4983 struct mount *mnt = NULL, *old;
4984 int err = mount_is_safe(path);
4985 + int recurse = flags & MS_REC;
4989 if (!old_name || !*old_name)
4990 @@ -1715,13 +1728,13 @@ static int change_mount_flags(struct vfs
4991 * on it - tough luck.
4993 static int do_remount(struct path *path, int flags, int mnt_flags,
4995 + void *data, xid_t xid)
4998 struct super_block *sb = path->mnt->mnt_sb;
4999 struct mount *mnt = real_mount(path->mnt);
5001 - if (!capable(CAP_SYS_ADMIN))
5002 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
5005 if (!check_mnt(mnt))
5006 @@ -1770,7 +1783,7 @@ static int do_move_mount(struct path *pa
5010 - if (!capable(CAP_SYS_ADMIN))
5011 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5013 if (!old_name || !*old_name)
5015 @@ -1927,7 +1940,7 @@ static int do_new_mount(struct path *pat
5018 /* we need capabilities... */
5019 - if (!capable(CAP_SYS_ADMIN))
5020 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5023 mnt = do_kern_mount(type, flags, name, data);
5024 @@ -2197,6 +2210,7 @@ long do_mount(char *dev_name, char *dir_
5031 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
5032 @@ -2224,6 +2238,12 @@ long do_mount(char *dev_name, char *dir_
5033 if (!(flags & MS_NOATIME))
5034 mnt_flags |= MNT_RELATIME;
5036 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
5037 + /* FIXME: bind and re-mounts get the tag flag? */
5038 + if (flags & (MS_BIND|MS_REMOUNT))
5039 + flags |= MS_TAGID;
5042 /* Separate the per-mountpoint flags */
5043 if (flags & MS_NOSUID)
5044 mnt_flags |= MNT_NOSUID;
5045 @@ -2240,15 +2260,17 @@ long do_mount(char *dev_name, char *dir_
5046 if (flags & MS_RDONLY)
5047 mnt_flags |= MNT_READONLY;
5049 + if (!capable(CAP_SYS_ADMIN))
5050 + mnt_flags |= MNT_NODEV;
5051 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN |
5052 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
5055 if (flags & MS_REMOUNT)
5056 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
5059 else if (flags & MS_BIND)
5060 - retval = do_loopback(&path, dev_name, flags & MS_REC);
5061 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
5062 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
5063 retval = do_change_type(&path, flags);
5064 else if (flags & MS_MOVE)
5065 @@ -2329,6 +2351,7 @@ static struct mnt_namespace *dup_mnt_ns(
5066 q = next_mnt(q, new);
5068 up_write(&namespace_sem);
5069 + atomic_inc(&vs_global_mnt_ns);
5073 @@ -2524,9 +2547,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
5075 new_mnt = real_mount(new.mnt);
5076 root_mnt = real_mount(root.mnt);
5077 - if (IS_MNT_SHARED(real_mount(old.mnt)) ||
5078 + if ((IS_MNT_SHARED(real_mount(old.mnt)) ||
5079 IS_MNT_SHARED(new_mnt->mnt_parent) ||
5080 - IS_MNT_SHARED(root_mnt->mnt_parent))
5081 + IS_MNT_SHARED(root_mnt->mnt_parent)) &&
5082 + !vx_flags(VXF_STATE_SETUP, 0))
5084 if (!check_mnt(root_mnt) || !check_mnt(new_mnt))
5086 @@ -2647,6 +2671,7 @@ void put_mnt_ns(struct mnt_namespace *ns
5087 br_write_unlock(&vfsmount_lock);
5088 up_write(&namespace_sem);
5089 release_mounts(&umount_list);
5090 + atomic_dec(&vs_global_mnt_ns);
5094 diff -NurpP --minimal linux-3.6.10/fs/nfs/client.c linux-3.6.10-vs2.3.4.5/fs/nfs/client.c
5095 --- linux-3.6.10/fs/nfs/client.c 2012-12-11 12:36:58.000000000 +0100
5096 +++ linux-3.6.10-vs2.3.4.5/fs/nfs/client.c 2012-11-06 18:43:41.000000000 +0100
5097 @@ -692,6 +692,9 @@ int nfs_init_server_rpcclient(struct nfs
5098 if (server->flags & NFS_MOUNT_SOFT)
5099 server->client->cl_softrtry = 1;
5101 + server->client->cl_tag = 0;
5102 + if (server->flags & NFS_MOUNT_TAGGED)
5103 + server->client->cl_tag = 1;
5106 EXPORT_SYMBOL_GPL(nfs_init_server_rpcclient);
5107 @@ -869,6 +872,10 @@ static void nfs_server_set_fsinfo(struct
5108 server->acdirmin = server->acdirmax = 0;
5111 + /* FIXME: needs fsinfo
5112 + if (server->flags & NFS_MOUNT_TAGGED)
5113 + sb->s_flags |= MS_TAGGED; */
5115 server->maxfilesize = fsinfo->maxfilesize;
5117 server->time_delta = fsinfo->time_delta;
5118 diff -NurpP --minimal linux-3.6.10/fs/nfs/dir.c linux-3.6.10-vs2.3.4.5/fs/nfs/dir.c
5119 --- linux-3.6.10/fs/nfs/dir.c 2012-10-04 15:27:40.000000000 +0200
5120 +++ linux-3.6.10-vs2.3.4.5/fs/nfs/dir.c 2012-10-04 18:47:00.000000000 +0200
5122 #include <linux/sched.h>
5123 #include <linux/kmemleak.h>
5124 #include <linux/xattr.h>
5125 +#include <linux/vs_tag.h>
5127 #include "delegation.h"
5129 @@ -1251,6 +1252,7 @@ struct dentry *nfs_lookup(struct inode *
5130 /* Success: notify readdir to use READDIRPLUS */
5131 nfs_advise_use_readdirplus(dir);
5133 + dx_propagate_tag(nd, inode);
5135 res = d_materialise_unique(dentry, inode);
5137 diff -NurpP --minimal linux-3.6.10/fs/nfs/inode.c linux-3.6.10-vs2.3.4.5/fs/nfs/inode.c
5138 --- linux-3.6.10/fs/nfs/inode.c 2012-10-04 15:27:40.000000000 +0200
5139 +++ linux-3.6.10-vs2.3.4.5/fs/nfs/inode.c 2012-10-04 18:47:00.000000000 +0200
5141 #include <linux/compat.h>
5142 #include <linux/freezer.h>
5143 #include <linux/crc32.h>
5144 +#include <linux/vs_tag.h>
5146 #include <asm/uaccess.h>
5148 @@ -279,6 +280,8 @@ nfs_fhget(struct super_block *sb, struct
5149 if (inode->i_state & I_NEW) {
5150 struct nfs_inode *nfsi = NFS_I(inode);
5151 unsigned long now = jiffies;
5155 /* We set i_ino for the few things that still rely on it,
5156 * such as stat(2) */
5157 @@ -323,8 +326,8 @@ nfs_fhget(struct super_block *sb, struct
5158 inode->i_version = 0;
5161 - inode->i_uid = -2;
5162 - inode->i_gid = -2;
5165 inode->i_blocks = 0;
5166 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
5168 @@ -358,11 +361,11 @@ nfs_fhget(struct super_block *sb, struct
5169 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
5170 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5171 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
5172 - inode->i_uid = fattr->uid;
5174 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
5175 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5176 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
5177 - inode->i_gid = fattr->gid;
5179 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
5180 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5181 if (fattr->valid & NFS_ATTR_FATTR_BLOCKS_USED)
5182 @@ -373,6 +376,11 @@ nfs_fhget(struct super_block *sb, struct
5184 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
5186 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5187 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5188 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
5189 + /* maybe fattr->xid someday */
5191 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
5192 nfsi->attrtimeo_timestamp = now;
5193 nfsi->access_cache = RB_ROOT;
5194 @@ -494,6 +502,8 @@ void nfs_setattr_update_inode(struct ino
5195 inode->i_uid = attr->ia_uid;
5196 if ((attr->ia_valid & ATTR_GID) != 0)
5197 inode->i_gid = attr->ia_gid;
5198 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5199 + inode->i_tag = attr->ia_tag;
5200 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5201 spin_unlock(&inode->i_lock);
5203 @@ -965,6 +975,9 @@ static int nfs_check_inode_attributes(st
5204 struct nfs_inode *nfsi = NFS_I(inode);
5205 loff_t cur_size, new_isize;
5206 unsigned long invalid = 0;
5212 if (nfs_have_delegated_attributes(inode))
5213 @@ -990,13 +1003,18 @@ static int nfs_check_inode_attributes(st
5214 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5217 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5218 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5219 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5221 /* Have any file permissions changed? */
5222 if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
5223 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5224 - if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
5225 + if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
5226 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5227 - if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
5228 + if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
5229 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5230 + /* maybe check for tag too? */
5232 /* Has the link count changed? */
5233 if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
5234 @@ -1300,6 +1318,9 @@ static int nfs_update_inode(struct inode
5235 unsigned long invalid = 0;
5236 unsigned long now = jiffies;
5237 unsigned long save_cache_validity;
5242 dfprintk(VFS, "NFS: %s(%s/%ld fh_crc=0x%08x ct=%d info=0x%x)\n",
5243 __func__, inode->i_sb->s_id, inode->i_ino,
5244 @@ -1401,6 +1422,9 @@ static int nfs_update_inode(struct inode
5245 | NFS_INO_REVAL_PAGECACHE
5246 | NFS_INO_REVAL_FORCED);
5248 + uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
5249 + gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
5250 + tag = inode->i_tag;
5252 if (fattr->valid & NFS_ATTR_FATTR_ATIME)
5253 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5254 @@ -1422,9 +1446,9 @@ static int nfs_update_inode(struct inode
5255 | NFS_INO_REVAL_FORCED);
5257 if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
5258 - if (inode->i_uid != fattr->uid) {
5259 + if (uid != fattr->uid) {
5260 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5261 - inode->i_uid = fattr->uid;
5264 } else if (server->caps & NFS_CAP_OWNER)
5265 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5266 @@ -1433,9 +1457,9 @@ static int nfs_update_inode(struct inode
5267 | NFS_INO_REVAL_FORCED);
5269 if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
5270 - if (inode->i_gid != fattr->gid) {
5271 + if (gid != fattr->gid) {
5272 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5273 - inode->i_gid = fattr->gid;
5276 } else if (server->caps & NFS_CAP_OWNER_GROUP)
5277 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5278 @@ -1443,6 +1467,10 @@ static int nfs_update_inode(struct inode
5279 | NFS_INO_INVALID_ACL
5280 | NFS_INO_REVAL_FORCED);
5282 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5283 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5284 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, tag);
5286 if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
5287 if (inode->i_nlink != fattr->nlink) {
5288 invalid |= NFS_INO_INVALID_ATTR;
5289 diff -NurpP --minimal linux-3.6.10/fs/nfs/nfs3xdr.c linux-3.6.10-vs2.3.4.5/fs/nfs/nfs3xdr.c
5290 --- linux-3.6.10/fs/nfs/nfs3xdr.c 2012-10-04 15:27:40.000000000 +0200
5291 +++ linux-3.6.10-vs2.3.4.5/fs/nfs/nfs3xdr.c 2012-10-04 18:47:00.000000000 +0200
5293 #include <linux/nfs3.h>
5294 #include <linux/nfs_fs.h>
5295 #include <linux/nfsacl.h>
5296 +#include <linux/vs_tag.h>
5297 #include "internal.h"
5299 #define NFSDBG_FACILITY NFSDBG_XDR
5300 @@ -560,7 +561,8 @@ static __be32 *xdr_decode_nfstime3(__be3
5304 -static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr)
5305 +static void encode_sattr3(struct xdr_stream *xdr,
5306 + const struct iattr *attr, int tag)
5310 @@ -592,15 +594,19 @@ static void encode_sattr3(struct xdr_str
5314 - if (attr->ia_valid & ATTR_UID) {
5315 + if (attr->ia_valid & ATTR_UID ||
5316 + (tag && (attr->ia_valid & ATTR_TAG))) {
5318 - *p++ = cpu_to_be32(attr->ia_uid);
5319 + *p++ = cpu_to_be32(TAGINO_UID(tag,
5320 + attr->ia_uid, attr->ia_tag));
5324 - if (attr->ia_valid & ATTR_GID) {
5325 + if (attr->ia_valid & ATTR_GID ||
5326 + (tag && (attr->ia_valid & ATTR_TAG))) {
5328 - *p++ = cpu_to_be32(attr->ia_gid);
5329 + *p++ = cpu_to_be32(TAGINO_GID(tag,
5330 + attr->ia_gid, attr->ia_tag));
5334 @@ -879,7 +885,7 @@ static void nfs3_xdr_enc_setattr3args(st
5335 const struct nfs3_sattrargs *args)
5337 encode_nfs_fh3(xdr, args->fh);
5338 - encode_sattr3(xdr, args->sattr);
5339 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5340 encode_sattrguard3(xdr, args);
5343 @@ -1029,13 +1035,13 @@ static void nfs3_xdr_enc_write3args(stru
5346 static void encode_createhow3(struct xdr_stream *xdr,
5347 - const struct nfs3_createargs *args)
5348 + const struct nfs3_createargs *args, int tag)
5350 encode_uint32(xdr, args->createmode);
5351 switch (args->createmode) {
5352 case NFS3_CREATE_UNCHECKED:
5353 case NFS3_CREATE_GUARDED:
5354 - encode_sattr3(xdr, args->sattr);
5355 + encode_sattr3(xdr, args->sattr, tag);
5357 case NFS3_CREATE_EXCLUSIVE:
5358 encode_createverf3(xdr, args->verifier);
5359 @@ -1050,7 +1056,7 @@ static void nfs3_xdr_enc_create3args(str
5360 const struct nfs3_createargs *args)
5362 encode_diropargs3(xdr, args->fh, args->name, args->len);
5363 - encode_createhow3(xdr, args);
5364 + encode_createhow3(xdr, args, req->rq_task->tk_client->cl_tag);
5368 @@ -1066,7 +1072,7 @@ static void nfs3_xdr_enc_mkdir3args(stru
5369 const struct nfs3_mkdirargs *args)
5371 encode_diropargs3(xdr, args->fh, args->name, args->len);
5372 - encode_sattr3(xdr, args->sattr);
5373 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5377 @@ -1083,9 +1089,9 @@ static void nfs3_xdr_enc_mkdir3args(stru
5380 static void encode_symlinkdata3(struct xdr_stream *xdr,
5381 - const struct nfs3_symlinkargs *args)
5382 + const struct nfs3_symlinkargs *args, int tag)
5384 - encode_sattr3(xdr, args->sattr);
5385 + encode_sattr3(xdr, args->sattr, tag);
5386 encode_nfspath3(xdr, args->pages, args->pathlen);
5389 @@ -1094,7 +1100,7 @@ static void nfs3_xdr_enc_symlink3args(st
5390 const struct nfs3_symlinkargs *args)
5392 encode_diropargs3(xdr, args->fromfh, args->fromname, args->fromlen);
5393 - encode_symlinkdata3(xdr, args);
5394 + encode_symlinkdata3(xdr, args, req->rq_task->tk_client->cl_tag);
5398 @@ -1122,24 +1128,24 @@ static void nfs3_xdr_enc_symlink3args(st
5401 static void encode_devicedata3(struct xdr_stream *xdr,
5402 - const struct nfs3_mknodargs *args)
5403 + const struct nfs3_mknodargs *args, int tag)
5405 - encode_sattr3(xdr, args->sattr);
5406 + encode_sattr3(xdr, args->sattr, tag);
5407 encode_specdata3(xdr, args->rdev);
5410 static void encode_mknoddata3(struct xdr_stream *xdr,
5411 - const struct nfs3_mknodargs *args)
5412 + const struct nfs3_mknodargs *args, int tag)
5414 encode_ftype3(xdr, args->type);
5415 switch (args->type) {
5418 - encode_devicedata3(xdr, args);
5419 + encode_devicedata3(xdr, args, tag);
5423 - encode_sattr3(xdr, args->sattr);
5424 + encode_sattr3(xdr, args->sattr, tag);
5428 @@ -1154,7 +1160,7 @@ static void nfs3_xdr_enc_mknod3args(stru
5429 const struct nfs3_mknodargs *args)
5431 encode_diropargs3(xdr, args->fh, args->name, args->len);
5432 - encode_mknoddata3(xdr, args);
5433 + encode_mknoddata3(xdr, args, req->rq_task->tk_client->cl_tag);
5437 diff -NurpP --minimal linux-3.6.10/fs/nfs/super.c linux-3.6.10-vs2.3.4.5/fs/nfs/super.c
5438 --- linux-3.6.10/fs/nfs/super.c 2012-12-11 12:36:58.000000000 +0100
5439 +++ linux-3.6.10-vs2.3.4.5/fs/nfs/super.c 2012-12-08 01:36:33.000000000 +0100
5441 #include <linux/parser.h>
5442 #include <linux/nsproxy.h>
5443 #include <linux/rcupdate.h>
5444 +#include <linux/vs_tag.h>
5446 #include <asm/uaccess.h>
5448 @@ -88,6 +89,7 @@ enum {
5449 Opt_sharecache, Opt_nosharecache,
5450 Opt_resvport, Opt_noresvport,
5451 Opt_fscache, Opt_nofscache,
5452 + Opt_tag, Opt_notag,
5454 /* Mount options that take integer arguments */
5456 @@ -100,6 +102,7 @@ enum {
5462 /* Mount options that take string arguments */
5464 @@ -182,6 +185,10 @@ static const match_table_t nfs_mount_opt
5465 /* The following needs to be listed after all other options */
5466 { Opt_nfsvers, "v%s" },
5468 + { Opt_tag, "tag" },
5469 + { Opt_notag, "notag" },
5470 + { Opt_tagid, "tagid=%u" },
5475 @@ -626,6 +633,7 @@ static void nfs_show_mount_options(struc
5476 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
5477 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
5478 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
5479 + { NFS_MOUNT_TAGGED, ",tag", "" },
5482 const struct proc_nfs_info *nfs_infop;
5483 @@ -1243,6 +1251,14 @@ static int nfs_parse_mount_options(char
5484 kfree(mnt->fscache_uniq);
5485 mnt->fscache_uniq = NULL;
5487 +#ifndef CONFIG_TAGGING_NONE
5489 + mnt->flags |= NFS_MOUNT_TAGGED;
5492 + mnt->flags &= ~NFS_MOUNT_TAGGED;
5497 * options that take numeric values
5498 @@ -1329,6 +1345,12 @@ static int nfs_parse_mount_options(char
5499 goto out_invalid_value;
5500 mnt->minorversion = option;
5502 +#ifdef CONFIG_PROPAGATE
5505 + nfs_data.flags |= NFS_MOUNT_TAGGED;
5510 * options that take text values
5511 diff -NurpP --minimal linux-3.6.10/fs/nfsd/auth.c linux-3.6.10-vs2.3.4.5/fs/nfsd/auth.c
5512 --- linux-3.6.10/fs/nfsd/auth.c 2012-07-22 23:39:41.000000000 +0200
5513 +++ linux-3.6.10-vs2.3.4.5/fs/nfsd/auth.c 2012-10-04 18:47:00.000000000 +0200
5516 #include <linux/sched.h>
5517 #include <linux/user_namespace.h>
5518 +#include <linux/vs_tag.h>
5522 @@ -37,6 +38,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
5524 new->fsuid = rqstp->rq_cred.cr_uid;
5525 new->fsgid = rqstp->rq_cred.cr_gid;
5526 + /* FIXME: this desperately needs a tag :)
5527 + new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
5530 rqgi = rqstp->rq_cred.cr_group_info;
5532 diff -NurpP --minimal linux-3.6.10/fs/nfsd/nfs3xdr.c linux-3.6.10-vs2.3.4.5/fs/nfsd/nfs3xdr.c
5533 --- linux-3.6.10/fs/nfsd/nfs3xdr.c 2012-05-21 18:07:26.000000000 +0200
5534 +++ linux-3.6.10-vs2.3.4.5/fs/nfsd/nfs3xdr.c 2012-10-04 18:47:00.000000000 +0200
5538 #include <linux/namei.h>
5539 +#include <linux/vs_tag.h>
5543 @@ -95,6 +96,8 @@ static __be32 *
5544 decode_sattr3(__be32 *p, struct iattr *iap)
5552 @@ -104,12 +107,15 @@ decode_sattr3(__be32 *p, struct iattr *i
5555 iap->ia_valid |= ATTR_UID;
5556 - iap->ia_uid = ntohl(*p++);
5557 + uid = ntohl(*p++);
5560 iap->ia_valid |= ATTR_GID;
5561 - iap->ia_gid = ntohl(*p++);
5562 + gid = ntohl(*p++);
5564 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
5565 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
5566 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
5570 @@ -165,8 +171,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
5571 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
5572 *p++ = htonl((u32) stat->mode);
5573 *p++ = htonl((u32) stat->nlink);
5574 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
5575 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
5576 + *p++ = htonl((u32) nfsd_ruid(rqstp,
5577 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5578 + stat->uid, stat->tag)));
5579 + *p++ = htonl((u32) nfsd_rgid(rqstp,
5580 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5581 + stat->gid, stat->tag)));
5582 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
5583 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
5585 diff -NurpP --minimal linux-3.6.10/fs/nfsd/nfs4xdr.c linux-3.6.10-vs2.3.4.5/fs/nfsd/nfs4xdr.c
5586 --- linux-3.6.10/fs/nfsd/nfs4xdr.c 2012-10-04 15:27:40.000000000 +0200
5587 +++ linux-3.6.10-vs2.3.4.5/fs/nfsd/nfs4xdr.c 2012-10-04 18:47:00.000000000 +0200
5589 #include <linux/utsname.h>
5590 #include <linux/pagemap.h>
5591 #include <linux/sunrpc/svcauth_gss.h>
5592 +#include <linux/vs_tag.h>
5596 @@ -2351,14 +2352,18 @@ out_acl:
5597 WRITE32(stat.nlink);
5599 if (bmval1 & FATTR4_WORD1_OWNER) {
5600 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
5601 + status = nfsd4_encode_user(rqstp,
5602 + TAGINO_UID(DX_TAG(dentry->d_inode),
5603 + stat.uid, stat.tag), &p, &buflen);
5604 if (status == nfserr_resource)
5609 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
5610 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
5611 + status = nfsd4_encode_group(rqstp,
5612 + TAGINO_GID(DX_TAG(dentry->d_inode),
5613 + stat.gid, stat.tag), &p, &buflen);
5614 if (status == nfserr_resource)
5617 diff -NurpP --minimal linux-3.6.10/fs/nfsd/nfsxdr.c linux-3.6.10-vs2.3.4.5/fs/nfsd/nfsxdr.c
5618 --- linux-3.6.10/fs/nfsd/nfsxdr.c 2011-05-22 16:17:53.000000000 +0200
5619 +++ linux-3.6.10-vs2.3.4.5/fs/nfsd/nfsxdr.c 2012-10-04 18:47:00.000000000 +0200
5624 +#include <linux/vs_tag.h>
5626 #define NFSDDBG_FACILITY NFSDDBG_XDR
5628 @@ -88,6 +89,8 @@ static __be32 *
5629 decode_sattr(__be32 *p, struct iattr *iap)
5637 @@ -101,12 +104,15 @@ decode_sattr(__be32 *p, struct iattr *ia
5639 if ((tmp = ntohl(*p++)) != (u32)-1) {
5640 iap->ia_valid |= ATTR_UID;
5641 - iap->ia_uid = tmp;
5644 if ((tmp = ntohl(*p++)) != (u32)-1) {
5645 iap->ia_valid |= ATTR_GID;
5646 - iap->ia_gid = tmp;
5649 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
5650 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
5651 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
5652 if ((tmp = ntohl(*p++)) != (u32)-1) {
5653 iap->ia_valid |= ATTR_SIZE;
5655 @@ -151,8 +157,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
5656 *p++ = htonl(nfs_ftypes[type >> 12]);
5657 *p++ = htonl((u32) stat->mode);
5658 *p++ = htonl((u32) stat->nlink);
5659 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
5660 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
5661 + *p++ = htonl((u32) nfsd_ruid(rqstp,
5662 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
5663 + *p++ = htonl((u32) nfsd_rgid(rqstp,
5664 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
5666 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
5667 *p++ = htonl(NFS_MAXPATHLEN);
5668 diff -NurpP --minimal linux-3.6.10/fs/ocfs2/dlmglue.c linux-3.6.10-vs2.3.4.5/fs/ocfs2/dlmglue.c
5669 --- linux-3.6.10/fs/ocfs2/dlmglue.c 2012-07-22 23:39:41.000000000 +0200
5670 +++ linux-3.6.10-vs2.3.4.5/fs/ocfs2/dlmglue.c 2012-10-04 18:47:00.000000000 +0200
5671 @@ -2047,6 +2047,7 @@ static void __ocfs2_stuff_meta_lvb(struc
5672 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
5673 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
5674 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
5675 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
5676 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
5677 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
5678 lvb->lvb_iatime_packed =
5679 @@ -2097,6 +2098,7 @@ static void ocfs2_refresh_inode_from_lvb
5681 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
5682 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
5683 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
5684 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
5685 set_nlink(inode, be16_to_cpu(lvb->lvb_inlink));
5686 ocfs2_unpack_timespec(&inode->i_atime,
5687 diff -NurpP --minimal linux-3.6.10/fs/ocfs2/dlmglue.h linux-3.6.10-vs2.3.4.5/fs/ocfs2/dlmglue.h
5688 --- linux-3.6.10/fs/ocfs2/dlmglue.h 2010-10-21 13:07:50.000000000 +0200
5689 +++ linux-3.6.10-vs2.3.4.5/fs/ocfs2/dlmglue.h 2012-10-04 18:47:00.000000000 +0200
5690 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
5693 __be32 lvb_igeneration;
5694 - __be32 lvb_reserved2;
5696 + __be16 lvb_reserved2;
5699 #define OCFS2_QINFO_LVB_VERSION 1
5700 diff -NurpP --minimal linux-3.6.10/fs/ocfs2/file.c linux-3.6.10-vs2.3.4.5/fs/ocfs2/file.c
5701 --- linux-3.6.10/fs/ocfs2/file.c 2012-10-04 15:27:41.000000000 +0200
5702 +++ linux-3.6.10-vs2.3.4.5/fs/ocfs2/file.c 2012-10-04 18:47:00.000000000 +0200
5703 @@ -1123,7 +1123,7 @@ int ocfs2_setattr(struct dentry *dentry,
5704 attr->ia_valid &= ~ATTR_SIZE;
5706 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
5707 - | ATTR_GID | ATTR_UID | ATTR_MODE)
5708 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
5709 if (!(attr->ia_valid & OCFS2_VALID_ATTRS))
5712 diff -NurpP --minimal linux-3.6.10/fs/ocfs2/inode.c linux-3.6.10-vs2.3.4.5/fs/ocfs2/inode.c
5713 --- linux-3.6.10/fs/ocfs2/inode.c 2012-07-22 23:39:41.000000000 +0200
5714 +++ linux-3.6.10-vs2.3.4.5/fs/ocfs2/inode.c 2012-10-04 18:47:00.000000000 +0200
5716 #include <linux/highmem.h>
5717 #include <linux/pagemap.h>
5718 #include <linux/quotaops.h>
5719 +#include <linux/vs_tag.h>
5721 #include <asm/byteorder.h>
5723 @@ -78,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode
5725 unsigned int flags = OCFS2_I(inode)->ip_attr;
5727 - inode->i_flags &= ~(S_IMMUTABLE |
5728 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5729 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5731 if (flags & OCFS2_IMMUTABLE_FL)
5732 inode->i_flags |= S_IMMUTABLE;
5733 + if (flags & OCFS2_IXUNLINK_FL)
5734 + inode->i_flags |= S_IXUNLINK;
5736 if (flags & OCFS2_SYNC_FL)
5737 inode->i_flags |= S_SYNC;
5738 @@ -92,25 +95,44 @@ void ocfs2_set_inode_flags(struct inode
5739 inode->i_flags |= S_NOATIME;
5740 if (flags & OCFS2_DIRSYNC_FL)
5741 inode->i_flags |= S_DIRSYNC;
5743 + inode->i_vflags &= ~(V_BARRIER | V_COW);
5745 + if (flags & OCFS2_BARRIER_FL)
5746 + inode->i_vflags |= V_BARRIER;
5747 + if (flags & OCFS2_COW_FL)
5748 + inode->i_vflags |= V_COW;
5751 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
5752 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
5754 unsigned int flags = oi->vfs_inode.i_flags;
5755 + unsigned int vflags = oi->vfs_inode.i_vflags;
5757 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
5758 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
5759 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
5760 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
5762 + if (flags & S_IMMUTABLE)
5763 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
5764 + if (flags & S_IXUNLINK)
5765 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
5767 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
5768 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
5770 oi->ip_attr |= OCFS2_SYNC_FL;
5771 if (flags & S_APPEND)
5772 oi->ip_attr |= OCFS2_APPEND_FL;
5773 - if (flags & S_IMMUTABLE)
5774 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
5775 if (flags & S_NOATIME)
5776 oi->ip_attr |= OCFS2_NOATIME_FL;
5777 if (flags & S_DIRSYNC)
5778 oi->ip_attr |= OCFS2_DIRSYNC_FL;
5780 + if (vflags & V_BARRIER)
5781 + oi->ip_attr |= OCFS2_BARRIER_FL;
5782 + if (vflags & V_COW)
5783 + oi->ip_attr |= OCFS2_COW_FL;
5786 struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
5787 @@ -241,6 +263,8 @@ void ocfs2_populate_inode(struct inode *
5788 struct super_block *sb;
5789 struct ocfs2_super *osb;
5796 @@ -269,8 +293,12 @@ void ocfs2_populate_inode(struct inode *
5797 inode->i_generation = le32_to_cpu(fe->i_generation);
5798 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
5799 inode->i_mode = le16_to_cpu(fe->i_mode);
5800 - inode->i_uid = le32_to_cpu(fe->i_uid);
5801 - inode->i_gid = le32_to_cpu(fe->i_gid);
5802 + uid = le32_to_cpu(fe->i_uid);
5803 + gid = le32_to_cpu(fe->i_gid);
5804 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5805 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5806 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
5807 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
5809 /* Fast symlinks will have i_size but no allocated clusters. */
5810 if (S_ISLNK(inode->i_mode) && !fe->i_clusters) {
5811 diff -NurpP --minimal linux-3.6.10/fs/ocfs2/inode.h linux-3.6.10-vs2.3.4.5/fs/ocfs2/inode.h
5812 --- linux-3.6.10/fs/ocfs2/inode.h 2012-01-09 16:14:55.000000000 +0100
5813 +++ linux-3.6.10-vs2.3.4.5/fs/ocfs2/inode.h 2012-10-04 18:47:00.000000000 +0200
5814 @@ -154,6 +154,7 @@ struct buffer_head *ocfs2_bread(struct i
5816 void ocfs2_set_inode_flags(struct inode *inode);
5817 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
5818 +int ocfs2_sync_flags(struct inode *inode, int, int);
5820 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
5822 diff -NurpP --minimal linux-3.6.10/fs/ocfs2/ioctl.c linux-3.6.10-vs2.3.4.5/fs/ocfs2/ioctl.c
5823 --- linux-3.6.10/fs/ocfs2/ioctl.c 2012-10-04 15:27:41.000000000 +0200
5824 +++ linux-3.6.10-vs2.3.4.5/fs/ocfs2/ioctl.c 2012-10-04 18:47:00.000000000 +0200
5825 @@ -76,7 +76,41 @@ static int ocfs2_get_inode_attr(struct i
5829 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
5830 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
5832 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
5833 + struct buffer_head *bh = NULL;
5834 + handle_t *handle = NULL;
5837 + status = ocfs2_inode_lock(inode, &bh, 1);
5839 + mlog_errno(status);
5842 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
5843 + if (IS_ERR(handle)) {
5844 + status = PTR_ERR(handle);
5845 + mlog_errno(status);
5849 + inode->i_flags = flags;
5850 + inode->i_vflags = vflags;
5851 + ocfs2_get_inode_flags(OCFS2_I(inode));
5853 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
5855 + mlog_errno(status);
5857 + ocfs2_commit_trans(osb, handle);
5859 + ocfs2_inode_unlock(inode, 1);
5864 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
5867 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
5868 @@ -101,6 +135,11 @@ static int ocfs2_set_inode_attr(struct i
5869 if (!S_ISDIR(inode->i_mode))
5870 flags &= ~OCFS2_DIRSYNC_FL;
5872 + if (IS_BARRIER(inode)) {
5873 + vxwprintk_task(1, "messing with the barrier.");
5877 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
5878 if (IS_ERR(handle)) {
5879 status = PTR_ERR(handle);
5880 @@ -879,6 +918,7 @@ bail:
5885 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5887 struct inode *inode = filp->f_path.dentry->d_inode;
5888 diff -NurpP --minimal linux-3.6.10/fs/ocfs2/namei.c linux-3.6.10-vs2.3.4.5/fs/ocfs2/namei.c
5889 --- linux-3.6.10/fs/ocfs2/namei.c 2012-10-04 15:27:41.000000000 +0200
5890 +++ linux-3.6.10-vs2.3.4.5/fs/ocfs2/namei.c 2012-10-04 18:47:00.000000000 +0200
5892 #include <linux/slab.h>
5893 #include <linux/highmem.h>
5894 #include <linux/quotaops.h>
5895 +#include <linux/vs_tag.h>
5897 #include <cluster/masklog.h>
5899 @@ -475,6 +476,7 @@ static int __ocfs2_mknod_locked(struct i
5900 struct ocfs2_dinode *fe = NULL;
5901 struct ocfs2_extent_list *fel;
5907 @@ -512,8 +514,11 @@ static int __ocfs2_mknod_locked(struct i
5908 fe->i_suballoc_loc = cpu_to_le64(suballoc_loc);
5909 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
5910 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
5911 - fe->i_uid = cpu_to_le32(inode->i_uid);
5912 - fe->i_gid = cpu_to_le32(inode->i_gid);
5914 + tag = dx_current_fstag(osb->sb);
5915 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
5916 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
5917 + inode->i_tag = tag;
5918 fe->i_mode = cpu_to_le16(inode->i_mode);
5919 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
5920 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
5921 diff -NurpP --minimal linux-3.6.10/fs/ocfs2/ocfs2.h linux-3.6.10-vs2.3.4.5/fs/ocfs2/ocfs2.h
5922 --- linux-3.6.10/fs/ocfs2/ocfs2.h 2012-01-09 16:14:55.000000000 +0100
5923 +++ linux-3.6.10-vs2.3.4.5/fs/ocfs2/ocfs2.h 2012-10-04 18:47:00.000000000 +0200
5924 @@ -272,6 +272,7 @@ enum ocfs2_mount_options
5926 OCFS2_MOUNT_HB_NONE = 1 << 13, /* No heartbeat */
5927 OCFS2_MOUNT_HB_GLOBAL = 1 << 14, /* Global heartbeat */
5928 + OCFS2_MOUNT_TAGGED = 1 << 15, /* use tagging */
5931 #define OCFS2_OSB_SOFT_RO 0x0001
5932 diff -NurpP --minimal linux-3.6.10/fs/ocfs2/ocfs2_fs.h linux-3.6.10-vs2.3.4.5/fs/ocfs2/ocfs2_fs.h
5933 --- linux-3.6.10/fs/ocfs2/ocfs2_fs.h 2011-05-22 16:17:53.000000000 +0200
5934 +++ linux-3.6.10-vs2.3.4.5/fs/ocfs2/ocfs2_fs.h 2012-10-04 18:47:00.000000000 +0200
5935 @@ -266,6 +266,11 @@
5936 #define OCFS2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
5937 #define OCFS2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
5939 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
5941 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
5942 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
5944 #define OCFS2_FL_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
5945 #define OCFS2_FL_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
5947 diff -NurpP --minimal linux-3.6.10/fs/ocfs2/super.c linux-3.6.10-vs2.3.4.5/fs/ocfs2/super.c
5948 --- linux-3.6.10/fs/ocfs2/super.c 2012-05-21 18:07:26.000000000 +0200
5949 +++ linux-3.6.10-vs2.3.4.5/fs/ocfs2/super.c 2012-10-04 18:47:00.000000000 +0200
5950 @@ -185,6 +185,7 @@ enum {
5954 + Opt_tag, Opt_notag, Opt_tagid,
5958 @@ -216,6 +217,9 @@ static const match_table_t tokens = {
5959 {Opt_coherency_full, "coherency=full"},
5960 {Opt_resv_level, "resv_level=%u"},
5961 {Opt_dir_resv_level, "dir_resv_level=%u"},
5963 + {Opt_notag, "notag"},
5964 + {Opt_tagid, "tagid=%u"},
5968 @@ -662,6 +666,13 @@ static int ocfs2_remount(struct super_bl
5972 + if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
5973 + (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
5975 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
5979 /* We're going to/from readonly mode. */
5980 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
5981 /* Disable quota accounting before remounting RO */
5982 @@ -1177,6 +1188,9 @@ static int ocfs2_fill_super(struct super
5984 ocfs2_complete_mount_recovery(osb);
5986 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
5987 + sb->s_flags |= MS_TAGGED;
5989 if (ocfs2_mount_local(osb))
5990 snprintf(nodestr, sizeof(nodestr), "local");
5992 @@ -1503,6 +1517,20 @@ static int ocfs2_parse_options(struct su
5993 option < OCFS2_MAX_RESV_LEVEL)
5994 mopt->dir_resv_level = option;
5996 +#ifndef CONFIG_TAGGING_NONE
5998 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6001 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
6004 +#ifdef CONFIG_PROPAGATE
6007 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6012 "Unrecognized mount option \"%s\" "
6013 diff -NurpP --minimal linux-3.6.10/fs/open.c linux-3.6.10-vs2.3.4.5/fs/open.c
6014 --- linux-3.6.10/fs/open.c 2012-10-04 15:27:41.000000000 +0200
6015 +++ linux-3.6.10-vs2.3.4.5/fs/open.c 2012-10-04 18:47:00.000000000 +0200
6017 #include <linux/fs_struct.h>
6018 #include <linux/ima.h>
6019 #include <linux/dnotify.h>
6020 +#include <linux/vs_base.h>
6021 +#include <linux/vs_limit.h>
6022 +#include <linux/vs_tag.h>
6023 +#include <linux/vs_cowbl.h>
6024 +#include <linux/vserver/dlimit.h>
6026 #include "internal.h"
6028 @@ -74,6 +79,12 @@ static long do_sys_truncate(const char _
6029 error = user_path(pathname, &path);
6033 +#ifdef CONFIG_VSERVER_COWBL
6034 + error = cow_check_and_break(&path);
6036 + goto dput_and_out;
6038 inode = path.dentry->d_inode;
6040 /* For directories it's -EISDIR, for other non-regulars - -EINVAL */
6041 @@ -495,6 +506,10 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
6043 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
6045 +#ifdef CONFIG_VSERVER_COWBL
6046 + error = cow_check_and_break(&path);
6049 error = chmod_common(&path, mode);
6052 @@ -522,13 +537,13 @@ static int chown_common(struct path *pat
6053 if (!uid_valid(uid))
6055 newattrs.ia_valid |= ATTR_UID;
6056 - newattrs.ia_uid = uid;
6057 + newattrs.ia_uid = dx_map_uid(user);
6059 if (group != (gid_t) -1) {
6060 if (!gid_valid(gid))
6062 newattrs.ia_valid |= ATTR_GID;
6063 - newattrs.ia_gid = gid;
6064 + newattrs.ia_gid = dx_map_gid(group);
6066 if (!S_ISDIR(inode->i_mode))
6067 newattrs.ia_valid |=
6068 @@ -561,6 +576,18 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
6069 error = mnt_want_write(path.mnt);
6072 +#ifdef CONFIG_VSERVER_COWBL
6073 + error = cow_check_and_break(&path);
6076 +#ifdef CONFIG_VSERVER_COWBL
6077 + error = cow_check_and_break(&path);
6080 +#ifdef CONFIG_VSERVER_COWBL
6081 + error = cow_check_and_break(&path);
6084 error = chown_common(&path, user, group);
6085 mnt_drop_write(path.mnt);
6087 @@ -809,6 +836,7 @@ static void __put_unused_fd(struct files
6088 __clear_open_fd(fd, fdt);
6089 if (fd < files->next_fd)
6090 files->next_fd = fd;
6091 + vx_openfd_dec(fd);
6094 void put_unused_fd(unsigned int fd)
6095 diff -NurpP --minimal linux-3.6.10/fs/proc/array.c linux-3.6.10-vs2.3.4.5/fs/proc/array.c
6096 --- linux-3.6.10/fs/proc/array.c 2012-07-22 23:39:42.000000000 +0200
6097 +++ linux-3.6.10-vs2.3.4.5/fs/proc/array.c 2012-10-04 18:47:00.000000000 +0200
6099 #include <linux/ptrace.h>
6100 #include <linux/tracehook.h>
6101 #include <linux/user_namespace.h>
6102 +#include <linux/vs_context.h>
6103 +#include <linux/vs_network.h>
6105 #include <asm/pgtable.h>
6106 #include <asm/processor.h>
6107 @@ -172,6 +174,9 @@ static inline void task_state(struct seq
6109 ppid = pid_alive(p) ?
6110 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
6111 + if (unlikely(vx_current_initpid(p->pid)))
6116 struct task_struct *tracer = ptrace_parent(p);
6117 @@ -296,7 +301,7 @@ static inline void task_sig(struct seq_f
6120 static void render_cap_t(struct seq_file *m, const char *header,
6122 + struct vx_info *vxi, kernel_cap_t *a)
6126 @@ -321,10 +326,11 @@ static inline void task_cap(struct seq_f
6127 cap_bset = cred->cap_bset;
6130 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
6131 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
6132 - render_cap_t(m, "CapEff:\t", &cap_effective);
6133 - render_cap_t(m, "CapBnd:\t", &cap_bset);
6134 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
6135 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
6136 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
6137 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
6138 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
6141 static inline void task_context_switch_counts(struct seq_file *m,
6142 @@ -346,6 +352,42 @@ static void task_cpus_allowed(struct seq
6146 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6147 + struct pid *pid, struct task_struct *task)
6149 + seq_printf(m, "Proxy:\t%p(%c)\n"
6157 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6158 + atomic_read(&task->nsproxy->count),
6159 + task->nsproxy->uts_ns,
6160 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6161 + task->nsproxy->ipc_ns,
6162 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6163 + task->nsproxy->mnt_ns,
6164 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6165 + task->nsproxy->pid_ns,
6166 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6167 + task->nsproxy->net_ns,
6168 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6172 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6174 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6177 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6178 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6182 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6183 struct pid *pid, struct task_struct *task)
6185 @@ -362,6 +404,7 @@ int proc_pid_status(struct seq_file *m,
6187 task_cpus_allowed(m, task);
6188 cpuset_task_status_allowed(m, task);
6189 + task_vs_id(m, task);
6190 task_context_switch_counts(m, task);
6193 @@ -471,6 +514,17 @@ static int do_task_stat(struct seq_file
6194 /* convert nsec -> ticks */
6195 start_time = nsec_to_clock_t(start_time);
6197 + /* fixup start time for virt uptime */
6198 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6199 + unsigned long long bias =
6200 + current->vx_info->cvirt.bias_clock;
6202 + if (start_time > bias)
6203 + start_time -= bias;
6208 seq_printf(m, "%d (%s) %c", pid_nr_ns(pid, ns), tcomm, state);
6209 seq_put_decimal_ll(m, ' ', ppid);
6210 seq_put_decimal_ll(m, ' ', pgid);
6211 diff -NurpP --minimal linux-3.6.10/fs/proc/base.c linux-3.6.10-vs2.3.4.5/fs/proc/base.c
6212 --- linux-3.6.10/fs/proc/base.c 2012-10-04 15:27:41.000000000 +0200
6213 +++ linux-3.6.10-vs2.3.4.5/fs/proc/base.c 2012-10-04 18:47:00.000000000 +0200
6215 #include <linux/fs_struct.h>
6216 #include <linux/slab.h>
6217 #include <linux/flex_array.h>
6218 +#include <linux/vs_context.h>
6219 +#include <linux/vs_network.h>
6220 #ifdef CONFIG_HARDWALL
6221 #include <asm/hardwall.h>
6223 @@ -941,11 +943,16 @@ static ssize_t oom_adjust_write(struct f
6227 - if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
6228 + if (oom_adjust < task->signal->oom_adj &&
6229 + !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
6234 + /* prevent guest processes from circumventing the oom killer */
6235 + if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
6236 + oom_adjust = OOM_ADJUST_MIN;
6239 * Warn that /proc/pid/oom_adj is deprecated, see
6240 * Documentation/feature-removal-schedule.txt.
6241 @@ -1548,6 +1555,8 @@ struct inode *proc_pid_make_inode(struct
6242 inode->i_gid = cred->egid;
6245 + /* procfs is xid tagged */
6246 + inode->i_tag = (tag_t)vx_task_xid(task);
6247 security_task_to_inode(task, inode);
6250 @@ -1593,6 +1602,8 @@ int pid_getattr(struct vfsmount *mnt, st
6254 +static unsigned name_to_int(struct dentry *dentry);
6257 * Exceptional case: normally we are not allowed to unhash a busy
6258 * directory. In this case, however, we can do it - no aliasing problems
6259 @@ -1621,6 +1632,12 @@ int pid_revalidate(struct dentry *dentry
6260 task = get_proc_task(inode);
6263 + unsigned pid = name_to_int(dentry);
6265 + if (pid != ~0U && pid != vx_map_pid(task->pid)) {
6266 + put_task_struct(task);
6269 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
6270 task_dumpable(task)) {
6272 @@ -1637,6 +1654,7 @@ int pid_revalidate(struct dentry *dentry
6273 put_task_struct(task);
6280 @@ -2457,6 +2475,13 @@ static struct dentry *proc_pident_lookup
6284 + /* TODO: maybe we can come up with a generic approach? */
6285 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
6286 + (dentry->d_name.len == 5) &&
6287 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
6288 + !memcmp(dentry->d_name.name, "ninfo", 5)))
6292 * Yes, it does not scale. And it should not. Don't add
6293 * new entries into /proc/<tgid>/ without very good reasons.
6294 @@ -2842,7 +2867,7 @@ out_iput:
6295 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
6297 struct dentry *error;
6298 - struct task_struct *task = get_proc_task(dir);
6299 + struct task_struct *task = get_proc_task_real(dir);
6300 const struct pid_entry *p, *last;
6302 error = ERR_PTR(-ENOENT);
6303 @@ -3017,6 +3042,9 @@ static int proc_pid_personality(struct s
6304 static const struct file_operations proc_task_operations;
6305 static const struct inode_operations proc_task_inode_operations;
6307 +extern int proc_pid_vx_info(struct task_struct *, char *);
6308 +extern int proc_pid_nx_info(struct task_struct *, char *);
6310 static const struct pid_entry tgid_base_stuff[] = {
6311 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
6312 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
6313 @@ -3083,6 +3111,8 @@ static const struct pid_entry tgid_base_
6314 #ifdef CONFIG_CGROUPS
6315 REG("cgroup", S_IRUGO, proc_cgroup_operations),
6317 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
6318 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
6319 INF("oom_score", S_IRUGO, proc_oom_score),
6320 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
6321 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
6322 @@ -3106,6 +3136,7 @@ static const struct pid_entry tgid_base_
6323 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
6324 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
6326 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
6329 static int proc_tgid_base_readdir(struct file * filp,
6330 @@ -3300,7 +3331,7 @@ retry:
6332 pid = find_ge_pid(iter.tgid, ns);
6334 - iter.tgid = pid_nr_ns(pid, ns);
6335 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
6336 iter.task = pid_task(pid, PIDTYPE_PID);
6337 /* What we to know is if the pid we have find is the
6338 * pid of a thread_group_leader. Testing for task
6339 @@ -3330,7 +3361,7 @@ static int proc_pid_fill_cache(struct fi
6340 struct tgid_iter iter)
6342 char name[PROC_NUMBUF];
6343 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
6344 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
6345 return proc_fill_cache(filp, dirent, filldir, name, len,
6346 proc_pid_instantiate, iter.task, NULL);
6348 @@ -3354,7 +3385,7 @@ int proc_pid_readdir(struct file * filp,
6350 nr = filp->f_pos - FIRST_PROCESS_ENTRY;
6352 - reaper = get_proc_task(filp->f_path.dentry->d_inode);
6353 + reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
6357 @@ -3376,6 +3407,8 @@ int proc_pid_readdir(struct file * filp,
6358 __filldir = fake_filldir;
6360 filp->f_pos = iter.tgid + TGID_OFFSET;
6361 + if (!vx_proc_task_visible(iter.task))
6363 if (proc_pid_fill_cache(filp, dirent, __filldir, iter) < 0) {
6364 put_task_struct(iter.task);
6366 @@ -3537,6 +3570,8 @@ static struct dentry *proc_task_lookup(s
6367 tid = name_to_int(dentry);
6370 + if (vx_current_initpid(tid))
6373 ns = dentry->d_sb->s_fs_info;
6375 diff -NurpP --minimal linux-3.6.10/fs/proc/generic.c linux-3.6.10-vs2.3.4.5/fs/proc/generic.c
6376 --- linux-3.6.10/fs/proc/generic.c 2012-10-04 15:27:41.000000000 +0200
6377 +++ linux-3.6.10-vs2.3.4.5/fs/proc/generic.c 2012-10-04 18:47:00.000000000 +0200
6379 #include <linux/bitops.h>
6380 #include <linux/spinlock.h>
6381 #include <linux/completion.h>
6382 +#include <linux/vserver/inode.h>
6383 #include <asm/uaccess.h>
6385 #include "internal.h"
6386 @@ -424,11 +425,15 @@ struct dentry *proc_lookup_de(struct pro
6387 for (de = de->subdir; de ; de = de->next) {
6388 if (de->namelen != dentry->d_name.len)
6390 + if (!vx_hide_check(0, de->vx_flags))
6392 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
6394 spin_unlock(&proc_subdir_lock);
6396 inode = proc_get_inode(dir->i_sb, de);
6397 + /* generic proc entries belong to the host */
6402 @@ -506,6 +511,8 @@ int proc_readdir_de(struct proc_dir_entr
6404 /* filldir passes info to user space */
6406 + if (!vx_hide_check(0, de->vx_flags))
6408 spin_unlock(&proc_subdir_lock);
6409 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
6410 de->low_ino, de->mode >> 12) < 0) {
6411 @@ -513,6 +520,7 @@ int proc_readdir_de(struct proc_dir_entr
6414 spin_lock(&proc_subdir_lock);
6419 @@ -626,6 +634,7 @@ static struct proc_dir_entry *__proc_cre
6421 atomic_set(&ent->count, 1);
6423 + ent->vx_flags = IATTR_PROC_DEFAULT;
6424 spin_lock_init(&ent->pde_unload_lock);
6425 ent->pde_unload_completion = NULL;
6426 INIT_LIST_HEAD(&ent->pde_openers);
6427 @@ -649,7 +658,8 @@ struct proc_dir_entry *proc_symlink(cons
6433 + ent->vx_flags = IATTR_PROC_SYMLINK;
6437 diff -NurpP --minimal linux-3.6.10/fs/proc/inode.c linux-3.6.10-vs2.3.4.5/fs/proc/inode.c
6438 --- linux-3.6.10/fs/proc/inode.c 2012-07-22 23:39:42.000000000 +0200
6439 +++ linux-3.6.10-vs2.3.4.5/fs/proc/inode.c 2012-10-04 18:47:00.000000000 +0200
6440 @@ -458,6 +458,8 @@ struct inode *proc_get_inode(struct supe
6441 inode->i_uid = de->uid;
6442 inode->i_gid = de->gid;
6445 + PROC_I(inode)->vx_flags = de->vx_flags;
6447 inode->i_size = de->size;
6449 diff -NurpP --minimal linux-3.6.10/fs/proc/internal.h linux-3.6.10-vs2.3.4.5/fs/proc/internal.h
6450 --- linux-3.6.10/fs/proc/internal.h 2012-10-04 15:27:41.000000000 +0200
6451 +++ linux-3.6.10-vs2.3.4.5/fs/proc/internal.h 2012-10-04 18:47:00.000000000 +0200
6455 #include <linux/proc_fs.h>
6456 +#include <linux/vs_pid.h>
6458 struct ctl_table_header;
6460 extern struct proc_dir_entry proc_root;
6461 @@ -52,6 +54,9 @@ extern int proc_pid_status(struct seq_fi
6462 struct pid *pid, struct task_struct *task);
6463 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
6464 struct pid *pid, struct task_struct *task);
6465 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6466 + struct pid *pid, struct task_struct *task);
6468 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
6470 extern const struct file_operations proc_tid_children_operations;
6471 @@ -81,11 +86,16 @@ static inline struct pid *proc_pid(struc
6472 return PROC_I(inode)->pid;
6475 -static inline struct task_struct *get_proc_task(struct inode *inode)
6476 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
6478 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
6481 +static inline struct task_struct *get_proc_task(struct inode *inode)
6483 + return vx_get_proc_task(inode, proc_pid(inode));
6486 static inline int proc_fd(struct inode *inode)
6488 return PROC_I(inode)->fd;
6489 diff -NurpP --minimal linux-3.6.10/fs/proc/loadavg.c linux-3.6.10-vs2.3.4.5/fs/proc/loadavg.c
6490 --- linux-3.6.10/fs/proc/loadavg.c 2009-09-10 15:26:23.000000000 +0200
6491 +++ linux-3.6.10-vs2.3.4.5/fs/proc/loadavg.c 2012-10-04 18:47:00.000000000 +0200
6494 static int loadavg_proc_show(struct seq_file *m, void *v)
6496 + unsigned long running;
6497 + unsigned int threads;
6498 unsigned long avnrun[3];
6500 get_avenrun(avnrun, FIXED_1/200, 0);
6502 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
6503 + struct vx_info *vxi = current_vx_info();
6505 + running = atomic_read(&vxi->cvirt.nr_running);
6506 + threads = atomic_read(&vxi->cvirt.nr_threads);
6508 + running = nr_running();
6509 + threads = nr_threads;
6512 seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
6513 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
6514 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
6515 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
6516 - nr_running(), nr_threads,
6518 task_active_pid_ns(current)->last_pid);
6521 diff -NurpP --minimal linux-3.6.10/fs/proc/meminfo.c linux-3.6.10-vs2.3.4.5/fs/proc/meminfo.c
6522 --- linux-3.6.10/fs/proc/meminfo.c 2012-01-09 16:14:55.000000000 +0100
6523 +++ linux-3.6.10-vs2.3.4.5/fs/proc/meminfo.c 2012-10-04 18:47:00.000000000 +0200
6524 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
6525 allowed = ((totalram_pages - hugetlb_total_pages())
6526 * sysctl_overcommit_ratio / 100) + total_swap_pages;
6528 - cached = global_page_state(NR_FILE_PAGES) -
6529 + cached = vx_flags(VXF_VIRT_MEM, 0) ?
6530 + vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
6531 total_swapcache_pages - i.bufferram;
6534 diff -NurpP --minimal linux-3.6.10/fs/proc/root.c linux-3.6.10-vs2.3.4.5/fs/proc/root.c
6535 --- linux-3.6.10/fs/proc/root.c 2012-10-04 15:27:41.000000000 +0200
6536 +++ linux-3.6.10-vs2.3.4.5/fs/proc/root.c 2012-10-04 18:47:00.000000000 +0200
6538 #include <linux/mount.h>
6539 #include <linux/pid_namespace.h>
6540 #include <linux/parser.h>
6541 +#include <linux/vserver/inode.h>
6543 #include "internal.h"
6545 +struct proc_dir_entry *proc_virtual;
6547 +extern void proc_vx_init(void);
6549 static int proc_test_super(struct super_block *sb, void *data)
6551 return sb->s_fs_info == data;
6552 @@ -189,6 +194,7 @@ void __init proc_root_init(void)
6554 proc_mkdir("bus", NULL);
6559 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
6560 @@ -255,6 +261,7 @@ struct proc_dir_entry proc_root = {
6561 .proc_iops = &proc_root_inode_operations,
6562 .proc_fops = &proc_root_operations,
6563 .parent = &proc_root,
6564 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
6568 diff -NurpP --minimal linux-3.6.10/fs/proc/stat.c linux-3.6.10-vs2.3.4.5/fs/proc/stat.c
6569 --- linux-3.6.10/fs/proc/stat.c 2012-12-11 12:36:58.000000000 +0100
6570 +++ linux-3.6.10-vs2.3.4.5/fs/proc/stat.c 2012-11-06 18:43:41.000000000 +0100
6572 #include <linux/slab.h>
6573 #include <linux/time.h>
6574 #include <linux/irqnr.h>
6575 +#include <linux/vserver/cvirt.h>
6576 #include <asm/cputime.h>
6577 #include <linux/tick.h>
6579 @@ -92,6 +93,10 @@ static int show_stat(struct seq_file *p,
6580 irq = softirq = steal = 0;
6581 guest = guest_nice = 0;
6582 getboottime(&boottime);
6584 + if (vx_flags(VXF_VIRT_UPTIME, 0))
6585 + vx_vsi_boottime(&boottime);
6587 jif = boottime.tv_sec;
6589 for_each_possible_cpu(i) {
6590 diff -NurpP --minimal linux-3.6.10/fs/proc/uptime.c linux-3.6.10-vs2.3.4.5/fs/proc/uptime.c
6591 --- linux-3.6.10/fs/proc/uptime.c 2012-03-19 19:47:26.000000000 +0100
6592 +++ linux-3.6.10-vs2.3.4.5/fs/proc/uptime.c 2012-10-04 18:47:00.000000000 +0200
6594 #include <linux/seq_file.h>
6595 #include <linux/time.h>
6596 #include <linux/kernel_stat.h>
6597 +#include <linux/vserver/cvirt.h>
6598 #include <asm/cputime.h>
6600 static int uptime_proc_show(struct seq_file *m, void *v)
6601 @@ -25,6 +26,10 @@ static int uptime_proc_show(struct seq_f
6602 nsec = cputime64_to_jiffies64(idletime) * TICK_NSEC;
6603 idle.tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem);
6606 + if (vx_flags(VXF_VIRT_UPTIME, 0))
6607 + vx_vsi_uptime(&uptime, &idle);
6609 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
6610 (unsigned long) uptime.tv_sec,
6611 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
6612 diff -NurpP --minimal linux-3.6.10/fs/proc_namespace.c linux-3.6.10-vs2.3.4.5/fs/proc_namespace.c
6613 --- linux-3.6.10/fs/proc_namespace.c 2012-10-04 15:27:41.000000000 +0200
6614 +++ linux-3.6.10-vs2.3.4.5/fs/proc_namespace.c 2012-12-10 18:17:40.000000000 +0100
6615 @@ -44,6 +44,8 @@ static int show_sb_opts(struct seq_file
6616 { MS_SYNCHRONOUS, ",sync" },
6617 { MS_DIRSYNC, ",dirsync" },
6618 { MS_MANDLOCK, ",mand" },
6619 + { MS_TAGGED, ",tag" },
6620 + { MS_NOTAGCHECK, ",notagcheck" },
6623 const struct proc_fs_info *fs_infop;
6624 @@ -80,6 +82,40 @@ static inline void mangle(struct seq_fil
6625 seq_escape(m, s, " \t\n\\");
6628 +#ifdef CONFIG_VSERVER_EXTRA_MNT_CHECK
6630 +static int mnt_is_reachable(struct vfsmount *vfsmnt)
6633 + struct dentry *point;
6634 + struct mount *mnt = real_mount(vfsmnt);
6635 + struct mount *root_mnt;
6638 + if (mnt == mnt->mnt_ns->root)
6641 + br_read_lock(&vfsmount_lock);
6642 + root = current->fs->root;
6643 + root_mnt = real_mount(root.mnt);
6644 + point = root.dentry;
6646 + while ((mnt != mnt->mnt_parent) && (mnt != root_mnt)) {
6647 + point = mnt->mnt_mountpoint;
6648 + mnt = mnt->mnt_parent;
6651 + ret = (mnt == root_mnt) && is_subdir(point, root.dentry);
6653 + br_read_unlock(&vfsmount_lock);
6659 +#define mnt_is_reachable(v) (1)
6662 static void show_type(struct seq_file *m, struct super_block *sb)
6664 mangle(m, sb->s_type->name);
6665 @@ -96,6 +132,17 @@ static int show_vfsmnt(struct seq_file *
6666 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
6667 struct super_block *sb = mnt_path.dentry->d_sb;
6669 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6671 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6674 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6675 + mnt == current->fs->root.mnt) {
6676 + seq_puts(m, "/dev/root / ");
6680 if (sb->s_op->show_devname) {
6681 err = sb->s_op->show_devname(m, mnt_path.dentry);
6683 @@ -106,6 +153,7 @@ static int show_vfsmnt(struct seq_file *
6685 seq_path(m, &mnt_path, " \t\n\\");
6689 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
6690 err = show_sb_opts(m, sb);
6691 @@ -128,6 +176,11 @@ static int show_mountinfo(struct seq_fil
6692 struct path root = p->root;
6695 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6697 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6700 seq_printf(m, "%i %i %u:%u ", r->mnt_id, r->mnt_parent->mnt_id,
6701 MAJOR(sb->s_dev), MINOR(sb->s_dev));
6702 if (sb->s_op->show_path)
6703 @@ -187,6 +240,17 @@ static int show_vfsstat(struct seq_file
6704 struct super_block *sb = mnt_path.dentry->d_sb;
6707 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6709 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6712 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6713 + mnt == current->fs->root.mnt) {
6714 + seq_puts(m, "device /dev/root mounted on / ");
6719 if (sb->s_op->show_devname) {
6720 seq_puts(m, "device ");
6721 @@ -203,7 +267,7 @@ static int show_vfsstat(struct seq_file
6722 seq_puts(m, " mounted on ");
6723 seq_path(m, &mnt_path, " \t\n\\");
6727 /* file system type */
6728 seq_puts(m, "with fstype ");
6730 diff -NurpP --minimal linux-3.6.10/fs/quota/dquot.c linux-3.6.10-vs2.3.4.5/fs/quota/dquot.c
6731 --- linux-3.6.10/fs/quota/dquot.c 2012-10-04 15:27:41.000000000 +0200
6732 +++ linux-3.6.10-vs2.3.4.5/fs/quota/dquot.c 2012-10-04 18:47:00.000000000 +0200
6733 @@ -1580,6 +1580,9 @@ int __dquot_alloc_space(struct inode *in
6734 struct dquot **dquots = inode->i_dquot;
6735 int reserve = flags & DQUOT_SPACE_RESERVE;
6737 + if ((ret = dl_alloc_space(inode, number)))
6741 * First test before acquiring mutex - solves deadlocks when we
6742 * re-enter the quota code and are already holding the mutex
6743 @@ -1635,6 +1638,9 @@ int dquot_alloc_inode(const struct inode
6744 struct dquot_warn warn[MAXQUOTAS];
6745 struct dquot * const *dquots = inode->i_dquot;
6747 + if ((ret = dl_alloc_inode(inode)))
6750 /* First test before acquiring mutex - solves deadlocks when we
6751 * re-enter the quota code and are already holding the mutex */
6752 if (!dquot_active(inode))
6753 @@ -1706,6 +1712,8 @@ void __dquot_free_space(struct inode *in
6754 struct dquot **dquots = inode->i_dquot;
6755 int reserve = flags & DQUOT_SPACE_RESERVE;
6757 + dl_free_space(inode, number);
6759 /* First test before acquiring mutex - solves deadlocks when we
6760 * re-enter the quota code and are already holding the mutex */
6761 if (!dquot_active(inode)) {
6762 @@ -1750,6 +1758,8 @@ void dquot_free_inode(const struct inode
6763 struct dquot_warn warn[MAXQUOTAS];
6764 struct dquot * const *dquots = inode->i_dquot;
6766 + dl_free_inode(inode);
6768 /* First test before acquiring mutex - solves deadlocks when we
6769 * re-enter the quota code and are already holding the mutex */
6770 if (!dquot_active(inode))
6771 diff -NurpP --minimal linux-3.6.10/fs/quota/quota.c linux-3.6.10-vs2.3.4.5/fs/quota/quota.c
6772 --- linux-3.6.10/fs/quota/quota.c 2012-10-04 15:27:41.000000000 +0200
6773 +++ linux-3.6.10-vs2.3.4.5/fs/quota/quota.c 2012-10-04 18:47:00.000000000 +0200
6775 #include <linux/fs.h>
6776 #include <linux/namei.h>
6777 #include <linux/slab.h>
6778 +#include <linux/vs_context.h>
6779 #include <asm/current.h>
6780 #include <linux/uaccess.h>
6781 #include <linux/kernel.h>
6782 @@ -37,7 +38,7 @@ static int check_quotactl_permission(str
6786 - if (!capable(CAP_SYS_ADMIN))
6787 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
6791 @@ -291,6 +292,46 @@ static int do_quotactl(struct super_bloc
6795 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
6797 +#include <linux/vroot.h>
6798 +#include <linux/major.h>
6799 +#include <linux/module.h>
6800 +#include <linux/kallsyms.h>
6801 +#include <linux/vserver/debug.h>
6803 +static vroot_grb_func *vroot_get_real_bdev = NULL;
6805 +static DEFINE_SPINLOCK(vroot_grb_lock);
6807 +int register_vroot_grb(vroot_grb_func *func) {
6810 + spin_lock(&vroot_grb_lock);
6811 + if (!vroot_get_real_bdev) {
6812 + vroot_get_real_bdev = func;
6815 + spin_unlock(&vroot_grb_lock);
6818 +EXPORT_SYMBOL(register_vroot_grb);
6820 +int unregister_vroot_grb(vroot_grb_func *func) {
6821 + int ret = -EINVAL;
6823 + spin_lock(&vroot_grb_lock);
6824 + if (vroot_get_real_bdev) {
6825 + vroot_get_real_bdev = NULL;
6828 + spin_unlock(&vroot_grb_lock);
6831 +EXPORT_SYMBOL(unregister_vroot_grb);
6835 /* Return 1 if 'cmd' will block on frozen filesystem */
6836 static int quotactl_cmd_write(int cmd)
6838 @@ -323,6 +364,22 @@ static struct super_block *quotactl_bloc
6841 return ERR_CAST(bdev);
6842 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
6843 + if (bdev && bdev->bd_inode &&
6844 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
6845 + struct block_device *bdnew = (void *)-EINVAL;
6847 + if (vroot_get_real_bdev)
6848 + bdnew = vroot_get_real_bdev(bdev);
6850 + vxdprintk(VXD_CBIT(misc, 0),
6851 + "vroot_get_real_bdev not set");
6853 + if (IS_ERR(bdnew))
6854 + return ERR_PTR(PTR_ERR(bdnew));
6858 if (quotactl_cmd_write(cmd))
6859 sb = get_super_thawed(bdev);
6861 diff -NurpP --minimal linux-3.6.10/fs/reiserfs/file.c linux-3.6.10-vs2.3.4.5/fs/reiserfs/file.c
6862 --- linux-3.6.10/fs/reiserfs/file.c 2012-05-21 18:07:26.000000000 +0200
6863 +++ linux-3.6.10-vs2.3.4.5/fs/reiserfs/file.c 2012-10-04 18:47:00.000000000 +0200
6864 @@ -319,5 +319,6 @@ const struct inode_operations reiserfs_f
6865 .listxattr = reiserfs_listxattr,
6866 .removexattr = reiserfs_removexattr,
6867 .permission = reiserfs_permission,
6868 + .sync_flags = reiserfs_sync_flags,
6869 .get_acl = reiserfs_get_acl,
6871 diff -NurpP --minimal linux-3.6.10/fs/reiserfs/inode.c linux-3.6.10-vs2.3.4.5/fs/reiserfs/inode.c
6872 --- linux-3.6.10/fs/reiserfs/inode.c 2012-12-11 12:36:58.000000000 +0100
6873 +++ linux-3.6.10-vs2.3.4.5/fs/reiserfs/inode.c 2012-12-08 01:36:33.000000000 +0100
6875 #include <linux/writeback.h>
6876 #include <linux/quotaops.h>
6877 #include <linux/swap.h>
6878 +#include <linux/vs_tag.h>
6880 int reiserfs_commit_write(struct file *f, struct page *page,
6881 unsigned from, unsigned to);
6882 @@ -1131,6 +1132,8 @@ static void init_inode(struct inode *ino
6883 struct buffer_head *bh;
6884 struct item_head *ih;
6888 //int version = ITEM_VERSION_1;
6890 bh = PATH_PLAST_BUFFER(path);
6891 @@ -1151,12 +1154,13 @@ static void init_inode(struct inode *ino
6892 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
6893 unsigned long blocks;
6895 + uid = sd_v1_uid(sd);
6896 + gid = sd_v1_gid(sd);
6898 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
6899 set_inode_sd_version(inode, STAT_DATA_V1);
6900 inode->i_mode = sd_v1_mode(sd);
6901 set_nlink(inode, sd_v1_nlink(sd));
6902 - inode->i_uid = sd_v1_uid(sd);
6903 - inode->i_gid = sd_v1_gid(sd);
6904 inode->i_size = sd_v1_size(sd);
6905 inode->i_atime.tv_sec = sd_v1_atime(sd);
6906 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
6907 @@ -1198,11 +1202,12 @@ static void init_inode(struct inode *ino
6908 // (directories and symlinks)
6909 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
6911 + uid = sd_v2_uid(sd);
6912 + gid = sd_v2_gid(sd);
6914 inode->i_mode = sd_v2_mode(sd);
6915 set_nlink(inode, sd_v2_nlink(sd));
6916 - inode->i_uid = sd_v2_uid(sd);
6917 inode->i_size = sd_v2_size(sd);
6918 - inode->i_gid = sd_v2_gid(sd);
6919 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
6920 inode->i_atime.tv_sec = sd_v2_atime(sd);
6921 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
6922 @@ -1232,6 +1237,10 @@ static void init_inode(struct inode *ino
6923 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
6926 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6927 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6928 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
6931 if (S_ISREG(inode->i_mode)) {
6932 inode->i_op = &reiserfs_file_inode_operations;
6933 @@ -1254,13 +1263,15 @@ static void init_inode(struct inode *ino
6934 static void inode2sd(void *sd, struct inode *inode, loff_t size)
6936 struct stat_data *sd_v2 = (struct stat_data *)sd;
6937 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
6938 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
6941 + set_sd_v2_uid(sd_v2, uid);
6942 + set_sd_v2_gid(sd_v2, gid);
6943 set_sd_v2_mode(sd_v2, inode->i_mode);
6944 set_sd_v2_nlink(sd_v2, inode->i_nlink);
6945 - set_sd_v2_uid(sd_v2, inode->i_uid);
6946 set_sd_v2_size(sd_v2, size);
6947 - set_sd_v2_gid(sd_v2, inode->i_gid);
6948 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
6949 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
6950 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
6951 @@ -2869,14 +2880,19 @@ int reiserfs_commit_write(struct file *f
6952 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
6954 if (reiserfs_attrs(inode->i_sb)) {
6955 - if (sd_attrs & REISERFS_SYNC_FL)
6956 - inode->i_flags |= S_SYNC;
6958 - inode->i_flags &= ~S_SYNC;
6959 if (sd_attrs & REISERFS_IMMUTABLE_FL)
6960 inode->i_flags |= S_IMMUTABLE;
6962 inode->i_flags &= ~S_IMMUTABLE;
6963 + if (sd_attrs & REISERFS_IXUNLINK_FL)
6964 + inode->i_flags |= S_IXUNLINK;
6966 + inode->i_flags &= ~S_IXUNLINK;
6968 + if (sd_attrs & REISERFS_SYNC_FL)
6969 + inode->i_flags |= S_SYNC;
6971 + inode->i_flags &= ~S_SYNC;
6972 if (sd_attrs & REISERFS_APPEND_FL)
6973 inode->i_flags |= S_APPEND;
6975 @@ -2889,6 +2905,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
6976 REISERFS_I(inode)->i_flags |= i_nopack_mask;
6978 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
6980 + if (sd_attrs & REISERFS_BARRIER_FL)
6981 + inode->i_vflags |= V_BARRIER;
6983 + inode->i_vflags &= ~V_BARRIER;
6984 + if (sd_attrs & REISERFS_COW_FL)
6985 + inode->i_vflags |= V_COW;
6987 + inode->i_vflags &= ~V_COW;
6991 @@ -2899,6 +2924,11 @@ void i_attrs_to_sd_attrs(struct inode *i
6992 *sd_attrs |= REISERFS_IMMUTABLE_FL;
6994 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
6995 + if (inode->i_flags & S_IXUNLINK)
6996 + *sd_attrs |= REISERFS_IXUNLINK_FL;
6998 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
7000 if (inode->i_flags & S_SYNC)
7001 *sd_attrs |= REISERFS_SYNC_FL;
7003 @@ -2911,6 +2941,15 @@ void i_attrs_to_sd_attrs(struct inode *i
7004 *sd_attrs |= REISERFS_NOTAIL_FL;
7006 *sd_attrs &= ~REISERFS_NOTAIL_FL;
7008 + if (inode->i_vflags & V_BARRIER)
7009 + *sd_attrs |= REISERFS_BARRIER_FL;
7011 + *sd_attrs &= ~REISERFS_BARRIER_FL;
7012 + if (inode->i_vflags & V_COW)
7013 + *sd_attrs |= REISERFS_COW_FL;
7015 + *sd_attrs &= ~REISERFS_COW_FL;
7019 @@ -3155,7 +3194,8 @@ int reiserfs_setattr(struct dentry *dent
7022 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
7023 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
7024 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
7025 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
7026 struct reiserfs_transaction_handle th;
7029 @@ -3186,6 +3226,9 @@ int reiserfs_setattr(struct dentry *dent
7030 inode->i_uid = attr->ia_uid;
7031 if (attr->ia_valid & ATTR_GID)
7032 inode->i_gid = attr->ia_gid;
7033 + if ((attr->ia_valid & ATTR_TAG) &&
7035 + inode->i_tag = attr->ia_tag;
7036 mark_inode_dirty(inode);
7037 error = journal_end(&th, inode->i_sb, jbegin_count);
7039 diff -NurpP --minimal linux-3.6.10/fs/reiserfs/ioctl.c linux-3.6.10-vs2.3.4.5/fs/reiserfs/ioctl.c
7040 --- linux-3.6.10/fs/reiserfs/ioctl.c 2012-05-21 18:07:27.000000000 +0200
7041 +++ linux-3.6.10-vs2.3.4.5/fs/reiserfs/ioctl.c 2012-10-04 18:47:00.000000000 +0200
7043 #include <linux/pagemap.h>
7044 #include <linux/compat.h>
7047 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
7049 + __u16 sd_attrs = 0;
7051 + inode->i_flags = flags;
7052 + inode->i_vflags = vflags;
7054 + i_attrs_to_sd_attrs(inode, &sd_attrs);
7055 + REISERFS_I(inode)->i_attrs = sd_attrs;
7056 + inode->i_ctime = CURRENT_TIME_SEC;
7057 + mark_inode_dirty(inode);
7062 * reiserfs_ioctl - handler for ioctl for inode
7063 * supported commands:
7065 long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
7067 struct inode *inode = filp->f_path.dentry->d_inode;
7068 - unsigned int flags;
7069 + unsigned int flags, oldflags;
7072 reiserfs_write_lock(inode->i_sb);
7073 @@ -47,6 +62,7 @@ long reiserfs_ioctl(struct file *filp, u
7075 flags = REISERFS_I(inode)->i_attrs;
7076 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
7077 + flags &= REISERFS_FL_USER_VISIBLE;
7078 err = put_user(flags, (int __user *)arg);
7080 case REISERFS_IOC_SETFLAGS:{
7081 @@ -67,6 +83,10 @@ long reiserfs_ioctl(struct file *filp, u
7085 + if (IS_BARRIER(inode)) {
7086 + vxwprintk_task(1, "messing with the barrier.");
7090 * Is it quota file? Do not allow user to mess with it
7092 @@ -91,6 +111,10 @@ long reiserfs_ioctl(struct file *filp, u
7097 + oldflags = REISERFS_I(inode)->i_attrs;
7098 + flags &= REISERFS_FL_USER_MODIFIABLE;
7099 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
7100 sd_attrs_to_i_attrs(flags, inode);
7101 REISERFS_I(inode)->i_attrs = flags;
7102 inode->i_ctime = CURRENT_TIME_SEC;
7103 diff -NurpP --minimal linux-3.6.10/fs/reiserfs/namei.c linux-3.6.10-vs2.3.4.5/fs/reiserfs/namei.c
7104 --- linux-3.6.10/fs/reiserfs/namei.c 2012-10-04 15:27:41.000000000 +0200
7105 +++ linux-3.6.10-vs2.3.4.5/fs/reiserfs/namei.c 2012-10-04 18:47:00.000000000 +0200
7109 #include <linux/quotaops.h>
7110 +#include <linux/vs_tag.h>
7112 #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); }
7113 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
7114 @@ -362,6 +363,7 @@ static struct dentry *reiserfs_lookup(st
7115 if (retval == IO_ERROR) {
7116 return ERR_PTR(-EIO);
7118 + dx_propagate_tag(nd, inode);
7120 return d_splice_alias(inode, dentry);
7122 diff -NurpP --minimal linux-3.6.10/fs/reiserfs/reiserfs.h linux-3.6.10-vs2.3.4.5/fs/reiserfs/reiserfs.h
7123 --- linux-3.6.10/fs/reiserfs/reiserfs.h 2012-07-22 23:39:42.000000000 +0200
7124 +++ linux-3.6.10-vs2.3.4.5/fs/reiserfs/reiserfs.h 2012-10-04 18:47:00.000000000 +0200
7125 @@ -549,6 +549,7 @@ enum reiserfs_mount_options {
7126 REISERFS_EXPOSE_PRIVROOT,
7127 REISERFS_BARRIER_NONE,
7128 REISERFS_BARRIER_FLUSH,
7131 /* Actions on error */
7132 REISERFS_ERROR_PANIC,
7133 @@ -1548,6 +1549,11 @@ struct stat_data_v1 {
7134 #define REISERFS_COMPR_FL FS_COMPR_FL
7135 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
7137 +/* unfortunately reiserfs sdattr is only 16 bit */
7138 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
7139 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
7140 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
7142 /* persistent flags that file inherits from the parent directory */
7143 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
7144 REISERFS_SYNC_FL | \
7145 @@ -1557,6 +1563,9 @@ struct stat_data_v1 {
7146 REISERFS_COMPR_FL | \
7147 REISERFS_NOTAIL_FL )
7149 +#define REISERFS_FL_USER_VISIBLE 0x80FF
7150 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
7152 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
7155 @@ -2647,6 +2656,7 @@ static inline void reiserfs_update_sd(st
7156 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
7157 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
7158 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
7159 +int reiserfs_sync_flags(struct inode *inode, int, int);
7161 int __reiserfs_write_begin(struct page *page, unsigned from, unsigned len);
7163 diff -NurpP --minimal linux-3.6.10/fs/reiserfs/super.c linux-3.6.10-vs2.3.4.5/fs/reiserfs/super.c
7164 --- linux-3.6.10/fs/reiserfs/super.c 2012-12-11 12:36:58.000000000 +0100
7165 +++ linux-3.6.10-vs2.3.4.5/fs/reiserfs/super.c 2012-12-08 01:36:33.000000000 +0100
7166 @@ -1020,6 +1020,14 @@ static int reiserfs_parse_options(struct
7167 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
7168 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
7170 +#ifndef CONFIG_TAGGING_NONE
7171 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
7172 + {"tag",.setmask = 1 << REISERFS_TAGGED},
7173 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
7175 +#ifdef CONFIG_PROPAGATE
7176 + {"tag",.arg_required = 'T',.values = NULL},
7178 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
7179 {"acl",.setmask = 1 << REISERFS_POSIXACL},
7180 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
7181 @@ -1338,6 +1346,14 @@ static int reiserfs_remount(struct super
7182 handle_quota_files(s, qf_names, &qfmt);
7185 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
7186 + !(s->s_flags & MS_TAGGED)) {
7187 + reiserfs_warning(s, "super-vs01",
7188 + "reiserfs: tagging not permitted on remount.");
7195 /* Add options that are safe here */
7196 @@ -1831,6 +1847,10 @@ static int reiserfs_fill_super(struct su
7197 goto error_unlocked;
7200 + /* map mount option tagxid */
7201 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
7202 + s->s_flags |= MS_TAGGED;
7204 rs = SB_DISK_SUPER_BLOCK(s);
7205 /* Let's do basic sanity check to verify that underlying device is not
7206 smaller than the filesystem. If the check fails then abort and scream,
7207 diff -NurpP --minimal linux-3.6.10/fs/reiserfs/xattr.c linux-3.6.10-vs2.3.4.5/fs/reiserfs/xattr.c
7208 --- linux-3.6.10/fs/reiserfs/xattr.c 2012-10-04 15:27:41.000000000 +0200
7209 +++ linux-3.6.10-vs2.3.4.5/fs/reiserfs/xattr.c 2012-10-04 18:47:00.000000000 +0200
7211 #include <linux/errno.h>
7212 #include <linux/gfp.h>
7213 #include <linux/fs.h>
7214 +#include <linux/mount.h>
7215 #include <linux/file.h>
7216 #include <linux/pagemap.h>
7217 #include <linux/xattr.h>
7218 diff -NurpP --minimal linux-3.6.10/fs/stat.c linux-3.6.10-vs2.3.4.5/fs/stat.c
7219 --- linux-3.6.10/fs/stat.c 2012-10-04 15:27:41.000000000 +0200
7220 +++ linux-3.6.10-vs2.3.4.5/fs/stat.c 2012-10-04 18:47:00.000000000 +0200
7221 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
7222 stat->nlink = inode->i_nlink;
7223 stat->uid = inode->i_uid;
7224 stat->gid = inode->i_gid;
7225 + stat->tag = inode->i_tag;
7226 stat->rdev = inode->i_rdev;
7227 stat->size = i_size_read(inode);
7228 stat->atime = inode->i_atime;
7229 diff -NurpP --minimal linux-3.6.10/fs/statfs.c linux-3.6.10-vs2.3.4.5/fs/statfs.c
7230 --- linux-3.6.10/fs/statfs.c 2012-07-22 23:39:42.000000000 +0200
7231 +++ linux-3.6.10-vs2.3.4.5/fs/statfs.c 2012-10-04 18:47:00.000000000 +0200
7233 #include <linux/statfs.h>
7234 #include <linux/security.h>
7235 #include <linux/uaccess.h>
7236 +#include <linux/vs_base.h>
7237 +#include <linux/vs_dlimit.h>
7238 #include "internal.h"
7240 static int flags_by_mnt(int mnt_flags)
7241 @@ -60,6 +62,8 @@ static int statfs_by_dentry(struct dentr
7242 retval = dentry->d_sb->s_op->statfs(dentry, buf);
7243 if (retval == 0 && buf->f_frsize == 0)
7244 buf->f_frsize = buf->f_bsize;
7245 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
7246 + vx_vsi_statfs(dentry->d_sb, buf);
7250 diff -NurpP --minimal linux-3.6.10/fs/super.c linux-3.6.10-vs2.3.4.5/fs/super.c
7251 --- linux-3.6.10/fs/super.c 2012-10-04 15:27:41.000000000 +0200
7252 +++ linux-3.6.10-vs2.3.4.5/fs/super.c 2012-10-04 19:06:05.000000000 +0200
7254 #include <linux/cleancache.h>
7255 #include <linux/fsnotify.h>
7256 #include <linux/lockdep.h>
7257 +#include <linux/magic.h>
7258 +#include <linux/vs_context.h>
7259 #include "internal.h"
7262 @@ -1148,6 +1150,13 @@ mount_fs(struct file_system_type *type,
7263 WARN_ON(sb->s_bdi == &default_backing_dev_info);
7264 sb->s_flags |= MS_BORN;
7267 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) &&
7269 + (sb->s_magic != PROC_SUPER_MAGIC) &&
7270 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
7273 error = security_sb_kern_mount(sb, flags, secdata);
7276 diff -NurpP --minimal linux-3.6.10/fs/sysfs/mount.c linux-3.6.10-vs2.3.4.5/fs/sysfs/mount.c
7277 --- linux-3.6.10/fs/sysfs/mount.c 2012-10-04 15:27:41.000000000 +0200
7278 +++ linux-3.6.10-vs2.3.4.5/fs/sysfs/mount.c 2012-10-04 18:47:00.000000000 +0200
7279 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
7281 sb->s_blocksize = PAGE_CACHE_SIZE;
7282 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
7283 - sb->s_magic = SYSFS_MAGIC;
7284 + sb->s_magic = SYSFS_SUPER_MAGIC;
7285 sb->s_op = &sysfs_ops;
7286 sb->s_time_gran = 1;
7288 diff -NurpP --minimal linux-3.6.10/fs/utimes.c linux-3.6.10-vs2.3.4.5/fs/utimes.c
7289 --- linux-3.6.10/fs/utimes.c 2012-07-22 23:39:42.000000000 +0200
7290 +++ linux-3.6.10-vs2.3.4.5/fs/utimes.c 2012-10-04 18:47:00.000000000 +0200
7292 #include <linux/stat.h>
7293 #include <linux/utime.h>
7294 #include <linux/syscalls.h>
7295 +#include <linux/mount.h>
7296 +#include <linux/vs_cowbl.h>
7297 #include <asm/uaccess.h>
7298 #include <asm/unistd.h>
7300 @@ -52,12 +54,18 @@ static int utimes_common(struct path *pa
7303 struct iattr newattrs;
7304 - struct inode *inode = path->dentry->d_inode;
7305 + struct inode *inode;
7307 error = mnt_want_write(path->mnt);
7311 + error = cow_check_and_break(path);
7313 + goto mnt_drop_write_and_out;
7315 + inode = path->dentry->d_inode;
7317 if (times && times[0].tv_nsec == UTIME_NOW &&
7318 times[1].tv_nsec == UTIME_NOW)
7320 diff -NurpP --minimal linux-3.6.10/fs/xattr.c linux-3.6.10-vs2.3.4.5/fs/xattr.c
7321 --- linux-3.6.10/fs/xattr.c 2012-10-04 15:27:44.000000000 +0200
7322 +++ linux-3.6.10-vs2.3.4.5/fs/xattr.c 2012-10-04 18:47:00.000000000 +0200
7324 #include <linux/fsnotify.h>
7325 #include <linux/audit.h>
7326 #include <linux/vmalloc.h>
7327 +#include <linux/mount.h>
7329 #include <asm/uaccess.h>
7331 @@ -51,7 +52,7 @@ xattr_permission(struct inode *inode, co
7332 * The trusted.* namespace can only be accessed by privileged users.
7334 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) {
7335 - if (!capable(CAP_SYS_ADMIN))
7336 + if (!vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED))
7337 return (mask & MAY_WRITE) ? -EPERM : -ENODATA;
7340 diff -NurpP --minimal linux-3.6.10/fs/xfs/xfs_dinode.h linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_dinode.h
7341 --- linux-3.6.10/fs/xfs/xfs_dinode.h 2012-10-04 15:27:44.000000000 +0200
7342 +++ linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_dinode.h 2012-10-04 18:47:00.000000000 +0200
7343 @@ -51,7 +51,9 @@ typedef struct xfs_dinode {
7344 __be32 di_nlink; /* number of links to file */
7345 __be16 di_projid_lo; /* lower part of owner's project id */
7346 __be16 di_projid_hi; /* higher part owner's project id */
7347 - __u8 di_pad[6]; /* unused, zeroed space */
7348 + __u8 di_pad[2]; /* unused, zeroed space */
7349 + __be16 di_tag; /* context tagging */
7350 + __be16 di_vflags; /* vserver specific flags */
7351 __be16 di_flushiter; /* incremented on flush */
7352 xfs_timestamp_t di_atime; /* time last accessed */
7353 xfs_timestamp_t di_mtime; /* time last modified */
7354 @@ -184,6 +186,8 @@ static inline void xfs_dinode_put_rdev(s
7355 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
7356 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
7357 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
7358 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
7360 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
7361 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
7362 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
7363 @@ -199,6 +203,7 @@ static inline void xfs_dinode_put_rdev(s
7364 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
7365 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
7366 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
7367 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
7369 #ifdef CONFIG_XFS_RT
7370 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
7371 @@ -211,6 +216,10 @@ static inline void xfs_dinode_put_rdev(s
7372 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
7373 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
7374 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
7375 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
7376 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
7377 + XFS_DIFLAG_IXUNLINK)
7379 +#define XFS_DIVFLAG_BARRIER 0x01
7380 +#define XFS_DIVFLAG_COW 0x02
7382 #endif /* __XFS_DINODE_H__ */
7383 diff -NurpP --minimal linux-3.6.10/fs/xfs/xfs_fs.h linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_fs.h
7384 --- linux-3.6.10/fs/xfs/xfs_fs.h 2011-10-24 18:45:31.000000000 +0200
7385 +++ linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_fs.h 2012-10-04 18:47:00.000000000 +0200
7386 @@ -67,6 +67,9 @@ struct fsxattr {
7387 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
7388 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
7389 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
7390 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
7391 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
7392 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
7393 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
7396 @@ -302,7 +305,8 @@ typedef struct xfs_bstat {
7397 #define bs_projid bs_projid_lo /* (previously just bs_projid) */
7398 __u16 bs_forkoff; /* inode fork offset in bytes */
7399 __u16 bs_projid_hi; /* higher part of project id */
7400 - unsigned char bs_pad[10]; /* pad space, unused */
7401 + unsigned char bs_pad[8]; /* pad space, unused */
7402 + __u16 bs_tag; /* context tagging */
7403 __u32 bs_dmevmask; /* DMIG event mask */
7404 __u16 bs_dmstate; /* DMIG state info */
7405 __u16 bs_aextents; /* attribute number of extents */
7406 diff -NurpP --minimal linux-3.6.10/fs/xfs/xfs_ialloc.c linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_ialloc.c
7407 --- linux-3.6.10/fs/xfs/xfs_ialloc.c 2012-10-04 15:27:44.000000000 +0200
7408 +++ linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_ialloc.c 2012-10-04 18:47:00.000000000 +0200
7410 #include "xfs_error.h"
7411 #include "xfs_bmap.h"
7415 * Allocation group level functions.
7417 diff -NurpP --minimal linux-3.6.10/fs/xfs/xfs_inode.c linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_inode.c
7418 --- linux-3.6.10/fs/xfs/xfs_inode.c 2012-10-04 15:27:44.000000000 +0200
7419 +++ linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_inode.c 2012-11-16 22:43:16.000000000 +0100
7421 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
7423 #include <linux/log2.h>
7424 +#include <linux/vs_tag.h>
7428 @@ -563,15 +564,25 @@ xfs_iformat_btree(
7430 xfs_dinode_from_disk(
7432 - xfs_dinode_t *from)
7433 + xfs_dinode_t *from,
7436 + uint32_t uid, gid, tag;
7438 to->di_magic = be16_to_cpu(from->di_magic);
7439 to->di_mode = be16_to_cpu(from->di_mode);
7440 to->di_version = from ->di_version;
7441 to->di_format = from->di_format;
7442 to->di_onlink = be16_to_cpu(from->di_onlink);
7443 - to->di_uid = be32_to_cpu(from->di_uid);
7444 - to->di_gid = be32_to_cpu(from->di_gid);
7446 + uid = be32_to_cpu(from->di_uid);
7447 + gid = be32_to_cpu(from->di_gid);
7448 + tag = be16_to_cpu(from->di_tag);
7450 + to->di_uid = INOTAG_UID(tagged, uid, gid);
7451 + to->di_gid = INOTAG_GID(tagged, uid, gid);
7452 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
7454 to->di_nlink = be32_to_cpu(from->di_nlink);
7455 to->di_projid_lo = be16_to_cpu(from->di_projid_lo);
7456 to->di_projid_hi = be16_to_cpu(from->di_projid_hi);
7457 @@ -593,21 +604,26 @@ xfs_dinode_from_disk(
7458 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
7459 to->di_dmstate = be16_to_cpu(from->di_dmstate);
7460 to->di_flags = be16_to_cpu(from->di_flags);
7461 + to->di_vflags = be16_to_cpu(from->di_vflags);
7462 to->di_gen = be32_to_cpu(from->di_gen);
7468 - xfs_icdinode_t *from)
7469 + xfs_icdinode_t *from,
7472 to->di_magic = cpu_to_be16(from->di_magic);
7473 to->di_mode = cpu_to_be16(from->di_mode);
7474 to->di_version = from ->di_version;
7475 to->di_format = from->di_format;
7476 to->di_onlink = cpu_to_be16(from->di_onlink);
7477 - to->di_uid = cpu_to_be32(from->di_uid);
7478 - to->di_gid = cpu_to_be32(from->di_gid);
7480 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
7481 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
7482 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
7484 to->di_nlink = cpu_to_be32(from->di_nlink);
7485 to->di_projid_lo = cpu_to_be16(from->di_projid_lo);
7486 to->di_projid_hi = cpu_to_be16(from->di_projid_hi);
7487 @@ -629,12 +645,14 @@ xfs_dinode_to_disk(
7488 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
7489 to->di_dmstate = cpu_to_be16(from->di_dmstate);
7490 to->di_flags = cpu_to_be16(from->di_flags);
7491 + to->di_vflags = cpu_to_be16(from->di_vflags);
7492 to->di_gen = cpu_to_be32(from->di_gen);
7497 - __uint16_t di_flags)
7498 + __uint16_t di_flags,
7499 + __uint16_t di_vflags)
7503 @@ -645,6 +663,8 @@ _xfs_dic2xflags(
7504 flags |= XFS_XFLAG_PREALLOC;
7505 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7506 flags |= XFS_XFLAG_IMMUTABLE;
7507 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7508 + flags |= XFS_XFLAG_IXUNLINK;
7509 if (di_flags & XFS_DIFLAG_APPEND)
7510 flags |= XFS_XFLAG_APPEND;
7511 if (di_flags & XFS_DIFLAG_SYNC)
7512 @@ -669,6 +689,10 @@ _xfs_dic2xflags(
7513 flags |= XFS_XFLAG_FILESTREAM;
7516 + if (di_vflags & XFS_DIVFLAG_BARRIER)
7517 + flags |= FS_BARRIER_FL;
7518 + if (di_vflags & XFS_DIVFLAG_COW)
7519 + flags |= FS_COW_FL;
7523 @@ -678,7 +702,7 @@ xfs_ip2xflags(
7525 xfs_icdinode_t *dic = &ip->i_d;
7527 - return _xfs_dic2xflags(dic->di_flags) |
7528 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
7529 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
7532 @@ -686,7 +710,8 @@ uint
7536 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
7537 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
7538 + be16_to_cpu(dip->di_vflags)) |
7539 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
7542 @@ -740,7 +765,8 @@ xfs_iread(
7543 * Otherwise, just get the truly permanent information.
7546 - xfs_dinode_from_disk(&ip->i_d, dip);
7547 + xfs_dinode_from_disk(&ip->i_d, dip,
7548 + mp->m_flags & XFS_MOUNT_TAGGED);
7549 error = xfs_iformat(ip, dip);
7552 @@ -927,6 +953,7 @@ xfs_ialloc(
7553 ASSERT(ip->i_d.di_nlink == nlink);
7554 ip->i_d.di_uid = current_fsuid();
7555 ip->i_d.di_gid = current_fsgid();
7556 + ip->i_d.di_tag = current_fstag(&ip->i_vnode);
7557 xfs_set_projid(ip, prid);
7558 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
7560 @@ -986,6 +1013,7 @@ xfs_ialloc(
7561 ip->i_d.di_dmevmask = 0;
7562 ip->i_d.di_dmstate = 0;
7563 ip->i_d.di_flags = 0;
7564 + ip->i_d.di_vflags = 0;
7565 flags = XFS_ILOG_CORE;
7566 switch (mode & S_IFMT) {
7568 @@ -1667,6 +1695,7 @@ xfs_ifree(
7570 ip->i_d.di_mode = 0; /* mark incore inode as free */
7571 ip->i_d.di_flags = 0;
7572 + ip->i_d.di_vflags = 0;
7573 ip->i_d.di_dmevmask = 0;
7574 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
7575 ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
7576 @@ -1833,6 +1862,7 @@ xfs_iroot_realloc(
7580 +#include <linux/vs_tag.h>
7583 * This is called when the amount of space needed for if_data
7584 @@ -2521,7 +2551,8 @@ xfs_iflush_int(
7585 * because if the inode is dirty at all the core must
7588 - xfs_dinode_to_disk(dip, &ip->i_d);
7589 + xfs_dinode_to_disk(dip, &ip->i_d,
7590 + mp->m_flags & XFS_MOUNT_TAGGED);
7592 /* Wrap, we never let the log put out DI_MAX_FLUSH */
7593 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
7594 diff -NurpP --minimal linux-3.6.10/fs/xfs/xfs_inode.h linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_inode.h
7595 --- linux-3.6.10/fs/xfs/xfs_inode.h 2012-10-04 15:27:44.000000000 +0200
7596 +++ linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_inode.h 2012-10-04 18:47:00.000000000 +0200
7597 @@ -134,7 +134,9 @@ typedef struct xfs_icdinode {
7598 __uint32_t di_nlink; /* number of links to file */
7599 __uint16_t di_projid_lo; /* lower part of owner's project id */
7600 __uint16_t di_projid_hi; /* higher part of owner's project id */
7601 - __uint8_t di_pad[6]; /* unused, zeroed space */
7602 + __uint8_t di_pad[2]; /* unused, zeroed space */
7603 + __uint16_t di_tag; /* context tagging */
7604 + __uint16_t di_vflags; /* vserver specific flags */
7605 __uint16_t di_flushiter; /* incremented on flush */
7606 xfs_ictimestamp_t di_atime; /* time last accessed */
7607 xfs_ictimestamp_t di_mtime; /* time last modified */
7608 @@ -561,7 +563,7 @@ int xfs_imap_to_bp(struct xfs_mount *,
7609 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
7610 struct xfs_inode *, uint);
7611 void xfs_dinode_to_disk(struct xfs_dinode *,
7612 - struct xfs_icdinode *);
7613 + struct xfs_icdinode *, int);
7614 void xfs_idestroy_fork(struct xfs_inode *, int);
7615 void xfs_idata_realloc(struct xfs_inode *, int, int);
7616 void xfs_iroot_realloc(struct xfs_inode *, int, int);
7617 diff -NurpP --minimal linux-3.6.10/fs/xfs/xfs_ioctl.c linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_ioctl.c
7618 --- linux-3.6.10/fs/xfs/xfs_ioctl.c 2012-10-04 15:27:44.000000000 +0200
7619 +++ linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_ioctl.c 2012-10-04 18:47:00.000000000 +0200
7621 #include "xfs_bmap_btree.h"
7622 #include "xfs_dinode.h"
7623 #include "xfs_inode.h"
7624 -#include "xfs_ioctl.h"
7625 +// #include "xfs_ioctl.h"
7626 #include "xfs_rtalloc.h"
7627 #include "xfs_itable.h"
7628 #include "xfs_error.h"
7629 @@ -762,6 +762,10 @@ xfs_merge_ioc_xflags(
7630 xflags |= XFS_XFLAG_IMMUTABLE;
7632 xflags &= ~XFS_XFLAG_IMMUTABLE;
7633 + if (flags & FS_IXUNLINK_FL)
7634 + xflags |= XFS_XFLAG_IXUNLINK;
7636 + xflags &= ~XFS_XFLAG_IXUNLINK;
7637 if (flags & FS_APPEND_FL)
7638 xflags |= XFS_XFLAG_APPEND;
7640 @@ -790,6 +794,8 @@ xfs_di2lxflags(
7642 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7643 flags |= FS_IMMUTABLE_FL;
7644 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7645 + flags |= FS_IXUNLINK_FL;
7646 if (di_flags & XFS_DIFLAG_APPEND)
7647 flags |= FS_APPEND_FL;
7648 if (di_flags & XFS_DIFLAG_SYNC)
7649 @@ -850,6 +856,8 @@ xfs_set_diflags(
7650 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
7651 if (xflags & XFS_XFLAG_IMMUTABLE)
7652 di_flags |= XFS_DIFLAG_IMMUTABLE;
7653 + if (xflags & XFS_XFLAG_IXUNLINK)
7654 + di_flags |= XFS_DIFLAG_IXUNLINK;
7655 if (xflags & XFS_XFLAG_APPEND)
7656 di_flags |= XFS_DIFLAG_APPEND;
7657 if (xflags & XFS_XFLAG_SYNC)
7658 @@ -892,6 +900,10 @@ xfs_diflags_to_linux(
7659 inode->i_flags |= S_IMMUTABLE;
7661 inode->i_flags &= ~S_IMMUTABLE;
7662 + if (xflags & XFS_XFLAG_IXUNLINK)
7663 + inode->i_flags |= S_IXUNLINK;
7665 + inode->i_flags &= ~S_IXUNLINK;
7666 if (xflags & XFS_XFLAG_APPEND)
7667 inode->i_flags |= S_APPEND;
7669 @@ -1396,10 +1408,18 @@ xfs_file_ioctl(
7670 case XFS_IOC_FSGETXATTRA:
7671 return xfs_ioc_fsgetxattr(ip, 1, arg);
7672 case XFS_IOC_FSSETXATTR:
7673 + if (IS_BARRIER(inode)) {
7674 + vxwprintk_task(1, "messing with the barrier.");
7675 + return -XFS_ERROR(EACCES);
7677 return xfs_ioc_fssetxattr(ip, filp, arg);
7678 case XFS_IOC_GETXFLAGS:
7679 return xfs_ioc_getxflags(ip, arg);
7680 case XFS_IOC_SETXFLAGS:
7681 + if (IS_BARRIER(inode)) {
7682 + vxwprintk_task(1, "messing with the barrier.");
7683 + return -XFS_ERROR(EACCES);
7685 return xfs_ioc_setxflags(ip, filp, arg);
7687 case XFS_IOC_FSSETDM: {
7688 diff -NurpP --minimal linux-3.6.10/fs/xfs/xfs_ioctl.h linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_ioctl.h
7689 --- linux-3.6.10/fs/xfs/xfs_ioctl.h 2011-10-24 18:45:31.000000000 +0200
7690 +++ linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_ioctl.h 2012-10-04 18:47:00.000000000 +0200
7691 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
7692 void __user *uhandle,
7697 + struct inode *inode,
7704 diff -NurpP --minimal linux-3.6.10/fs/xfs/xfs_iops.c linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_iops.c
7705 --- linux-3.6.10/fs/xfs/xfs_iops.c 2012-10-04 15:27:44.000000000 +0200
7706 +++ linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_iops.c 2012-11-16 22:14:53.000000000 +0100
7708 #include "xfs_bmap_btree.h"
7709 #include "xfs_dinode.h"
7710 #include "xfs_inode.h"
7711 +#include "xfs_ioctl.h"
7712 #include "xfs_bmap.h"
7713 #include "xfs_rtalloc.h"
7714 #include "xfs_error.h"
7716 #include <linux/security.h>
7717 #include <linux/fiemap.h>
7718 #include <linux/slab.h>
7719 +#include <linux/vs_tag.h>
7723 @@ -421,6 +423,7 @@ xfs_vn_getattr(
7724 stat->nlink = ip->i_d.di_nlink;
7725 stat->uid = ip->i_d.di_uid;
7726 stat->gid = ip->i_d.di_gid;
7727 + stat->tag = ip->i_d.di_tag;
7728 stat->ino = ip->i_ino;
7729 stat->atime = inode->i_atime;
7730 stat->mtime = inode->i_mtime;
7731 @@ -1033,6 +1036,7 @@ static const struct inode_operations xfs
7732 .listxattr = xfs_vn_listxattr,
7733 .fiemap = xfs_vn_fiemap,
7734 .update_time = xfs_vn_update_time,
7735 + .sync_flags = xfs_sync_flags,
7738 static const struct inode_operations xfs_dir_inode_operations = {
7739 @@ -1059,6 +1063,7 @@ static const struct inode_operations xfs
7740 .removexattr = generic_removexattr,
7741 .listxattr = xfs_vn_listxattr,
7742 .update_time = xfs_vn_update_time,
7743 + .sync_flags = xfs_sync_flags,
7746 static const struct inode_operations xfs_dir_ci_inode_operations = {
7747 @@ -1110,6 +1115,10 @@ xfs_diflags_to_iflags(
7748 inode->i_flags |= S_IMMUTABLE;
7750 inode->i_flags &= ~S_IMMUTABLE;
7751 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
7752 + inode->i_flags |= S_IXUNLINK;
7754 + inode->i_flags &= ~S_IXUNLINK;
7755 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
7756 inode->i_flags |= S_APPEND;
7758 @@ -1122,6 +1131,15 @@ xfs_diflags_to_iflags(
7759 inode->i_flags |= S_NOATIME;
7761 inode->i_flags &= ~S_NOATIME;
7763 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
7764 + inode->i_vflags |= V_BARRIER;
7766 + inode->i_vflags &= ~V_BARRIER;
7767 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
7768 + inode->i_vflags |= V_COW;
7770 + inode->i_vflags &= ~V_COW;
7774 @@ -1153,6 +1171,7 @@ xfs_setup_inode(
7775 set_nlink(inode, ip->i_d.di_nlink);
7776 inode->i_uid = ip->i_d.di_uid;
7777 inode->i_gid = ip->i_d.di_gid;
7778 + inode->i_tag = ip->i_d.di_tag;
7780 switch (inode->i_mode & S_IFMT) {
7782 diff -NurpP --minimal linux-3.6.10/fs/xfs/xfs_itable.c linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_itable.c
7783 --- linux-3.6.10/fs/xfs/xfs_itable.c 2012-10-04 15:27:44.000000000 +0200
7784 +++ linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_itable.c 2012-10-04 18:47:00.000000000 +0200
7785 @@ -96,6 +96,7 @@ xfs_bulkstat_one_int(
7786 buf->bs_mode = dic->di_mode;
7787 buf->bs_uid = dic->di_uid;
7788 buf->bs_gid = dic->di_gid;
7789 + buf->bs_tag = dic->di_tag;
7790 buf->bs_size = dic->di_size;
7791 buf->bs_atime.tv_sec = dic->di_atime.t_sec;
7792 buf->bs_atime.tv_nsec = dic->di_atime.t_nsec;
7793 diff -NurpP --minimal linux-3.6.10/fs/xfs/xfs_linux.h linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_linux.h
7794 --- linux-3.6.10/fs/xfs/xfs_linux.h 2011-10-24 18:45:31.000000000 +0200
7795 +++ linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_linux.h 2012-10-04 18:47:00.000000000 +0200
7798 #define current_cpu() (raw_smp_processor_id())
7799 #define current_pid() (current->pid)
7800 +#define current_fstag(vp) (dx_current_fstag((vp)->i_sb))
7801 #define current_test_flags(f) (current->flags & (f))
7802 #define current_set_flags_nested(sp, f) \
7803 (*(sp) = current->flags, current->flags |= (f))
7804 diff -NurpP --minimal linux-3.6.10/fs/xfs/xfs_log_recover.c linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_log_recover.c
7805 --- linux-3.6.10/fs/xfs/xfs_log_recover.c 2012-12-11 12:36:58.000000000 +0100
7806 +++ linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_log_recover.c 2012-12-08 01:36:33.000000000 +0100
7807 @@ -2359,7 +2359,8 @@ xlog_recover_inode_pass2(
7810 /* The core is in in-core format */
7811 - xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr);
7812 + xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr,
7813 + mp->m_flags & XFS_MOUNT_TAGGED);
7815 /* the rest is in on-disk format */
7816 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
7817 diff -NurpP --minimal linux-3.6.10/fs/xfs/xfs_mount.h linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_mount.h
7818 --- linux-3.6.10/fs/xfs/xfs_mount.h 2012-10-04 15:27:44.000000000 +0200
7819 +++ linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_mount.h 2012-10-04 18:47:00.000000000 +0200
7820 @@ -251,6 +251,7 @@ typedef struct xfs_mount {
7822 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
7824 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
7827 * Default minimum read and write sizes.
7828 diff -NurpP --minimal linux-3.6.10/fs/xfs/xfs_super.c linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_super.c
7829 --- linux-3.6.10/fs/xfs/xfs_super.c 2012-10-04 15:27:44.000000000 +0200
7830 +++ linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_super.c 2012-10-04 18:47:00.000000000 +0200
7831 @@ -112,6 +112,9 @@ mempool_t *xfs_ioend_pool;
7832 #define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed logging disabled */
7833 #define MNTOPT_DISCARD "discard" /* Discard unused blocks */
7834 #define MNTOPT_NODISCARD "nodiscard" /* Do not discard unused blocks */
7835 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
7836 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
7837 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
7840 * Table driven mount option parser.
7841 @@ -120,10 +123,14 @@ mempool_t *xfs_ioend_pool;
7842 * in the future, too.
7845 + Opt_tag, Opt_notag,
7846 Opt_barrier, Opt_nobarrier, Opt_err
7849 static const match_table_t tokens = {
7850 + {Opt_tag, "tagxid"},
7852 + {Opt_notag, "notag"},
7853 {Opt_barrier, "barrier"},
7854 {Opt_nobarrier, "nobarrier"},
7856 @@ -371,6 +378,19 @@ xfs_parseargs(
7857 } else if (!strcmp(this_char, "irixsgid")) {
7859 "irixsgid is now a sysctl(2) variable, option is deprecated.");
7860 +#ifndef CONFIG_TAGGING_NONE
7861 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7862 + mp->m_flags |= XFS_MOUNT_TAGGED;
7863 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
7864 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
7865 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
7866 + mp->m_flags |= XFS_MOUNT_TAGGED;
7868 +#ifdef CONFIG_PROPAGATE
7869 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7871 + mp->m_flags |= XFS_MOUNT_TAGGED;
7874 xfs_warn(mp, "unknown mount option [%s].", this_char);
7876 @@ -1056,6 +1076,16 @@ xfs_fs_remount(
7878 mp->m_flags &= ~XFS_MOUNT_BARRIER;
7881 + if (!(sb->s_flags & MS_TAGGED)) {
7883 + "XFS: %s: tagging not permitted on remount.\n",
7892 * Logically we would return an error here to prevent
7893 @@ -1275,6 +1305,9 @@ xfs_fs_fill_super(
7897 + if (mp->m_flags & XFS_MOUNT_TAGGED)
7898 + sb->s_flags |= MS_TAGGED;
7901 * we must configure the block size in the superblock before we run the
7902 * full mount process as the mount process can lookup and cache inodes.
7903 diff -NurpP --minimal linux-3.6.10/fs/xfs/xfs_vnodeops.c linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_vnodeops.c
7904 --- linux-3.6.10/fs/xfs/xfs_vnodeops.c 2012-10-04 15:27:44.000000000 +0200
7905 +++ linux-3.6.10-vs2.3.4.5/fs/xfs/xfs_vnodeops.c 2012-10-04 18:47:00.000000000 +0200
7906 @@ -103,6 +103,77 @@ xfs_readlink_bmap(
7912 +xfs_get_inode_flags(
7915 + struct inode *inode = VFS_I(ip);
7916 + unsigned int flags = inode->i_flags;
7917 + unsigned int vflags = inode->i_vflags;
7919 + if (flags & S_IMMUTABLE)
7920 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
7922 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
7923 + if (flags & S_IXUNLINK)
7924 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
7926 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
7928 + if (vflags & V_BARRIER)
7929 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
7931 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
7932 + if (vflags & V_COW)
7933 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
7935 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
7940 + struct inode *inode,
7944 + struct xfs_inode *ip = XFS_I(inode);
7945 + struct xfs_mount *mp = ip->i_mount;
7946 + struct xfs_trans *tp;
7947 + unsigned int lock_flags = 0;
7950 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
7951 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
7955 + xfs_ilock(ip, XFS_ILOCK_EXCL);
7956 + xfs_trans_ijoin(tp, ip, 0);
7958 + inode->i_flags = flags;
7959 + inode->i_vflags = vflags;
7960 + xfs_get_inode_flags(ip);
7962 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
7963 + xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
7965 + XFS_STATS_INC(xs_ig_attrchg);
7967 + if (mp->m_flags & XFS_MOUNT_WSYNC)
7968 + xfs_trans_set_sync(tp);
7969 + code = xfs_trans_commit(tp, 0);
7970 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
7974 + xfs_trans_cancel(tp, 0);
7976 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
7984 diff -NurpP --minimal linux-3.6.10/include/linux/Kbuild linux-3.6.10-vs2.3.4.5/include/linux/Kbuild
7985 --- linux-3.6.10/include/linux/Kbuild 2012-10-04 15:27:45.000000000 +0200
7986 +++ linux-3.6.10-vs2.3.4.5/include/linux/Kbuild 2012-10-04 18:47:00.000000000 +0200
7987 @@ -18,6 +18,7 @@ header-y += netfilter_bridge/
7988 header-y += netfilter_ipv4/
7989 header-y += netfilter_ipv6/
7991 +header-y += vserver/
7994 objhdr-y += version.h
7995 diff -NurpP --minimal linux-3.6.10/include/linux/capability.h linux-3.6.10-vs2.3.4.5/include/linux/capability.h
7996 --- linux-3.6.10/include/linux/capability.h 2012-07-22 23:39:43.000000000 +0200
7997 +++ linux-3.6.10-vs2.3.4.5/include/linux/capability.h 2012-10-04 18:47:00.000000000 +0200
7998 @@ -280,6 +280,7 @@ struct cpu_vfs_cap_data {
7999 arbitrary SCSI commands */
8000 /* Allow setting encryption key on loopback filesystem */
8001 /* Allow setting zone reclaim policy */
8002 +/* Allow the selection of a security context */
8004 #define CAP_SYS_ADMIN 21
8006 @@ -366,7 +367,12 @@ struct cpu_vfs_cap_data {
8008 #define CAP_LAST_CAP CAP_BLOCK_SUSPEND
8010 -#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
8011 +/* Allow context manipulations */
8012 +/* Allow changing context info on files */
8014 +#define CAP_CONTEXT 63
8016 +#define cap_valid(x) ((x) >= 0 && ((x) <= CAP_LAST_CAP || (x) == CAP_CONTEXT))
8019 * Bit location of each capability (used by user-space library and kernel)
8020 diff -NurpP --minimal linux-3.6.10/include/linux/cred.h linux-3.6.10-vs2.3.4.5/include/linux/cred.h
8021 --- linux-3.6.10/include/linux/cred.h 2012-07-22 23:39:43.000000000 +0200
8022 +++ linux-3.6.10-vs2.3.4.5/include/linux/cred.h 2012-10-04 18:47:00.000000000 +0200
8023 @@ -157,6 +157,7 @@ extern void exit_creds(struct task_struc
8024 extern int copy_creds(struct task_struct *, unsigned long);
8025 extern const struct cred *get_task_cred(struct task_struct *);
8026 extern struct cred *cred_alloc_blank(void);
8027 +extern struct cred *__prepare_creds(const struct cred *);
8028 extern struct cred *prepare_creds(void);
8029 extern struct cred *prepare_exec_creds(void);
8030 extern int commit_creds(struct cred *);
8031 @@ -210,6 +211,31 @@ static inline void validate_process_cred
8035 +static inline void set_cred_subscribers(struct cred *cred, int n)
8037 +#ifdef CONFIG_DEBUG_CREDENTIALS
8038 + atomic_set(&cred->subscribers, n);
8042 +static inline int read_cred_subscribers(const struct cred *cred)
8044 +#ifdef CONFIG_DEBUG_CREDENTIALS
8045 + return atomic_read(&cred->subscribers);
8051 +static inline void alter_cred_subscribers(const struct cred *_cred, int n)
8053 +#ifdef CONFIG_DEBUG_CREDENTIALS
8054 + struct cred *cred = (struct cred *) _cred;
8056 + atomic_add(n, &cred->subscribers);
8061 * get_new_cred - Get a reference on a new set of credentials
8062 * @cred: The new credentials to reference
8063 diff -NurpP --minimal linux-3.6.10/include/linux/devpts_fs.h linux-3.6.10-vs2.3.4.5/include/linux/devpts_fs.h
8064 --- linux-3.6.10/include/linux/devpts_fs.h 2008-12-25 00:26:37.000000000 +0100
8065 +++ linux-3.6.10-vs2.3.4.5/include/linux/devpts_fs.h 2012-10-04 18:47:00.000000000 +0200
8066 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
8071 #endif /* _LINUX_DEVPTS_FS_H */
8072 diff -NurpP --minimal linux-3.6.10/include/linux/fs.h linux-3.6.10-vs2.3.4.5/include/linux/fs.h
8073 --- linux-3.6.10/include/linux/fs.h 2012-10-04 15:27:45.000000000 +0200
8074 +++ linux-3.6.10-vs2.3.4.5/include/linux/fs.h 2012-10-04 18:47:00.000000000 +0200
8075 @@ -225,6 +225,9 @@ struct inodes_stat_t {
8076 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
8077 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
8078 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
8079 +#define MS_TAGGED (1<<25) /* use generic inode tagging */
8080 +#define MS_TAGID (1<<26) /* use specific tag for this mount */
8081 +#define MS_NOTAGCHECK (1<<27) /* don't check tags */
8082 #define MS_NOSEC (1<<28)
8083 #define MS_BORN (1<<29)
8084 #define MS_ACTIVE (1<<30)
8085 @@ -256,6 +259,14 @@ struct inodes_stat_t {
8086 #define S_IMA 1024 /* Inode has an associated IMA struct */
8087 #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */
8088 #define S_NOSEC 4096 /* no suid or xattr security attributes */
8089 +#define S_IXUNLINK 8192 /* Immutable Invert on unlink */
8091 +/* Linux-VServer related Inode flags */
8095 +#define V_BARRIER 4 /* Barrier for chroot() */
8096 +#define V_COW 8 /* Copy on Write */
8099 * Note that nosuid etc flags are inode-specific: setting some file-system
8100 @@ -278,12 +289,15 @@ struct inodes_stat_t {
8101 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
8102 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
8103 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
8104 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8105 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8106 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8107 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8108 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
8110 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
8111 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
8112 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
8113 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
8114 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
8115 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
8117 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
8118 @@ -294,6 +308,16 @@ struct inodes_stat_t {
8119 #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT)
8120 #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC)
8122 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
8124 +#ifdef CONFIG_VSERVER_COWBL
8125 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
8126 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
8128 +# define IS_COW(inode) (0)
8129 +# define IS_COW_LINK(inode) (0)
8132 /* the read-only stuff doesn't really belong here, but any other place is
8133 probably as bad and I don't want to create yet another include file. */
8135 @@ -380,11 +404,14 @@ struct inodes_stat_t {
8136 #define FS_EXTENT_FL 0x00080000 /* Extents */
8137 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
8138 #define FS_NOCOW_FL 0x00800000 /* Do not cow file */
8139 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8140 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
8142 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8143 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8144 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8145 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
8147 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8148 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8150 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
8151 #define SYNC_FILE_RANGE_WRITE 2
8152 @@ -472,6 +499,7 @@ typedef void (dio_iodone_t)(struct kiocb
8153 #define ATTR_KILL_PRIV (1 << 14)
8154 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
8155 #define ATTR_TIMES_SET (1 << 16)
8156 +#define ATTR_TAG (1 << 17)
8159 * This is the Inode Attributes structure, used for notify_change(). It
8160 @@ -487,6 +515,7 @@ struct iattr {
8166 struct timespec ia_atime;
8167 struct timespec ia_mtime;
8168 @@ -500,6 +529,9 @@ struct iattr {
8169 struct file *ia_file;
8172 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
8173 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
8176 * Includes for diskquotas.
8178 @@ -784,7 +816,9 @@ struct inode {
8179 unsigned short i_opflags;
8182 - unsigned int i_flags;
8184 + unsigned short i_flags;
8185 + unsigned short i_vflags;
8187 #ifdef CONFIG_FS_POSIX_ACL
8188 struct posix_acl *i_acl;
8189 @@ -813,6 +847,7 @@ struct inode {
8190 unsigned int __i_nlink;
8195 struct timespec i_atime;
8196 struct timespec i_mtime;
8197 @@ -975,12 +1010,12 @@ static inline void i_gid_write(struct in
8199 static inline unsigned iminor(const struct inode *inode)
8201 - return MINOR(inode->i_rdev);
8202 + return MINOR(inode->i_mdev);
8205 static inline unsigned imajor(const struct inode *inode)
8207 - return MAJOR(inode->i_rdev);
8208 + return MAJOR(inode->i_mdev);
8211 extern struct block_device *I_BDEV(struct inode *inode);
8212 @@ -1047,6 +1082,7 @@ struct file {
8214 struct fown_struct f_owner;
8215 const struct cred *f_cred;
8217 struct file_ra_state f_ra;
8220 @@ -1194,6 +1230,7 @@ struct file_lock {
8221 struct file *fl_file;
8226 struct fasync_struct * fl_fasync; /* for lease break notifications */
8227 /* for lease breaks: */
8228 @@ -1829,6 +1866,7 @@ struct inode_operations {
8229 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
8230 ssize_t (*listxattr) (struct dentry *, char *, size_t);
8231 int (*removexattr) (struct dentry *, const char *);
8232 + int (*sync_flags) (struct inode *, int, int);
8233 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
8235 int (*update_time)(struct inode *, struct timespec *, int);
8236 @@ -1850,6 +1888,7 @@ extern ssize_t vfs_readv(struct file *,
8237 unsigned long, loff_t *);
8238 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
8239 unsigned long, loff_t *);
8240 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
8242 struct super_operations {
8243 struct inode *(*alloc_inode)(struct super_block *sb);
8244 @@ -2692,6 +2731,7 @@ extern int dcache_dir_open(struct inode
8245 extern int dcache_dir_close(struct inode *, struct file *);
8246 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
8247 extern int dcache_readdir(struct file *, void *, filldir_t);
8248 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
8249 extern int simple_setattr(struct dentry *, struct iattr *);
8250 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
8251 extern int simple_statfs(struct dentry *, struct kstatfs *);
8252 diff -NurpP --minimal linux-3.6.10/include/linux/gfs2_ondisk.h linux-3.6.10-vs2.3.4.5/include/linux/gfs2_ondisk.h
8253 --- linux-3.6.10/include/linux/gfs2_ondisk.h 2012-10-04 15:27:45.000000000 +0200
8254 +++ linux-3.6.10-vs2.3.4.5/include/linux/gfs2_ondisk.h 2012-10-04 18:54:29.000000000 +0200
8255 @@ -225,6 +225,9 @@ enum {
8258 gfs2fl_TopLevel = 10,
8259 + gfs2fl_IXUnlink = 16,
8260 + gfs2fl_Barrier = 17,
8262 gfs2fl_TruncInProg = 29,
8263 gfs2fl_InheritDirectio = 30,
8264 gfs2fl_InheritJdata = 31,
8265 @@ -242,6 +245,9 @@ enum {
8266 #define GFS2_DIF_SYNC 0x00000100
8267 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
8268 #define GFS2_DIF_TOPDIR 0x00000400 /* New in gfs2 */
8269 +#define GFS2_DIF_IXUNLINK 0x00010000
8270 +#define GFS2_DIF_BARRIER 0x00020000
8271 +#define GFS2_DIF_COW 0x00040000
8272 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
8273 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000 /* only in gfs1 */
8274 #define GFS2_DIF_INHERIT_JDATA 0x80000000
8275 diff -NurpP --minimal linux-3.6.10/include/linux/if_tun.h linux-3.6.10-vs2.3.4.5/include/linux/if_tun.h
8276 --- linux-3.6.10/include/linux/if_tun.h 2010-08-02 16:52:54.000000000 +0200
8277 +++ linux-3.6.10-vs2.3.4.5/include/linux/if_tun.h 2012-10-04 18:47:00.000000000 +0200
8279 #define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog)
8280 #define TUNGETVNETHDRSZ _IOR('T', 215, int)
8281 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
8282 +#define TUNSETNID _IOW('T', 217, int)
8284 /* TUNSETIFF ifr flags */
8285 #define IFF_TUN 0x0001
8286 diff -NurpP --minimal linux-3.6.10/include/linux/init_task.h linux-3.6.10-vs2.3.4.5/include/linux/init_task.h
8287 --- linux-3.6.10/include/linux/init_task.h 2012-10-04 15:27:45.000000000 +0200
8288 +++ linux-3.6.10-vs2.3.4.5/include/linux/init_task.h 2012-10-04 18:47:00.000000000 +0200
8289 @@ -210,6 +210,10 @@ extern struct task_group root_task_group
8290 INIT_TRACE_RECURSION \
8291 INIT_TASK_RCU_PREEMPT(tsk) \
8294 + .vx_info = NULL, \
8296 + .nx_info = NULL, \
8300 diff -NurpP --minimal linux-3.6.10/include/linux/ipc.h linux-3.6.10-vs2.3.4.5/include/linux/ipc.h
8301 --- linux-3.6.10/include/linux/ipc.h 2012-03-19 19:47:28.000000000 +0100
8302 +++ linux-3.6.10-vs2.3.4.5/include/linux/ipc.h 2012-10-04 18:47:00.000000000 +0200
8303 @@ -91,6 +91,7 @@ struct kern_ipc_perm
8311 diff -NurpP --minimal linux-3.6.10/include/linux/ipc_namespace.h linux-3.6.10-vs2.3.4.5/include/linux/ipc_namespace.h
8312 --- linux-3.6.10/include/linux/ipc_namespace.h 2012-07-22 23:39:43.000000000 +0200
8313 +++ linux-3.6.10-vs2.3.4.5/include/linux/ipc_namespace.h 2012-10-04 18:47:00.000000000 +0200
8314 @@ -133,7 +133,8 @@ static inline int mq_init_ns(struct ipc_
8316 #if defined(CONFIG_IPC_NS)
8317 extern struct ipc_namespace *copy_ipcs(unsigned long flags,
8318 - struct task_struct *tsk);
8319 + struct ipc_namespace *old_ns,
8320 + struct user_namespace *user_ns);
8321 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
8324 @@ -144,12 +145,13 @@ static inline struct ipc_namespace *get_
8325 extern void put_ipc_ns(struct ipc_namespace *ns);
8327 static inline struct ipc_namespace *copy_ipcs(unsigned long flags,
8328 - struct task_struct *tsk)
8329 + struct ipc_namespace *old_ns,
8330 + struct user_namespace *user_ns)
8332 if (flags & CLONE_NEWIPC)
8333 return ERR_PTR(-EINVAL);
8335 - return tsk->nsproxy->ipc_ns;
8339 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
8340 diff -NurpP --minimal linux-3.6.10/include/linux/loop.h linux-3.6.10-vs2.3.4.5/include/linux/loop.h
8341 --- linux-3.6.10/include/linux/loop.h 2012-01-09 16:14:58.000000000 +0100
8342 +++ linux-3.6.10-vs2.3.4.5/include/linux/loop.h 2012-10-04 18:47:00.000000000 +0200
8343 @@ -45,6 +45,7 @@ struct loop_device {
8344 struct loop_func_table *lo_encryption;
8346 uid_t lo_key_owner; /* Who set the key */
8348 int (*ioctl)(struct loop_device *, int cmd,
8351 diff -NurpP --minimal linux-3.6.10/include/linux/magic.h linux-3.6.10-vs2.3.4.5/include/linux/magic.h
8352 --- linux-3.6.10/include/linux/magic.h 2012-05-21 18:07:31.000000000 +0200
8353 +++ linux-3.6.10-vs2.3.4.5/include/linux/magic.h 2012-10-04 18:47:00.000000000 +0200
8356 #define ADFS_SUPER_MAGIC 0xadf5
8357 #define AFFS_SUPER_MAGIC 0xadff
8358 -#define AFS_SUPER_MAGIC 0x5346414F
8359 +#define AFS_SUPER_MAGIC 0x5346414F
8360 #define AUTOFS_SUPER_MAGIC 0x0187
8361 #define CODA_SUPER_MAGIC 0x73757245
8362 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
8363 diff -NurpP --minimal linux-3.6.10/include/linux/major.h linux-3.6.10-vs2.3.4.5/include/linux/major.h
8364 --- linux-3.6.10/include/linux/major.h 2009-09-10 15:26:25.000000000 +0200
8365 +++ linux-3.6.10-vs2.3.4.5/include/linux/major.h 2012-10-04 18:47:00.000000000 +0200
8367 #define HD_MAJOR IDE0_MAJOR
8368 #define PTY_SLAVE_MAJOR 3
8370 +#define VROOT_MAJOR 4
8371 #define TTYAUX_MAJOR 5
8374 diff -NurpP --minimal linux-3.6.10/include/linux/memcontrol.h linux-3.6.10-vs2.3.4.5/include/linux/memcontrol.h
8375 --- linux-3.6.10/include/linux/memcontrol.h 2012-10-04 15:27:45.000000000 +0200
8376 +++ linux-3.6.10-vs2.3.4.5/include/linux/memcontrol.h 2012-10-04 18:47:00.000000000 +0200
8377 @@ -83,6 +83,13 @@ extern struct mem_cgroup *try_get_mem_cg
8378 extern struct mem_cgroup *parent_mem_cgroup(struct mem_cgroup *memcg);
8379 extern struct mem_cgroup *mem_cgroup_from_cont(struct cgroup *cont);
8381 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
8382 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
8384 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
8385 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
8386 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
8389 int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
8391 diff -NurpP --minimal linux-3.6.10/include/linux/mm_types.h linux-3.6.10-vs2.3.4.5/include/linux/mm_types.h
8392 --- linux-3.6.10/include/linux/mm_types.h 2012-10-04 15:27:46.000000000 +0200
8393 +++ linux-3.6.10-vs2.3.4.5/include/linux/mm_types.h 2012-10-04 18:47:00.000000000 +0200
8394 @@ -370,6 +370,7 @@ struct mm_struct {
8396 /* Architecture-specific MM context */
8397 mm_context_t context;
8398 + struct vx_info *mm_vx_info;
8400 unsigned long flags; /* Must use atomic bitops to access the bits */
8402 diff -NurpP --minimal linux-3.6.10/include/linux/mmzone.h linux-3.6.10-vs2.3.4.5/include/linux/mmzone.h
8403 --- linux-3.6.10/include/linux/mmzone.h 2012-12-11 12:36:59.000000000 +0100
8404 +++ linux-3.6.10-vs2.3.4.5/include/linux/mmzone.h 2012-12-08 01:36:33.000000000 +0100
8405 @@ -727,6 +727,13 @@ typedef struct pglist_data {
8406 __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
8409 +#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
8411 +#define node_end_pfn(nid) ({\
8412 + pg_data_t *__pgdat = NODE_DATA(nid);\
8413 + __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
8416 #include <linux/memory_hotplug.h>
8418 extern struct mutex zonelists_mutex;
8419 diff -NurpP --minimal linux-3.6.10/include/linux/mount.h linux-3.6.10-vs2.3.4.5/include/linux/mount.h
8420 --- linux-3.6.10/include/linux/mount.h 2012-03-19 19:47:28.000000000 +0100
8421 +++ linux-3.6.10-vs2.3.4.5/include/linux/mount.h 2012-10-04 18:47:00.000000000 +0200
8422 @@ -47,6 +47,9 @@ struct mnt_namespace;
8424 #define MNT_INTERNAL 0x4000
8426 +#define MNT_TAGID 0x10000
8427 +#define MNT_NOTAG 0x20000
8430 struct dentry *mnt_root; /* root of the mounted tree */
8431 struct super_block *mnt_sb; /* pointer to superblock */
8432 diff -NurpP --minimal linux-3.6.10/include/linux/net.h linux-3.6.10-vs2.3.4.5/include/linux/net.h
8433 --- linux-3.6.10/include/linux/net.h 2012-10-04 15:27:46.000000000 +0200
8434 +++ linux-3.6.10-vs2.3.4.5/include/linux/net.h 2012-10-04 18:47:00.000000000 +0200
8435 @@ -73,6 +73,7 @@ struct net;
8436 #define SOCK_PASSCRED 3
8437 #define SOCK_PASSSEC 4
8438 #define SOCK_EXTERNALLY_ALLOCATED 5
8439 +#define SOCK_USER_SOCKET 6
8441 #ifndef ARCH_HAS_SOCKET_TYPES
8443 diff -NurpP --minimal linux-3.6.10/include/linux/netdevice.h linux-3.6.10-vs2.3.4.5/include/linux/netdevice.h
8444 --- linux-3.6.10/include/linux/netdevice.h 2012-10-04 15:27:46.000000000 +0200
8445 +++ linux-3.6.10-vs2.3.4.5/include/linux/netdevice.h 2012-10-04 18:47:00.000000000 +0200
8446 @@ -1651,6 +1651,7 @@ extern void netdev_resync_ops(struct ne
8448 extern struct net_device *dev_get_by_index(struct net *net, int ifindex);
8449 extern struct net_device *__dev_get_by_index(struct net *net, int ifindex);
8450 +extern struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex);
8451 extern struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex);
8452 extern int dev_restart(struct net_device *dev);
8453 #ifdef CONFIG_NETPOLL_TRAP
8454 diff -NurpP --minimal linux-3.6.10/include/linux/nfs_mount.h linux-3.6.10-vs2.3.4.5/include/linux/nfs_mount.h
8455 --- linux-3.6.10/include/linux/nfs_mount.h 2011-01-05 21:50:31.000000000 +0100
8456 +++ linux-3.6.10-vs2.3.4.5/include/linux/nfs_mount.h 2012-10-04 18:47:00.000000000 +0200
8457 @@ -63,7 +63,8 @@ struct nfs_mount_data {
8458 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
8459 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
8460 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
8461 -#define NFS_MOUNT_FLAGMASK 0xFFFF
8462 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
8463 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
8465 /* The following are for internal use only */
8466 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
8467 diff -NurpP --minimal linux-3.6.10/include/linux/nsproxy.h linux-3.6.10-vs2.3.4.5/include/linux/nsproxy.h
8468 --- linux-3.6.10/include/linux/nsproxy.h 2011-10-24 18:45:32.000000000 +0200
8469 +++ linux-3.6.10-vs2.3.4.5/include/linux/nsproxy.h 2012-10-04 18:47:00.000000000 +0200
8472 #include <linux/spinlock.h>
8473 #include <linux/sched.h>
8474 +#include <linux/vserver/debug.h>
8476 struct mnt_namespace;
8477 struct uts_namespace;
8478 @@ -63,6 +64,7 @@ static inline struct nsproxy *task_nspro
8481 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
8482 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
8483 void exit_task_namespaces(struct task_struct *tsk);
8484 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
8485 void free_nsproxy(struct nsproxy *ns);
8486 @@ -70,16 +72,26 @@ int unshare_nsproxy_namespaces(unsigned
8487 struct fs_struct *);
8488 int __init nsproxy_cache_init(void);
8490 -static inline void put_nsproxy(struct nsproxy *ns)
8491 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
8493 +static inline void __get_nsproxy(struct nsproxy *ns,
8494 + const char *_file, int _line)
8496 - if (atomic_dec_and_test(&ns->count)) {
8499 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
8500 + ns, atomic_read(&ns->count), _file, _line);
8501 + atomic_inc(&ns->count);
8504 -static inline void get_nsproxy(struct nsproxy *ns)
8505 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
8507 +static inline void __put_nsproxy(struct nsproxy *ns,
8508 + const char *_file, int _line)
8510 - atomic_inc(&ns->count);
8511 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
8512 + ns, atomic_read(&ns->count), _file, _line);
8513 + if (atomic_dec_and_test(&ns->count)) {
8519 diff -NurpP --minimal linux-3.6.10/include/linux/pid.h linux-3.6.10-vs2.3.4.5/include/linux/pid.h
8520 --- linux-3.6.10/include/linux/pid.h 2011-07-22 11:18:11.000000000 +0200
8521 +++ linux-3.6.10-vs2.3.4.5/include/linux/pid.h 2012-10-04 18:47:00.000000000 +0200
8522 @@ -8,7 +8,8 @@ enum pid_type
8532 @@ -171,6 +172,7 @@ static inline pid_t pid_nr(struct pid *p
8535 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
8536 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
8537 pid_t pid_vnr(struct pid *pid);
8539 #define do_each_pid_task(pid, type, task) \
8540 diff -NurpP --minimal linux-3.6.10/include/linux/proc_fs.h linux-3.6.10-vs2.3.4.5/include/linux/proc_fs.h
8541 --- linux-3.6.10/include/linux/proc_fs.h 2012-07-22 23:39:44.000000000 +0200
8542 +++ linux-3.6.10-vs2.3.4.5/include/linux/proc_fs.h 2012-10-04 18:47:00.000000000 +0200
8543 @@ -54,6 +54,7 @@ struct proc_dir_entry {
8549 const struct inode_operations *proc_iops;
8551 @@ -252,12 +253,18 @@ extern const struct proc_ns_operations n
8552 extern const struct proc_ns_operations utsns_operations;
8553 extern const struct proc_ns_operations ipcns_operations;
8559 int (*proc_get_link)(struct dentry *, struct path *);
8560 int (*proc_read)(struct task_struct *task, char *page);
8561 int (*proc_show)(struct seq_file *m,
8562 struct pid_namespace *ns, struct pid *pid,
8563 struct task_struct *task);
8564 + int (*proc_vs_read)(char *page);
8565 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
8566 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
8569 struct ctl_table_header;
8570 @@ -265,6 +272,7 @@ struct ctl_table;
8577 struct proc_dir_entry *pde;
8578 diff -NurpP --minimal linux-3.6.10/include/linux/quotaops.h linux-3.6.10-vs2.3.4.5/include/linux/quotaops.h
8579 --- linux-3.6.10/include/linux/quotaops.h 2012-10-04 15:27:46.000000000 +0200
8580 +++ linux-3.6.10-vs2.3.4.5/include/linux/quotaops.h 2012-10-04 18:47:00.000000000 +0200
8582 #define _LINUX_QUOTAOPS_
8584 #include <linux/fs.h>
8585 +#include <linux/vs_dlimit.h>
8587 #define DQUOT_SPACE_WARN 0x1
8588 #define DQUOT_SPACE_RESERVE 0x2
8589 @@ -205,11 +206,12 @@ static inline void dquot_drop(struct ino
8591 static inline int dquot_alloc_inode(const struct inode *inode)
8594 + return dl_alloc_inode(inode);
8597 static inline void dquot_free_inode(const struct inode *inode)
8599 + dl_free_inode(inode);
8602 static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
8603 @@ -220,6 +222,10 @@ static inline int dquot_transfer(struct
8604 static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
8609 + if ((ret = dl_alloc_space(inode, number)))
8611 if (!(flags & DQUOT_SPACE_RESERVE))
8612 inode_add_bytes(inode, number);
8614 @@ -230,6 +236,7 @@ static inline void __dquot_free_space(st
8616 if (!(flags & DQUOT_SPACE_RESERVE))
8617 inode_sub_bytes(inode, number);
8618 + dl_free_space(inode, number);
8621 static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
8622 diff -NurpP --minimal linux-3.6.10/include/linux/reboot.h linux-3.6.10-vs2.3.4.5/include/linux/reboot.h
8623 --- linux-3.6.10/include/linux/reboot.h 2011-10-24 18:45:32.000000000 +0200
8624 +++ linux-3.6.10-vs2.3.4.5/include/linux/reboot.h 2012-10-04 18:47:00.000000000 +0200
8626 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
8627 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
8628 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
8629 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
8633 diff -NurpP --minimal linux-3.6.10/include/linux/sched.h linux-3.6.10-vs2.3.4.5/include/linux/sched.h
8634 --- linux-3.6.10/include/linux/sched.h 2012-10-04 15:27:46.000000000 +0200
8635 +++ linux-3.6.10-vs2.3.4.5/include/linux/sched.h 2012-10-04 18:47:00.000000000 +0200
8636 @@ -1422,6 +1422,14 @@ struct task_struct {
8638 struct seccomp seccomp;
8640 +/* vserver context data */
8641 + struct vx_info *vx_info;
8642 + struct nx_info *nx_info;
8648 /* Thread group tracking */
8651 @@ -1668,6 +1676,11 @@ struct pid_namespace;
8652 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
8653 struct pid_namespace *ns);
8655 +#include <linux/vserver/base.h>
8656 +#include <linux/vserver/context.h>
8657 +#include <linux/vserver/debug.h>
8658 +#include <linux/vserver/pid.h>
8660 static inline pid_t task_pid_nr(struct task_struct *tsk)
8663 @@ -1681,7 +1694,8 @@ static inline pid_t task_pid_nr_ns(struc
8665 static inline pid_t task_pid_vnr(struct task_struct *tsk)
8667 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
8668 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
8669 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
8673 @@ -1694,7 +1708,7 @@ pid_t task_tgid_nr_ns(struct task_struct
8675 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
8677 - return pid_vnr(task_tgid(tsk));
8678 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
8682 diff -NurpP --minimal linux-3.6.10/include/linux/shmem_fs.h linux-3.6.10-vs2.3.4.5/include/linux/shmem_fs.h
8683 --- linux-3.6.10/include/linux/shmem_fs.h 2012-07-22 23:39:44.000000000 +0200
8684 +++ linux-3.6.10-vs2.3.4.5/include/linux/shmem_fs.h 2012-10-04 18:47:00.000000000 +0200
8687 /* inode in-kernel data */
8689 +#define TMPFS_SUPER_MAGIC 0x01021994
8692 struct shmem_inode_info {
8694 unsigned long flags;
8695 diff -NurpP --minimal linux-3.6.10/include/linux/stat.h linux-3.6.10-vs2.3.4.5/include/linux/stat.h
8696 --- linux-3.6.10/include/linux/stat.h 2012-07-22 23:39:44.000000000 +0200
8697 +++ linux-3.6.10-vs2.3.4.5/include/linux/stat.h 2012-10-04 18:47:00.000000000 +0200
8698 @@ -67,6 +67,7 @@ struct kstat {
8705 struct timespec atime;
8706 diff -NurpP --minimal linux-3.6.10/include/linux/sunrpc/auth.h linux-3.6.10-vs2.3.4.5/include/linux/sunrpc/auth.h
8707 --- linux-3.6.10/include/linux/sunrpc/auth.h 2012-10-04 15:27:46.000000000 +0200
8708 +++ linux-3.6.10-vs2.3.4.5/include/linux/sunrpc/auth.h 2012-10-04 18:47:00.000000000 +0200
8714 struct group_info *group_info;
8715 const char *principal;
8716 unsigned char machine_cred : 1;
8717 diff -NurpP --minimal linux-3.6.10/include/linux/sunrpc/clnt.h linux-3.6.10-vs2.3.4.5/include/linux/sunrpc/clnt.h
8718 --- linux-3.6.10/include/linux/sunrpc/clnt.h 2012-05-21 18:07:32.000000000 +0200
8719 +++ linux-3.6.10-vs2.3.4.5/include/linux/sunrpc/clnt.h 2012-10-04 18:47:00.000000000 +0200
8720 @@ -49,7 +49,8 @@ struct rpc_clnt {
8721 unsigned int cl_softrtry : 1,/* soft timeouts */
8722 cl_discrtry : 1,/* disconnect before retry */
8723 cl_autobind : 1,/* use getport() */
8724 - cl_chatty : 1;/* be verbose */
8725 + cl_chatty : 1,/* be verbose */
8726 + cl_tag : 1;/* context tagging */
8728 struct rpc_rtt * cl_rtt; /* RTO estimator data */
8729 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
8730 diff -NurpP --minimal linux-3.6.10/include/linux/sysctl.h linux-3.6.10-vs2.3.4.5/include/linux/sysctl.h
8731 --- linux-3.6.10/include/linux/sysctl.h 2012-05-21 18:07:32.000000000 +0200
8732 +++ linux-3.6.10-vs2.3.4.5/include/linux/sysctl.h 2012-10-04 18:47:00.000000000 +0200
8733 @@ -60,6 +60,7 @@ enum
8734 CTL_ABI=9, /* Binary emulation */
8735 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
8736 CTL_ARLAN=254, /* arlan wireless driver */
8737 + CTL_VSERVER=4242, /* Linux-VServer debug */
8738 CTL_S390DBF=5677, /* s390 debug */
8739 CTL_SUNRPC=7249, /* sunrpc debug */
8740 CTL_PM=9899, /* frv power management */
8741 @@ -94,6 +95,7 @@ enum
8743 KERN_PANIC=15, /* int: panic timeout */
8744 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
8745 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
8747 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
8748 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
8749 diff -NurpP --minimal linux-3.6.10/include/linux/sysfs.h linux-3.6.10-vs2.3.4.5/include/linux/sysfs.h
8750 --- linux-3.6.10/include/linux/sysfs.h 2012-07-22 23:39:44.000000000 +0200
8751 +++ linux-3.6.10-vs2.3.4.5/include/linux/sysfs.h 2012-10-04 18:47:00.000000000 +0200
8753 #include <linux/kobject_ns.h>
8754 #include <linux/atomic.h>
8756 +#define SYSFS_SUPER_MAGIC 0x62656572
8761 diff -NurpP --minimal linux-3.6.10/include/linux/time.h linux-3.6.10-vs2.3.4.5/include/linux/time.h
8762 --- linux-3.6.10/include/linux/time.h 2012-10-04 15:27:46.000000000 +0200
8763 +++ linux-3.6.10-vs2.3.4.5/include/linux/time.h 2012-10-04 18:47:00.000000000 +0200
8764 @@ -280,6 +280,8 @@ static __always_inline void timespec_add
8768 +#include <linux/vs_time.h>
8770 #endif /* __KERNEL__ */
8773 diff -NurpP --minimal linux-3.6.10/include/linux/types.h linux-3.6.10-vs2.3.4.5/include/linux/types.h
8774 --- linux-3.6.10/include/linux/types.h 2012-10-04 15:27:47.000000000 +0200
8775 +++ linux-3.6.10-vs2.3.4.5/include/linux/types.h 2012-10-04 18:47:00.000000000 +0200
8776 @@ -41,6 +41,9 @@ typedef __kernel_uid32_t uid_t;
8777 typedef __kernel_gid32_t gid_t;
8778 typedef __kernel_uid16_t uid16_t;
8779 typedef __kernel_gid16_t gid16_t;
8780 +typedef unsigned int xid_t;
8781 +typedef unsigned int nid_t;
8782 +typedef unsigned int tag_t;
8784 typedef unsigned long uintptr_t;
8786 diff -NurpP --minimal linux-3.6.10/include/linux/utsname.h linux-3.6.10-vs2.3.4.5/include/linux/utsname.h
8787 --- linux-3.6.10/include/linux/utsname.h 2012-01-09 16:14:59.000000000 +0100
8788 +++ linux-3.6.10-vs2.3.4.5/include/linux/utsname.h 2012-10-04 18:47:00.000000000 +0200
8789 @@ -62,7 +62,8 @@ static inline void get_uts_ns(struct uts
8792 extern struct uts_namespace *copy_utsname(unsigned long flags,
8793 - struct task_struct *tsk);
8794 + struct uts_namespace *old_ns,
8795 + struct user_namespace *user_ns);
8796 extern void free_uts_ns(struct kref *kref);
8798 static inline void put_uts_ns(struct uts_namespace *ns)
8799 @@ -79,12 +80,13 @@ static inline void put_uts_ns(struct uts
8802 static inline struct uts_namespace *copy_utsname(unsigned long flags,
8803 - struct task_struct *tsk)
8804 + struct uts_namespace *old_ns,
8805 + struct user_namespace *user_ns)
8807 if (flags & CLONE_NEWUTS)
8808 return ERR_PTR(-EINVAL);
8810 - return tsk->nsproxy->uts_ns;
8815 diff -NurpP --minimal linux-3.6.10/include/linux/vroot.h linux-3.6.10-vs2.3.4.5/include/linux/vroot.h
8816 --- linux-3.6.10/include/linux/vroot.h 1970-01-01 01:00:00.000000000 +0100
8817 +++ linux-3.6.10-vs2.3.4.5/include/linux/vroot.h 2012-10-04 18:47:00.000000000 +0200
8821 + * include/linux/vroot.h
8823 + * written by Herbert Pötzl, 9/11/2002
8824 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
8826 + * Copyright (C) 2002-2007 by Herbert Pötzl.
8827 + * Redistribution of this file is permitted under the
8828 + * GNU General Public License.
8831 +#ifndef _LINUX_VROOT_H
8832 +#define _LINUX_VROOT_H
8837 +/* Possible states of device */
8843 +struct vroot_device {
8847 + struct semaphore vr_ctl_mutex;
8848 + struct block_device *vr_device;
8853 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
8855 +extern int register_vroot_grb(vroot_grb_func *);
8856 +extern int unregister_vroot_grb(vroot_grb_func *);
8858 +#endif /* __KERNEL__ */
8860 +#define MAX_VROOT_DEFAULT 8
8863 + * IOCTL commands --- we will commandeer 0x56 ('V')
8866 +#define VROOT_SET_DEV 0x5600
8867 +#define VROOT_CLR_DEV 0x5601
8869 +#endif /* _LINUX_VROOT_H */
8870 diff -NurpP --minimal linux-3.6.10/include/linux/vs_base.h linux-3.6.10-vs2.3.4.5/include/linux/vs_base.h
8871 --- linux-3.6.10/include/linux/vs_base.h 1970-01-01 01:00:00.000000000 +0100
8872 +++ linux-3.6.10-vs2.3.4.5/include/linux/vs_base.h 2012-10-04 18:47:00.000000000 +0200
8877 +#include "vserver/base.h"
8878 +#include "vserver/check.h"
8879 +#include "vserver/debug.h"
8882 +#warning duplicate inclusion
8884 diff -NurpP --minimal linux-3.6.10/include/linux/vs_context.h linux-3.6.10-vs2.3.4.5/include/linux/vs_context.h
8885 --- linux-3.6.10/include/linux/vs_context.h 1970-01-01 01:00:00.000000000 +0100
8886 +++ linux-3.6.10-vs2.3.4.5/include/linux/vs_context.h 2012-10-04 18:47:00.000000000 +0200
8888 +#ifndef _VS_CONTEXT_H
8889 +#define _VS_CONTEXT_H
8891 +#include "vserver/base.h"
8892 +#include "vserver/check.h"
8893 +#include "vserver/context.h"
8894 +#include "vserver/history.h"
8895 +#include "vserver/debug.h"
8897 +#include <linux/sched.h>
8900 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
8902 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
8903 + const char *_file, int _line, void *_here)
8908 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
8909 + vxi, vxi ? vxi->vx_id : 0,
8910 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8912 + __vxh_get_vx_info(vxi, _here);
8914 + atomic_inc(&vxi->vx_usecnt);
8919 +extern void free_vx_info(struct vx_info *);
8921 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
8923 +static inline void __put_vx_info(struct vx_info *vxi,
8924 + const char *_file, int _line, void *_here)
8929 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
8930 + vxi, vxi ? vxi->vx_id : 0,
8931 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8933 + __vxh_put_vx_info(vxi, _here);
8935 + if (atomic_dec_and_test(&vxi->vx_usecnt))
8936 + free_vx_info(vxi);
8940 +#define init_vx_info(p, i) \
8941 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
8943 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
8944 + const char *_file, int _line, void *_here)
8947 + vxlprintk(VXD_CBIT(xid, 3),
8948 + "init_vx_info(%p[#%d.%d])",
8949 + vxi, vxi ? vxi->vx_id : 0,
8950 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8952 + __vxh_init_vx_info(vxi, vxp, _here);
8954 + atomic_inc(&vxi->vx_usecnt);
8960 +#define set_vx_info(p, i) \
8961 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
8963 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
8964 + const char *_file, int _line, void *_here)
8966 + struct vx_info *vxo;
8971 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
8972 + vxi, vxi ? vxi->vx_id : 0,
8973 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8975 + __vxh_set_vx_info(vxi, vxp, _here);
8977 + atomic_inc(&vxi->vx_usecnt);
8978 + vxo = xchg(vxp, vxi);
8983 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
8985 +static inline void __clr_vx_info(struct vx_info **vxp,
8986 + const char *_file, int _line, void *_here)
8988 + struct vx_info *vxo;
8990 + vxo = xchg(vxp, NULL);
8994 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
8995 + vxo, vxo ? vxo->vx_id : 0,
8996 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
8998 + __vxh_clr_vx_info(vxo, vxp, _here);
9000 + if (atomic_dec_and_test(&vxo->vx_usecnt))
9001 + free_vx_info(vxo);
9005 +#define claim_vx_info(v, p) \
9006 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9008 +static inline void __claim_vx_info(struct vx_info *vxi,
9009 + struct task_struct *task,
9010 + const char *_file, int _line, void *_here)
9012 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
9013 + vxi, vxi ? vxi->vx_id : 0,
9014 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9015 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9016 + task, _file, _line);
9017 + __vxh_claim_vx_info(vxi, task, _here);
9019 + atomic_inc(&vxi->vx_tasks);
9023 +extern void unhash_vx_info(struct vx_info *);
9025 +#define release_vx_info(v, p) \
9026 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9028 +static inline void __release_vx_info(struct vx_info *vxi,
9029 + struct task_struct *task,
9030 + const char *_file, int _line, void *_here)
9032 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
9033 + vxi, vxi ? vxi->vx_id : 0,
9034 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9035 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9036 + task, _file, _line);
9037 + __vxh_release_vx_info(vxi, task, _here);
9041 + if (atomic_dec_and_test(&vxi->vx_tasks))
9042 + unhash_vx_info(vxi);
9046 +#define task_get_vx_info(p) \
9047 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
9049 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
9050 + const char *_file, int _line, void *_here)
9052 + struct vx_info *vxi;
9055 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
9057 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
9063 +static inline void __wakeup_vx_info(struct vx_info *vxi)
9065 + if (waitqueue_active(&vxi->vx_wait))
9066 + wake_up_interruptible(&vxi->vx_wait);
9070 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
9072 +static inline void __enter_vx_info(struct vx_info *vxi,
9073 + struct vx_info_save *vxis, const char *_file, int _line)
9075 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
9076 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
9077 + current->xid, current->vx_info, _file, _line);
9078 + vxis->vxi = xchg(¤t->vx_info, vxi);
9079 + vxis->xid = current->xid;
9080 + current->xid = vxi ? vxi->vx_id : 0;
9083 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
9085 +static inline void __leave_vx_info(struct vx_info_save *vxis,
9086 + const char *_file, int _line)
9088 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
9089 + vxis, vxis->xid, vxis->vxi, current,
9090 + current->xid, current->vx_info, _file, _line);
9091 + (void)xchg(¤t->vx_info, vxis->vxi);
9092 + current->xid = vxis->xid;
9096 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
9098 + vxis->vxi = xchg(¤t->vx_info, NULL);
9099 + vxis->xid = xchg(¤t->xid, (xid_t)0);
9102 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
9104 + (void)xchg(¤t->xid, vxis->xid);
9105 + (void)xchg(¤t->vx_info, vxis->vxi);
9108 +#define task_is_init(p) \
9109 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
9111 +static inline int __task_is_init(struct task_struct *p,
9112 + const char *_file, int _line, void *_here)
9114 + int is_init = is_global_init(p);
9118 + is_init = p->vx_info->vx_initpid == p->pid;
9123 +extern void exit_vx_info(struct task_struct *, int);
9124 +extern void exit_vx_info_early(struct task_struct *, int);
9128 +#warning duplicate inclusion
9130 diff -NurpP --minimal linux-3.6.10/include/linux/vs_cowbl.h linux-3.6.10-vs2.3.4.5/include/linux/vs_cowbl.h
9131 --- linux-3.6.10/include/linux/vs_cowbl.h 1970-01-01 01:00:00.000000000 +0100
9132 +++ linux-3.6.10-vs2.3.4.5/include/linux/vs_cowbl.h 2012-10-04 18:47:00.000000000 +0200
9134 +#ifndef _VS_COWBL_H
9135 +#define _VS_COWBL_H
9137 +#include <linux/fs.h>
9138 +#include <linux/dcache.h>
9139 +#include <linux/namei.h>
9140 +#include <linux/slab.h>
9142 +extern struct dentry *cow_break_link(const char *pathname);
9144 +static inline int cow_check_and_break(struct path *path)
9146 + struct inode *inode = path->dentry->d_inode;
9149 + /* do we need this check? */
9150 + if (IS_RDONLY(inode))
9153 + if (IS_COW(inode)) {
9154 + if (IS_COW_LINK(inode)) {
9155 + struct dentry *new_dentry, *old_dentry = path->dentry;
9158 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
9162 + pp = d_path(path, buf, PATH_MAX);
9163 + new_dentry = cow_break_link(pp);
9165 + if (!IS_ERR(new_dentry)) {
9166 + path->dentry = new_dentry;
9169 + error = PTR_ERR(new_dentry);
9171 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
9172 + inode->i_ctime = CURRENT_TIME;
9173 + mark_inode_dirty(inode);
9180 +#warning duplicate inclusion
9182 diff -NurpP --minimal linux-3.6.10/include/linux/vs_cvirt.h linux-3.6.10-vs2.3.4.5/include/linux/vs_cvirt.h
9183 --- linux-3.6.10/include/linux/vs_cvirt.h 1970-01-01 01:00:00.000000000 +0100
9184 +++ linux-3.6.10-vs2.3.4.5/include/linux/vs_cvirt.h 2012-10-04 18:47:00.000000000 +0200
9186 +#ifndef _VS_CVIRT_H
9187 +#define _VS_CVIRT_H
9189 +#include "vserver/cvirt.h"
9190 +#include "vserver/context.h"
9191 +#include "vserver/base.h"
9192 +#include "vserver/check.h"
9193 +#include "vserver/debug.h"
9196 +static inline void vx_activate_task(struct task_struct *p)
9198 + struct vx_info *vxi;
9200 + if ((vxi = p->vx_info)) {
9201 + vx_update_load(vxi);
9202 + atomic_inc(&vxi->cvirt.nr_running);
9206 +static inline void vx_deactivate_task(struct task_struct *p)
9208 + struct vx_info *vxi;
9210 + if ((vxi = p->vx_info)) {
9211 + vx_update_load(vxi);
9212 + atomic_dec(&vxi->cvirt.nr_running);
9216 +static inline void vx_uninterruptible_inc(struct task_struct *p)
9218 + struct vx_info *vxi;
9220 + if ((vxi = p->vx_info))
9221 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
9224 +static inline void vx_uninterruptible_dec(struct task_struct *p)
9226 + struct vx_info *vxi;
9228 + if ((vxi = p->vx_info))
9229 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
9234 +#warning duplicate inclusion
9236 diff -NurpP --minimal linux-3.6.10/include/linux/vs_device.h linux-3.6.10-vs2.3.4.5/include/linux/vs_device.h
9237 --- linux-3.6.10/include/linux/vs_device.h 1970-01-01 01:00:00.000000000 +0100
9238 +++ linux-3.6.10-vs2.3.4.5/include/linux/vs_device.h 2012-10-04 18:47:00.000000000 +0200
9240 +#ifndef _VS_DEVICE_H
9241 +#define _VS_DEVICE_H
9243 +#include "vserver/base.h"
9244 +#include "vserver/device.h"
9245 +#include "vserver/debug.h"
9248 +#ifdef CONFIG_VSERVER_DEVICE
9250 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
9252 +#define vs_device_perm(v, d, m, p) \
9253 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
9258 +int vs_map_device(struct vx_info *vxi,
9259 + dev_t device, dev_t *target, umode_t mode)
9266 +#define vs_device_perm(v, d, m, p) ((p) == (p))
9271 +#define vs_map_chrdev(d, t, p) \
9272 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
9273 +#define vs_map_blkdev(d, t, p) \
9274 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
9276 +#define vs_chrdev_perm(d, p) \
9277 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
9278 +#define vs_blkdev_perm(d, p) \
9279 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
9283 +#warning duplicate inclusion
9285 diff -NurpP --minimal linux-3.6.10/include/linux/vs_dlimit.h linux-3.6.10-vs2.3.4.5/include/linux/vs_dlimit.h
9286 --- linux-3.6.10/include/linux/vs_dlimit.h 1970-01-01 01:00:00.000000000 +0100
9287 +++ linux-3.6.10-vs2.3.4.5/include/linux/vs_dlimit.h 2012-10-04 18:47:00.000000000 +0200
9289 +#ifndef _VS_DLIMIT_H
9290 +#define _VS_DLIMIT_H
9292 +#include <linux/fs.h>
9294 +#include "vserver/dlimit.h"
9295 +#include "vserver/base.h"
9296 +#include "vserver/debug.h"
9299 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
9301 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
9302 + const char *_file, int _line)
9306 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
9307 + dli, dli ? dli->dl_tag : 0,
9308 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9310 + atomic_inc(&dli->dl_usecnt);
9315 +#define free_dl_info(i) \
9316 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
9318 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
9320 +static inline void __put_dl_info(struct dl_info *dli,
9321 + const char *_file, int _line)
9325 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
9326 + dli, dli ? dli->dl_tag : 0,
9327 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9329 + if (atomic_dec_and_test(&dli->dl_usecnt))
9330 + free_dl_info(dli);
9334 +#define __dlimit_char(d) ((d) ? '*' : ' ')
9336 +static inline int __dl_alloc_space(struct super_block *sb,
9337 + tag_t tag, dlsize_t nr, const char *file, int line)
9339 + struct dl_info *dli = NULL;
9344 + dli = locate_dl_info(sb, tag);
9348 + spin_lock(&dli->dl_lock);
9349 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
9351 + dli->dl_space_used += nr;
9352 + spin_unlock(&dli->dl_lock);
9355 + vxlprintk(VXD_CBIT(dlim, 1),
9356 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
9357 + sb, tag, __dlimit_char(dli), (long long)nr,
9359 + return ret ? -ENOSPC : 0;
9362 +static inline void __dl_free_space(struct super_block *sb,
9363 + tag_t tag, dlsize_t nr, const char *_file, int _line)
9365 + struct dl_info *dli = NULL;
9369 + dli = locate_dl_info(sb, tag);
9373 + spin_lock(&dli->dl_lock);
9374 + if (dli->dl_space_used > nr)
9375 + dli->dl_space_used -= nr;
9377 + dli->dl_space_used = 0;
9378 + spin_unlock(&dli->dl_lock);
9381 + vxlprintk(VXD_CBIT(dlim, 1),
9382 + "FREE (%p,#%d)%c %lld bytes",
9383 + sb, tag, __dlimit_char(dli), (long long)nr,
9387 +static inline int __dl_alloc_inode(struct super_block *sb,
9388 + tag_t tag, const char *_file, int _line)
9390 + struct dl_info *dli;
9393 + dli = locate_dl_info(sb, tag);
9397 + spin_lock(&dli->dl_lock);
9398 + dli->dl_inodes_used++;
9399 + ret = (dli->dl_inodes_used > dli->dl_inodes_total);
9400 + spin_unlock(&dli->dl_lock);
9403 + vxlprintk(VXD_CBIT(dlim, 0),
9404 + "ALLOC (%p,#%d)%c inode (%d)",
9405 + sb, tag, __dlimit_char(dli), ret, _file, _line);
9406 + return ret ? -ENOSPC : 0;
9409 +static inline void __dl_free_inode(struct super_block *sb,
9410 + tag_t tag, const char *_file, int _line)
9412 + struct dl_info *dli;
9414 + dli = locate_dl_info(sb, tag);
9418 + spin_lock(&dli->dl_lock);
9419 + if (dli->dl_inodes_used > 1)
9420 + dli->dl_inodes_used--;
9422 + dli->dl_inodes_used = 0;
9423 + spin_unlock(&dli->dl_lock);
9426 + vxlprintk(VXD_CBIT(dlim, 0),
9427 + "FREE (%p,#%d)%c inode",
9428 + sb, tag, __dlimit_char(dli), _file, _line);
9431 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
9432 + unsigned long long *free_blocks, unsigned long long *root_blocks,
9433 + const char *_file, int _line)
9435 + struct dl_info *dli;
9436 + uint64_t broot, bfree;
9438 + dli = locate_dl_info(sb, tag);
9442 + spin_lock(&dli->dl_lock);
9443 + broot = (dli->dl_space_total -
9444 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
9445 + >> sb->s_blocksize_bits;
9446 + bfree = (dli->dl_space_total - dli->dl_space_used)
9447 + >> sb->s_blocksize_bits;
9448 + spin_unlock(&dli->dl_lock);
9450 + vxlprintk(VXD_CBIT(dlim, 2),
9451 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
9452 + (long long)bfree, (long long)broot,
9453 + *free_blocks, *root_blocks, dli->dl_nrlmult,
9455 + if (free_blocks) {
9456 + if (*free_blocks > bfree)
9457 + *free_blocks = bfree;
9459 + if (root_blocks) {
9460 + if (*root_blocks > broot)
9461 + *root_blocks = broot;
9466 +#define dl_prealloc_space(in, bytes) \
9467 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9468 + __FILE__, __LINE__ )
9470 +#define dl_alloc_space(in, bytes) \
9471 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9472 + __FILE__, __LINE__ )
9474 +#define dl_reserve_space(in, bytes) \
9475 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9476 + __FILE__, __LINE__ )
9478 +#define dl_claim_space(in, bytes) (0)
9480 +#define dl_release_space(in, bytes) \
9481 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9482 + __FILE__, __LINE__ )
9484 +#define dl_free_space(in, bytes) \
9485 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9486 + __FILE__, __LINE__ )
9490 +#define dl_alloc_inode(in) \
9491 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
9493 +#define dl_free_inode(in) \
9494 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
9497 +#define dl_adjust_block(sb, tag, fb, rb) \
9498 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
9502 +#warning duplicate inclusion
9504 diff -NurpP --minimal linux-3.6.10/include/linux/vs_inet.h linux-3.6.10-vs2.3.4.5/include/linux/vs_inet.h
9505 --- linux-3.6.10/include/linux/vs_inet.h 1970-01-01 01:00:00.000000000 +0100
9506 +++ linux-3.6.10-vs2.3.4.5/include/linux/vs_inet.h 2012-10-04 18:47:00.000000000 +0200
9511 +#include "vserver/base.h"
9512 +#include "vserver/network.h"
9513 +#include "vserver/debug.h"
9515 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
9517 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
9518 + NIPQUAD((a)->mask), (a)->type
9519 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
9521 +#define NIPQUAD(addr) \
9522 + ((unsigned char *)&addr)[0], \
9523 + ((unsigned char *)&addr)[1], \
9524 + ((unsigned char *)&addr)[2], \
9525 + ((unsigned char *)&addr)[3]
9527 +#define NIPQUAD_FMT "%u.%u.%u.%u"
9531 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
9533 + __be32 ip = nxa->ip[0].s_addr;
9534 + __be32 mask = nxa->mask.s_addr;
9535 + __be32 bcast = ip | ~mask;
9538 + switch (nxa->type & tmask) {
9539 + case NXA_TYPE_MASK:
9540 + ret = (ip == (addr & mask));
9542 + case NXA_TYPE_ADDR:
9546 + /* fall through to broadcast */
9547 + case NXA_MOD_BCAST:
9548 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
9550 + case NXA_TYPE_RANGE:
9551 + ret = ((nxa->ip[0].s_addr <= addr) &&
9552 + (nxa->ip[1].s_addr > addr));
9554 + case NXA_TYPE_ANY:
9559 + vxdprintk(VXD_CBIT(net, 0),
9560 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
9561 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
9566 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
9568 + struct nx_addr_v4 *nxa;
9575 + /* allow 127.0.0.1 when remapping lback */
9576 + if ((tmask & NXA_LOOPBACK) &&
9577 + (addr == IPI_LOOPBACK) &&
9578 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9581 + /* check for lback address */
9582 + if ((tmask & NXA_MOD_LBACK) &&
9583 + (nxi->v4_lback.s_addr == addr))
9586 + /* check for broadcast address */
9587 + if ((tmask & NXA_MOD_BCAST) &&
9588 + (nxi->v4_bcast.s_addr == addr))
9591 + /* check for v4 addresses */
9592 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
9593 + if (v4_addr_match(nxa, addr, tmask))
9597 + vxdprintk(VXD_CBIT(net, 0),
9598 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
9599 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
9604 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
9606 + /* FIXME: needs full range checks */
9607 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
9611 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
9613 + struct nx_addr_v4 *ptr;
9615 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
9616 + if (v4_nx_addr_match(ptr, nxa, mask))
9621 +#include <net/inet_sock.h>
9624 + * Check if a given address matches for a socket
9626 + * nxi: the socket's nx_info if any
9627 + * addr: to be verified address
9630 +int v4_sock_addr_match (
9631 + struct nx_info *nxi,
9632 + struct inet_sock *inet,
9635 + __be32 saddr = inet->inet_rcv_saddr;
9636 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
9638 + if (addr && (saddr == addr || bcast == addr))
9641 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
9646 +/* inet related checks and helpers */
9655 +#include <linux/netdevice.h>
9656 +#include <linux/inetdevice.h>
9657 +#include <net/inet_sock.h>
9658 +#include <net/inet_timewait_sock.h>
9661 +int dev_in_nx_info(struct net_device *, struct nx_info *);
9662 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
9663 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
9667 + * check if address is covered by socket
9669 + * sk: the socket to check against
9670 + * addr: the address in question (must be != 0)
9674 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
9676 + struct nx_info *nxi = sk->sk_nx_info;
9677 + __be32 saddr = sk_rcv_saddr(sk);
9679 + vxdprintk(VXD_CBIT(net, 5),
9680 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
9681 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
9682 + (sk->sk_socket?sk->sk_socket->flags:0));
9684 + if (saddr) { /* direct address match */
9685 + return v4_addr_match(nxa, saddr, -1);
9686 + } else if (nxi) { /* match against nx_info */
9687 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
9688 + } else { /* unrestricted any socket */
9696 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
9698 + vxdprintk(VXD_CBIT(net, 1),
9699 + "nx_dev_visible(%p[#%u],%p " VS_Q("%s") ") %d",
9700 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
9701 + nxi ? dev_in_nx_info(dev, nxi) : 0);
9703 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9705 + if (dev_in_nx_info(dev, nxi))
9712 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
9718 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
9722 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
9724 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
9725 + nxi, nxi ? nxi->nx_id : 0, ifa,
9726 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
9728 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9730 + if (v4_ifa_in_nx_info(ifa, nxi))
9736 +struct nx_v4_sock_addr {
9737 + __be32 saddr; /* Address used for validation */
9738 + __be32 baddr; /* Address used for socket bind */
9742 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
9743 + struct nx_v4_sock_addr *nsa)
9745 + struct sock *sk = &inet->sk;
9746 + struct nx_info *nxi = sk->sk_nx_info;
9747 + __be32 saddr = addr->sin_addr.s_addr;
9748 + __be32 baddr = saddr;
9750 + vxdprintk(VXD_CBIT(net, 3),
9751 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
9752 + sk, sk->sk_nx_info, sk->sk_socket,
9753 + (sk->sk_socket ? sk->sk_socket->flags : 0),
9757 + if (saddr == INADDR_ANY) {
9758 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
9759 + baddr = nxi->v4.ip[0].s_addr;
9760 + } else if (saddr == IPI_LOOPBACK) {
9761 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9762 + baddr = nxi->v4_lback.s_addr;
9763 + } else if (!ipv4_is_multicast(saddr) ||
9764 + !nx_info_ncaps(nxi, NXC_MULTICAST)) {
9765 + /* normal address bind */
9766 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
9767 + return -EADDRNOTAVAIL;
9771 + vxdprintk(VXD_CBIT(net, 3),
9772 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
9773 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
9775 + nsa->saddr = saddr;
9776 + nsa->baddr = baddr;
9781 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
9783 + inet->inet_saddr = nsa->baddr;
9784 + inet->inet_rcv_saddr = nsa->baddr;
9789 + * helper to simplify inet_lookup_listener
9791 + * nxi: the socket's nx_info if any
9792 + * addr: to be verified address
9793 + * saddr: socket address
9795 +static inline int v4_inet_addr_match (
9796 + struct nx_info *nxi,
9800 + if (addr && (saddr == addr))
9803 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
9807 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
9809 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
9810 + (addr == nxi->v4_lback.s_addr))
9811 + return IPI_LOOPBACK;
9816 +int nx_info_has_v4(struct nx_info *nxi)
9822 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9827 +#else /* CONFIG_INET */
9830 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
9836 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
9842 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
9848 +int nx_info_has_v4(struct nx_info *nxi)
9853 +#endif /* CONFIG_INET */
9855 +#define current_nx_info_has_v4() \
9856 + nx_info_has_v4(current_nx_info())
9859 +// #warning duplicate inclusion
9861 diff -NurpP --minimal linux-3.6.10/include/linux/vs_inet6.h linux-3.6.10-vs2.3.4.5/include/linux/vs_inet6.h
9862 --- linux-3.6.10/include/linux/vs_inet6.h 1970-01-01 01:00:00.000000000 +0100
9863 +++ linux-3.6.10-vs2.3.4.5/include/linux/vs_inet6.h 2012-10-04 18:47:00.000000000 +0200
9865 +#ifndef _VS_INET6_H
9866 +#define _VS_INET6_H
9868 +#include "vserver/base.h"
9869 +#include "vserver/network.h"
9870 +#include "vserver/debug.h"
9872 +#include <net/ipv6.h>
9874 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
9875 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
9881 +int v6_addr_match(struct nx_addr_v6 *nxa,
9882 + const struct in6_addr *addr, uint16_t mask)
9886 + switch (nxa->type & mask) {
9887 + case NXA_TYPE_MASK:
9888 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
9890 + case NXA_TYPE_ADDR:
9891 + ret = ipv6_addr_equal(&nxa->ip, addr);
9893 + case NXA_TYPE_ANY:
9897 + vxdprintk(VXD_CBIT(net, 0),
9898 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
9899 + nxa, NXAV6(nxa), addr, mask, ret);
9904 +int v6_addr_in_nx_info(struct nx_info *nxi,
9905 + const struct in6_addr *addr, uint16_t mask)
9907 + struct nx_addr_v6 *nxa;
9912 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
9913 + if (v6_addr_match(nxa, addr, mask))
9917 + vxdprintk(VXD_CBIT(net, 0),
9918 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
9919 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
9924 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
9926 + /* FIXME: needs full range checks */
9927 + return v6_addr_match(nxa, &addr->ip, mask);
9931 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
9933 + struct nx_addr_v6 *ptr;
9935 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
9936 + if (v6_nx_addr_match(ptr, nxa, mask))
9943 + * Check if a given address matches for a socket
9945 + * nxi: the socket's nx_info if any
9946 + * addr: to be verified address
9949 +int v6_sock_addr_match (
9950 + struct nx_info *nxi,
9951 + struct inet_sock *inet,
9952 + struct in6_addr *addr)
9954 + struct sock *sk = &inet->sk;
9955 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
9957 + if (!ipv6_addr_any(addr) &&
9958 + ipv6_addr_equal(saddr, addr))
9960 + if (ipv6_addr_any(saddr))
9961 + return v6_addr_in_nx_info(nxi, addr, -1);
9966 + * check if address is covered by socket
9968 + * sk: the socket to check against
9969 + * addr: the address in question (must be != 0)
9973 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
9975 + struct nx_info *nxi = sk->sk_nx_info;
9976 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
9978 + vxdprintk(VXD_CBIT(net, 5),
9979 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
9980 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
9981 + (sk->sk_socket?sk->sk_socket->flags:0));
9983 + if (!ipv6_addr_any(saddr)) { /* direct address match */
9984 + return v6_addr_match(nxa, saddr, -1);
9985 + } else if (nxi) { /* match against nx_info */
9986 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
9987 + } else { /* unrestricted any socket */
9993 +/* inet related checks and helpers */
10001 +#include <linux/netdevice.h>
10002 +#include <linux/inetdevice.h>
10003 +#include <net/inet_timewait_sock.h>
10006 +int dev_in_nx_info(struct net_device *, struct nx_info *);
10007 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
10008 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
10013 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
10019 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
10023 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
10025 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
10026 + nxi, nxi ? nxi->nx_id : 0, ifa,
10027 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
10029 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
10031 + if (v6_ifa_in_nx_info(ifa, nxi))
10037 +struct nx_v6_sock_addr {
10038 + struct in6_addr saddr; /* Address used for validation */
10039 + struct in6_addr baddr; /* Address used for socket bind */
10043 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
10044 + struct nx_v6_sock_addr *nsa)
10046 + // struct sock *sk = &inet->sk;
10047 + // struct nx_info *nxi = sk->sk_nx_info;
10048 + struct in6_addr saddr = addr->sin6_addr;
10049 + struct in6_addr baddr = saddr;
10051 + nsa->saddr = saddr;
10052 + nsa->baddr = baddr;
10057 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
10059 + // struct sock *sk = &inet->sk;
10060 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
10062 + // *saddr = nsa->baddr;
10063 + // inet->inet_saddr = nsa->baddr;
10067 +int nx_info_has_v6(struct nx_info *nxi)
10071 + if (NX_IPV6(nxi))
10076 +#else /* CONFIG_IPV6 */
10079 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
10086 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
10092 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
10098 +int nx_info_has_v6(struct nx_info *nxi)
10103 +#endif /* CONFIG_IPV6 */
10105 +#define current_nx_info_has_v6() \
10106 + nx_info_has_v6(current_nx_info())
10109 +#warning duplicate inclusion
10111 diff -NurpP --minimal linux-3.6.10/include/linux/vs_limit.h linux-3.6.10-vs2.3.4.5/include/linux/vs_limit.h
10112 --- linux-3.6.10/include/linux/vs_limit.h 1970-01-01 01:00:00.000000000 +0100
10113 +++ linux-3.6.10-vs2.3.4.5/include/linux/vs_limit.h 2012-10-04 18:47:00.000000000 +0200
10115 +#ifndef _VS_LIMIT_H
10116 +#define _VS_LIMIT_H
10118 +#include "vserver/limit.h"
10119 +#include "vserver/base.h"
10120 +#include "vserver/context.h"
10121 +#include "vserver/debug.h"
10122 +#include "vserver/context.h"
10123 +#include "vserver/limit_int.h"
10126 +#define vx_acc_cres(v, d, p, r) \
10127 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
10129 +#define vx_acc_cres_cond(x, d, p, r) \
10130 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
10131 + r, d, p, __FILE__, __LINE__)
10134 +#define vx_add_cres(v, a, p, r) \
10135 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
10136 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
10138 +#define vx_add_cres_cond(x, a, p, r) \
10139 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
10140 + r, a, p, __FILE__, __LINE__)
10141 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
10144 +/* process and file limits */
10146 +#define vx_nproc_inc(p) \
10147 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
10149 +#define vx_nproc_dec(p) \
10150 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
10152 +#define vx_files_inc(f) \
10153 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
10155 +#define vx_files_dec(f) \
10156 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
10158 +#define vx_locks_inc(l) \
10159 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
10161 +#define vx_locks_dec(l) \
10162 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
10164 +#define vx_openfd_inc(f) \
10165 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
10167 +#define vx_openfd_dec(f) \
10168 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
10171 +#define vx_cres_avail(v, n, r) \
10172 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
10175 +#define vx_nproc_avail(n) \
10176 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
10178 +#define vx_files_avail(n) \
10179 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
10181 +#define vx_locks_avail(n) \
10182 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
10184 +#define vx_openfd_avail(n) \
10185 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
10188 +/* dentry limits */
10190 +#define vx_dentry_inc(d) do { \
10191 + if ((d)->d_count == 1) \
10192 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
10195 +#define vx_dentry_dec(d) do { \
10196 + if ((d)->d_count == 0) \
10197 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
10200 +#define vx_dentry_avail(n) \
10201 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
10204 +/* socket limits */
10206 +#define vx_sock_inc(s) \
10207 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
10209 +#define vx_sock_dec(s) \
10210 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
10212 +#define vx_sock_avail(n) \
10213 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
10216 +/* ipc resource limits */
10218 +#define vx_ipcmsg_add(v, u, a) \
10219 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
10221 +#define vx_ipcmsg_sub(v, u, a) \
10222 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
10224 +#define vx_ipcmsg_avail(v, a) \
10225 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
10228 +#define vx_ipcshm_add(v, k, a) \
10229 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
10231 +#define vx_ipcshm_sub(v, k, a) \
10232 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
10234 +#define vx_ipcshm_avail(v, a) \
10235 + vx_cres_avail(v, a, VLIMIT_SHMEM)
10238 +#define vx_semary_inc(a) \
10239 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
10241 +#define vx_semary_dec(a) \
10242 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
10245 +#define vx_nsems_add(a,n) \
10246 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10248 +#define vx_nsems_sub(a,n) \
10249 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10253 +#warning duplicate inclusion
10255 diff -NurpP --minimal linux-3.6.10/include/linux/vs_network.h linux-3.6.10-vs2.3.4.5/include/linux/vs_network.h
10256 --- linux-3.6.10/include/linux/vs_network.h 1970-01-01 01:00:00.000000000 +0100
10257 +++ linux-3.6.10-vs2.3.4.5/include/linux/vs_network.h 2012-10-04 18:47:00.000000000 +0200
10259 +#ifndef _NX_VS_NETWORK_H
10260 +#define _NX_VS_NETWORK_H
10262 +#include "vserver/context.h"
10263 +#include "vserver/network.h"
10264 +#include "vserver/base.h"
10265 +#include "vserver/check.h"
10266 +#include "vserver/debug.h"
10268 +#include <linux/sched.h>
10271 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
10273 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
10274 + const char *_file, int _line)
10279 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
10280 + nxi, nxi ? nxi->nx_id : 0,
10281 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10284 + atomic_inc(&nxi->nx_usecnt);
10289 +extern void free_nx_info(struct nx_info *);
10291 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
10293 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
10298 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
10299 + nxi, nxi ? nxi->nx_id : 0,
10300 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10303 + if (atomic_dec_and_test(&nxi->nx_usecnt))
10304 + free_nx_info(nxi);
10308 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
10310 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
10311 + const char *_file, int _line)
10314 + vxlprintk(VXD_CBIT(nid, 3),
10315 + "init_nx_info(%p[#%d.%d])",
10316 + nxi, nxi ? nxi->nx_id : 0,
10317 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10320 + atomic_inc(&nxi->nx_usecnt);
10326 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
10328 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
10329 + const char *_file, int _line)
10331 + struct nx_info *nxo;
10336 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
10337 + nxi, nxi ? nxi->nx_id : 0,
10338 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10341 + atomic_inc(&nxi->nx_usecnt);
10342 + nxo = xchg(nxp, nxi);
10346 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
10348 +static inline void __clr_nx_info(struct nx_info **nxp,
10349 + const char *_file, int _line)
10351 + struct nx_info *nxo;
10353 + nxo = xchg(nxp, NULL);
10357 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
10358 + nxo, nxo ? nxo->nx_id : 0,
10359 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
10362 + if (atomic_dec_and_test(&nxo->nx_usecnt))
10363 + free_nx_info(nxo);
10367 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
10369 +static inline void __claim_nx_info(struct nx_info *nxi,
10370 + struct task_struct *task, const char *_file, int _line)
10372 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
10373 + nxi, nxi ? nxi->nx_id : 0,
10374 + nxi?atomic_read(&nxi->nx_usecnt):0,
10375 + nxi?atomic_read(&nxi->nx_tasks):0,
10376 + task, _file, _line);
10378 + atomic_inc(&nxi->nx_tasks);
10382 +extern void unhash_nx_info(struct nx_info *);
10384 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
10386 +static inline void __release_nx_info(struct nx_info *nxi,
10387 + struct task_struct *task, const char *_file, int _line)
10389 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
10390 + nxi, nxi ? nxi->nx_id : 0,
10391 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10392 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
10393 + task, _file, _line);
10397 + if (atomic_dec_and_test(&nxi->nx_tasks))
10398 + unhash_nx_info(nxi);
10402 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
10404 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
10405 + const char *_file, int _line)
10407 + struct nx_info *nxi;
10410 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
10411 + p, _file, _line);
10412 + nxi = __get_nx_info(p->nx_info, _file, _line);
10418 +static inline void exit_nx_info(struct task_struct *p)
10421 + release_nx_info(p->nx_info, p);
10426 +#warning duplicate inclusion
10428 diff -NurpP --minimal linux-3.6.10/include/linux/vs_pid.h linux-3.6.10-vs2.3.4.5/include/linux/vs_pid.h
10429 --- linux-3.6.10/include/linux/vs_pid.h 1970-01-01 01:00:00.000000000 +0100
10430 +++ linux-3.6.10-vs2.3.4.5/include/linux/vs_pid.h 2012-10-04 18:47:00.000000000 +0200
10435 +#include "vserver/base.h"
10436 +#include "vserver/check.h"
10437 +#include "vserver/context.h"
10438 +#include "vserver/debug.h"
10439 +#include "vserver/pid.h"
10440 +#include <linux/pid_namespace.h>
10443 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
10446 +int vx_proc_task_visible(struct task_struct *task)
10448 + if ((task->pid == 1) &&
10449 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
10450 + /* show a blend through init */
10452 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
10459 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
10463 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
10465 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
10467 + if (task && !vx_proc_task_visible(task)) {
10468 + vxdprintk(VXD_CBIT(misc, 6),
10469 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
10470 + task, task->xid, task->pid,
10471 + current, current->xid, current->pid);
10472 + put_task_struct(task);
10480 +#warning duplicate inclusion
10482 diff -NurpP --minimal linux-3.6.10/include/linux/vs_sched.h linux-3.6.10-vs2.3.4.5/include/linux/vs_sched.h
10483 --- linux-3.6.10/include/linux/vs_sched.h 1970-01-01 01:00:00.000000000 +0100
10484 +++ linux-3.6.10-vs2.3.4.5/include/linux/vs_sched.h 2012-10-04 18:47:00.000000000 +0200
10486 +#ifndef _VS_SCHED_H
10487 +#define _VS_SCHED_H
10489 +#include "vserver/base.h"
10490 +#include "vserver/context.h"
10491 +#include "vserver/sched.h"
10494 +#define MAX_PRIO_BIAS 20
10495 +#define MIN_PRIO_BIAS -20
10498 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
10500 + struct vx_info *vxi = p->vx_info;
10503 + prio += vx_cpu(vxi, sched_pc).prio_bias;
10507 +static inline void vx_account_user(struct vx_info *vxi,
10508 + cputime_t cputime, int nice)
10512 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
10515 +static inline void vx_account_system(struct vx_info *vxi,
10516 + cputime_t cputime, int idle)
10520 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
10524 +#warning duplicate inclusion
10526 diff -NurpP --minimal linux-3.6.10/include/linux/vs_socket.h linux-3.6.10-vs2.3.4.5/include/linux/vs_socket.h
10527 --- linux-3.6.10/include/linux/vs_socket.h 1970-01-01 01:00:00.000000000 +0100
10528 +++ linux-3.6.10-vs2.3.4.5/include/linux/vs_socket.h 2012-10-04 18:47:00.000000000 +0200
10530 +#ifndef _VS_SOCKET_H
10531 +#define _VS_SOCKET_H
10533 +#include "vserver/debug.h"
10534 +#include "vserver/base.h"
10535 +#include "vserver/cacct.h"
10536 +#include "vserver/context.h"
10537 +#include "vserver/tag.h"
10540 +/* socket accounting */
10542 +#include <linux/socket.h>
10544 +static inline int vx_sock_type(int family)
10546 + switch (family) {
10548 + return VXA_SOCK_UNSPEC;
10550 + return VXA_SOCK_UNIX;
10552 + return VXA_SOCK_INET;
10554 + return VXA_SOCK_INET6;
10556 + return VXA_SOCK_PACKET;
10558 + return VXA_SOCK_OTHER;
10562 +#define vx_acc_sock(v, f, p, s) \
10563 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
10565 +static inline void __vx_acc_sock(struct vx_info *vxi,
10566 + int family, int pos, int size, char *file, int line)
10569 + int type = vx_sock_type(family);
10571 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
10572 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
10576 +#define vx_sock_recv(sk, s) \
10577 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
10578 +#define vx_sock_send(sk, s) \
10579 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
10580 +#define vx_sock_fail(sk, s) \
10581 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
10584 +#define sock_vx_init(s) do { \
10585 + (s)->sk_xid = 0; \
10586 + (s)->sk_vx_info = NULL; \
10589 +#define sock_nx_init(s) do { \
10590 + (s)->sk_nid = 0; \
10591 + (s)->sk_nx_info = NULL; \
10595 +#warning duplicate inclusion
10597 diff -NurpP --minimal linux-3.6.10/include/linux/vs_tag.h linux-3.6.10-vs2.3.4.5/include/linux/vs_tag.h
10598 --- linux-3.6.10/include/linux/vs_tag.h 1970-01-01 01:00:00.000000000 +0100
10599 +++ linux-3.6.10-vs2.3.4.5/include/linux/vs_tag.h 2012-10-04 18:47:00.000000000 +0200
10604 +#include <linux/vserver/tag.h>
10606 +/* check conditions */
10608 +#define DX_ADMIN 0x0001
10609 +#define DX_WATCH 0x0002
10610 +#define DX_HOSTID 0x0008
10612 +#define DX_IDENT 0x0010
10614 +#define DX_ARG_MASK 0x0010
10617 +#define dx_task_tag(t) ((t)->tag)
10619 +#define dx_current_tag() dx_task_tag(current)
10621 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
10623 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
10627 + * check current context for ADMIN/WATCH and
10628 + * optionally against supplied argument
10630 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
10632 + if (mode & DX_ARG_MASK) {
10633 + if ((mode & DX_IDENT) && (id == cid))
10636 + return (((mode & DX_ADMIN) && (cid == 0)) ||
10637 + ((mode & DX_WATCH) && (cid == 1)) ||
10638 + ((mode & DX_HOSTID) && (id == 0)));
10642 +int dx_permission(const struct inode *inode, int mask);
10646 +#warning duplicate inclusion
10648 diff -NurpP --minimal linux-3.6.10/include/linux/vs_time.h linux-3.6.10-vs2.3.4.5/include/linux/vs_time.h
10649 --- linux-3.6.10/include/linux/vs_time.h 1970-01-01 01:00:00.000000000 +0100
10650 +++ linux-3.6.10-vs2.3.4.5/include/linux/vs_time.h 2012-10-04 18:47:00.000000000 +0200
10652 +#ifndef _VS_TIME_H
10653 +#define _VS_TIME_H
10656 +/* time faking stuff */
10658 +#ifdef CONFIG_VSERVER_VTIME
10660 +extern void vx_adjust_timespec(struct timespec *ts);
10661 +extern int vx_settimeofday(const struct timespec *ts);
10664 +#define vx_adjust_timespec(t) do { } while (0)
10665 +#define vx_settimeofday(t) do_settimeofday(t)
10669 +#warning duplicate inclusion
10671 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/Kbuild linux-3.6.10-vs2.3.4.5/include/linux/vserver/Kbuild
10672 --- linux-3.6.10/include/linux/vserver/Kbuild 1970-01-01 01:00:00.000000000 +0100
10673 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/Kbuild 2012-10-04 18:47:00.000000000 +0200
10676 +header-y += context_cmd.h network_cmd.h space_cmd.h \
10677 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
10678 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
10679 + debug_cmd.h device_cmd.h
10681 +header-y += switch.h network.h monitor.h inode.h device.h
10683 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/base.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/base.h
10684 --- linux-3.6.10/include/linux/vserver/base.h 1970-01-01 01:00:00.000000000 +0100
10685 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/base.h 2012-10-04 18:47:00.000000000 +0200
10687 +#ifndef _VX_BASE_H
10688 +#define _VX_BASE_H
10691 +/* context state changes */
10703 +#define vx_task_xid(t) ((t)->xid)
10705 +#define vx_current_xid() vx_task_xid(current)
10707 +#define current_vx_info() (current->vx_info)
10710 +#define nx_task_nid(t) ((t)->nid)
10712 +#define nx_current_nid() nx_task_nid(current)
10714 +#define current_nx_info() (current->nx_info)
10717 +/* generic flag merging */
10719 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
10721 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
10723 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
10725 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
10728 +/* context flags */
10730 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
10732 +#define vx_current_flags() __vx_flags(current_vx_info())
10734 +#define vx_info_flags(v, m, f) \
10735 + vs_check_flags(__vx_flags(v), m, f)
10737 +#define task_vx_flags(t, m, f) \
10738 + ((t) && vx_info_flags((t)->vx_info, m, f))
10740 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
10743 +/* context caps */
10745 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
10747 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
10749 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
10751 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
10755 +/* network flags */
10757 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
10759 +#define nx_current_flags() __nx_flags(current_nx_info())
10761 +#define nx_info_flags(n, m, f) \
10762 + vs_check_flags(__nx_flags(n), m, f)
10764 +#define task_nx_flags(t, m, f) \
10765 + ((t) && nx_info_flags((t)->nx_info, m, f))
10767 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
10770 +/* network caps */
10772 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
10774 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
10776 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
10778 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
10781 +/* context mask capabilities */
10783 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
10785 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
10787 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
10790 +/* context bcap mask */
10792 +#define __vx_bcaps(v) ((v)->vx_bcaps)
10794 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
10797 +/* mask given bcaps */
10799 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
10801 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
10804 +/* masked cap_bset */
10806 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
10808 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
10811 +#define vx_info_mbcap(v, b) \
10812 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
10813 + vx_info_bcaps(v, b) : (b))
10815 +#define task_vx_mbcap(t, b) \
10816 + vx_info_mbcap((t)->vx_info, (t)->b)
10818 +#define vx_mbcap(b) task_vx_mbcap(current, b)
10821 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
10823 +#define vx_capable(b, c) (capable(b) || \
10824 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10826 +#define vx_ns_capable(n, b, c) (ns_capable(n, b) || \
10827 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10829 +#define nx_capable(b, c) (capable(b) || \
10830 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
10832 +#define vx_task_initpid(t, n) \
10833 + ((t)->vx_info && \
10834 + ((t)->vx_info->vx_initpid == (n)))
10836 +#define vx_current_initpid(n) vx_task_initpid(current, n)
10839 +/* context unshare mask */
10841 +#define __vx_umask(v) ((v)->vx_umask)
10843 +#define vx_current_umask() __vx_umask(current_vx_info())
10845 +#define vx_can_unshare(b, f) (capable(b) || \
10846 + (cap_raised(current_cap(), b) && \
10847 + !((f) & ~vx_current_umask())))
10850 +#define __vx_wmask(v) ((v)->vx_wmask)
10852 +#define vx_current_wmask() __vx_wmask(current_vx_info())
10855 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
10857 +#define vx_info_state(v, m) (__vx_state(v) & (m))
10860 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
10862 +#define nx_info_state(n, m) (__nx_state(n) & (m))
10865 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/cacct.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/cacct.h
10866 --- linux-3.6.10/include/linux/vserver/cacct.h 1970-01-01 01:00:00.000000000 +0100
10867 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/cacct.h 2012-10-04 18:47:00.000000000 +0200
10869 +#ifndef _VX_CACCT_H
10870 +#define _VX_CACCT_H
10873 +enum sock_acc_field {
10874 + VXA_SOCK_UNSPEC = 0,
10880 + VXA_SOCK_SIZE /* array size */
10883 +#endif /* _VX_CACCT_H */
10884 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/cacct_cmd.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/cacct_cmd.h
10885 --- linux-3.6.10/include/linux/vserver/cacct_cmd.h 1970-01-01 01:00:00.000000000 +0100
10886 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/cacct_cmd.h 2012-10-04 18:47:00.000000000 +0200
10888 +#ifndef _VX_CACCT_CMD_H
10889 +#define _VX_CACCT_CMD_H
10892 +/* virtual host info name commands */
10894 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
10896 +struct vcmd_sock_stat_v0 {
10898 + uint32_t count[3];
10899 + uint64_t total[3];
10905 +#include <linux/compiler.h>
10907 +extern int vc_sock_stat(struct vx_info *, void __user *);
10909 +#endif /* __KERNEL__ */
10910 +#endif /* _VX_CACCT_CMD_H */
10911 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/cacct_def.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/cacct_def.h
10912 --- linux-3.6.10/include/linux/vserver/cacct_def.h 1970-01-01 01:00:00.000000000 +0100
10913 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/cacct_def.h 2012-10-04 18:47:00.000000000 +0200
10915 +#ifndef _VX_CACCT_DEF_H
10916 +#define _VX_CACCT_DEF_H
10918 +#include <asm/atomic.h>
10919 +#include <linux/vserver/cacct.h>
10922 +struct _vx_sock_acc {
10923 + atomic_long_t count;
10924 + atomic_long_t total;
10927 +/* context sub struct */
10929 +struct _vx_cacct {
10930 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
10931 + atomic_t slab[8];
10932 + atomic_t page[6][8];
10935 +#ifdef CONFIG_VSERVER_DEBUG
10937 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
10941 + printk("\t_vx_cacct:");
10942 + for (i = 0; i < 6; i++) {
10943 + struct _vx_sock_acc *ptr = cacct->sock[i];
10945 + printk("\t [%d] =", i);
10946 + for (j = 0; j < 3; j++) {
10947 + printk(" [%d] = %8lu, %8lu", j,
10948 + atomic_long_read(&ptr[j].count),
10949 + atomic_long_read(&ptr[j].total));
10957 +#endif /* _VX_CACCT_DEF_H */
10958 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/cacct_int.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/cacct_int.h
10959 --- linux-3.6.10/include/linux/vserver/cacct_int.h 1970-01-01 01:00:00.000000000 +0100
10960 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/cacct_int.h 2012-10-04 18:47:00.000000000 +0200
10962 +#ifndef _VX_CACCT_INT_H
10963 +#define _VX_CACCT_INT_H
10969 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
10971 + return atomic_long_read(&cacct->sock[type][pos].count);
10976 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
10978 + return atomic_long_read(&cacct->sock[type][pos].total);
10981 +#endif /* __KERNEL__ */
10982 +#endif /* _VX_CACCT_INT_H */
10983 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/check.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/check.h
10984 --- linux-3.6.10/include/linux/vserver/check.h 1970-01-01 01:00:00.000000000 +0100
10985 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/check.h 2012-10-04 18:47:00.000000000 +0200
10987 +#ifndef _VS_CHECK_H
10988 +#define _VS_CHECK_H
10991 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
10993 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
10994 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
10996 +#define MIN_D_CONTEXT 65536
10999 +/* check conditions */
11001 +#define VS_ADMIN 0x0001
11002 +#define VS_WATCH 0x0002
11003 +#define VS_HIDE 0x0004
11004 +#define VS_HOSTID 0x0008
11006 +#define VS_IDENT 0x0010
11007 +#define VS_EQUIV 0x0020
11008 +#define VS_PARENT 0x0040
11009 +#define VS_CHILD 0x0080
11011 +#define VS_ARG_MASK 0x00F0
11013 +#define VS_DYNAMIC 0x0100
11014 +#define VS_STATIC 0x0200
11016 +#define VS_ATR_MASK 0x0F00
11018 +#ifdef CONFIG_VSERVER_PRIVACY
11019 +#define VS_ADMIN_P (0)
11020 +#define VS_WATCH_P (0)
11022 +#define VS_ADMIN_P VS_ADMIN
11023 +#define VS_WATCH_P VS_WATCH
11026 +#define VS_HARDIRQ 0x1000
11027 +#define VS_SOFTIRQ 0x2000
11028 +#define VS_IRQ 0x4000
11030 +#define VS_IRQ_MASK 0xF000
11032 +#include <linux/hardirq.h>
11035 + * check current context for ADMIN/WATCH and
11036 + * optionally against supplied argument
11038 +static inline int __vs_check(int cid, int id, unsigned int mode)
11040 + if (mode & VS_ARG_MASK) {
11041 + if ((mode & VS_IDENT) && (id == cid))
11044 + if (mode & VS_ATR_MASK) {
11045 + if ((mode & VS_DYNAMIC) &&
11046 + (id >= MIN_D_CONTEXT) &&
11047 + (id <= MAX_S_CONTEXT))
11049 + if ((mode & VS_STATIC) &&
11050 + (id > 1) && (id < MIN_D_CONTEXT))
11053 + if (mode & VS_IRQ_MASK) {
11054 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
11056 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
11058 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
11061 + return (((mode & VS_ADMIN) && (cid == 0)) ||
11062 + ((mode & VS_WATCH) && (cid == 1)) ||
11063 + ((mode & VS_HOSTID) && (id == 0)));
11066 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
11068 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
11071 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
11073 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
11076 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/context.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/context.h
11077 --- linux-3.6.10/include/linux/vserver/context.h 1970-01-01 01:00:00.000000000 +0100
11078 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/context.h 2012-10-04 18:47:00.000000000 +0200
11080 +#ifndef _VX_CONTEXT_H
11081 +#define _VX_CONTEXT_H
11083 +#include <linux/types.h>
11084 +#include <linux/capability.h>
11087 +/* context flags */
11089 +#define VXF_INFO_SCHED 0x00000002
11090 +#define VXF_INFO_NPROC 0x00000004
11091 +#define VXF_INFO_PRIVATE 0x00000008
11093 +#define VXF_INFO_INIT 0x00000010
11094 +#define VXF_INFO_HIDE 0x00000020
11095 +#define VXF_INFO_ULIMIT 0x00000040
11096 +#define VXF_INFO_NSPACE 0x00000080
11098 +#define VXF_SCHED_HARD 0x00000100
11099 +#define VXF_SCHED_PRIO 0x00000200
11100 +#define VXF_SCHED_PAUSE 0x00000400
11102 +#define VXF_VIRT_MEM 0x00010000
11103 +#define VXF_VIRT_UPTIME 0x00020000
11104 +#define VXF_VIRT_CPU 0x00040000
11105 +#define VXF_VIRT_LOAD 0x00080000
11106 +#define VXF_VIRT_TIME 0x00100000
11108 +#define VXF_HIDE_MOUNT 0x01000000
11109 +/* was VXF_HIDE_NETIF 0x02000000 */
11110 +#define VXF_HIDE_VINFO 0x04000000
11112 +#define VXF_STATE_SETUP (1ULL << 32)
11113 +#define VXF_STATE_INIT (1ULL << 33)
11114 +#define VXF_STATE_ADMIN (1ULL << 34)
11116 +#define VXF_SC_HELPER (1ULL << 36)
11117 +#define VXF_REBOOT_KILL (1ULL << 37)
11118 +#define VXF_PERSISTENT (1ULL << 38)
11120 +#define VXF_FORK_RSS (1ULL << 48)
11121 +#define VXF_PROLIFIC (1ULL << 49)
11123 +#define VXF_IGNEG_NICE (1ULL << 52)
11125 +#define VXF_ONE_TIME (0x0007ULL << 32)
11127 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
11130 +/* context migration */
11132 +#define VXM_SET_INIT 0x00000001
11133 +#define VXM_SET_REAPER 0x00000002
11135 +/* context caps */
11137 +#define VXC_SET_UTSNAME 0x00000001
11138 +#define VXC_SET_RLIMIT 0x00000002
11139 +#define VXC_FS_SECURITY 0x00000004
11140 +#define VXC_FS_TRUSTED 0x00000008
11141 +#define VXC_TIOCSTI 0x00000010
11143 +/* was VXC_RAW_ICMP 0x00000100 */
11144 +#define VXC_SYSLOG 0x00001000
11145 +#define VXC_OOM_ADJUST 0x00002000
11146 +#define VXC_AUDIT_CONTROL 0x00004000
11148 +#define VXC_SECURE_MOUNT 0x00010000
11149 +#define VXC_SECURE_REMOUNT 0x00020000
11150 +#define VXC_BINARY_MOUNT 0x00040000
11152 +#define VXC_QUOTA_CTL 0x00100000
11153 +#define VXC_ADMIN_MAPPER 0x00200000
11154 +#define VXC_ADMIN_CLOOP 0x00400000
11156 +#define VXC_KTHREAD 0x01000000
11157 +#define VXC_NAMESPACE 0x02000000
11162 +#include <linux/list.h>
11163 +#include <linux/spinlock.h>
11164 +#include <linux/rcupdate.h>
11166 +#include "limit_def.h"
11167 +#include "sched_def.h"
11168 +#include "cvirt_def.h"
11169 +#include "cacct_def.h"
11170 +#include "device_def.h"
11172 +#define VX_SPACES 2
11174 +struct _vx_info_pc {
11175 + struct _vx_sched_pc sched_pc;
11176 + struct _vx_cvirt_pc cvirt_pc;
11179 +struct _vx_space {
11180 + unsigned long vx_nsmask; /* assignment mask */
11181 + struct nsproxy *vx_nsproxy; /* private namespaces */
11182 + struct fs_struct *vx_fs; /* private namespace fs */
11183 + const struct cred *vx_cred; /* task credentials */
11187 + struct hlist_node vx_hlist; /* linked list of contexts */
11188 + xid_t vx_id; /* context id */
11189 + atomic_t vx_usecnt; /* usage count */
11190 + atomic_t vx_tasks; /* tasks count */
11191 + struct vx_info *vx_parent; /* parent context */
11192 + int vx_state; /* context state */
11194 + struct _vx_space space[VX_SPACES]; /* namespace store */
11196 + uint64_t vx_flags; /* context flags */
11197 + uint64_t vx_ccaps; /* context caps (vserver) */
11198 + uint64_t vx_umask; /* unshare mask (guest) */
11199 + uint64_t vx_wmask; /* warn mask (guest) */
11200 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
11202 + struct task_struct *vx_reaper; /* guest reaper process */
11203 + pid_t vx_initpid; /* PID of guest init */
11204 + int64_t vx_badness_bias; /* OOM points bias */
11206 + struct _vx_limit limit; /* vserver limits */
11207 + struct _vx_sched sched; /* vserver scheduler */
11208 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
11209 + struct _vx_cacct cacct; /* context accounting */
11211 + struct _vx_device dmap; /* default device map targets */
11213 +#ifndef CONFIG_SMP
11214 + struct _vx_info_pc info_pc; /* per cpu data */
11216 + struct _vx_info_pc *ptr_pc; /* per cpu array */
11219 + wait_queue_head_t vx_wait; /* context exit waitqueue */
11220 + int reboot_cmd; /* last sys_reboot() cmd */
11221 + int exit_code; /* last process exit code */
11223 + char vx_name[65]; /* vserver name */
11226 +#ifndef CONFIG_SMP
11227 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
11228 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
11230 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
11231 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
11234 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
11237 +struct vx_info_save {
11238 + struct vx_info *vxi;
11243 +/* status flags */
11245 +#define VXS_HASHED 0x0001
11246 +#define VXS_PAUSED 0x0010
11247 +#define VXS_SHUTDOWN 0x0100
11248 +#define VXS_HELPER 0x1000
11249 +#define VXS_RELEASED 0x8000
11252 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
11253 +extern void release_vx_info(struct vx_info *, struct task_struct *);
11255 +extern struct vx_info *lookup_vx_info(int);
11256 +extern struct vx_info *lookup_or_create_vx_info(int);
11258 +extern int get_xid_list(int, unsigned int *, int);
11259 +extern int xid_is_hashed(xid_t);
11261 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
11263 +extern long vs_state_change(struct vx_info *, unsigned int);
11266 +#endif /* __KERNEL__ */
11267 +#endif /* _VX_CONTEXT_H */
11268 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/context_cmd.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/context_cmd.h
11269 --- linux-3.6.10/include/linux/vserver/context_cmd.h 1970-01-01 01:00:00.000000000 +0100
11270 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/context_cmd.h 2012-10-04 18:47:00.000000000 +0200
11272 +#ifndef _VX_CONTEXT_CMD_H
11273 +#define _VX_CONTEXT_CMD_H
11276 +/* vinfo commands */
11278 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
11281 +extern int vc_task_xid(uint32_t);
11283 +#endif /* __KERNEL__ */
11285 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
11287 +struct vcmd_vx_info_v0 {
11289 + uint32_t initpid;
11290 + /* more to come */
11294 +extern int vc_vx_info(struct vx_info *, void __user *);
11296 +#endif /* __KERNEL__ */
11298 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
11300 +struct vcmd_ctx_stat_v0 {
11303 + /* more to come */
11307 +extern int vc_ctx_stat(struct vx_info *, void __user *);
11309 +#endif /* __KERNEL__ */
11311 +/* context commands */
11313 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
11314 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
11316 +struct vcmd_ctx_create {
11317 + uint64_t flagword;
11320 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
11321 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
11323 +struct vcmd_ctx_migrate {
11324 + uint64_t flagword;
11328 +extern int vc_ctx_create(uint32_t, void __user *);
11329 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
11331 +#endif /* __KERNEL__ */
11334 +/* flag commands */
11336 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
11337 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
11339 +struct vcmd_ctx_flags_v0 {
11340 + uint64_t flagword;
11345 +extern int vc_get_cflags(struct vx_info *, void __user *);
11346 +extern int vc_set_cflags(struct vx_info *, void __user *);
11348 +#endif /* __KERNEL__ */
11351 +/* context caps commands */
11353 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
11354 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
11356 +struct vcmd_ctx_caps_v1 {
11362 +extern int vc_get_ccaps(struct vx_info *, void __user *);
11363 +extern int vc_set_ccaps(struct vx_info *, void __user *);
11365 +#endif /* __KERNEL__ */
11368 +/* bcaps commands */
11370 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
11371 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
11373 +struct vcmd_bcaps {
11379 +extern int vc_get_bcaps(struct vx_info *, void __user *);
11380 +extern int vc_set_bcaps(struct vx_info *, void __user *);
11382 +#endif /* __KERNEL__ */
11385 +/* umask commands */
11387 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
11388 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
11390 +struct vcmd_umask {
11396 +extern int vc_get_umask(struct vx_info *, void __user *);
11397 +extern int vc_set_umask(struct vx_info *, void __user *);
11399 +#endif /* __KERNEL__ */
11402 +/* wmask commands */
11404 +#define VCMD_get_wmask VC_CMD(FLAGS, 15, 0)
11405 +#define VCMD_set_wmask VC_CMD(FLAGS, 16, 0)
11407 +struct vcmd_wmask {
11413 +extern int vc_get_wmask(struct vx_info *, void __user *);
11414 +extern int vc_set_wmask(struct vx_info *, void __user *);
11416 +#endif /* __KERNEL__ */
11421 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
11422 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
11424 +struct vcmd_badness_v0 {
11429 +extern int vc_get_badness(struct vx_info *, void __user *);
11430 +extern int vc_set_badness(struct vx_info *, void __user *);
11432 +#endif /* __KERNEL__ */
11433 +#endif /* _VX_CONTEXT_CMD_H */
11434 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/cvirt.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/cvirt.h
11435 --- linux-3.6.10/include/linux/vserver/cvirt.h 1970-01-01 01:00:00.000000000 +0100
11436 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/cvirt.h 2012-10-04 18:47:00.000000000 +0200
11438 +#ifndef _VX_CVIRT_H
11439 +#define _VX_CVIRT_H
11446 +void vx_vsi_boottime(struct timespec *);
11448 +void vx_vsi_uptime(struct timespec *, struct timespec *);
11453 +void vx_update_load(struct vx_info *);
11456 +int vx_do_syslog(int, char __user *, int);
11458 +#endif /* __KERNEL__ */
11459 +#endif /* _VX_CVIRT_H */
11460 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/cvirt_cmd.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/cvirt_cmd.h
11461 --- linux-3.6.10/include/linux/vserver/cvirt_cmd.h 1970-01-01 01:00:00.000000000 +0100
11462 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/cvirt_cmd.h 2012-10-04 18:47:00.000000000 +0200
11464 +#ifndef _VX_CVIRT_CMD_H
11465 +#define _VX_CVIRT_CMD_H
11468 +/* virtual host info name commands */
11470 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
11471 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
11473 +struct vcmd_vhi_name_v0 {
11479 +enum vhi_name_field {
11480 + VHIN_CONTEXT = 0,
11492 +#include <linux/compiler.h>
11494 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
11495 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
11497 +#endif /* __KERNEL__ */
11499 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
11501 +struct vcmd_virt_stat_v0 {
11504 + uint32_t nr_threads;
11505 + uint32_t nr_running;
11506 + uint32_t nr_uninterruptible;
11507 + uint32_t nr_onhold;
11508 + uint32_t nr_forks;
11509 + uint32_t load[3];
11513 +extern int vc_virt_stat(struct vx_info *, void __user *);
11515 +#endif /* __KERNEL__ */
11516 +#endif /* _VX_CVIRT_CMD_H */
11517 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/cvirt_def.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/cvirt_def.h
11518 --- linux-3.6.10/include/linux/vserver/cvirt_def.h 1970-01-01 01:00:00.000000000 +0100
11519 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/cvirt_def.h 2012-10-04 18:47:00.000000000 +0200
11521 +#ifndef _VX_CVIRT_DEF_H
11522 +#define _VX_CVIRT_DEF_H
11524 +#include <linux/jiffies.h>
11525 +#include <linux/spinlock.h>
11526 +#include <linux/wait.h>
11527 +#include <linux/time.h>
11528 +#include <asm/atomic.h>
11531 +struct _vx_usage_stat {
11535 + uint64_t softirq;
11541 +struct _vx_syslog {
11542 + wait_queue_head_t log_wait;
11543 + spinlock_t logbuf_lock; /* lock for the log buffer */
11545 + unsigned long log_start; /* next char to be read by syslog() */
11546 + unsigned long con_start; /* next char to be sent to consoles */
11547 + unsigned long log_end; /* most-recently-written-char + 1 */
11548 + unsigned long logged_chars; /* #chars since last read+clear operation */
11550 + char log_buf[1024];
11554 +/* context sub struct */
11556 +struct _vx_cvirt {
11557 + atomic_t nr_threads; /* number of current threads */
11558 + atomic_t nr_running; /* number of running threads */
11559 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
11561 + atomic_t nr_onhold; /* processes on hold */
11562 + uint32_t onhold_last; /* jiffies when put on hold */
11564 + struct timespec bias_ts; /* time offset to the host */
11565 + struct timespec bias_idle;
11566 + struct timespec bias_uptime; /* context creation point */
11567 + uint64_t bias_clock; /* offset in clock_t */
11569 + spinlock_t load_lock; /* lock for the load averages */
11570 + atomic_t load_updates; /* nr of load updates done so far */
11571 + uint32_t load_last; /* last time load was calculated */
11572 + uint32_t load[3]; /* load averages 1,5,15 */
11574 + atomic_t total_forks; /* number of forks so far */
11576 + struct _vx_syslog syslog;
11579 +struct _vx_cvirt_pc {
11580 + struct _vx_usage_stat cpustat;
11584 +#ifdef CONFIG_VSERVER_DEBUG
11586 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
11588 + printk("\t_vx_cvirt:\n");
11589 + printk("\t threads: %4d, %4d, %4d, %4d\n",
11590 + atomic_read(&cvirt->nr_threads),
11591 + atomic_read(&cvirt->nr_running),
11592 + atomic_read(&cvirt->nr_uninterruptible),
11593 + atomic_read(&cvirt->nr_onhold));
11594 + /* add rest here */
11595 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
11600 +#endif /* _VX_CVIRT_DEF_H */
11601 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/debug.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/debug.h
11602 --- linux-3.6.10/include/linux/vserver/debug.h 1970-01-01 01:00:00.000000000 +0100
11603 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/debug.h 2012-10-04 18:47:00.000000000 +0200
11605 +#ifndef _VX_DEBUG_H
11606 +#define _VX_DEBUG_H
11609 +#define VXD_CBIT(n, m) (vs_debug_ ## n & (1 << (m)))
11610 +#define VXD_CMIN(n, m) (vs_debug_ ## n > (m))
11611 +#define VXD_MASK(n, m) (vs_debug_ ## n & (m))
11613 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
11614 + imajor((d)->bd_inode), iminor((d)->bd_inode)
11615 +#define VXF_DEV "%p[%lu,%d:%d]"
11617 +#if defined(CONFIG_QUOTES_UTF8)
11618 +#define VS_Q_LQM "\xc2\xbb"
11619 +#define VS_Q_RQM "\xc2\xab"
11620 +#elif defined(CONFIG_QUOTES_ASCII)
11621 +#define VS_Q_LQM "\x27"
11622 +#define VS_Q_RQM "\x27"
11624 +#define VS_Q_LQM "\xbb"
11625 +#define VS_Q_RQM "\xab"
11628 +#define VS_Q(f) VS_Q_LQM f VS_Q_RQM
11631 +#define vxd_path(p) \
11632 + ({ static char _buffer[PATH_MAX]; \
11633 + d_path(p, _buffer, sizeof(_buffer)); })
11635 +#define vxd_cond_path(n) \
11636 + ((n) ? vxd_path(&(n)->path) : "<null>" )
11639 +#ifdef CONFIG_VSERVER_DEBUG
11641 +extern unsigned int vs_debug_switch;
11642 +extern unsigned int vs_debug_xid;
11643 +extern unsigned int vs_debug_nid;
11644 +extern unsigned int vs_debug_tag;
11645 +extern unsigned int vs_debug_net;
11646 +extern unsigned int vs_debug_limit;
11647 +extern unsigned int vs_debug_cres;
11648 +extern unsigned int vs_debug_dlim;
11649 +extern unsigned int vs_debug_quota;
11650 +extern unsigned int vs_debug_cvirt;
11651 +extern unsigned int vs_debug_space;
11652 +extern unsigned int vs_debug_perm;
11653 +extern unsigned int vs_debug_misc;
11656 +#define VX_LOGLEVEL "vxD: "
11657 +#define VX_PROC_FMT "%p: "
11658 +#define VX_PROCESS current
11660 +#define vxdprintk(c, f, x...) \
11663 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
11664 + VX_PROCESS , ##x); \
11667 +#define vxlprintk(c, f, x...) \
11670 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
11673 +#define vxfprintk(c, f, x...) \
11676 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
11682 +void dump_vx_info(struct vx_info *, int);
11683 +void dump_vx_info_inactive(int);
11685 +#else /* CONFIG_VSERVER_DEBUG */
11687 +#define vs_debug_switch 0
11688 +#define vs_debug_xid 0
11689 +#define vs_debug_nid 0
11690 +#define vs_debug_tag 0
11691 +#define vs_debug_net 0
11692 +#define vs_debug_limit 0
11693 +#define vs_debug_cres 0
11694 +#define vs_debug_dlim 0
11695 +#define vs_debug_quota 0
11696 +#define vs_debug_cvirt 0
11697 +#define vs_debug_space 0
11698 +#define vs_debug_perm 0
11699 +#define vs_debug_misc 0
11701 +#define vxdprintk(x...) do { } while (0)
11702 +#define vxlprintk(x...) do { } while (0)
11703 +#define vxfprintk(x...) do { } while (0)
11705 +#endif /* CONFIG_VSERVER_DEBUG */
11708 +#ifdef CONFIG_VSERVER_WARN
11710 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
11711 +#define VX_WARN_TASK "[" VS_Q("%s") ",%u:#%u|%u|%u] "
11712 +#define VX_WARN_XID "[xid #%u] "
11713 +#define VX_WARN_NID "[nid #%u] "
11714 +#define VX_WARN_TAG "[tag #%u] "
11716 +#define vxwprintk(c, f, x...) \
11719 + printk(VX_WARNLEVEL f "\n", ##x); \
11722 +#else /* CONFIG_VSERVER_WARN */
11724 +#define vxwprintk(x...) do { } while (0)
11726 +#endif /* CONFIG_VSERVER_WARN */
11728 +#define vxwprintk_task(c, f, x...) \
11729 + vxwprintk(c, VX_WARN_TASK f, \
11730 + current->comm, current->pid, \
11731 + current->xid, current->nid, current->tag, ##x)
11732 +#define vxwprintk_xid(c, f, x...) \
11733 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
11734 +#define vxwprintk_nid(c, f, x...) \
11735 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
11736 +#define vxwprintk_tag(c, f, x...) \
11737 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
11739 +#ifdef CONFIG_VSERVER_DEBUG
11740 +#define vxd_assert_lock(l) assert_spin_locked(l)
11741 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
11742 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
11744 +#define vxd_assert_lock(l) do { } while (0)
11745 +#define vxd_assert(c, f, x...) do { } while (0)
11749 +#endif /* _VX_DEBUG_H */
11750 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/debug_cmd.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/debug_cmd.h
11751 --- linux-3.6.10/include/linux/vserver/debug_cmd.h 1970-01-01 01:00:00.000000000 +0100
11752 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/debug_cmd.h 2012-10-04 18:47:00.000000000 +0200
11754 +#ifndef _VX_DEBUG_CMD_H
11755 +#define _VX_DEBUG_CMD_H
11758 +/* debug commands */
11760 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
11762 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
11763 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
11765 +struct vcmd_read_history_v0 {
11768 + char __user *data;
11771 +struct vcmd_read_monitor_v0 {
11774 + char __user *data;
11780 +#ifdef CONFIG_COMPAT
11782 +#include <asm/compat.h>
11784 +struct vcmd_read_history_v0_x32 {
11787 + compat_uptr_t data_ptr;
11790 +struct vcmd_read_monitor_v0_x32 {
11793 + compat_uptr_t data_ptr;
11796 +#endif /* CONFIG_COMPAT */
11798 +extern int vc_dump_history(uint32_t);
11800 +extern int vc_read_history(uint32_t, void __user *);
11801 +extern int vc_read_monitor(uint32_t, void __user *);
11803 +#ifdef CONFIG_COMPAT
11805 +extern int vc_read_history_x32(uint32_t, void __user *);
11806 +extern int vc_read_monitor_x32(uint32_t, void __user *);
11808 +#endif /* CONFIG_COMPAT */
11810 +#endif /* __KERNEL__ */
11811 +#endif /* _VX_DEBUG_CMD_H */
11812 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/device.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/device.h
11813 --- linux-3.6.10/include/linux/vserver/device.h 1970-01-01 01:00:00.000000000 +0100
11814 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/device.h 2012-10-04 18:47:00.000000000 +0200
11816 +#ifndef _VX_DEVICE_H
11817 +#define _VX_DEVICE_H
11820 +#define DATTR_CREATE 0x00000001
11821 +#define DATTR_OPEN 0x00000002
11823 +#define DATTR_REMAP 0x00000010
11825 +#define DATTR_MASK 0x00000013
11828 +#else /* _VX_DEVICE_H */
11829 +#warning duplicate inclusion
11830 +#endif /* _VX_DEVICE_H */
11831 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/device_cmd.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/device_cmd.h
11832 --- linux-3.6.10/include/linux/vserver/device_cmd.h 1970-01-01 01:00:00.000000000 +0100
11833 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/device_cmd.h 2012-10-04 18:47:00.000000000 +0200
11835 +#ifndef _VX_DEVICE_CMD_H
11836 +#define _VX_DEVICE_CMD_H
11839 +/* device vserver commands */
11841 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
11842 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
11844 +struct vcmd_set_mapping_v0 {
11845 + const char __user *device;
11846 + const char __user *target;
11853 +#ifdef CONFIG_COMPAT
11855 +#include <asm/compat.h>
11857 +struct vcmd_set_mapping_v0_x32 {
11858 + compat_uptr_t device_ptr;
11859 + compat_uptr_t target_ptr;
11863 +#endif /* CONFIG_COMPAT */
11865 +#include <linux/compiler.h>
11867 +extern int vc_set_mapping(struct vx_info *, void __user *);
11868 +extern int vc_unset_mapping(struct vx_info *, void __user *);
11870 +#ifdef CONFIG_COMPAT
11872 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
11873 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
11875 +#endif /* CONFIG_COMPAT */
11877 +#endif /* __KERNEL__ */
11878 +#endif /* _VX_DEVICE_CMD_H */
11879 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/device_def.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/device_def.h
11880 --- linux-3.6.10/include/linux/vserver/device_def.h 1970-01-01 01:00:00.000000000 +0100
11881 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/device_def.h 2012-10-04 18:47:00.000000000 +0200
11883 +#ifndef _VX_DEVICE_DEF_H
11884 +#define _VX_DEVICE_DEF_H
11886 +#include <linux/types.h>
11888 +struct vx_dmap_target {
11893 +struct _vx_device {
11894 +#ifdef CONFIG_VSERVER_DEVICE
11895 + struct vx_dmap_target targets[2];
11899 +#endif /* _VX_DEVICE_DEF_H */
11900 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/dlimit.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/dlimit.h
11901 --- linux-3.6.10/include/linux/vserver/dlimit.h 1970-01-01 01:00:00.000000000 +0100
11902 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/dlimit.h 2012-10-04 18:47:00.000000000 +0200
11904 +#ifndef _VX_DLIMIT_H
11905 +#define _VX_DLIMIT_H
11907 +#include "switch.h"
11912 +/* keep in sync with CDLIM_INFINITY */
11914 +#define DLIM_INFINITY (~0ULL)
11916 +#include <linux/spinlock.h>
11917 +#include <linux/rcupdate.h>
11919 +struct super_block;
11922 + struct hlist_node dl_hlist; /* linked list of contexts */
11923 + struct rcu_head dl_rcu; /* the rcu head */
11924 + tag_t dl_tag; /* context tag */
11925 + atomic_t dl_usecnt; /* usage count */
11926 + atomic_t dl_refcnt; /* reference count */
11928 + struct super_block *dl_sb; /* associated superblock */
11930 + spinlock_t dl_lock; /* protect the values */
11932 + unsigned long long dl_space_used; /* used space in bytes */
11933 + unsigned long long dl_space_total; /* maximum space in bytes */
11934 + unsigned long dl_inodes_used; /* used inodes */
11935 + unsigned long dl_inodes_total; /* maximum inodes */
11937 + unsigned int dl_nrlmult; /* non root limit mult */
11942 +extern void rcu_free_dl_info(struct rcu_head *);
11943 +extern void unhash_dl_info(struct dl_info *);
11945 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
11950 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
11952 +typedef uint64_t dlsize_t;
11954 +#endif /* __KERNEL__ */
11955 +#else /* _VX_DLIMIT_H */
11956 +#warning duplicate inclusion
11957 +#endif /* _VX_DLIMIT_H */
11958 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/dlimit_cmd.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/dlimit_cmd.h
11959 --- linux-3.6.10/include/linux/vserver/dlimit_cmd.h 1970-01-01 01:00:00.000000000 +0100
11960 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/dlimit_cmd.h 2012-10-04 18:47:00.000000000 +0200
11962 +#ifndef _VX_DLIMIT_CMD_H
11963 +#define _VX_DLIMIT_CMD_H
11966 +/* dlimit vserver commands */
11968 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
11969 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
11971 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
11972 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
11974 +struct vcmd_ctx_dlimit_base_v0 {
11975 + const char __user *name;
11979 +struct vcmd_ctx_dlimit_v0 {
11980 + const char __user *name;
11981 + uint32_t space_used; /* used space in kbytes */
11982 + uint32_t space_total; /* maximum space in kbytes */
11983 + uint32_t inodes_used; /* used inodes */
11984 + uint32_t inodes_total; /* maximum inodes */
11985 + uint32_t reserved; /* reserved for root in % */
11989 +#define CDLIM_UNSET ((uint32_t)0UL)
11990 +#define CDLIM_INFINITY ((uint32_t)~0UL)
11991 +#define CDLIM_KEEP ((uint32_t)~1UL)
11993 +#define DLIME_UNIT 0
11994 +#define DLIME_KILO 1
11995 +#define DLIME_MEGA 2
11996 +#define DLIME_GIGA 3
11998 +#define DLIMF_SHIFT 0x10
12000 +#define DLIMS_USED 0
12001 +#define DLIMS_TOTAL 2
12004 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
12006 + int exp = (flags & DLIMF_SHIFT) ?
12007 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
12008 + return ((uint64_t)val) << (10 * exp);
12012 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
12016 + if (*flags & DLIMF_SHIFT) {
12017 + while (val > (1LL << 32) && (exp < 3)) {
12021 + *flags &= ~(DLIME_GIGA << shift);
12022 + *flags |= exp << shift;
12030 +#ifdef CONFIG_COMPAT
12032 +#include <asm/compat.h>
12034 +struct vcmd_ctx_dlimit_base_v0_x32 {
12035 + compat_uptr_t name_ptr;
12039 +struct vcmd_ctx_dlimit_v0_x32 {
12040 + compat_uptr_t name_ptr;
12041 + uint32_t space_used; /* used space in kbytes */
12042 + uint32_t space_total; /* maximum space in kbytes */
12043 + uint32_t inodes_used; /* used inodes */
12044 + uint32_t inodes_total; /* maximum inodes */
12045 + uint32_t reserved; /* reserved for root in % */
12049 +#endif /* CONFIG_COMPAT */
12051 +#include <linux/compiler.h>
12053 +extern int vc_add_dlimit(uint32_t, void __user *);
12054 +extern int vc_rem_dlimit(uint32_t, void __user *);
12056 +extern int vc_set_dlimit(uint32_t, void __user *);
12057 +extern int vc_get_dlimit(uint32_t, void __user *);
12059 +#ifdef CONFIG_COMPAT
12061 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
12062 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
12064 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
12065 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
12067 +#endif /* CONFIG_COMPAT */
12069 +#endif /* __KERNEL__ */
12070 +#endif /* _VX_DLIMIT_CMD_H */
12071 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/global.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/global.h
12072 --- linux-3.6.10/include/linux/vserver/global.h 1970-01-01 01:00:00.000000000 +0100
12073 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/global.h 2012-10-04 18:47:00.000000000 +0200
12075 +#ifndef _VX_GLOBAL_H
12076 +#define _VX_GLOBAL_H
12079 +extern atomic_t vx_global_ctotal;
12080 +extern atomic_t vx_global_cactive;
12082 +extern atomic_t nx_global_ctotal;
12083 +extern atomic_t nx_global_cactive;
12085 +extern atomic_t vs_global_nsproxy;
12086 +extern atomic_t vs_global_fs;
12087 +extern atomic_t vs_global_mnt_ns;
12088 +extern atomic_t vs_global_uts_ns;
12089 +extern atomic_t vs_global_user_ns;
12090 +extern atomic_t vs_global_pid_ns;
12093 +#endif /* _VX_GLOBAL_H */
12094 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/history.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/history.h
12095 --- linux-3.6.10/include/linux/vserver/history.h 1970-01-01 01:00:00.000000000 +0100
12096 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/history.h 2012-10-04 18:47:00.000000000 +0200
12098 +#ifndef _VX_HISTORY_H
12099 +#define _VX_HISTORY_H
12104 + VXH_THROW_OOPS = 1,
12108 + VXH_INIT_VX_INFO,
12111 + VXH_CLAIM_VX_INFO,
12112 + VXH_RELEASE_VX_INFO,
12113 + VXH_ALLOC_VX_INFO,
12114 + VXH_DEALLOC_VX_INFO,
12115 + VXH_HASH_VX_INFO,
12116 + VXH_UNHASH_VX_INFO,
12118 + VXH_LOOKUP_VX_INFO,
12119 + VXH_CREATE_VX_INFO,
12122 +struct _vxhe_vxi {
12123 + struct vx_info *ptr;
12129 +struct _vxhe_set_clr {
12133 +struct _vxhe_loc_lookup {
12137 +struct _vx_hist_entry {
12139 + unsigned short seq;
12140 + unsigned short type;
12141 + struct _vxhe_vxi vxi;
12143 + struct _vxhe_set_clr sc;
12144 + struct _vxhe_loc_lookup ll;
12148 +#ifdef CONFIG_VSERVER_HISTORY
12150 +extern unsigned volatile int vxh_active;
12152 +struct _vx_hist_entry *vxh_advance(void *loc);
12156 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
12158 + entry->vxi.ptr = vxi;
12160 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
12161 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
12162 + entry->vxi.xid = vxi->vx_id;
12167 +#define __HERE__ current_text_addr()
12169 +#define __VXH_BODY(__type, __data, __here) \
12170 + struct _vx_hist_entry *entry; \
12172 + preempt_disable(); \
12173 + entry = vxh_advance(__here); \
12175 + entry->type = __type; \
12176 + preempt_enable();
12179 + /* pass vxi only */
12181 +#define __VXH_SMPL \
12182 + __vxh_copy_vxi(entry, vxi)
12185 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
12187 + __VXH_BODY(__type, __VXH_SMPL, __here)
12190 + /* pass vxi and data (void *) */
12192 +#define __VXH_DATA \
12193 + __vxh_copy_vxi(entry, vxi); \
12194 + entry->sc.data = data
12197 +void __vxh_data(struct vx_info *vxi, void *data,
12198 + int __type, void *__here)
12200 + __VXH_BODY(__type, __VXH_DATA, __here)
12203 + /* pass vxi and arg (long) */
12205 +#define __VXH_LONG \
12206 + __vxh_copy_vxi(entry, vxi); \
12207 + entry->ll.arg = arg
12210 +void __vxh_long(struct vx_info *vxi, long arg,
12211 + int __type, void *__here)
12213 + __VXH_BODY(__type, __VXH_LONG, __here)
12218 +void __vxh_throw_oops(void *__here)
12220 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
12221 + /* prevent further acquisition */
12226 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
12228 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
12229 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
12231 +#define __vxh_init_vx_info(v, d, h) \
12232 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
12233 +#define __vxh_set_vx_info(v, d, h) \
12234 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
12235 +#define __vxh_clr_vx_info(v, d, h) \
12236 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
12238 +#define __vxh_claim_vx_info(v, d, h) \
12239 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
12240 +#define __vxh_release_vx_info(v, d, h) \
12241 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
12243 +#define vxh_alloc_vx_info(v) \
12244 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
12245 +#define vxh_dealloc_vx_info(v) \
12246 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
12248 +#define vxh_hash_vx_info(v) \
12249 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
12250 +#define vxh_unhash_vx_info(v) \
12251 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
12253 +#define vxh_loc_vx_info(v, l) \
12254 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
12255 +#define vxh_lookup_vx_info(v, l) \
12256 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
12257 +#define vxh_create_vx_info(v, l) \
12258 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
12260 +extern void vxh_dump_history(void);
12263 +#else /* CONFIG_VSERVER_HISTORY */
12265 +#define __HERE__ 0
12267 +#define vxh_throw_oops() do { } while (0)
12269 +#define __vxh_get_vx_info(v, h) do { } while (0)
12270 +#define __vxh_put_vx_info(v, h) do { } while (0)
12272 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
12273 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
12274 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
12276 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
12277 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
12279 +#define vxh_alloc_vx_info(v) do { } while (0)
12280 +#define vxh_dealloc_vx_info(v) do { } while (0)
12282 +#define vxh_hash_vx_info(v) do { } while (0)
12283 +#define vxh_unhash_vx_info(v) do { } while (0)
12285 +#define vxh_loc_vx_info(v, l) do { } while (0)
12286 +#define vxh_lookup_vx_info(v, l) do { } while (0)
12287 +#define vxh_create_vx_info(v, l) do { } while (0)
12289 +#define vxh_dump_history() do { } while (0)
12292 +#endif /* CONFIG_VSERVER_HISTORY */
12294 +#endif /* _VX_HISTORY_H */
12295 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/inode.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/inode.h
12296 --- linux-3.6.10/include/linux/vserver/inode.h 1970-01-01 01:00:00.000000000 +0100
12297 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/inode.h 2012-10-04 18:47:00.000000000 +0200
12299 +#ifndef _VX_INODE_H
12300 +#define _VX_INODE_H
12303 +#define IATTR_TAG 0x01000000
12305 +#define IATTR_ADMIN 0x00000001
12306 +#define IATTR_WATCH 0x00000002
12307 +#define IATTR_HIDE 0x00000004
12308 +#define IATTR_FLAGS 0x00000007
12310 +#define IATTR_BARRIER 0x00010000
12311 +#define IATTR_IXUNLINK 0x00020000
12312 +#define IATTR_IMMUTABLE 0x00040000
12313 +#define IATTR_COW 0x00080000
12318 +#ifdef CONFIG_VSERVER_PROC_SECURE
12319 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
12320 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
12322 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
12323 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
12326 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
12328 +#endif /* __KERNEL__ */
12330 +/* inode ioctls */
12332 +#define FIOC_GETXFLG _IOR('x', 5, long)
12333 +#define FIOC_SETXFLG _IOW('x', 6, long)
12335 +#else /* _VX_INODE_H */
12336 +#warning duplicate inclusion
12337 +#endif /* _VX_INODE_H */
12338 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/inode_cmd.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/inode_cmd.h
12339 --- linux-3.6.10/include/linux/vserver/inode_cmd.h 1970-01-01 01:00:00.000000000 +0100
12340 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/inode_cmd.h 2012-10-04 18:47:00.000000000 +0200
12342 +#ifndef _VX_INODE_CMD_H
12343 +#define _VX_INODE_CMD_H
12346 +/* inode vserver commands */
12348 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
12349 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
12351 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
12352 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
12354 +struct vcmd_ctx_iattr_v1 {
12355 + const char __user *name;
12361 +struct vcmd_ctx_fiattr_v0 {
12371 +#ifdef CONFIG_COMPAT
12373 +#include <asm/compat.h>
12375 +struct vcmd_ctx_iattr_v1_x32 {
12376 + compat_uptr_t name_ptr;
12382 +#endif /* CONFIG_COMPAT */
12384 +#include <linux/compiler.h>
12386 +extern int vc_get_iattr(void __user *);
12387 +extern int vc_set_iattr(void __user *);
12389 +extern int vc_fget_iattr(uint32_t, void __user *);
12390 +extern int vc_fset_iattr(uint32_t, void __user *);
12392 +#ifdef CONFIG_COMPAT
12394 +extern int vc_get_iattr_x32(void __user *);
12395 +extern int vc_set_iattr_x32(void __user *);
12397 +#endif /* CONFIG_COMPAT */
12399 +#endif /* __KERNEL__ */
12400 +#endif /* _VX_INODE_CMD_H */
12401 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/limit.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/limit.h
12402 --- linux-3.6.10/include/linux/vserver/limit.h 1970-01-01 01:00:00.000000000 +0100
12403 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/limit.h 2012-10-04 18:47:00.000000000 +0200
12405 +#ifndef _VX_LIMIT_H
12406 +#define _VX_LIMIT_H
12408 +#define VLIMIT_NSOCK 16
12409 +#define VLIMIT_OPENFD 17
12410 +#define VLIMIT_ANON 18
12411 +#define VLIMIT_SHMEM 19
12412 +#define VLIMIT_SEMARY 20
12413 +#define VLIMIT_NSEMS 21
12414 +#define VLIMIT_DENTRY 22
12415 +#define VLIMIT_MAPPED 23
12420 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
12422 +/* keep in sync with CRLIM_INFINITY */
12424 +#define VLIM_INFINITY (~0ULL)
12426 +#include <asm/atomic.h>
12427 +#include <asm/resource.h>
12429 +#ifndef RLIM_INFINITY
12430 +#warning RLIM_INFINITY is undefined
12433 +#define __rlim_val(l, r, v) ((l)->res[r].v)
12435 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
12436 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
12438 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
12439 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
12440 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
12442 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
12443 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
12445 +typedef atomic_long_t rlim_atomic_t;
12446 +typedef unsigned long rlim_t;
12448 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
12449 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
12450 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
12451 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
12452 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
12453 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
12456 +#if (RLIM_INFINITY == VLIM_INFINITY)
12457 +#define VX_VLIM(r) ((long long)(long)(r))
12458 +#define VX_RLIM(v) ((rlim_t)(v))
12460 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
12461 + ? VLIM_INFINITY : (long long)(r))
12462 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
12463 + ? RLIM_INFINITY : (rlim_t)(v))
12468 +void vx_vsi_meminfo(struct sysinfo *);
12469 +void vx_vsi_swapinfo(struct sysinfo *);
12470 +long vx_vsi_cached(struct sysinfo *);
12472 +#define NUM_LIMITS 24
12474 +#endif /* __KERNEL__ */
12475 +#endif /* _VX_LIMIT_H */
12476 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/limit_cmd.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/limit_cmd.h
12477 --- linux-3.6.10/include/linux/vserver/limit_cmd.h 1970-01-01 01:00:00.000000000 +0100
12478 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/limit_cmd.h 2012-10-04 18:47:00.000000000 +0200
12480 +#ifndef _VX_LIMIT_CMD_H
12481 +#define _VX_LIMIT_CMD_H
12484 +/* rlimit vserver commands */
12486 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
12487 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
12488 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
12489 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
12490 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
12492 +struct vcmd_ctx_rlimit_v0 {
12494 + uint64_t minimum;
12495 + uint64_t softlimit;
12496 + uint64_t maximum;
12499 +struct vcmd_ctx_rlimit_mask_v0 {
12500 + uint32_t minimum;
12501 + uint32_t softlimit;
12502 + uint32_t maximum;
12505 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
12507 +struct vcmd_rlimit_stat_v0 {
12511 + uint64_t minimum;
12512 + uint64_t maximum;
12515 +#define CRLIM_UNSET (0ULL)
12516 +#define CRLIM_INFINITY (~0ULL)
12517 +#define CRLIM_KEEP (~1ULL)
12521 +#ifdef CONFIG_IA32_EMULATION
12523 +struct vcmd_ctx_rlimit_v0_x32 {
12525 + uint64_t minimum;
12526 + uint64_t softlimit;
12527 + uint64_t maximum;
12528 +} __attribute__ ((packed));
12530 +#endif /* CONFIG_IA32_EMULATION */
12532 +#include <linux/compiler.h>
12534 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
12535 +extern int vc_get_rlimit(struct vx_info *, void __user *);
12536 +extern int vc_set_rlimit(struct vx_info *, void __user *);
12537 +extern int vc_reset_hits(struct vx_info *, void __user *);
12538 +extern int vc_reset_minmax(struct vx_info *, void __user *);
12540 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
12542 +#ifdef CONFIG_IA32_EMULATION
12544 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
12545 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
12547 +#endif /* CONFIG_IA32_EMULATION */
12549 +#endif /* __KERNEL__ */
12550 +#endif /* _VX_LIMIT_CMD_H */
12551 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/limit_def.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/limit_def.h
12552 --- linux-3.6.10/include/linux/vserver/limit_def.h 1970-01-01 01:00:00.000000000 +0100
12553 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/limit_def.h 2012-10-04 18:47:00.000000000 +0200
12555 +#ifndef _VX_LIMIT_DEF_H
12556 +#define _VX_LIMIT_DEF_H
12558 +#include <asm/atomic.h>
12559 +#include <asm/resource.h>
12561 +#include "limit.h"
12564 +struct _vx_res_limit {
12565 + rlim_t soft; /* Context soft limit */
12566 + rlim_t hard; /* Context hard limit */
12568 + rlim_atomic_t rcur; /* Current value */
12569 + rlim_t rmin; /* Context minimum */
12570 + rlim_t rmax; /* Context maximum */
12572 + atomic_t lhit; /* Limit hits */
12575 +/* context sub struct */
12577 +struct _vx_limit {
12578 + struct _vx_res_limit res[NUM_LIMITS];
12581 +#ifdef CONFIG_VSERVER_DEBUG
12583 +static inline void __dump_vx_limit(struct _vx_limit *limit)
12587 + printk("\t_vx_limit:");
12588 + for (i = 0; i < NUM_LIMITS; i++) {
12589 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
12590 + i, (unsigned long)__rlim_get(limit, i),
12591 + (unsigned long)__rlim_rmin(limit, i),
12592 + (unsigned long)__rlim_rmax(limit, i),
12593 + (long)__rlim_soft(limit, i),
12594 + (long)__rlim_hard(limit, i),
12595 + atomic_read(&__rlim_lhit(limit, i)));
12601 +#endif /* _VX_LIMIT_DEF_H */
12602 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/limit_int.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/limit_int.h
12603 --- linux-3.6.10/include/linux/vserver/limit_int.h 1970-01-01 01:00:00.000000000 +0100
12604 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/limit_int.h 2012-10-04 18:47:00.000000000 +0200
12606 +#ifndef _VX_LIMIT_INT_H
12607 +#define _VX_LIMIT_INT_H
12609 +#include "context.h"
12613 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
12614 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
12616 +extern const char *vlimit_name[NUM_LIMITS];
12618 +static inline void __vx_acc_cres(struct vx_info *vxi,
12619 + int res, int dir, void *_data, char *_file, int _line)
12621 + if (VXD_RCRES_COND(res))
12622 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
12623 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12624 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12625 + (dir > 0) ? "++" : "--", _data, _file, _line);
12630 + __rlim_inc(&vxi->limit, res);
12632 + __rlim_dec(&vxi->limit, res);
12635 +static inline void __vx_add_cres(struct vx_info *vxi,
12636 + int res, int amount, void *_data, char *_file, int _line)
12638 + if (VXD_RCRES_COND(res))
12639 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
12640 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12641 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12642 + amount, _data, _file, _line);
12647 + __rlim_add(&vxi->limit, res, amount);
12651 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
12653 + int cond = (value > __rlim_rmax(limit, res));
12656 + __rlim_rmax(limit, res) = value;
12661 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
12663 + int cond = (value < __rlim_rmin(limit, res));
12666 + __rlim_rmin(limit, res) = value;
12671 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
12673 + if (!__vx_cres_adjust_max(limit, res, value))
12674 + __vx_cres_adjust_min(limit, res, value);
12679 + +1 ... no limit hit
12680 + -1 ... over soft limit
12681 + 0 ... over hard limit */
12683 +static inline int __vx_cres_avail(struct vx_info *vxi,
12684 + int res, int num, char *_file, int _line)
12686 + struct _vx_limit *limit;
12689 + if (VXD_RLIMIT_COND(res))
12690 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
12691 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12692 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
12693 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
12694 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12695 + num, _file, _line);
12699 + limit = &vxi->limit;
12700 + value = __rlim_get(limit, res);
12702 + if (!__vx_cres_adjust_max(limit, res, value))
12703 + __vx_cres_adjust_min(limit, res, value);
12708 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
12710 + if (value + num <= __rlim_soft(limit, res))
12713 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
12715 + if (value + num <= __rlim_hard(limit, res))
12718 + __rlim_hit(limit, res);
12723 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
12726 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
12728 + rlim_t value, sum = 0;
12731 + while ((res = *array++)) {
12732 + value = __rlim_get(limit, res);
12733 + __vx_cres_fixup(limit, res, value);
12740 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
12742 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
12743 + int res = *array;
12745 + if (value == __rlim_get(limit, res))
12748 + __rlim_set(limit, res, value);
12749 + /* now adjust min/max */
12750 + if (!__vx_cres_adjust_max(limit, res, value))
12751 + __vx_cres_adjust_min(limit, res, value);
12756 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
12757 + const int *array, int num, char *_file, int _line)
12759 + struct _vx_limit *limit;
12760 + rlim_t value = 0;
12768 + limit = &vxi->limit;
12770 + value = __vx_cres_array_sum(limit, array + 1);
12772 + __rlim_set(limit, res, value);
12773 + __vx_cres_fixup(limit, res, value);
12775 + return __vx_cres_avail(vxi, res, num, _file, _line);
12779 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
12784 + /* complex resources first */
12785 + if ((id < 0) || (id == RLIMIT_RSS))
12786 + __vx_cres_array_fixup(limit, VLA_RSS);
12788 + for (res = 0; res < NUM_LIMITS; res++) {
12789 + if ((id > 0) && (res != id))
12792 + value = __rlim_get(limit, res);
12793 + __vx_cres_fixup(limit, res, value);
12795 + /* not supposed to happen, maybe warn? */
12796 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
12797 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
12802 +#endif /* __KERNEL__ */
12803 +#endif /* _VX_LIMIT_INT_H */
12804 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/monitor.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/monitor.h
12805 --- linux-3.6.10/include/linux/vserver/monitor.h 1970-01-01 01:00:00.000000000 +0100
12806 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/monitor.h 2012-10-04 18:47:00.000000000 +0200
12808 +#ifndef _VX_MONITOR_H
12809 +#define _VX_MONITOR_H
12811 +#include <linux/types.h>
12818 + VXM_UPDATE = 0x20,
12822 + VXM_RQINFO_1 = 0x24,
12825 + VXM_ACTIVATE = 0x40,
12832 + VXM_MIGRATE = 0x48,
12835 + /* all other bits are flags */
12836 + VXM_SCHED = 0x80,
12839 +struct _vxm_update_1 {
12840 + uint32_t tokens_max;
12841 + uint32_t fill_rate;
12842 + uint32_t interval;
12845 +struct _vxm_update_2 {
12846 + uint32_t tokens_min;
12847 + uint32_t fill_rate;
12848 + uint32_t interval;
12851 +struct _vxm_rqinfo_1 {
12852 + uint16_t running;
12856 + uint32_t idle_tokens;
12859 +struct _vxm_rqinfo_2 {
12860 + uint32_t norm_time;
12861 + uint32_t idle_time;
12862 + uint32_t idle_skip;
12865 +struct _vxm_sched {
12867 + uint32_t norm_time;
12868 + uint32_t idle_time;
12871 +struct _vxm_task {
12876 +struct _vxm_event {
12885 + struct _vxm_task tsk;
12889 +struct _vx_mon_entry {
12893 + struct _vxm_event ev;
12894 + struct _vxm_sched sd;
12895 + struct _vxm_update_1 u1;
12896 + struct _vxm_update_2 u2;
12897 + struct _vxm_rqinfo_1 q1;
12898 + struct _vxm_rqinfo_2 q2;
12903 +#endif /* _VX_MONITOR_H */
12904 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/network.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/network.h
12905 --- linux-3.6.10/include/linux/vserver/network.h 1970-01-01 01:00:00.000000000 +0100
12906 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/network.h 2012-10-04 18:47:00.000000000 +0200
12908 +#ifndef _VX_NETWORK_H
12909 +#define _VX_NETWORK_H
12911 +#include <linux/types.h>
12914 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
12917 +/* network flags */
12919 +#define NXF_INFO_PRIVATE 0x00000008
12921 +#define NXF_SINGLE_IP 0x00000100
12922 +#define NXF_LBACK_REMAP 0x00000200
12923 +#define NXF_LBACK_ALLOW 0x00000400
12925 +#define NXF_HIDE_NETIF 0x02000000
12926 +#define NXF_HIDE_LBACK 0x04000000
12928 +#define NXF_STATE_SETUP (1ULL << 32)
12929 +#define NXF_STATE_ADMIN (1ULL << 34)
12931 +#define NXF_SC_HELPER (1ULL << 36)
12932 +#define NXF_PERSISTENT (1ULL << 38)
12934 +#define NXF_ONE_TIME (0x0005ULL << 32)
12937 +#define NXF_INIT_SET (__nxf_init_set())
12939 +static inline uint64_t __nxf_init_set(void) {
12940 + return NXF_STATE_ADMIN
12941 +#ifdef CONFIG_VSERVER_AUTO_LBACK
12942 + | NXF_LBACK_REMAP
12945 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
12948 + | NXF_HIDE_NETIF;
12952 +/* network caps */
12954 +#define NXC_TUN_CREATE 0x00000001
12956 +#define NXC_RAW_ICMP 0x00000100
12958 +#define NXC_MULTICAST 0x00001000
12961 +/* address types */
12963 +#define NXA_TYPE_IPV4 0x0001
12964 +#define NXA_TYPE_IPV6 0x0002
12966 +#define NXA_TYPE_NONE 0x0000
12967 +#define NXA_TYPE_ANY 0x00FF
12969 +#define NXA_TYPE_ADDR 0x0010
12970 +#define NXA_TYPE_MASK 0x0020
12971 +#define NXA_TYPE_RANGE 0x0040
12973 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
12975 +#define NXA_MOD_BCAST 0x0100
12976 +#define NXA_MOD_LBACK 0x0200
12978 +#define NXA_LOOPBACK 0x1000
12980 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
12981 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
12985 +#include <linux/list.h>
12986 +#include <linux/spinlock.h>
12987 +#include <linux/rcupdate.h>
12988 +#include <linux/in.h>
12989 +#include <linux/in6.h>
12990 +#include <asm/atomic.h>
12992 +struct nx_addr_v4 {
12993 + struct nx_addr_v4 *next;
12994 + struct in_addr ip[2];
12995 + struct in_addr mask;
13000 +struct nx_addr_v6 {
13001 + struct nx_addr_v6 *next;
13002 + struct in6_addr ip;
13003 + struct in6_addr mask;
13010 + struct hlist_node nx_hlist; /* linked list of nxinfos */
13011 + nid_t nx_id; /* vnet id */
13012 + atomic_t nx_usecnt; /* usage count */
13013 + atomic_t nx_tasks; /* tasks count */
13014 + int nx_state; /* context state */
13016 + uint64_t nx_flags; /* network flag word */
13017 + uint64_t nx_ncaps; /* network capabilities */
13019 + struct in_addr v4_lback; /* Loopback address */
13020 + struct in_addr v4_bcast; /* Broadcast address */
13021 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
13022 +#ifdef CONFIG_IPV6
13023 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
13025 + char nx_name[65]; /* network context name */
13029 +/* status flags */
13031 +#define NXS_HASHED 0x0001
13032 +#define NXS_SHUTDOWN 0x0100
13033 +#define NXS_RELEASED 0x8000
13035 +extern struct nx_info *lookup_nx_info(int);
13037 +extern int get_nid_list(int, unsigned int *, int);
13038 +extern int nid_is_hashed(nid_t);
13040 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
13042 +extern long vs_net_change(struct nx_info *, unsigned int);
13047 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
13048 +#ifdef CONFIG_IPV6
13049 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
13051 +#define NX_IPV6(n) (0)
13054 +#endif /* __KERNEL__ */
13055 +#endif /* _VX_NETWORK_H */
13056 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/network_cmd.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/network_cmd.h
13057 --- linux-3.6.10/include/linux/vserver/network_cmd.h 1970-01-01 01:00:00.000000000 +0100
13058 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/network_cmd.h 2012-10-04 18:47:00.000000000 +0200
13060 +#ifndef _VX_NETWORK_CMD_H
13061 +#define _VX_NETWORK_CMD_H
13064 +/* vinfo commands */
13066 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
13069 +extern int vc_task_nid(uint32_t);
13071 +#endif /* __KERNEL__ */
13073 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
13075 +struct vcmd_nx_info_v0 {
13077 + /* more to come */
13081 +extern int vc_nx_info(struct nx_info *, void __user *);
13083 +#endif /* __KERNEL__ */
13085 +#include <linux/in.h>
13086 +#include <linux/in6.h>
13088 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
13089 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
13091 +struct vcmd_net_create {
13092 + uint64_t flagword;
13095 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
13097 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
13098 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
13100 +struct vcmd_net_addr_v0 {
13103 + struct in_addr ip[4];
13104 + struct in_addr mask[4];
13107 +#define VCMD_net_add_ipv4_v1 VC_CMD(NETALT, 1, 1)
13108 +#define VCMD_net_rem_ipv4_v1 VC_CMD(NETALT, 2, 1)
13110 +struct vcmd_net_addr_ipv4_v1 {
13113 + struct in_addr ip;
13114 + struct in_addr mask;
13117 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 2)
13118 +#define VCMD_net_rem_ipv4 VC_CMD(NETALT, 2, 2)
13120 +struct vcmd_net_addr_ipv4_v2 {
13123 + struct in_addr ip;
13124 + struct in_addr ip2;
13125 + struct in_addr mask;
13128 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
13129 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
13131 +struct vcmd_net_addr_ipv6_v1 {
13135 + struct in6_addr ip;
13136 + struct in6_addr mask;
13139 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
13140 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
13142 +struct vcmd_match_ipv4_v0 {
13147 + struct in_addr ip;
13148 + struct in_addr ip2;
13149 + struct in_addr mask;
13152 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
13153 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
13155 +struct vcmd_match_ipv6_v0 {
13160 + struct in6_addr ip;
13161 + struct in6_addr ip2;
13162 + struct in6_addr mask;
13167 +extern int vc_net_create(uint32_t, void __user *);
13168 +extern int vc_net_migrate(struct nx_info *, void __user *);
13170 +extern int vc_net_add(struct nx_info *, void __user *);
13171 +extern int vc_net_remove(struct nx_info *, void __user *);
13173 +extern int vc_net_add_ipv4_v1(struct nx_info *, void __user *);
13174 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
13176 +extern int vc_net_rem_ipv4_v1(struct nx_info *, void __user *);
13177 +extern int vc_net_rem_ipv4(struct nx_info *, void __user *);
13179 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
13180 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
13182 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
13183 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
13185 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
13186 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
13188 +#endif /* __KERNEL__ */
13191 +/* flag commands */
13193 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
13194 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
13196 +struct vcmd_net_flags_v0 {
13197 + uint64_t flagword;
13202 +extern int vc_get_nflags(struct nx_info *, void __user *);
13203 +extern int vc_set_nflags(struct nx_info *, void __user *);
13205 +#endif /* __KERNEL__ */
13208 +/* network caps commands */
13210 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
13211 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
13213 +struct vcmd_net_caps_v0 {
13219 +extern int vc_get_ncaps(struct nx_info *, void __user *);
13220 +extern int vc_set_ncaps(struct nx_info *, void __user *);
13222 +#endif /* __KERNEL__ */
13223 +#endif /* _VX_CONTEXT_CMD_H */
13224 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/percpu.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/percpu.h
13225 --- linux-3.6.10/include/linux/vserver/percpu.h 1970-01-01 01:00:00.000000000 +0100
13226 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/percpu.h 2012-10-04 18:47:00.000000000 +0200
13228 +#ifndef _VX_PERCPU_H
13229 +#define _VX_PERCPU_H
13231 +#include "cvirt_def.h"
13232 +#include "sched_def.h"
13234 +struct _vx_percpu {
13235 + struct _vx_cvirt_pc cvirt;
13236 + struct _vx_sched_pc sched;
13239 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
13241 +#endif /* _VX_PERCPU_H */
13242 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/pid.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/pid.h
13243 --- linux-3.6.10/include/linux/vserver/pid.h 1970-01-01 01:00:00.000000000 +0100
13244 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/pid.h 2012-10-04 18:47:00.000000000 +0200
13246 +#ifndef _VSERVER_PID_H
13247 +#define _VSERVER_PID_H
13249 +/* pid faking stuff */
13251 +#define vx_info_map_pid(v, p) \
13252 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
13253 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
13254 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
13255 +#define vx_map_tgid(p) vx_map_pid(p)
13257 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
13258 + const char *func, const char *file, int line)
13260 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13261 + vxfprintk(VXD_CBIT(cvirt, 2),
13262 + "vx_map_tgid: %p/%llx: %d -> %d",
13263 + vxi, (long long)vxi->vx_flags, pid,
13264 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
13265 + func, file, line);
13268 + if (pid == vxi->vx_initpid)
13274 +#define vx_info_rmap_pid(v, p) \
13275 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
13276 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
13277 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
13279 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
13280 + const char *func, const char *file, int line)
13282 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13283 + vxfprintk(VXD_CBIT(cvirt, 2),
13284 + "vx_rmap_tgid: %p/%llx: %d -> %d",
13285 + vxi, (long long)vxi->vx_flags, pid,
13286 + (pid == 1) ? vxi->vx_initpid : pid,
13287 + func, file, line);
13288 + if ((pid == 1) && vxi->vx_initpid)
13289 + return vxi->vx_initpid;
13290 + if (pid == vxi->vx_initpid)
13297 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/sched.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/sched.h
13298 --- linux-3.6.10/include/linux/vserver/sched.h 1970-01-01 01:00:00.000000000 +0100
13299 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/sched.h 2012-10-04 18:47:00.000000000 +0200
13301 +#ifndef _VX_SCHED_H
13302 +#define _VX_SCHED_H
13309 +void vx_vsi_uptime(struct timespec *, struct timespec *);
13314 +void vx_update_load(struct vx_info *);
13317 +void vx_update_sched_param(struct _vx_sched *sched,
13318 + struct _vx_sched_pc *sched_pc);
13320 +#endif /* __KERNEL__ */
13321 +#else /* _VX_SCHED_H */
13322 +#warning duplicate inclusion
13323 +#endif /* _VX_SCHED_H */
13324 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/sched_cmd.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/sched_cmd.h
13325 --- linux-3.6.10/include/linux/vserver/sched_cmd.h 1970-01-01 01:00:00.000000000 +0100
13326 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/sched_cmd.h 2012-10-04 18:47:00.000000000 +0200
13328 +#ifndef _VX_SCHED_CMD_H
13329 +#define _VX_SCHED_CMD_H
13332 +struct vcmd_prio_bias {
13334 + int32_t prio_bias;
13337 +#define VCMD_set_prio_bias VC_CMD(SCHED, 4, 0)
13338 +#define VCMD_get_prio_bias VC_CMD(SCHED, 5, 0)
13342 +#include <linux/compiler.h>
13344 +extern int vc_set_prio_bias(struct vx_info *, void __user *);
13345 +extern int vc_get_prio_bias(struct vx_info *, void __user *);
13347 +#endif /* __KERNEL__ */
13348 +#endif /* _VX_SCHED_CMD_H */
13349 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/sched_def.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/sched_def.h
13350 --- linux-3.6.10/include/linux/vserver/sched_def.h 1970-01-01 01:00:00.000000000 +0100
13351 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/sched_def.h 2012-10-04 18:47:00.000000000 +0200
13353 +#ifndef _VX_SCHED_DEF_H
13354 +#define _VX_SCHED_DEF_H
13356 +#include <linux/spinlock.h>
13357 +#include <linux/jiffies.h>
13358 +#include <linux/cpumask.h>
13359 +#include <asm/atomic.h>
13360 +#include <asm/param.h>
13363 +/* context sub struct */
13365 +struct _vx_sched {
13366 + int prio_bias; /* bias offset for priority */
13368 + cpumask_t update; /* CPUs which should update */
13371 +struct _vx_sched_pc {
13372 + int prio_bias; /* bias offset for priority */
13374 + uint64_t user_ticks; /* token tick events */
13375 + uint64_t sys_ticks; /* token tick events */
13376 + uint64_t hold_ticks; /* token ticks paused */
13380 +#ifdef CONFIG_VSERVER_DEBUG
13382 +static inline void __dump_vx_sched(struct _vx_sched *sched)
13384 + printk("\t_vx_sched:\n");
13385 + printk("\t priority = %4d\n", sched->prio_bias);
13390 +#endif /* _VX_SCHED_DEF_H */
13391 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/signal.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/signal.h
13392 --- linux-3.6.10/include/linux/vserver/signal.h 1970-01-01 01:00:00.000000000 +0100
13393 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/signal.h 2012-10-04 18:47:00.000000000 +0200
13395 +#ifndef _VX_SIGNAL_H
13396 +#define _VX_SIGNAL_H
13403 +int vx_info_kill(struct vx_info *, int, int);
13405 +#endif /* __KERNEL__ */
13406 +#else /* _VX_SIGNAL_H */
13407 +#warning duplicate inclusion
13408 +#endif /* _VX_SIGNAL_H */
13409 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/signal_cmd.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/signal_cmd.h
13410 --- linux-3.6.10/include/linux/vserver/signal_cmd.h 1970-01-01 01:00:00.000000000 +0100
13411 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/signal_cmd.h 2012-10-04 18:47:00.000000000 +0200
13413 +#ifndef _VX_SIGNAL_CMD_H
13414 +#define _VX_SIGNAL_CMD_H
13417 +/* signalling vserver commands */
13419 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
13420 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
13422 +struct vcmd_ctx_kill_v0 {
13427 +struct vcmd_wait_exit_v0 {
13428 + int32_t reboot_cmd;
13429 + int32_t exit_code;
13434 +extern int vc_ctx_kill(struct vx_info *, void __user *);
13435 +extern int vc_wait_exit(struct vx_info *, void __user *);
13437 +#endif /* __KERNEL__ */
13439 +/* process alteration commands */
13441 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
13442 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
13444 +struct vcmd_pflags_v0 {
13445 + uint32_t flagword;
13451 +extern int vc_get_pflags(uint32_t pid, void __user *);
13452 +extern int vc_set_pflags(uint32_t pid, void __user *);
13454 +#endif /* __KERNEL__ */
13455 +#endif /* _VX_SIGNAL_CMD_H */
13456 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/space.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/space.h
13457 --- linux-3.6.10/include/linux/vserver/space.h 1970-01-01 01:00:00.000000000 +0100
13458 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/space.h 2012-10-04 18:47:00.000000000 +0200
13460 +#ifndef _VX_SPACE_H
13461 +#define _VX_SPACE_H
13463 +#include <linux/types.h>
13467 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
13469 +#else /* _VX_SPACE_H */
13470 +#warning duplicate inclusion
13471 +#endif /* _VX_SPACE_H */
13472 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/space_cmd.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/space_cmd.h
13473 --- linux-3.6.10/include/linux/vserver/space_cmd.h 1970-01-01 01:00:00.000000000 +0100
13474 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/space_cmd.h 2012-10-04 18:47:00.000000000 +0200
13476 +#ifndef _VX_SPACE_CMD_H
13477 +#define _VX_SPACE_CMD_H
13480 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
13481 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
13482 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
13484 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
13485 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
13486 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
13488 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
13490 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
13491 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
13494 +struct vcmd_space_mask_v1 {
13498 +struct vcmd_space_mask_v2 {
13506 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
13507 +extern int vc_set_space_v1(struct vx_info *, void __user *);
13508 +extern int vc_enter_space(struct vx_info *, void __user *);
13509 +extern int vc_set_space(struct vx_info *, void __user *);
13510 +extern int vc_get_space_mask(void __user *, int);
13512 +#endif /* __KERNEL__ */
13513 +#endif /* _VX_SPACE_CMD_H */
13514 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/switch.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/switch.h
13515 --- linux-3.6.10/include/linux/vserver/switch.h 1970-01-01 01:00:00.000000000 +0100
13516 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/switch.h 2012-10-04 18:47:00.000000000 +0200
13518 +#ifndef _VX_SWITCH_H
13519 +#define _VX_SWITCH_H
13521 +#include <linux/types.h>
13524 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
13525 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
13526 +#define VC_VERSION(c) ((c) & 0xFFF)
13528 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
13529 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
13533 + Syscall Matrix V2.8
13535 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
13536 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
13537 + |INFO |SETUP | |MOVE | | | | | |
13538 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13539 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
13540 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
13541 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13542 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
13543 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
13544 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13545 + MEMORY | | | | |MEMCTRL| | |SWAP | |
13546 + | 16| 17| 18| 19| 20| 21| | 22| 23|
13547 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13548 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
13549 + | 24| 25| 26| 27| 28| 29| | 30| 31|
13550 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13551 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
13552 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
13553 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13554 + OTHER |VSTAT | | | | | | |VINFO | |
13555 + | 40| 41| 42| 43| 44| 45| | 46| 47|
13556 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
13557 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
13558 + | 48| 49| 50| 51| 52| 53| | 54| 55|
13559 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13560 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
13561 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
13562 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13566 +#define VC_CAT_VERSION 0
13568 +#define VC_CAT_VSETUP 1
13569 +#define VC_CAT_VHOST 2
13571 +#define VC_CAT_DEVICE 6
13573 +#define VC_CAT_VPROC 9
13574 +#define VC_CAT_PROCALT 10
13575 +#define VC_CAT_PROCMIG 11
13576 +#define VC_CAT_PROCTRL 12
13578 +#define VC_CAT_SCHED 14
13579 +#define VC_CAT_MEMCTRL 20
13581 +#define VC_CAT_VNET 25
13582 +#define VC_CAT_NETALT 26
13583 +#define VC_CAT_NETMIG 27
13584 +#define VC_CAT_NETCTRL 28
13586 +#define VC_CAT_TAGMIG 35
13587 +#define VC_CAT_DLIMIT 36
13588 +#define VC_CAT_INODE 38
13590 +#define VC_CAT_VSTAT 40
13591 +#define VC_CAT_VINFO 46
13592 +#define VC_CAT_EVENT 48
13594 +#define VC_CAT_FLAGS 52
13595 +#define VC_CAT_VSPACE 54
13596 +#define VC_CAT_DEBUG 56
13597 +#define VC_CAT_RLIMIT 60
13599 +#define VC_CAT_SYSTEST 61
13600 +#define VC_CAT_COMPAT 63
13602 +/* query version */
13604 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
13605 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
13610 +#include <linux/errno.h>
13612 +#endif /* __KERNEL__ */
13614 +#endif /* _VX_SWITCH_H */
13616 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/tag.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/tag.h
13617 --- linux-3.6.10/include/linux/vserver/tag.h 1970-01-01 01:00:00.000000000 +0100
13618 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/tag.h 2012-10-04 18:47:00.000000000 +0200
13623 +#include <linux/types.h>
13626 +#define DX_TAG(in) (IS_TAGGED(in))
13629 +#ifdef CONFIG_TAG_NFSD
13630 +#define DX_TAG_NFSD 1
13632 +#define DX_TAG_NFSD 0
13636 +#ifdef CONFIG_TAGGING_NONE
13638 +#define MAX_UID 0xFFFFFFFF
13639 +#define MAX_GID 0xFFFFFFFF
13641 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
13643 +#define TAGINO_UID(cond, uid, tag) (uid)
13644 +#define TAGINO_GID(cond, gid, tag) (gid)
13649 +#ifdef CONFIG_TAGGING_GID16
13651 +#define MAX_UID 0xFFFFFFFF
13652 +#define MAX_GID 0x0000FFFF
13654 +#define INOTAG_TAG(cond, uid, gid, tag) \
13655 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
13657 +#define TAGINO_UID(cond, uid, tag) (uid)
13658 +#define TAGINO_GID(cond, gid, tag) \
13659 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
13664 +#ifdef CONFIG_TAGGING_ID24
13666 +#define MAX_UID 0x00FFFFFF
13667 +#define MAX_GID 0x00FFFFFF
13669 +#define INOTAG_TAG(cond, uid, gid, tag) \
13670 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
13672 +#define TAGINO_UID(cond, uid, tag) \
13673 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
13674 +#define TAGINO_GID(cond, gid, tag) \
13675 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
13680 +#ifdef CONFIG_TAGGING_UID16
13682 +#define MAX_UID 0x0000FFFF
13683 +#define MAX_GID 0xFFFFFFFF
13685 +#define INOTAG_TAG(cond, uid, gid, tag) \
13686 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
13688 +#define TAGINO_UID(cond, uid, tag) \
13689 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
13690 +#define TAGINO_GID(cond, gid, tag) (gid)
13695 +#ifdef CONFIG_TAGGING_INTERN
13697 +#define MAX_UID 0xFFFFFFFF
13698 +#define MAX_GID 0xFFFFFFFF
13700 +#define INOTAG_TAG(cond, uid, gid, tag) \
13701 + ((cond) ? (tag) : 0)
13703 +#define TAGINO_UID(cond, uid, tag) (uid)
13704 +#define TAGINO_GID(cond, gid, tag) (gid)
13709 +#ifndef CONFIG_TAGGING_NONE
13710 +#define dx_current_fstag(sb) \
13711 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
13713 +#define dx_current_fstag(sb) (0)
13716 +#ifndef CONFIG_TAGGING_INTERN
13717 +#define TAGINO_TAG(cond, tag) (0)
13719 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
13722 +#define INOTAG_UID(cond, uid, gid) \
13723 + ((cond) ? ((uid) & MAX_UID) : (uid))
13724 +#define INOTAG_GID(cond, uid, gid) \
13725 + ((cond) ? ((gid) & MAX_GID) : (gid))
13728 +static inline uid_t dx_map_uid(uid_t uid)
13730 + if ((uid > MAX_UID) && (uid != -1))
13732 + return (uid & MAX_UID);
13735 +static inline gid_t dx_map_gid(gid_t gid)
13737 + if ((gid > MAX_GID) && (gid != -1))
13739 + return (gid & MAX_GID);
13747 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
13749 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
13750 + unsigned long *flags);
13752 +#ifdef CONFIG_PROPAGATE
13754 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
13756 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
13759 +#define dx_propagate_tag(n, i) do { } while (0)
13762 +#endif /* _DX_TAG_H */
13763 diff -NurpP --minimal linux-3.6.10/include/linux/vserver/tag_cmd.h linux-3.6.10-vs2.3.4.5/include/linux/vserver/tag_cmd.h
13764 --- linux-3.6.10/include/linux/vserver/tag_cmd.h 1970-01-01 01:00:00.000000000 +0100
13765 +++ linux-3.6.10-vs2.3.4.5/include/linux/vserver/tag_cmd.h 2012-10-04 18:47:00.000000000 +0200
13767 +#ifndef _VX_TAG_CMD_H
13768 +#define _VX_TAG_CMD_H
13771 +/* vinfo commands */
13773 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
13776 +extern int vc_task_tag(uint32_t);
13778 +#endif /* __KERNEL__ */
13780 +/* context commands */
13782 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
13785 +extern int vc_tag_migrate(uint32_t);
13787 +#endif /* __KERNEL__ */
13788 +#endif /* _VX_TAG_CMD_H */
13789 diff -NurpP --minimal linux-3.6.10/include/net/addrconf.h linux-3.6.10-vs2.3.4.5/include/net/addrconf.h
13790 --- linux-3.6.10/include/net/addrconf.h 2012-10-04 15:27:47.000000000 +0200
13791 +++ linux-3.6.10-vs2.3.4.5/include/net/addrconf.h 2012-10-04 18:47:00.000000000 +0200
13792 @@ -81,7 +81,8 @@ extern int ipv6_dev_get_saddr(struct n
13793 struct net_device *dev,
13794 const struct in6_addr *daddr,
13795 unsigned int srcprefs,
13796 - struct in6_addr *saddr);
13797 + struct in6_addr *saddr,
13798 + struct nx_info *nxi);
13799 extern int ipv6_get_lladdr(struct net_device *dev,
13800 struct in6_addr *addr,
13801 unsigned char banned_flags);
13802 diff -NurpP --minimal linux-3.6.10/include/net/af_unix.h linux-3.6.10-vs2.3.4.5/include/net/af_unix.h
13803 --- linux-3.6.10/include/net/af_unix.h 2012-10-04 15:27:47.000000000 +0200
13804 +++ linux-3.6.10-vs2.3.4.5/include/net/af_unix.h 2012-10-04 18:47:00.000000000 +0200
13806 #include <linux/socket.h>
13807 #include <linux/un.h>
13808 #include <linux/mutex.h>
13809 +#include <linux/vs_base.h>
13810 #include <net/sock.h>
13812 extern void unix_inflight(struct file *fp);
13813 diff -NurpP --minimal linux-3.6.10/include/net/inet_timewait_sock.h linux-3.6.10-vs2.3.4.5/include/net/inet_timewait_sock.h
13814 --- linux-3.6.10/include/net/inet_timewait_sock.h 2012-03-19 19:47:29.000000000 +0100
13815 +++ linux-3.6.10-vs2.3.4.5/include/net/inet_timewait_sock.h 2012-10-04 18:47:00.000000000 +0200
13816 @@ -112,6 +112,10 @@ struct inet_timewait_sock {
13817 #define tw_net __tw_common.skc_net
13818 #define tw_daddr __tw_common.skc_daddr
13819 #define tw_rcv_saddr __tw_common.skc_rcv_saddr
13820 +#define tw_xid __tw_common.skc_xid
13821 +#define tw_vx_info __tw_common.skc_vx_info
13822 +#define tw_nid __tw_common.skc_nid
13823 +#define tw_nx_info __tw_common.skc_nx_info
13825 volatile unsigned char tw_substate;
13826 unsigned char tw_rcv_wscale;
13827 diff -NurpP --minimal linux-3.6.10/include/net/ip6_route.h linux-3.6.10-vs2.3.4.5/include/net/ip6_route.h
13828 --- linux-3.6.10/include/net/ip6_route.h 2012-10-04 15:27:47.000000000 +0200
13829 +++ linux-3.6.10-vs2.3.4.5/include/net/ip6_route.h 2012-10-04 18:47:00.000000000 +0200
13830 @@ -97,7 +97,8 @@ extern int ip6_route_get_saddr(struct
13831 struct rt6_info *rt,
13832 const struct in6_addr *daddr,
13833 unsigned int prefs,
13834 - struct in6_addr *saddr);
13835 + struct in6_addr *saddr,
13836 + struct nx_info *nxi);
13838 extern struct rt6_info *rt6_lookup(struct net *net,
13839 const struct in6_addr *daddr,
13840 diff -NurpP --minimal linux-3.6.10/include/net/route.h linux-3.6.10-vs2.3.4.5/include/net/route.h
13841 --- linux-3.6.10/include/net/route.h 2012-12-11 12:36:59.000000000 +0100
13842 +++ linux-3.6.10-vs2.3.4.5/include/net/route.h 2012-11-06 18:43:41.000000000 +0100
13843 @@ -204,6 +204,9 @@ static inline void ip_rt_put(struct rtab
13844 dst_release(&rt->dst);
13847 +#include <linux/vs_base.h>
13848 +#include <linux/vs_inet.h>
13850 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
13852 extern const __u8 ip_tos2prio[16];
13853 @@ -253,6 +256,9 @@ static inline void ip_route_connect_init
13854 protocol, flow_flags, dst, src, dport, sport);
13857 +extern struct rtable *ip_v4_find_src(struct net *net, struct nx_info *,
13858 + struct flowi4 *);
13860 static inline struct rtable *ip_route_connect(struct flowi4 *fl4,
13861 __be32 dst, __be32 src, u32 tos,
13862 int oif, u8 protocol,
13863 @@ -261,11 +267,25 @@ static inline struct rtable *ip_route_co
13865 struct net *net = sock_net(sk);
13867 + struct nx_info *nx_info = current_nx_info();
13869 ip_route_connect_init(fl4, dst, src, tos, oif, protocol,
13870 sport, dport, sk, can_sleep);
13872 - if (!dst || !src) {
13874 + nx_info = sk->sk_nx_info;
13876 + vxdprintk(VXD_CBIT(net, 4),
13877 + "ip_route_connect(%p) %p,%p;%lx",
13878 + sk, nx_info, sk->sk_socket,
13879 + (sk->sk_socket?sk->sk_socket->flags:0));
13881 + rt = ip_v4_find_src(net, nx_info, fl4);
13886 + if (!fl4->daddr || !fl4->saddr) {
13887 rt = __ip_route_output_key(net, fl4);
13890 diff -NurpP --minimal linux-3.6.10/include/net/sock.h linux-3.6.10-vs2.3.4.5/include/net/sock.h
13891 --- linux-3.6.10/include/net/sock.h 2012-10-04 15:27:47.000000000 +0200
13892 +++ linux-3.6.10-vs2.3.4.5/include/net/sock.h 2012-10-04 18:47:00.000000000 +0200
13893 @@ -171,6 +171,10 @@ struct sock_common {
13894 #ifdef CONFIG_NET_NS
13895 struct net *skc_net;
13898 + struct vx_info *skc_vx_info;
13900 + struct nx_info *skc_nx_info;
13902 * fields between dontcopy_begin/dontcopy_end
13903 * are not copied in sock_copy()
13904 @@ -284,6 +288,10 @@ struct sock {
13905 #define sk_bind_node __sk_common.skc_bind_node
13906 #define sk_prot __sk_common.skc_prot
13907 #define sk_net __sk_common.skc_net
13908 +#define sk_xid __sk_common.skc_xid
13909 +#define sk_vx_info __sk_common.skc_vx_info
13910 +#define sk_nid __sk_common.skc_nid
13911 +#define sk_nx_info __sk_common.skc_nx_info
13912 socket_lock_t sk_lock;
13913 struct sk_buff_head sk_receive_queue;
13915 diff -NurpP --minimal linux-3.6.10/init/Kconfig linux-3.6.10-vs2.3.4.5/init/Kconfig
13916 --- linux-3.6.10/init/Kconfig 2012-10-04 15:27:48.000000000 +0200
13917 +++ linux-3.6.10-vs2.3.4.5/init/Kconfig 2012-10-04 18:47:00.000000000 +0200
13918 @@ -624,6 +624,7 @@ config HAVE_UNSTABLE_SCHED_CLOCK
13920 boolean "Control Group support"
13924 This option adds support for grouping sets of processes together, for
13925 use with process control subsystems such as Cpusets, CFS, memory
13926 @@ -889,6 +890,7 @@ config USER_NS
13927 bool "User namespace (EXPERIMENTAL)"
13928 depends on EXPERIMENTAL
13929 depends on UIDGID_CONVERTED
13930 + depends on VSERVER_DISABLED
13931 select UIDGID_STRICT_TYPE_CHECKS
13934 diff -NurpP --minimal linux-3.6.10/init/main.c linux-3.6.10-vs2.3.4.5/init/main.c
13935 --- linux-3.6.10/init/main.c 2012-12-11 12:36:59.000000000 +0100
13936 +++ linux-3.6.10-vs2.3.4.5/init/main.c 2012-11-06 18:43:41.000000000 +0100
13938 #include <linux/slab.h>
13939 #include <linux/perf_event.h>
13940 #include <linux/file.h>
13941 +#include <linux/vserver/percpu.h>
13943 #include <asm/io.h>
13944 #include <asm/bugs.h>
13945 diff -NurpP --minimal linux-3.6.10/ipc/mqueue.c linux-3.6.10-vs2.3.4.5/ipc/mqueue.c
13946 --- linux-3.6.10/ipc/mqueue.c 2012-10-04 15:27:48.000000000 +0200
13947 +++ linux-3.6.10-vs2.3.4.5/ipc/mqueue.c 2012-10-04 18:47:00.000000000 +0200
13949 #include <linux/ipc_namespace.h>
13950 #include <linux/user_namespace.h>
13951 #include <linux/slab.h>
13952 +#include <linux/vs_context.h>
13953 +#include <linux/vs_limit.h>
13955 #include <net/sock.h>
13957 @@ -76,6 +78,7 @@ struct mqueue_inode_info {
13958 struct pid* notify_owner;
13959 struct user_namespace *notify_user_ns;
13960 struct user_struct *user; /* user who created, for accounting */
13961 + struct vx_info *vxi;
13962 struct sock *notify_sock;
13963 struct sk_buff *notify_cookie;
13965 @@ -235,6 +238,7 @@ static struct inode *mqueue_get_inode(st
13966 if (S_ISREG(mode)) {
13967 struct mqueue_inode_info *info;
13968 unsigned long mq_bytes, mq_treesize;
13969 + struct vx_info *vxi = current_vx_info();
13971 inode->i_fop = &mqueue_file_operations;
13972 inode->i_size = FILENT_SIZE;
13973 @@ -248,6 +252,7 @@ static struct inode *mqueue_get_inode(st
13974 info->notify_user_ns = NULL;
13976 info->user = NULL; /* set when all is ok */
13977 + info->vxi = NULL;
13978 info->msg_tree = RB_ROOT;
13979 info->node_cache = NULL;
13980 memset(&info->attr, 0, sizeof(info->attr));
13981 @@ -281,17 +286,20 @@ static struct inode *mqueue_get_inode(st
13983 spin_lock(&mq_lock);
13984 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
13985 - u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
13986 + u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE) ||
13987 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
13988 spin_unlock(&mq_lock);
13989 /* mqueue_evict_inode() releases info->messages */
13993 u->mq_bytes += mq_bytes;
13994 + vx_ipcmsg_add(vxi, u, mq_bytes);
13995 spin_unlock(&mq_lock);
13998 info->user = get_uid(u);
13999 + info->vxi = get_vx_info(vxi);
14000 } else if (S_ISDIR(mode)) {
14002 /* Some things misbehave if size == 0 on a directory */
14003 @@ -395,8 +403,11 @@ static void mqueue_evict_inode(struct in
14007 + struct vx_info *vxi = info->vxi;
14009 spin_lock(&mq_lock);
14010 user->mq_bytes -= mq_bytes;
14011 + vx_ipcmsg_sub(vxi, user, mq_bytes);
14013 * get_ns_from_inode() ensures that the
14014 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
14015 @@ -406,6 +417,7 @@ static void mqueue_evict_inode(struct in
14017 ipc_ns->mq_queues_count--;
14018 spin_unlock(&mq_lock);
14019 + put_vx_info(vxi);
14023 diff -NurpP --minimal linux-3.6.10/ipc/msg.c linux-3.6.10-vs2.3.4.5/ipc/msg.c
14024 --- linux-3.6.10/ipc/msg.c 2011-05-22 16:17:59.000000000 +0200
14025 +++ linux-3.6.10-vs2.3.4.5/ipc/msg.c 2012-10-04 18:47:00.000000000 +0200
14027 #include <linux/rwsem.h>
14028 #include <linux/nsproxy.h>
14029 #include <linux/ipc_namespace.h>
14030 +#include <linux/vs_base.h>
14032 #include <asm/current.h>
14033 #include <asm/uaccess.h>
14034 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
14036 msq->q_perm.mode = msgflg & S_IRWXUGO;
14037 msq->q_perm.key = key;
14038 + msq->q_perm.xid = vx_current_xid();
14040 msq->q_perm.security = NULL;
14041 retval = security_msg_queue_alloc(msq);
14042 diff -NurpP --minimal linux-3.6.10/ipc/namespace.c linux-3.6.10-vs2.3.4.5/ipc/namespace.c
14043 --- linux-3.6.10/ipc/namespace.c 2012-07-22 23:39:46.000000000 +0200
14044 +++ linux-3.6.10-vs2.3.4.5/ipc/namespace.c 2012-10-04 18:47:00.000000000 +0200
14045 @@ -13,11 +13,12 @@
14046 #include <linux/mount.h>
14047 #include <linux/user_namespace.h>
14048 #include <linux/proc_fs.h>
14049 +#include <linux/vs_base.h>
14050 +#include <linux/vserver/global.h>
14054 -static struct ipc_namespace *create_ipc_ns(struct task_struct *tsk,
14055 - struct ipc_namespace *old_ns)
14056 +static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns)
14058 struct ipc_namespace *ns;
14060 @@ -46,19 +47,19 @@ static struct ipc_namespace *create_ipc_
14061 ipcns_notify(IPCNS_CREATED);
14062 register_ipcns_notifier(ns);
14064 - ns->user_ns = get_user_ns(task_cred_xxx(tsk, user_ns));
14065 + // ns->user_ns = get_user_ns(task_cred_xxx(tsk, user_ns));
14066 + ns->user_ns = get_user_ns(user_ns);
14071 struct ipc_namespace *copy_ipcs(unsigned long flags,
14072 - struct task_struct *tsk)
14073 + struct ipc_namespace *old_ns,
14074 + struct user_namespace *user_ns)
14076 - struct ipc_namespace *ns = tsk->nsproxy->ipc_ns;
14078 if (!(flags & CLONE_NEWIPC))
14079 - return get_ipc_ns(ns);
14080 - return create_ipc_ns(tsk, ns);
14081 + return get_ipc_ns(old_ns);
14082 + return create_ipc_ns(user_ns);
14086 diff -NurpP --minimal linux-3.6.10/ipc/sem.c linux-3.6.10-vs2.3.4.5/ipc/sem.c
14087 --- linux-3.6.10/ipc/sem.c 2012-01-09 16:14:59.000000000 +0100
14088 +++ linux-3.6.10-vs2.3.4.5/ipc/sem.c 2012-10-04 18:47:00.000000000 +0200
14090 #include <linux/rwsem.h>
14091 #include <linux/nsproxy.h>
14092 #include <linux/ipc_namespace.h>
14093 +#include <linux/vs_base.h>
14094 +#include <linux/vs_limit.h>
14096 #include <asm/uaccess.h>
14098 @@ -306,6 +308,7 @@ static int newary(struct ipc_namespace *
14100 sma->sem_perm.mode = (semflg & S_IRWXUGO);
14101 sma->sem_perm.key = key;
14102 + sma->sem_perm.xid = vx_current_xid();
14104 sma->sem_perm.security = NULL;
14105 retval = security_sem_alloc(sma);
14106 @@ -321,6 +324,9 @@ static int newary(struct ipc_namespace *
14109 ns->used_sems += nsems;
14110 + /* FIXME: obsoleted? */
14111 + vx_semary_inc(sma);
14112 + vx_nsems_add(sma, nsems);
14114 sma->sem_base = (struct sem *) &sma[1];
14116 @@ -770,6 +776,9 @@ static void freeary(struct ipc_namespace
14118 wake_up_sem_queue_do(&tasks);
14119 ns->used_sems -= sma->sem_nsems;
14120 + /* FIXME: obsoleted? */
14121 + vx_nsems_sub(sma, sma->sem_nsems);
14122 + vx_semary_dec(sma);
14123 security_sem_free(sma);
14124 ipc_rcu_putref(sma);
14126 diff -NurpP --minimal linux-3.6.10/ipc/shm.c linux-3.6.10-vs2.3.4.5/ipc/shm.c
14127 --- linux-3.6.10/ipc/shm.c 2012-10-04 15:27:48.000000000 +0200
14128 +++ linux-3.6.10-vs2.3.4.5/ipc/shm.c 2012-10-04 18:47:00.000000000 +0200
14130 #include <linux/nsproxy.h>
14131 #include <linux/mount.h>
14132 #include <linux/ipc_namespace.h>
14133 +#include <linux/vs_context.h>
14134 +#include <linux/vs_limit.h>
14136 #include <asm/uaccess.h>
14138 @@ -187,7 +189,12 @@ static void shm_open(struct vm_area_stru
14140 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
14142 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14143 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
14144 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14146 + vx_ipcshm_sub(vxi, shp, numpages);
14147 + ns->shm_tot -= numpages;
14151 if (!is_file_hugepages(shp->shm_file))
14152 @@ -197,6 +204,7 @@ static void shm_destroy(struct ipc_names
14154 fput (shp->shm_file);
14155 security_shm_free(shp);
14156 + put_vx_info(vxi);
14157 ipc_rcu_putref(shp);
14160 @@ -474,11 +482,15 @@ static int newseg(struct ipc_namespace *
14161 if (ns->shm_tot + numpages > ns->shm_ctlall)
14164 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
14167 shp = ipc_rcu_alloc(sizeof(*shp));
14171 shp->shm_perm.key = key;
14172 + shp->shm_perm.xid = vx_current_xid();
14173 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
14174 shp->mlock_user = NULL;
14176 @@ -533,6 +545,7 @@ static int newseg(struct ipc_namespace *
14177 ns->shm_tot += numpages;
14178 error = shp->shm_perm.id;
14180 + vx_ipcshm_add(current_vx_info(), key, numpages);
14184 diff -NurpP --minimal linux-3.6.10/kernel/Makefile linux-3.6.10-vs2.3.4.5/kernel/Makefile
14185 --- linux-3.6.10/kernel/Makefile 2012-07-22 23:39:46.000000000 +0200
14186 +++ linux-3.6.10-vs2.3.4.5/kernel/Makefile 2012-10-04 18:47:00.000000000 +0200
14187 @@ -24,6 +24,7 @@ endif
14193 ifeq ($(CONFIG_CHECKPOINT_RESTORE),y)
14194 obj-$(CONFIG_X86) += kcmp.o
14195 diff -NurpP --minimal linux-3.6.10/kernel/auditsc.c linux-3.6.10-vs2.3.4.5/kernel/auditsc.c
14196 --- linux-3.6.10/kernel/auditsc.c 2012-07-22 23:39:46.000000000 +0200
14197 +++ linux-3.6.10-vs2.3.4.5/kernel/auditsc.c 2012-10-04 18:47:00.000000000 +0200
14198 @@ -2309,7 +2309,7 @@ int audit_set_loginuid(uid_t loginuid)
14199 if (task->loginuid != -1)
14201 #else /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
14202 - if (!capable(CAP_AUDIT_CONTROL))
14203 + if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
14205 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
14207 diff -NurpP --minimal linux-3.6.10/kernel/capability.c linux-3.6.10-vs2.3.4.5/kernel/capability.c
14208 --- linux-3.6.10/kernel/capability.c 2012-07-22 23:39:46.000000000 +0200
14209 +++ linux-3.6.10-vs2.3.4.5/kernel/capability.c 2012-10-04 18:47:00.000000000 +0200
14211 #include <linux/syscalls.h>
14212 #include <linux/pid_namespace.h>
14213 #include <linux/user_namespace.h>
14214 +#include <linux/vs_context.h>
14215 #include <asm/uaccess.h>
14218 @@ -116,6 +117,7 @@ static int cap_validate_magic(cap_user_h
14224 * The only thing that can change the capabilities of the current
14225 * process is the current process. As such, we can't be in this code
14226 @@ -349,6 +351,8 @@ bool has_ns_capability_noaudit(struct ta
14230 +#include <linux/vserver/base.h>
14233 * has_capability_noaudit - Does a task have a capability (unaudited) in the
14235 diff -NurpP --minimal linux-3.6.10/kernel/compat.c linux-3.6.10-vs2.3.4.5/kernel/compat.c
14236 --- linux-3.6.10/kernel/compat.c 2012-07-22 23:39:46.000000000 +0200
14237 +++ linux-3.6.10-vs2.3.4.5/kernel/compat.c 2012-10-04 18:47:00.000000000 +0200
14238 @@ -1054,7 +1054,7 @@ asmlinkage long compat_sys_stime(compat_
14242 - do_settimeofday(&tv);
14243 + vx_settimeofday(&tv);
14247 diff -NurpP --minimal linux-3.6.10/kernel/cred.c linux-3.6.10-vs2.3.4.5/kernel/cred.c
14248 --- linux-3.6.10/kernel/cred.c 2012-07-22 23:39:46.000000000 +0200
14249 +++ linux-3.6.10-vs2.3.4.5/kernel/cred.c 2012-10-04 18:47:00.000000000 +0200
14250 @@ -70,31 +70,6 @@ struct cred init_cred = {
14254 -static inline void set_cred_subscribers(struct cred *cred, int n)
14256 -#ifdef CONFIG_DEBUG_CREDENTIALS
14257 - atomic_set(&cred->subscribers, n);
14261 -static inline int read_cred_subscribers(const struct cred *cred)
14263 -#ifdef CONFIG_DEBUG_CREDENTIALS
14264 - return atomic_read(&cred->subscribers);
14270 -static inline void alter_cred_subscribers(const struct cred *_cred, int n)
14272 -#ifdef CONFIG_DEBUG_CREDENTIALS
14273 - struct cred *cred = (struct cred *) _cred;
14275 - atomic_add(n, &cred->subscribers);
14280 * Dispose of the shared task group credentials
14282 @@ -284,21 +259,16 @@ error:
14284 * Call commit_creds() or abort_creds() to clean up.
14286 -struct cred *prepare_creds(void)
14287 +struct cred *__prepare_creds(const struct cred *old)
14289 - struct task_struct *task = current;
14290 - const struct cred *old;
14293 - validate_process_creds();
14295 new = kmem_cache_alloc(cred_jar, GFP_KERNEL);
14299 kdebug("prepare_creds() alloc %p", new);
14301 - old = task->cred;
14302 memcpy(new, old, sizeof(struct cred));
14304 atomic_set(&new->usage, 1);
14305 @@ -326,6 +296,13 @@ error:
14310 +struct cred *prepare_creds(void)
14312 + validate_process_creds();
14314 + return __prepare_creds(current->cred);
14316 EXPORT_SYMBOL(prepare_creds);
14319 diff -NurpP --minimal linux-3.6.10/kernel/exit.c linux-3.6.10-vs2.3.4.5/kernel/exit.c
14320 --- linux-3.6.10/kernel/exit.c 2012-10-04 15:27:48.000000000 +0200
14321 +++ linux-3.6.10-vs2.3.4.5/kernel/exit.c 2012-12-08 01:20:39.000000000 +0100
14323 #include <linux/fs_struct.h>
14324 #include <linux/init_task.h>
14325 #include <linux/perf_event.h>
14326 +#include <linux/vs_limit.h>
14327 +#include <linux/vs_context.h>
14328 +#include <linux/vs_network.h>
14329 +#include <linux/vs_pid.h>
14330 #include <trace/events/sched.h>
14331 #include <linux/hw_breakpoint.h>
14332 #include <linux/oom.h>
14333 @@ -494,9 +498,11 @@ static void close_files(struct files_str
14334 filp_close(file, files);
14337 + vx_openfd_dec(i);
14345 @@ -711,15 +717,25 @@ static struct task_struct *find_new_reap
14346 __acquires(&tasklist_lock)
14348 struct pid_namespace *pid_ns = task_active_pid_ns(father);
14349 - struct task_struct *thread;
14350 + struct vx_info *vxi = task_get_vx_info(father);
14351 + struct task_struct *thread = father;
14352 + struct task_struct *reaper;
14355 while_each_thread(father, thread) {
14356 if (thread->flags & PF_EXITING)
14358 if (unlikely(pid_ns->child_reaper == father))
14359 pid_ns->child_reaper = thread;
14365 + reaper = pid_ns->child_reaper;
14367 + BUG_ON(!vxi->vx_reaper);
14368 + if (vxi->vx_reaper != init_pid_ns.child_reaper &&
14369 + vxi->vx_reaper != father)
14370 + reaper = vxi->vx_reaper;
14373 if (unlikely(pid_ns->child_reaper == father)) {
14374 @@ -757,7 +773,9 @@ static struct task_struct *find_new_reap
14378 - return pid_ns->child_reaper;
14380 + put_vx_info(vxi);
14385 @@ -808,10 +826,15 @@ static void forget_original_parent(struc
14386 list_for_each_entry_safe(p, n, &father->children, sibling) {
14387 struct task_struct *t = p;
14389 - t->real_parent = reaper;
14390 + struct task_struct *new_parent = reaper;
14392 + if (unlikely(p == reaper))
14393 + new_parent = task_active_pid_ns(p)->child_reaper;
14395 + t->real_parent = new_parent;
14396 if (t->parent == father) {
14398 - t->parent = t->real_parent;
14399 + t->parent = new_parent;
14401 if (t->pdeath_signal)
14402 group_send_sig_info(t->pdeath_signal,
14403 @@ -1018,6 +1041,9 @@ void do_exit(long code)
14405 ptrace_put_breakpoints(tsk);
14407 + /* needs to stay before exit_notify() */
14408 + exit_vx_info_early(tsk, code);
14410 exit_notify(tsk, group_dead);
14413 @@ -1068,10 +1094,15 @@ void do_exit(long code)
14415 raw_spin_unlock_wait(&tsk->pi_lock);
14417 + /* needs to stay after exit_notify() */
14418 + exit_vx_info(tsk, code);
14419 + exit_nx_info(tsk);
14421 /* causes final put_task_struct in finish_task_switch(). */
14422 tsk->state = TASK_DEAD;
14423 tsk->flags |= PF_NOFREEZE; /* tell freezer to ignore us */
14425 + printk("bad task: %p [%lx]\n", current, current->state);
14427 /* Avoid "noreturn function does return". */
14429 diff -NurpP --minimal linux-3.6.10/kernel/fork.c linux-3.6.10-vs2.3.4.5/kernel/fork.c
14430 --- linux-3.6.10/kernel/fork.c 2012-10-04 15:27:48.000000000 +0200
14431 +++ linux-3.6.10-vs2.3.4.5/kernel/fork.c 2012-10-04 18:47:00.000000000 +0200
14433 #include <linux/khugepaged.h>
14434 #include <linux/signalfd.h>
14435 #include <linux/uprobes.h>
14436 +#include <linux/vs_context.h>
14437 +#include <linux/vs_network.h>
14438 +#include <linux/vs_limit.h>
14440 #include <asm/pgtable.h>
14441 #include <asm/pgalloc.h>
14442 @@ -210,6 +213,8 @@ void free_task(struct task_struct *tsk)
14443 arch_release_thread_info(tsk->stack);
14444 free_thread_info(tsk->stack);
14445 rt_mutex_debug_task_free(tsk);
14446 + clr_vx_info(&tsk->vx_info);
14447 + clr_nx_info(&tsk->nx_info);
14448 ftrace_graph_exit_task(tsk);
14449 put_seccomp_filter(tsk);
14450 arch_release_task_struct(tsk);
14451 @@ -541,6 +546,7 @@ static struct mm_struct *mm_init(struct
14452 if (likely(!mm_alloc_pgd(mm))) {
14454 mmu_notifier_mm_init(mm);
14455 + set_vx_info(&mm->mm_vx_info, p->vx_info);
14459 @@ -593,6 +599,7 @@ void __mmdrop(struct mm_struct *mm)
14460 destroy_context(mm);
14461 mmu_notifier_mm_destroy(mm);
14463 + clr_vx_info(&mm->mm_vx_info);
14466 EXPORT_SYMBOL_GPL(__mmdrop);
14467 @@ -834,6 +841,7 @@ struct mm_struct *dup_mm(struct task_str
14470 memcpy(mm, oldmm, sizeof(*mm));
14471 + mm->mm_vx_info = NULL;
14472 mm_init_cpumask(mm);
14474 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
14475 @@ -874,6 +882,7 @@ fail_nocontext:
14476 * If init_new_context() failed, we cannot use mmput() to free the mm
14477 * because it calls destroy_context()
14479 + clr_vx_info(&mm->mm_vx_info);
14483 @@ -1157,6 +1166,8 @@ static struct task_struct *copy_process(
14485 struct task_struct *p;
14486 int cgroup_callbacks_done = 0;
14487 + struct vx_info *vxi;
14488 + struct nx_info *nxi;
14490 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
14491 return ERR_PTR(-EINVAL);
14492 @@ -1204,7 +1215,12 @@ static struct task_struct *copy_process(
14493 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
14494 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
14496 + init_vx_info(&p->vx_info, current_vx_info());
14497 + init_nx_info(&p->nx_info, current_nx_info());
14500 + if (!vx_nproc_avail(1))
14501 + goto bad_fork_free;
14502 if (atomic_read(&p->real_cred->user->processes) >=
14503 task_rlimit(p, RLIMIT_NPROC)) {
14504 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
14505 @@ -1483,6 +1499,18 @@ static struct task_struct *copy_process(
14508 spin_unlock(¤t->sighand->siglock);
14510 + /* p is copy of current */
14511 + vxi = p->vx_info;
14513 + claim_vx_info(vxi, p);
14514 + atomic_inc(&vxi->cvirt.nr_threads);
14515 + atomic_inc(&vxi->cvirt.total_forks);
14518 + nxi = p->nx_info;
14520 + claim_nx_info(nxi, p);
14521 write_unlock_irq(&tasklist_lock);
14522 proc_fork_connector(p);
14523 cgroup_post_fork(p);
14524 diff -NurpP --minimal linux-3.6.10/kernel/kthread.c linux-3.6.10-vs2.3.4.5/kernel/kthread.c
14525 --- linux-3.6.10/kernel/kthread.c 2012-10-04 15:27:48.000000000 +0200
14526 +++ linux-3.6.10-vs2.3.4.5/kernel/kthread.c 2012-10-04 18:47:00.000000000 +0200
14528 #include <linux/mutex.h>
14529 #include <linux/slab.h>
14530 #include <linux/freezer.h>
14531 +#include <linux/vs_pid.h>
14532 #include <trace/events/sched.h>
14534 static DEFINE_SPINLOCK(kthread_create_lock);
14535 diff -NurpP --minimal linux-3.6.10/kernel/nsproxy.c linux-3.6.10-vs2.3.4.5/kernel/nsproxy.c
14536 --- linux-3.6.10/kernel/nsproxy.c 2012-01-09 16:15:00.000000000 +0100
14537 +++ linux-3.6.10-vs2.3.4.5/kernel/nsproxy.c 2012-10-04 18:47:00.000000000 +0200
14538 @@ -20,11 +20,14 @@
14539 #include <linux/mnt_namespace.h>
14540 #include <linux/utsname.h>
14541 #include <linux/pid_namespace.h>
14542 +#include <linux/vserver/global.h>
14543 +#include <linux/vserver/debug.h>
14544 #include <net/net_namespace.h>
14545 #include <linux/ipc_namespace.h>
14546 #include <linux/proc_fs.h>
14547 #include <linux/file.h>
14548 #include <linux/syscalls.h>
14549 +#include "../fs/mount.h"
14551 static struct kmem_cache *nsproxy_cachep;
14553 @@ -46,8 +49,11 @@ static inline struct nsproxy *create_nsp
14554 struct nsproxy *nsproxy;
14556 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
14559 atomic_set(&nsproxy->count, 1);
14560 + atomic_inc(&vs_global_nsproxy);
14562 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
14566 @@ -56,8 +62,11 @@ static inline struct nsproxy *create_nsp
14567 * Return the newly created nsproxy. Do not attach this to the task,
14568 * leave it to the caller to do proper locking and attach it to task.
14570 -static struct nsproxy *create_new_namespaces(unsigned long flags,
14571 - struct task_struct *tsk, struct fs_struct *new_fs)
14572 +static struct nsproxy *unshare_namespaces(unsigned long flags,
14573 + struct nsproxy *orig,
14574 + struct fs_struct *new_fs,
14575 + struct user_namespace *new_user,
14576 + struct pid_namespace *new_pid)
14578 struct nsproxy *new_nsp;
14580 @@ -66,31 +75,31 @@ static struct nsproxy *create_new_namesp
14582 return ERR_PTR(-ENOMEM);
14584 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
14585 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
14586 if (IS_ERR(new_nsp->mnt_ns)) {
14587 err = PTR_ERR(new_nsp->mnt_ns);
14591 - new_nsp->uts_ns = copy_utsname(flags, tsk);
14592 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns, new_user);
14593 if (IS_ERR(new_nsp->uts_ns)) {
14594 err = PTR_ERR(new_nsp->uts_ns);
14598 - new_nsp->ipc_ns = copy_ipcs(flags, tsk);
14599 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns, new_user);
14600 if (IS_ERR(new_nsp->ipc_ns)) {
14601 err = PTR_ERR(new_nsp->ipc_ns);
14605 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
14606 + new_nsp->pid_ns = copy_pid_ns(flags, new_pid);
14607 if (IS_ERR(new_nsp->pid_ns)) {
14608 err = PTR_ERR(new_nsp->pid_ns);
14612 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
14613 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
14614 if (IS_ERR(new_nsp->net_ns)) {
14615 err = PTR_ERR(new_nsp->net_ns);
14617 @@ -115,6 +124,40 @@ out_ns:
14618 return ERR_PTR(err);
14621 +static struct nsproxy *create_new_namespaces(unsigned long flags,
14622 + struct task_struct *tsk, struct fs_struct *new_fs)
14624 + return unshare_namespaces(flags, tsk->nsproxy,
14625 + new_fs, task_cred_xxx(tsk, user_ns),
14626 + task_active_pid_ns(tsk));
14630 + * copies the nsproxy, setting refcount to 1, and grabbing a
14631 + * reference to all contained namespaces.
14633 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
14635 + struct nsproxy *ns = create_nsproxy();
14638 + memcpy(ns, orig, sizeof(struct nsproxy));
14639 + atomic_set(&ns->count, 1);
14642 + get_mnt_ns(ns->mnt_ns);
14644 + get_uts_ns(ns->uts_ns);
14646 + get_ipc_ns(ns->ipc_ns);
14648 + get_pid_ns(ns->pid_ns);
14650 + get_net(ns->net_ns);
14656 * called from clone. This now handles copy for nsproxy and all
14657 * namespaces therein.
14658 @@ -122,9 +165,12 @@ out_ns:
14659 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
14661 struct nsproxy *old_ns = tsk->nsproxy;
14662 - struct nsproxy *new_ns;
14663 + struct nsproxy *new_ns = NULL;
14666 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
14667 + flags, tsk, old_ns);
14672 @@ -134,7 +180,7 @@ int copy_namespaces(unsigned long flags,
14673 CLONE_NEWPID | CLONE_NEWNET)))
14676 - if (!capable(CAP_SYS_ADMIN)) {
14677 + if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
14681 @@ -161,6 +207,9 @@ int copy_namespaces(unsigned long flags,
14684 put_nsproxy(old_ns);
14685 + vxdprintk(VXD_CBIT(space, 3),
14686 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
14687 + flags, tsk, old_ns, err, new_ns);
14691 @@ -174,7 +223,9 @@ void free_nsproxy(struct nsproxy *ns)
14692 put_ipc_ns(ns->ipc_ns);
14694 put_pid_ns(ns->pid_ns);
14695 - put_net(ns->net_ns);
14697 + put_net(ns->net_ns);
14698 + atomic_dec(&vs_global_nsproxy);
14699 kmem_cache_free(nsproxy_cachep, ns);
14702 @@ -187,11 +238,15 @@ int unshare_nsproxy_namespaces(unsigned
14706 + vxdprintk(VXD_CBIT(space, 4),
14707 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
14708 + unshare_flags, current->nsproxy);
14710 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
14714 - if (!capable(CAP_SYS_ADMIN))
14715 + if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
14718 *new_nsp = create_new_namespaces(unshare_flags, current,
14719 diff -NurpP --minimal linux-3.6.10/kernel/pid.c linux-3.6.10-vs2.3.4.5/kernel/pid.c
14720 --- linux-3.6.10/kernel/pid.c 2012-07-22 23:39:46.000000000 +0200
14721 +++ linux-3.6.10-vs2.3.4.5/kernel/pid.c 2012-10-04 18:47:00.000000000 +0200
14723 #include <linux/pid_namespace.h>
14724 #include <linux/init_task.h>
14725 #include <linux/syscalls.h>
14726 +#include <linux/vs_pid.h>
14728 #define pid_hashfn(nr, ns) \
14729 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
14730 @@ -344,7 +345,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
14732 struct pid *find_vpid(int nr)
14734 - return find_pid_ns(nr, current->nsproxy->pid_ns);
14735 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
14737 EXPORT_SYMBOL_GPL(find_vpid);
14739 @@ -404,6 +405,9 @@ void transfer_pid(struct task_struct *ol
14740 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
14742 struct task_struct *result = NULL;
14744 + if (type == PIDTYPE_REALPID)
14745 + type = PIDTYPE_PID;
14747 struct hlist_node *first;
14748 first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]),
14749 @@ -423,7 +427,7 @@ struct task_struct *find_task_by_pid_ns(
14750 rcu_lockdep_assert(rcu_read_lock_held(),
14751 "find_task_by_pid_ns() needs rcu_read_lock()"
14753 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
14754 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
14757 struct task_struct *find_task_by_vpid(pid_t vnr)
14758 @@ -467,7 +471,7 @@ struct pid *find_get_pid(pid_t nr)
14760 EXPORT_SYMBOL_GPL(find_get_pid);
14762 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
14763 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
14767 @@ -480,6 +484,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
14771 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
14773 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
14776 pid_t pid_vnr(struct pid *pid)
14778 return pid_nr_ns(pid, current->nsproxy->pid_ns);
14779 diff -NurpP --minimal linux-3.6.10/kernel/pid_namespace.c linux-3.6.10-vs2.3.4.5/kernel/pid_namespace.c
14780 --- linux-3.6.10/kernel/pid_namespace.c 2012-10-04 15:27:48.000000000 +0200
14781 +++ linux-3.6.10-vs2.3.4.5/kernel/pid_namespace.c 2012-10-04 18:47:00.000000000 +0200
14783 #include <linux/slab.h>
14784 #include <linux/proc_fs.h>
14785 #include <linux/reboot.h>
14786 +#include <linux/vserver/global.h>
14788 #define BITS_PER_PAGE (PAGE_SIZE*8)
14790 @@ -89,6 +90,7 @@ static struct pid_namespace *create_pid_
14793 kref_init(&ns->kref);
14794 + atomic_inc(&vs_global_pid_ns);
14796 ns->parent = get_pid_ns(parent_pid_ns);
14798 @@ -120,6 +122,7 @@ static void destroy_pid_namespace(struct
14800 for (i = 0; i < PIDMAP_ENTRIES; i++)
14801 kfree(ns->pidmap[i].page);
14802 + atomic_dec(&vs_global_pid_ns);
14803 kmem_cache_free(pid_ns_cachep, ns);
14806 diff -NurpP --minimal linux-3.6.10/kernel/posix-timers.c linux-3.6.10-vs2.3.4.5/kernel/posix-timers.c
14807 --- linux-3.6.10/kernel/posix-timers.c 2012-01-09 16:15:00.000000000 +0100
14808 +++ linux-3.6.10-vs2.3.4.5/kernel/posix-timers.c 2012-10-04 18:47:00.000000000 +0200
14810 #include <linux/wait.h>
14811 #include <linux/workqueue.h>
14812 #include <linux/export.h>
14813 +#include <linux/vs_context.h>
14816 * Management arrays for POSIX timers. Timers are kept in slab memory
14817 @@ -340,6 +341,7 @@ int posix_timer_event(struct k_itimer *t
14819 struct task_struct *task;
14820 int shared, ret = -1;
14823 * FIXME: if ->sigq is queued we can race with
14824 * dequeue_signal()->do_schedule_next_timer().
14825 @@ -356,10 +358,18 @@ int posix_timer_event(struct k_itimer *t
14827 task = pid_task(timr->it_pid, PIDTYPE_PID);
14829 + struct vx_info_save vxis;
14830 + struct vx_info *vxi;
14832 + vxi = get_vx_info(task->vx_info);
14833 + enter_vx_info(vxi, &vxis);
14834 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
14835 ret = send_sigqueue(timr->sigq, task, shared);
14836 + leave_vx_info(&vxis);
14837 + put_vx_info(vxi);
14841 /* If we failed to send the signal the timer stops. */
14844 diff -NurpP --minimal linux-3.6.10/kernel/printk.c linux-3.6.10-vs2.3.4.5/kernel/printk.c
14845 --- linux-3.6.10/kernel/printk.c 2012-10-04 15:27:48.000000000 +0200
14846 +++ linux-3.6.10-vs2.3.4.5/kernel/printk.c 2012-10-04 18:47:00.000000000 +0200
14848 #include <linux/notifier.h>
14849 #include <linux/rculist.h>
14850 #include <linux/poll.h>
14851 +#include <linux/vs_cvirt.h>
14853 #include <asm/uaccess.h>
14855 @@ -818,7 +819,7 @@ static int check_syslog_permissions(int
14858 if (syslog_action_restricted(type)) {
14859 - if (capable(CAP_SYSLOG))
14860 + if (vx_capable(CAP_SYSLOG, VXC_SYSLOG))
14862 /* For historical reasons, accept CAP_SYS_ADMIN too, with a warning */
14863 if (capable(CAP_SYS_ADMIN)) {
14864 @@ -1111,12 +1112,9 @@ int do_syslog(int type, char __user *buf
14869 - case SYSLOG_ACTION_CLOSE: /* Close log */
14871 - case SYSLOG_ACTION_OPEN: /* Open log */
14873 - case SYSLOG_ACTION_READ: /* Read from log */
14874 + if ((type == SYSLOG_ACTION_READ) ||
14875 + (type == SYSLOG_ACTION_READ_ALL) ||
14876 + (type == SYSLOG_ACTION_READ_CLEAR)) {
14878 if (!buf || len < 0)
14880 @@ -1127,6 +1125,16 @@ int do_syslog(int type, char __user *buf
14885 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
14886 + return vx_do_syslog(type, buf, len);
14889 + case SYSLOG_ACTION_CLOSE: /* Close log */
14891 + case SYSLOG_ACTION_OPEN: /* Open log */
14893 + case SYSLOG_ACTION_READ: /* Read from log */
14894 error = wait_event_interruptible(log_wait,
14895 syslog_seq != log_next_seq);
14897 @@ -1139,16 +1147,6 @@ int do_syslog(int type, char __user *buf
14899 /* Read last kernel messages */
14900 case SYSLOG_ACTION_READ_ALL:
14902 - if (!buf || len < 0)
14907 - if (!access_ok(VERIFY_WRITE, buf, len)) {
14911 error = syslog_print_all(buf, len, clear);
14913 /* Clear ring buffer */
14914 diff -NurpP --minimal linux-3.6.10/kernel/ptrace.c linux-3.6.10-vs2.3.4.5/kernel/ptrace.c
14915 --- linux-3.6.10/kernel/ptrace.c 2012-07-22 23:39:46.000000000 +0200
14916 +++ linux-3.6.10-vs2.3.4.5/kernel/ptrace.c 2012-10-04 18:47:00.000000000 +0200
14918 #include <linux/syscalls.h>
14919 #include <linux/uaccess.h>
14920 #include <linux/regset.h>
14921 +#include <linux/vs_context.h>
14922 #include <linux/hw_breakpoint.h>
14923 #include <linux/cn_proc.h>
14925 @@ -216,6 +217,11 @@ ok:
14926 dumpable = get_dumpable(task->mm);
14927 if (!dumpable && !ptrace_has_cap(task_user_ns(task), mode))
14929 + if (!vx_check(task->xid, VS_ADMIN_P|VS_WATCH_P|VS_IDENT))
14931 + if (!vx_check(task->xid, VS_IDENT) &&
14932 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
14935 return security_ptrace_access_check(task, mode);
14937 diff -NurpP --minimal linux-3.6.10/kernel/sched/core.c linux-3.6.10-vs2.3.4.5/kernel/sched/core.c
14938 --- linux-3.6.10/kernel/sched/core.c 2012-12-11 12:37:02.000000000 +0100
14939 +++ linux-3.6.10-vs2.3.4.5/kernel/sched/core.c 2012-11-06 18:43:41.000000000 +0100
14941 #include <linux/slab.h>
14942 #include <linux/init_task.h>
14943 #include <linux/binfmts.h>
14944 +#include <linux/vs_sched.h>
14945 +#include <linux/vs_cvirt.h>
14947 #include <asm/switch_to.h>
14948 #include <asm/tlb.h>
14949 @@ -2223,9 +2225,17 @@ EXPORT_SYMBOL(avenrun); /* should be rem
14951 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
14953 - loads[0] = (avenrun[0] + offset) << shift;
14954 - loads[1] = (avenrun[1] + offset) << shift;
14955 - loads[2] = (avenrun[2] + offset) << shift;
14956 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
14957 + struct vx_info *vxi = current_vx_info();
14959 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
14960 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
14961 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
14963 + loads[0] = (avenrun[0] + offset) << shift;
14964 + loads[1] = (avenrun[1] + offset) << shift;
14965 + loads[2] = (avenrun[2] + offset) << shift;
14969 static long calc_load_fold_active(struct rq *this_rq)
14970 @@ -2854,14 +2864,17 @@ static inline void task_group_account_fi
14971 void account_user_time(struct task_struct *p, cputime_t cputime,
14972 cputime_t cputime_scaled)
14974 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
14975 + int nice = (TASK_NICE(p) > 0);
14978 /* Add user time to process. */
14979 p->utime += cputime;
14980 p->utimescaled += cputime_scaled;
14981 + vx_account_user(vxi, cputime, nice);
14982 account_group_user_time(p, cputime);
14984 - index = (TASK_NICE(p) > 0) ? CPUTIME_NICE : CPUTIME_USER;
14985 + index = (nice) ? CPUTIME_NICE : CPUTIME_USER;
14987 /* Add user time to cpustat. */
14988 task_group_account_field(p, index, (__force u64) cputime);
14989 @@ -2908,9 +2921,12 @@ static inline
14990 void __account_system_time(struct task_struct *p, cputime_t cputime,
14991 cputime_t cputime_scaled, int index)
14993 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
14995 /* Add system time to process. */
14996 p->stime += cputime;
14997 p->stimescaled += cputime_scaled;
14998 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
14999 account_group_system_time(p, cputime);
15001 /* Add system time to cpustat. */
15002 @@ -4137,7 +4153,7 @@ SYSCALL_DEFINE1(nice, int, increment)
15005 if (increment < 0 && !can_nice(current, nice))
15007 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
15009 retval = security_task_setnice(current, nice);
15011 diff -NurpP --minimal linux-3.6.10/kernel/sched/fair.c linux-3.6.10-vs2.3.4.5/kernel/sched/fair.c
15012 --- linux-3.6.10/kernel/sched/fair.c 2012-10-04 15:27:48.000000000 +0200
15013 +++ linux-3.6.10-vs2.3.4.5/kernel/sched/fair.c 2012-10-04 18:47:00.000000000 +0200
15015 #include <linux/slab.h>
15016 #include <linux/profile.h>
15017 #include <linux/interrupt.h>
15018 +#include <linux/vs_cvirt.h>
15020 #include <trace/events/sched.h>
15022 @@ -1111,6 +1112,8 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
15023 __enqueue_entity(cfs_rq, se);
15026 + if (entity_is_task(se))
15027 + vx_activate_task(task_of(se));
15028 if (cfs_rq->nr_running == 1) {
15029 list_add_leaf_cfs_rq(cfs_rq);
15030 check_enqueue_throttle(cfs_rq);
15031 @@ -1191,6 +1194,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
15032 if (se != cfs_rq->curr)
15033 __dequeue_entity(cfs_rq, se);
15035 + if (entity_is_task(se))
15036 + vx_deactivate_task(task_of(se));
15037 update_cfs_load(cfs_rq, 0);
15038 account_entity_dequeue(cfs_rq, se);
15040 diff -NurpP --minimal linux-3.6.10/kernel/signal.c linux-3.6.10-vs2.3.4.5/kernel/signal.c
15041 --- linux-3.6.10/kernel/signal.c 2012-10-04 15:27:48.000000000 +0200
15042 +++ linux-3.6.10-vs2.3.4.5/kernel/signal.c 2012-10-04 18:47:00.000000000 +0200
15044 #include <linux/nsproxy.h>
15045 #include <linux/user_namespace.h>
15046 #include <linux/uprobes.h>
15047 +#include <linux/vs_context.h>
15048 +#include <linux/vs_pid.h>
15049 #define CREATE_TRACE_POINTS
15050 #include <trace/events/signal.h>
15052 @@ -790,9 +792,18 @@ static int check_kill_permission(int sig
15056 + vxdprintk(VXD_CBIT(misc, 7),
15057 + "check_kill_permission(%d,%p,%p[#%u,%u])",
15058 + sig, info, t, vx_task_xid(t), t->pid);
15060 if (!valid_signal(sig))
15063 +/* FIXME: needed? if so, why?
15064 + if ((info != SEND_SIG_NOINFO) &&
15065 + (is_si_special(info) || !si_fromuser(info)))
15068 if (!si_fromuser(info))
15071 @@ -816,6 +827,20 @@ static int check_kill_permission(int sig
15076 + if (t->pid == 1 && current->xid)
15080 + /* FIXME: we shouldn't return ESRCH ever, to avoid
15081 + loops, maybe ENOENT or EACCES? */
15082 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
15083 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
15084 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
15085 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
15089 return security_task_kill(t, info, sig, 0);
15092 @@ -1351,7 +1376,7 @@ int kill_pid_info(int sig, struct siginf
15095 p = pid_task(pid, PIDTYPE_PID);
15097 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
15098 error = group_send_sig_info(sig, info, p);
15099 if (unlikely(error == -ESRCH))
15101 @@ -1399,7 +1424,7 @@ int kill_pid_info_as_cred(int sig, struc
15104 p = pid_task(pid, PIDTYPE_PID);
15106 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
15110 @@ -1451,8 +1476,10 @@ static int kill_something_info(int sig,
15111 struct task_struct * p;
15113 for_each_process(p) {
15114 - if (task_pid_vnr(p) > 1 &&
15115 - !same_thread_group(p, current)) {
15116 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
15117 + task_pid_vnr(p) > 1 &&
15118 + !same_thread_group(p, current) &&
15119 + !vx_current_initpid(p->pid)) {
15120 int err = group_send_sig_info(sig, info, p);
15123 @@ -2317,6 +2344,11 @@ relock:
15124 !sig_kernel_only(signr))
15127 + /* virtual init is protected against user signals */
15128 + if ((info->si_code == SI_USER) &&
15129 + vx_current_initpid(current->pid))
15132 if (sig_kernel_stop(signr)) {
15134 * The default action is to stop all threads in
15135 diff -NurpP --minimal linux-3.6.10/kernel/softirq.c linux-3.6.10-vs2.3.4.5/kernel/softirq.c
15136 --- linux-3.6.10/kernel/softirq.c 2012-10-04 15:27:48.000000000 +0200
15137 +++ linux-3.6.10-vs2.3.4.5/kernel/softirq.c 2012-10-04 18:47:00.000000000 +0200
15139 #include <linux/ftrace.h>
15140 #include <linux/smp.h>
15141 #include <linux/tick.h>
15142 +#include <linux/vs_context.h>
15144 #define CREATE_TRACE_POINTS
15145 #include <trace/events/irq.h>
15146 diff -NurpP --minimal linux-3.6.10/kernel/sys.c linux-3.6.10-vs2.3.4.5/kernel/sys.c
15147 --- linux-3.6.10/kernel/sys.c 2012-12-11 12:37:02.000000000 +0100
15148 +++ linux-3.6.10-vs2.3.4.5/kernel/sys.c 2012-11-06 18:43:41.000000000 +0100
15150 #include <linux/syscalls.h>
15151 #include <linux/kprobes.h>
15152 #include <linux/user_namespace.h>
15153 +#include <linux/vs_pid.h>
15155 #include <linux/kmsg_dump.h>
15156 /* Move somewhere else to avoid recompiling? */
15157 @@ -154,7 +155,10 @@ static int set_one_prio(struct task_stru
15160 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
15162 + if (vx_flags(VXF_IGNEG_NICE, 0))
15168 no_nice = security_task_setnice(p, niceval);
15169 @@ -205,6 +209,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
15171 pgrp = task_pgrp(current);
15172 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15173 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15175 error = set_one_prio(p, niceval, error);
15176 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
15178 @@ -270,6 +276,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
15180 pgrp = task_pgrp(current);
15181 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15182 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15184 niceval = 20 - task_nice(p);
15185 if (niceval > retval)
15187 @@ -422,6 +430,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
15189 static DEFINE_MUTEX(reboot_mutex);
15191 +long vs_reboot(unsigned int, void __user *);
15194 * Reboot system call: for obvious reasons only root may call it,
15195 * and even root needs to set up some magic numbers in the registers
15196 @@ -463,6 +473,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
15197 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
15198 cmd = LINUX_REBOOT_CMD_HALT;
15200 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15201 + return vs_reboot(cmd, arg);
15203 mutex_lock(&reboot_mutex);
15205 case LINUX_REBOOT_CMD_RESTART:
15206 @@ -1370,7 +1383,8 @@ SYSCALL_DEFINE2(sethostname, char __user
15208 char tmp[__NEW_UTS_LEN];
15210 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
15211 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
15212 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15215 if (len < 0 || len > __NEW_UTS_LEN)
15216 @@ -1421,7 +1435,8 @@ SYSCALL_DEFINE2(setdomainname, char __us
15218 char tmp[__NEW_UTS_LEN];
15220 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
15221 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
15222 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15224 if (len < 0 || len > __NEW_UTS_LEN)
15226 @@ -1540,7 +1555,7 @@ int do_prlimit(struct task_struct *tsk,
15227 /* Keep the capable check against init_user_ns until
15228 cgroups can contain all limits */
15229 if (new_rlim->rlim_max > rlim->rlim_max &&
15230 - !capable(CAP_SYS_RESOURCE))
15231 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
15234 retval = security_task_setrlimit(tsk->group_leader,
15235 @@ -1593,7 +1608,8 @@ static int check_prlimit_permission(stru
15236 gid_eq(cred->gid, tcred->sgid) &&
15237 gid_eq(cred->gid, tcred->gid))
15239 - if (ns_capable(tcred->user_ns, CAP_SYS_RESOURCE))
15240 + if (vx_ns_capable(tcred->user_ns,
15241 + CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
15245 diff -NurpP --minimal linux-3.6.10/kernel/sysctl.c linux-3.6.10-vs2.3.4.5/kernel/sysctl.c
15246 --- linux-3.6.10/kernel/sysctl.c 2012-10-04 15:27:48.000000000 +0200
15247 +++ linux-3.6.10-vs2.3.4.5/kernel/sysctl.c 2012-10-04 18:47:00.000000000 +0200
15249 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
15250 #include <linux/lockdep.h>
15252 +extern char vshelper_path[];
15253 #ifdef CONFIG_CHR_DEV_SG
15254 #include <scsi/sg.h>
15256 @@ -568,6 +569,13 @@ static struct ctl_table kern_table[] = {
15257 .proc_handler = proc_dostring,
15261 + .procname = "vshelper",
15262 + .data = &vshelper_path,
15265 + .proc_handler = &proc_dostring,
15267 #ifdef CONFIG_CHR_DEV_SG
15269 .procname = "sg-big-buff",
15270 diff -NurpP --minimal linux-3.6.10/kernel/sysctl_binary.c linux-3.6.10-vs2.3.4.5/kernel/sysctl_binary.c
15271 --- linux-3.6.10/kernel/sysctl_binary.c 2012-10-04 15:27:48.000000000 +0200
15272 +++ linux-3.6.10-vs2.3.4.5/kernel/sysctl_binary.c 2012-10-04 18:47:00.000000000 +0200
15273 @@ -73,6 +73,7 @@ static const struct bin_table bin_kern_t
15275 { CTL_INT, KERN_PANIC, "panic" },
15276 { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
15277 + { CTL_STR, KERN_VSHELPER, "vshelper" },
15279 { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
15280 { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
15281 diff -NurpP --minimal linux-3.6.10/kernel/time/timekeeping.c linux-3.6.10-vs2.3.4.5/kernel/time/timekeeping.c
15282 --- linux-3.6.10/kernel/time/timekeeping.c 2012-12-11 12:37:02.000000000 +0100
15283 +++ linux-3.6.10-vs2.3.4.5/kernel/time/timekeeping.c 2012-11-06 18:43:41.000000000 +0100
15284 @@ -309,6 +309,7 @@ void getnstimeofday(struct timespec *ts)
15287 timespec_add_ns(ts, nsecs);
15288 + vx_adjust_timespec(ts);
15290 EXPORT_SYMBOL(getnstimeofday);
15292 diff -NurpP --minimal linux-3.6.10/kernel/time.c linux-3.6.10-vs2.3.4.5/kernel/time.c
15293 --- linux-3.6.10/kernel/time.c 2012-05-21 18:07:34.000000000 +0200
15294 +++ linux-3.6.10-vs2.3.4.5/kernel/time.c 2012-10-04 18:47:00.000000000 +0200
15295 @@ -92,7 +92,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
15299 - do_settimeofday(&tv);
15300 + vx_settimeofday(&tv);
15304 @@ -172,7 +172,7 @@ int do_sys_settimeofday(const struct tim
15308 - return do_settimeofday(tv);
15309 + return vx_settimeofday(tv);
15313 diff -NurpP --minimal linux-3.6.10/kernel/timer.c linux-3.6.10-vs2.3.4.5/kernel/timer.c
15314 --- linux-3.6.10/kernel/timer.c 2012-12-11 12:37:02.000000000 +0100
15315 +++ linux-3.6.10-vs2.3.4.5/kernel/timer.c 2012-11-06 18:43:41.000000000 +0100
15317 #include <linux/irq_work.h>
15318 #include <linux/sched.h>
15319 #include <linux/slab.h>
15320 +#include <linux/vs_base.h>
15321 +#include <linux/vs_cvirt.h>
15322 +#include <linux/vs_pid.h>
15323 +#include <linux/vserver/sched.h>
15325 #include <asm/uaccess.h>
15326 #include <asm/unistd.h>
15327 diff -NurpP --minimal linux-3.6.10/kernel/user_namespace.c linux-3.6.10-vs2.3.4.5/kernel/user_namespace.c
15328 --- linux-3.6.10/kernel/user_namespace.c 2012-07-22 23:39:47.000000000 +0200
15329 +++ linux-3.6.10-vs2.3.4.5/kernel/user_namespace.c 2012-10-04 18:47:00.000000000 +0200
15331 #include <linux/fs.h>
15332 #include <linux/uaccess.h>
15333 #include <linux/ctype.h>
15334 +#include <linux/vserver/global.h>
15336 static struct kmem_cache *user_ns_cachep __read_mostly;
15338 @@ -52,6 +53,7 @@ int create_user_ns(struct cred *new)
15341 kref_init(&ns->kref);
15342 + atomic_inc(&vs_global_user_ns);
15343 ns->parent = parent_ns;
15346 @@ -84,6 +86,9 @@ void free_user_ns(struct kref *kref)
15348 parent = ns->parent;
15349 kmem_cache_free(user_ns_cachep, ns);
15351 + /* FIXME: maybe move into destroyer? */
15352 + atomic_dec(&vs_global_user_ns);
15353 put_user_ns(parent);
15355 EXPORT_SYMBOL(free_user_ns);
15356 diff -NurpP --minimal linux-3.6.10/kernel/utsname.c linux-3.6.10-vs2.3.4.5/kernel/utsname.c
15357 --- linux-3.6.10/kernel/utsname.c 2012-07-22 23:39:47.000000000 +0200
15358 +++ linux-3.6.10-vs2.3.4.5/kernel/utsname.c 2012-10-04 18:47:00.000000000 +0200
15359 @@ -16,14 +16,17 @@
15360 #include <linux/slab.h>
15361 #include <linux/user_namespace.h>
15362 #include <linux/proc_fs.h>
15363 +#include <linux/vserver/global.h>
15365 static struct uts_namespace *create_uts_ns(void)
15367 struct uts_namespace *uts_ns;
15369 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
15372 kref_init(&uts_ns->kref);
15373 + atomic_inc(&vs_global_uts_ns);
15378 @@ -32,8 +35,8 @@ static struct uts_namespace *create_uts_
15379 * @old_ns: namespace to clone
15380 * Return NULL on error (failure to kmalloc), new ns otherwise
15382 -static struct uts_namespace *clone_uts_ns(struct task_struct *tsk,
15383 - struct uts_namespace *old_ns)
15384 +static struct uts_namespace *clone_uts_ns(struct uts_namespace *old_ns,
15385 + struct user_namespace *old_user)
15387 struct uts_namespace *ns;
15389 @@ -43,7 +46,7 @@ static struct uts_namespace *clone_uts_n
15391 down_read(&uts_sem);
15392 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
15393 - ns->user_ns = get_user_ns(task_cred_xxx(tsk, user_ns));
15394 + ns->user_ns = get_user_ns(old_user);
15398 @@ -55,9 +58,9 @@ static struct uts_namespace *clone_uts_n
15401 struct uts_namespace *copy_utsname(unsigned long flags,
15402 - struct task_struct *tsk)
15403 + struct uts_namespace *old_ns,
15404 + struct user_namespace *user_ns)
15406 - struct uts_namespace *old_ns = tsk->nsproxy->uts_ns;
15407 struct uts_namespace *new_ns;
15410 @@ -66,7 +69,7 @@ struct uts_namespace *copy_utsname(unsig
15411 if (!(flags & CLONE_NEWUTS))
15414 - new_ns = clone_uts_ns(tsk, old_ns);
15415 + new_ns = clone_uts_ns(old_ns, user_ns);
15417 put_uts_ns(old_ns);
15419 @@ -78,6 +81,7 @@ void free_uts_ns(struct kref *kref)
15421 ns = container_of(kref, struct uts_namespace, kref);
15422 put_user_ns(ns->user_ns);
15423 + atomic_dec(&vs_global_uts_ns);
15427 diff -NurpP --minimal linux-3.6.10/kernel/vserver/Kconfig linux-3.6.10-vs2.3.4.5/kernel/vserver/Kconfig
15428 --- linux-3.6.10/kernel/vserver/Kconfig 1970-01-01 01:00:00.000000000 +0100
15429 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/Kconfig 2012-12-10 18:21:15.000000000 +0100
15432 +# Linux VServer configuration
15435 +menu "Linux VServer"
15437 +config VSERVER_AUTO_LBACK
15438 + bool "Automatically Assign Loopback IP"
15441 + Automatically assign a guest specific loopback
15442 + IP and add it to the kernel network stack on
15445 +config VSERVER_AUTO_SINGLE
15446 + bool "Automatic Single IP Special Casing"
15447 + depends on EXPERIMENTAL
15450 + This allows network contexts with a single IP to
15451 + automatically remap 0.0.0.0 bindings to that IP,
15452 + avoiding further network checks and improving
15455 + (note: such guests do not allow to change the ip
15456 + on the fly and do not show loopback addresses)
15458 +config VSERVER_COWBL
15459 + bool "Enable COW Immutable Link Breaking"
15462 + This enables the COW (Copy-On-Write) link break code.
15463 + It allows you to treat unified files like normal files
15464 + when writing to them (which will implicitely break the
15465 + link and create a copy of the unified file)
15467 +config VSERVER_VTIME
15468 + bool "Enable Virtualized Guest Time"
15469 + depends on EXPERIMENTAL
15472 + This enables per guest time offsets to allow for
15473 + adjusting the system clock individually per guest.
15474 + this adds some overhead to the time functions and
15475 + therefore should not be enabled without good reason.
15477 +config VSERVER_DEVICE
15478 + bool "Enable Guest Device Mapping"
15479 + depends on EXPERIMENTAL
15482 + This enables generic device remapping.
15484 +config VSERVER_PROC_SECURE
15485 + bool "Enable Proc Security"
15486 + depends on PROC_FS
15489 + This configures ProcFS security to initially hide
15490 + non-process entries for all contexts except the main and
15491 + spectator context (i.e. for all guests), which is a secure
15494 + (note: on 1.2x the entries were visible by default)
15497 + prompt "Persistent Inode Tagging"
15498 + default TAGGING_ID24
15500 + This adds persistent context information to filesystems
15501 + mounted with the tagxid option. Tagging is a requirement
15502 + for per-context disk limits and per-context quota.
15505 +config TAGGING_NONE
15508 + do not store per-context information in inodes.
15510 +config TAGGING_UID16
15511 + bool "UID16/GID32"
15513 + reduces UID to 16 bit, but leaves GID at 32 bit.
15515 +config TAGGING_GID16
15516 + bool "UID32/GID16"
15518 + reduces GID to 16 bit, but leaves UID at 32 bit.
15520 +config TAGGING_ID24
15521 + bool "UID24/GID24"
15523 + uses the upper 8bit from UID and GID for XID tagging
15524 + which leaves 24bit for UID/GID each, which should be
15525 + more than sufficient for normal use.
15527 +config TAGGING_INTERN
15528 + bool "UID32/GID32"
15530 + this uses otherwise reserved inode fields in the on
15531 + disk representation, which limits the use to a few
15532 + filesystems (currently ext2 and ext3)
15537 + bool "Tag NFSD User Auth and Files"
15540 + Enable this if you do want the in-kernel NFS
15541 + Server to use the tagging specified above.
15542 + (will require patched clients too)
15544 +config VSERVER_PRIVACY
15545 + bool "Honor Privacy Aspects of Guests"
15548 + When enabled, most context checks will disallow
15549 + access to structures assigned to a specific context,
15550 + like ptys or loop devices.
15552 +config VSERVER_CONTEXTS
15553 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
15555 + default "768" if 64BIT
15558 + This setting will optimize certain data structures
15559 + and memory allocations according to the expected
15562 + note: this is not a strict upper limit.
15564 +config VSERVER_WARN
15565 + bool "VServer Warnings"
15568 + This enables various runtime warnings, which will
15569 + notify about potential manipulation attempts or
15570 + resource shortage. It is generally considered to
15571 + be a good idea to have that enabled.
15573 +config VSERVER_WARN_DEVPTS
15574 + bool "VServer DevPTS Warnings"
15575 + depends on VSERVER_WARN
15578 + This enables DevPTS related warnings, issued when a
15579 + process inside a context tries to lookup or access
15580 + a dynamic pts from the host or a different context.
15582 +config VSERVER_DEBUG
15583 + bool "VServer Debugging Code"
15586 + Set this to yes if you want to be able to activate
15587 + debugging output at runtime. It adds a very small
15588 + overhead to all vserver related functions and
15589 + increases the kernel size by about 20k.
15591 +config VSERVER_HISTORY
15592 + bool "VServer History Tracing"
15593 + depends on VSERVER_DEBUG
15596 + Set this to yes if you want to record the history of
15597 + linux-vserver activities, so they can be replayed in
15598 + the event of a kernel panic or oops.
15600 +config VSERVER_HISTORY_SIZE
15601 + int "Per-CPU History Size (32-65536)"
15602 + depends on VSERVER_HISTORY
15606 + This allows you to specify the number of entries in
15607 + the per-CPU history buffer.
15609 +config VSERVER_EXTRA_MNT_CHECK
15610 + bool "Extra Checks for Reachability"
15613 + Set this to yes if you want to do extra checks for
15614 + vfsmount reachability in the proc filesystem code.
15615 + This shouldn't be required on any setup utilizing
15619 + prompt "Quotes used in debug and warn messages"
15620 + default QUOTES_ISO8859
15622 +config QUOTES_ISO8859
15623 + bool "Extended ASCII (ISO 8859) angle quotes"
15625 + This uses the extended ASCII characters \xbb
15626 + and \xab for quoting file and process names.
15628 +config QUOTES_UTF8
15629 + bool "UTF-8 angle quotes"
15631 + This uses the the UTF-8 sequences for angle
15632 + quotes to quote file and process names.
15634 +config QUOTES_ASCII
15635 + bool "ASCII single quotes"
15637 + This uses the ASCII single quote character
15638 + (\x27) to quote file and process names.
15648 + select NAMESPACES
15654 +config VSERVER_SECURITY
15656 + depends on SECURITY
15658 + select SECURITY_CAPABILITIES
15660 +config VSERVER_DISABLED
15664 diff -NurpP --minimal linux-3.6.10/kernel/vserver/Makefile linux-3.6.10-vs2.3.4.5/kernel/vserver/Makefile
15665 --- linux-3.6.10/kernel/vserver/Makefile 1970-01-01 01:00:00.000000000 +0100
15666 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/Makefile 2012-10-04 18:47:00.000000000 +0200
15669 +# Makefile for the Linux vserver routines.
15673 +obj-y += vserver.o
15675 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
15676 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
15679 +vserver-$(CONFIG_INET) += inet.o
15680 +vserver-$(CONFIG_PROC_FS) += proc.o
15681 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
15682 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
15683 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
15684 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
15686 diff -NurpP --minimal linux-3.6.10/kernel/vserver/cacct.c linux-3.6.10-vs2.3.4.5/kernel/vserver/cacct.c
15687 --- linux-3.6.10/kernel/vserver/cacct.c 1970-01-01 01:00:00.000000000 +0100
15688 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/cacct.c 2012-10-04 18:47:00.000000000 +0200
15691 + * linux/kernel/vserver/cacct.c
15693 + * Virtual Server: Context Accounting
15695 + * Copyright (C) 2006-2007 Herbert Pötzl
15697 + * V0.01 added accounting stats
15701 +#include <linux/types.h>
15702 +#include <linux/vs_context.h>
15703 +#include <linux/vserver/cacct_cmd.h>
15704 +#include <linux/vserver/cacct_int.h>
15706 +#include <asm/errno.h>
15707 +#include <asm/uaccess.h>
15710 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
15712 + struct vcmd_sock_stat_v0 vc_data;
15715 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
15718 + field = vc_data.field;
15719 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
15722 + for (j = 0; j < 3; j++) {
15723 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
15724 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
15727 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
15732 diff -NurpP --minimal linux-3.6.10/kernel/vserver/cacct_init.h linux-3.6.10-vs2.3.4.5/kernel/vserver/cacct_init.h
15733 --- linux-3.6.10/kernel/vserver/cacct_init.h 1970-01-01 01:00:00.000000000 +0100
15734 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/cacct_init.h 2012-10-04 18:47:00.000000000 +0200
15738 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
15743 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
15744 + for (j = 0; j < 3; j++) {
15745 + atomic_long_set(&cacct->sock[i][j].count, 0);
15746 + atomic_long_set(&cacct->sock[i][j].total, 0);
15749 + for (i = 0; i < 8; i++)
15750 + atomic_set(&cacct->slab[i], 0);
15751 + for (i = 0; i < 5; i++)
15752 + for (j = 0; j < 4; j++)
15753 + atomic_set(&cacct->page[i][j], 0);
15756 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
15761 diff -NurpP --minimal linux-3.6.10/kernel/vserver/cacct_proc.h linux-3.6.10-vs2.3.4.5/kernel/vserver/cacct_proc.h
15762 --- linux-3.6.10/kernel/vserver/cacct_proc.h 1970-01-01 01:00:00.000000000 +0100
15763 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/cacct_proc.h 2012-10-04 18:47:00.000000000 +0200
15765 +#ifndef _VX_CACCT_PROC_H
15766 +#define _VX_CACCT_PROC_H
15768 +#include <linux/vserver/cacct_int.h>
15771 +#define VX_SOCKA_TOP \
15772 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
15774 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
15776 + int i, j, length = 0;
15777 + static char *type[VXA_SOCK_SIZE] = {
15778 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
15781 + length += sprintf(buffer + length, VX_SOCKA_TOP);
15782 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
15783 + length += sprintf(buffer + length, "%s:", type[i]);
15784 + for (j = 0; j < 3; j++) {
15785 + length += sprintf(buffer + length,
15786 + "\t%10lu/%-10lu",
15787 + vx_sock_count(cacct, i, j),
15788 + vx_sock_total(cacct, i, j));
15790 + buffer[length++] = '\n';
15793 + length += sprintf(buffer + length, "\n");
15794 + length += sprintf(buffer + length,
15795 + "slab:\t %8u %8u %8u %8u\n",
15796 + atomic_read(&cacct->slab[1]),
15797 + atomic_read(&cacct->slab[4]),
15798 + atomic_read(&cacct->slab[0]),
15799 + atomic_read(&cacct->slab[2]));
15801 + length += sprintf(buffer + length, "\n");
15802 + for (i = 0; i < 5; i++) {
15803 + length += sprintf(buffer + length,
15804 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
15805 + atomic_read(&cacct->page[i][0]),
15806 + atomic_read(&cacct->page[i][1]),
15807 + atomic_read(&cacct->page[i][2]),
15808 + atomic_read(&cacct->page[i][3]),
15809 + atomic_read(&cacct->page[i][4]),
15810 + atomic_read(&cacct->page[i][5]),
15811 + atomic_read(&cacct->page[i][6]),
15812 + atomic_read(&cacct->page[i][7]));
15817 +#endif /* _VX_CACCT_PROC_H */
15818 diff -NurpP --minimal linux-3.6.10/kernel/vserver/context.c linux-3.6.10-vs2.3.4.5/kernel/vserver/context.c
15819 --- linux-3.6.10/kernel/vserver/context.c 1970-01-01 01:00:00.000000000 +0100
15820 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/context.c 2012-10-04 18:47:00.000000000 +0200
15823 + * linux/kernel/vserver/context.c
15825 + * Virtual Server: Context Support
15827 + * Copyright (C) 2003-2011 Herbert Pötzl
15829 + * V0.01 context helper
15830 + * V0.02 vx_ctx_kill syscall command
15831 + * V0.03 replaced context_info calls
15832 + * V0.04 redesign of struct (de)alloc
15833 + * V0.05 rlimit basic implementation
15834 + * V0.06 task_xid and info commands
15835 + * V0.07 context flags and caps
15836 + * V0.08 switch to RCU based hash
15837 + * V0.09 revert to non RCU for now
15838 + * V0.10 and back to working RCU hash
15839 + * V0.11 and back to locking again
15840 + * V0.12 referenced context store
15841 + * V0.13 separate per cpu data
15842 + * V0.14 changed vcmds to vxi arg
15843 + * V0.15 added context stat
15844 + * V0.16 have __create claim() the vxi
15845 + * V0.17 removed older and legacy stuff
15846 + * V0.18 added user credentials
15847 + * V0.19 added warn mask
15851 +#include <linux/slab.h>
15852 +#include <linux/types.h>
15853 +#include <linux/security.h>
15854 +#include <linux/pid_namespace.h>
15855 +#include <linux/capability.h>
15857 +#include <linux/vserver/context.h>
15858 +#include <linux/vserver/network.h>
15859 +#include <linux/vserver/debug.h>
15860 +#include <linux/vserver/limit.h>
15861 +#include <linux/vserver/limit_int.h>
15862 +#include <linux/vserver/space.h>
15863 +#include <linux/init_task.h>
15864 +#include <linux/fs_struct.h>
15865 +#include <linux/cred.h>
15867 +#include <linux/vs_context.h>
15868 +#include <linux/vs_limit.h>
15869 +#include <linux/vs_pid.h>
15870 +#include <linux/vserver/context_cmd.h>
15872 +#include "cvirt_init.h"
15873 +#include "cacct_init.h"
15874 +#include "limit_init.h"
15875 +#include "sched_init.h"
15878 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
15879 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
15882 +/* now inactive context structures */
15884 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
15886 +static DEFINE_SPINLOCK(vx_info_inactive_lock);
15889 +/* __alloc_vx_info()
15891 + * allocate an initialized vx_info struct
15892 + * doesn't make it visible (hash) */
15894 +static struct vx_info *__alloc_vx_info(xid_t xid)
15896 + struct vx_info *new = NULL;
15899 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
15901 + /* would this benefit from a slab cache? */
15902 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
15906 + memset(new, 0, sizeof(struct vx_info));
15908 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
15909 + if (!new->ptr_pc)
15912 + new->vx_id = xid;
15913 + INIT_HLIST_NODE(&new->vx_hlist);
15914 + atomic_set(&new->vx_usecnt, 0);
15915 + atomic_set(&new->vx_tasks, 0);
15916 + new->vx_parent = NULL;
15917 + new->vx_state = 0;
15918 + init_waitqueue_head(&new->vx_wait);
15920 + /* prepare reaper */
15921 + get_task_struct(init_pid_ns.child_reaper);
15922 + new->vx_reaper = init_pid_ns.child_reaper;
15923 + new->vx_badness_bias = 0;
15925 + /* rest of init goes here */
15926 + vx_info_init_limit(&new->limit);
15927 + vx_info_init_sched(&new->sched);
15928 + vx_info_init_cvirt(&new->cvirt);
15929 + vx_info_init_cacct(&new->cacct);
15931 + /* per cpu data structures */
15932 + for_each_possible_cpu(cpu) {
15933 + vx_info_init_sched_pc(
15934 + &vx_per_cpu(new, sched_pc, cpu), cpu);
15935 + vx_info_init_cvirt_pc(
15936 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
15939 + new->vx_flags = VXF_INIT_SET;
15940 + new->vx_bcaps = CAP_FULL_SET; // maybe ~CAP_SETPCAP
15941 + new->vx_ccaps = 0;
15942 + new->vx_umask = 0;
15943 + new->vx_wmask = 0;
15945 + new->reboot_cmd = 0;
15946 + new->exit_code = 0;
15948 + // preconfig spaces
15949 + for (index = 0; index < VX_SPACES; index++) {
15950 + struct _vx_space *space = &new->space[index];
15953 + spin_lock(&init_fs.lock);
15955 + spin_unlock(&init_fs.lock);
15956 + space->vx_fs = &init_fs;
15958 + /* FIXME: do we want defaults? */
15959 + // space->vx_real_cred = 0;
15960 + // space->vx_cred = 0;
15964 + vxdprintk(VXD_CBIT(xid, 0),
15965 + "alloc_vx_info(%d) = %p", xid, new);
15966 + vxh_alloc_vx_info(new);
15967 + atomic_inc(&vx_global_ctotal);
15976 +/* __dealloc_vx_info()
15978 + * final disposal of vx_info */
15980 +static void __dealloc_vx_info(struct vx_info *vxi)
15982 +#ifdef CONFIG_VSERVER_WARN
15983 + struct vx_info_save vxis;
15986 + vxdprintk(VXD_CBIT(xid, 0),
15987 + "dealloc_vx_info(%p)", vxi);
15988 + vxh_dealloc_vx_info(vxi);
15990 +#ifdef CONFIG_VSERVER_WARN
15991 + enter_vx_info(vxi, &vxis);
15992 + vx_info_exit_limit(&vxi->limit);
15993 + vx_info_exit_sched(&vxi->sched);
15994 + vx_info_exit_cvirt(&vxi->cvirt);
15995 + vx_info_exit_cacct(&vxi->cacct);
15997 + for_each_possible_cpu(cpu) {
15998 + vx_info_exit_sched_pc(
15999 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
16000 + vx_info_exit_cvirt_pc(
16001 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
16003 + leave_vx_info(&vxis);
16007 + vxi->vx_state |= VXS_RELEASED;
16010 + free_percpu(vxi->ptr_pc);
16013 + atomic_dec(&vx_global_ctotal);
16016 +static void __shutdown_vx_info(struct vx_info *vxi)
16018 + struct nsproxy *nsproxy;
16019 + struct fs_struct *fs;
16020 + struct cred *cred;
16025 + vxi->vx_state |= VXS_SHUTDOWN;
16026 + vs_state_change(vxi, VSC_SHUTDOWN);
16028 + for (index = 0; index < VX_SPACES; index++) {
16029 + struct _vx_space *space = &vxi->space[index];
16031 + nsproxy = xchg(&space->vx_nsproxy, NULL);
16033 + put_nsproxy(nsproxy);
16035 + fs = xchg(&space->vx_fs, NULL);
16036 + spin_lock(&fs->lock);
16037 + kill = !--fs->users;
16038 + spin_unlock(&fs->lock);
16040 + free_fs_struct(fs);
16042 + cred = (struct cred *)xchg(&space->vx_cred, NULL);
16044 + abort_creds(cred);
16048 +/* exported stuff */
16050 +void free_vx_info(struct vx_info *vxi)
16052 + unsigned long flags;
16055 + /* check for reference counts first */
16056 + BUG_ON(atomic_read(&vxi->vx_usecnt));
16057 + BUG_ON(atomic_read(&vxi->vx_tasks));
16059 + /* context must not be hashed */
16060 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16062 + /* context shutdown is mandatory */
16063 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
16065 + /* spaces check */
16066 + for (index = 0; index < VX_SPACES; index++) {
16067 + struct _vx_space *space = &vxi->space[index];
16069 + BUG_ON(space->vx_nsproxy);
16070 + BUG_ON(space->vx_fs);
16071 + // BUG_ON(space->vx_real_cred);
16072 + // BUG_ON(space->vx_cred);
16075 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16076 + hlist_del(&vxi->vx_hlist);
16077 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16079 + __dealloc_vx_info(vxi);
16083 +/* hash table for vx_info hash */
16085 +#define VX_HASH_SIZE 13
16087 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
16088 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
16090 +static DEFINE_SPINLOCK(vx_info_hash_lock);
16093 +static inline unsigned int __hashval(xid_t xid)
16095 + return (xid % VX_HASH_SIZE);
16100 +/* __hash_vx_info()
16102 + * add the vxi to the global hash table
16103 + * requires the hash_lock to be held */
16105 +static inline void __hash_vx_info(struct vx_info *vxi)
16107 + struct hlist_head *head;
16109 + vxd_assert_lock(&vx_info_hash_lock);
16110 + vxdprintk(VXD_CBIT(xid, 4),
16111 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
16112 + vxh_hash_vx_info(vxi);
16114 + /* context must not be hashed */
16115 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16117 + vxi->vx_state |= VXS_HASHED;
16118 + head = &vx_info_hash[__hashval(vxi->vx_id)];
16119 + hlist_add_head(&vxi->vx_hlist, head);
16120 + atomic_inc(&vx_global_cactive);
16123 +/* __unhash_vx_info()
16125 + * remove the vxi from the global hash table
16126 + * requires the hash_lock to be held */
16128 +static inline void __unhash_vx_info(struct vx_info *vxi)
16130 + unsigned long flags;
16132 + vxd_assert_lock(&vx_info_hash_lock);
16133 + vxdprintk(VXD_CBIT(xid, 4),
16134 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
16135 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
16136 + vxh_unhash_vx_info(vxi);
16138 + /* context must be hashed */
16139 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
16140 + /* but without tasks */
16141 + BUG_ON(atomic_read(&vxi->vx_tasks));
16143 + vxi->vx_state &= ~VXS_HASHED;
16144 + hlist_del_init(&vxi->vx_hlist);
16145 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16146 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
16147 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16148 + atomic_dec(&vx_global_cactive);
16152 +/* __lookup_vx_info()
16154 + * requires the hash_lock to be held
16155 + * doesn't increment the vx_refcnt */
16157 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
16159 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
16160 + struct hlist_node *pos;
16161 + struct vx_info *vxi;
16163 + vxd_assert_lock(&vx_info_hash_lock);
16164 + hlist_for_each(pos, head) {
16165 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16167 + if (vxi->vx_id == xid)
16172 + vxdprintk(VXD_CBIT(xid, 0),
16173 + "__lookup_vx_info(#%u): %p[#%u]",
16174 + xid, vxi, vxi ? vxi->vx_id : 0);
16175 + vxh_lookup_vx_info(vxi, xid);
16180 +/* __create_vx_info()
16182 + * create the requested context
16183 + * get(), claim() and hash it */
16185 +static struct vx_info *__create_vx_info(int id)
16187 + struct vx_info *new, *vxi = NULL;
16189 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
16191 + if (!(new = __alloc_vx_info(id)))
16192 + return ERR_PTR(-ENOMEM);
16194 + /* required to make dynamic xids unique */
16195 + spin_lock(&vx_info_hash_lock);
16197 + /* static context requested */
16198 + if ((vxi = __lookup_vx_info(id))) {
16199 + vxdprintk(VXD_CBIT(xid, 0),
16200 + "create_vx_info(%d) = %p (already there)", id, vxi);
16201 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16202 + vxi = ERR_PTR(-EBUSY);
16204 + vxi = ERR_PTR(-EEXIST);
16207 + /* new context */
16208 + vxdprintk(VXD_CBIT(xid, 0),
16209 + "create_vx_info(%d) = %p (new)", id, new);
16210 + claim_vx_info(new, NULL);
16211 + __hash_vx_info(get_vx_info(new));
16212 + vxi = new, new = NULL;
16215 + spin_unlock(&vx_info_hash_lock);
16216 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
16218 + __dealloc_vx_info(new);
16223 +/* exported stuff */
16226 +void unhash_vx_info(struct vx_info *vxi)
16228 + spin_lock(&vx_info_hash_lock);
16229 + __unhash_vx_info(vxi);
16230 + spin_unlock(&vx_info_hash_lock);
16231 + __shutdown_vx_info(vxi);
16232 + __wakeup_vx_info(vxi);
16236 +/* lookup_vx_info()
16238 + * search for a vx_info and get() it
16239 + * negative id means current */
16241 +struct vx_info *lookup_vx_info(int id)
16243 + struct vx_info *vxi = NULL;
16246 + vxi = get_vx_info(current_vx_info());
16247 + } else if (id > 1) {
16248 + spin_lock(&vx_info_hash_lock);
16249 + vxi = get_vx_info(__lookup_vx_info(id));
16250 + spin_unlock(&vx_info_hash_lock);
16255 +/* xid_is_hashed()
16257 + * verify that xid is still hashed */
16259 +int xid_is_hashed(xid_t xid)
16263 + spin_lock(&vx_info_hash_lock);
16264 + hashed = (__lookup_vx_info(xid) != NULL);
16265 + spin_unlock(&vx_info_hash_lock);
16269 +#ifdef CONFIG_PROC_FS
16273 + * get a subset of hashed xids for proc
16274 + * assumes size is at least one */
16276 +int get_xid_list(int index, unsigned int *xids, int size)
16278 + int hindex, nr_xids = 0;
16280 + /* only show current and children */
16281 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
16284 + xids[nr_xids] = vx_current_xid();
16288 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
16289 + struct hlist_head *head = &vx_info_hash[hindex];
16290 + struct hlist_node *pos;
16292 + spin_lock(&vx_info_hash_lock);
16293 + hlist_for_each(pos, head) {
16294 + struct vx_info *vxi;
16299 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16300 + xids[nr_xids] = vxi->vx_id;
16301 + if (++nr_xids >= size) {
16302 + spin_unlock(&vx_info_hash_lock);
16306 + /* keep the lock time short */
16307 + spin_unlock(&vx_info_hash_lock);
16314 +#ifdef CONFIG_VSERVER_DEBUG
16316 +void dump_vx_info_inactive(int level)
16318 + struct hlist_node *entry, *next;
16320 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
16321 + struct vx_info *vxi =
16322 + list_entry(entry, struct vx_info, vx_hlist);
16324 + dump_vx_info(vxi, level);
16331 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
16333 + struct user_struct *new_user, *old_user;
16338 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
16341 + new_user = alloc_uid(vxi->vx_id, p->uid);
16345 + old_user = p->user;
16346 + if (new_user != old_user) {
16347 + atomic_inc(&new_user->processes);
16348 + atomic_dec(&old_user->processes);
16349 + p->user = new_user;
16351 + free_uid(old_user);
16357 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
16359 + // p->cap_effective &= vxi->vx_cap_bset;
16360 + p->cap_effective =
16361 + cap_intersect(p->cap_effective, vxi->cap_bset);
16362 + // p->cap_inheritable &= vxi->vx_cap_bset;
16363 + p->cap_inheritable =
16364 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
16365 + // p->cap_permitted &= vxi->vx_cap_bset;
16366 + p->cap_permitted =
16367 + cap_intersect(p->cap_permitted, vxi->cap_bset);
16372 +#include <linux/file.h>
16373 +#include <linux/fdtable.h>
16375 +static int vx_openfd_task(struct task_struct *tsk)
16377 + struct files_struct *files = tsk->files;
16378 + struct fdtable *fdt;
16379 + const unsigned long *bptr;
16380 + int count, total;
16382 + /* no rcu_read_lock() because of spin_lock() */
16383 + spin_lock(&files->file_lock);
16384 + fdt = files_fdtable(files);
16385 + bptr = fdt->open_fds;
16386 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
16387 + for (total = 0; count > 0; count--) {
16389 + total += hweight_long(*bptr);
16392 + spin_unlock(&files->file_lock);
16397 +/* for *space compatibility */
16399 +asmlinkage long sys_unshare(unsigned long);
16402 + * migrate task to new context
16403 + * gets vxi, puts old_vxi on change
16404 + * optionally unshares namespaces (hack)
16407 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
16409 + struct vx_info *old_vxi;
16415 + vxdprintk(VXD_CBIT(xid, 5),
16416 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
16417 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
16419 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
16420 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16423 + if (vx_info_state(vxi, VXS_SHUTDOWN))
16426 + old_vxi = task_get_vx_info(p);
16427 + if (old_vxi == vxi)
16430 +// if (!(ret = vx_migrate_user(p, vxi))) {
16435 + openfd = vx_openfd_task(p);
16438 + atomic_dec(&old_vxi->cvirt.nr_threads);
16439 + atomic_dec(&old_vxi->cvirt.nr_running);
16440 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
16441 + /* FIXME: what about the struct files here? */
16442 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
16443 + /* account for the executable */
16444 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
16446 + atomic_inc(&vxi->cvirt.nr_threads);
16447 + atomic_inc(&vxi->cvirt.nr_running);
16448 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
16449 + /* FIXME: what about the struct files here? */
16450 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
16451 + /* account for the executable */
16452 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
16455 + release_vx_info(old_vxi, p);
16456 + clr_vx_info(&p->vx_info);
16458 + claim_vx_info(vxi, p);
16459 + set_vx_info(&p->vx_info, vxi);
16460 + p->xid = vxi->vx_id;
16462 + vxdprintk(VXD_CBIT(xid, 5),
16463 + "moved task %p into vxi:%p[#%d]",
16464 + p, vxi, vxi->vx_id);
16466 + // vx_mask_cap_bset(vxi, p);
16469 + /* hack for *spaces to provide compatibility */
16471 + struct nsproxy *old_nsp, *new_nsp;
16473 + ret = unshare_nsproxy_namespaces(
16474 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
16479 + old_nsp = xchg(&p->nsproxy, new_nsp);
16480 + vx_set_space(vxi,
16481 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
16482 + put_nsproxy(old_nsp);
16486 + put_vx_info(old_vxi);
16490 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
16492 + struct task_struct *old_reaper;
16493 + struct vx_info *reaper_vxi;
16498 + vxdprintk(VXD_CBIT(xid, 6),
16499 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
16500 + vxi, vxi->vx_id, p, p->xid, p->pid);
16502 + old_reaper = vxi->vx_reaper;
16503 + if (old_reaper == p)
16506 + reaper_vxi = task_get_vx_info(p);
16507 + if (reaper_vxi && reaper_vxi != vxi) {
16509 + "Unsuitable reaper [" VS_Q("%s") ",%u:#%u] "
16511 + p->comm, p->pid, p->xid, vx_current_xid());
16515 + /* set new child reaper */
16516 + get_task_struct(p);
16517 + vxi->vx_reaper = p;
16518 + put_task_struct(old_reaper);
16520 + put_vx_info(reaper_vxi);
16524 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
16529 + vxdprintk(VXD_CBIT(xid, 6),
16530 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
16531 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16533 + vxi->vx_flags &= ~VXF_STATE_INIT;
16534 + // vxi->vx_initpid = p->tgid;
16535 + vxi->vx_initpid = p->pid;
16539 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
16541 + vxdprintk(VXD_CBIT(xid, 6),
16542 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
16543 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16545 + vxi->exit_code = code;
16546 + vxi->vx_initpid = 0;
16550 +void vx_set_persistent(struct vx_info *vxi)
16552 + vxdprintk(VXD_CBIT(xid, 6),
16553 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
16555 + get_vx_info(vxi);
16556 + claim_vx_info(vxi, NULL);
16559 +void vx_clear_persistent(struct vx_info *vxi)
16561 + vxdprintk(VXD_CBIT(xid, 6),
16562 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
16564 + release_vx_info(vxi, NULL);
16565 + put_vx_info(vxi);
16568 +void vx_update_persistent(struct vx_info *vxi)
16570 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
16571 + vx_set_persistent(vxi);
16573 + vx_clear_persistent(vxi);
16577 +/* task must be current or locked */
16579 +void exit_vx_info(struct task_struct *p, int code)
16581 + struct vx_info *vxi = p->vx_info;
16584 + atomic_dec(&vxi->cvirt.nr_threads);
16587 + vxi->exit_code = code;
16588 + release_vx_info(vxi, p);
16592 +void exit_vx_info_early(struct task_struct *p, int code)
16594 + struct vx_info *vxi = p->vx_info;
16597 + if (vxi->vx_initpid == p->pid)
16598 + vx_exit_init(vxi, p, code);
16599 + if (vxi->vx_reaper == p)
16600 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
16605 +/* vserver syscall commands below here */
16607 +/* taks xid and vx_info functions */
16609 +#include <asm/uaccess.h>
16612 +int vc_task_xid(uint32_t id)
16617 + struct task_struct *tsk;
16620 + tsk = find_task_by_real_pid(id);
16621 + xid = (tsk) ? tsk->xid : -ESRCH;
16622 + rcu_read_unlock();
16624 + xid = vx_current_xid();
16629 +int vc_vx_info(struct vx_info *vxi, void __user *data)
16631 + struct vcmd_vx_info_v0 vc_data;
16633 + vc_data.xid = vxi->vx_id;
16634 + vc_data.initpid = vxi->vx_initpid;
16636 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16642 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
16644 + struct vcmd_ctx_stat_v0 vc_data;
16646 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
16647 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
16649 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16655 +/* context functions */
16657 +int vc_ctx_create(uint32_t xid, void __user *data)
16659 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
16660 + struct vx_info *new_vxi;
16663 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16666 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
16669 + new_vxi = __create_vx_info(xid);
16670 + if (IS_ERR(new_vxi))
16671 + return PTR_ERR(new_vxi);
16673 + /* initial flags */
16674 + new_vxi->vx_flags = vc_data.flagword;
16677 + if (vs_state_change(new_vxi, VSC_STARTUP))
16680 + ret = vx_migrate_task(current, new_vxi, (!data));
16684 + /* return context id on success */
16685 + ret = new_vxi->vx_id;
16687 + /* get a reference for persistent contexts */
16688 + if ((vc_data.flagword & VXF_PERSISTENT))
16689 + vx_set_persistent(new_vxi);
16691 + release_vx_info(new_vxi, NULL);
16692 + put_vx_info(new_vxi);
16697 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
16699 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
16702 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16705 + ret = vx_migrate_task(current, vxi, 0);
16708 + if (vc_data.flagword & VXM_SET_INIT)
16709 + ret = vx_set_init(vxi, current);
16712 + if (vc_data.flagword & VXM_SET_REAPER)
16713 + ret = vx_set_reaper(vxi, current);
16718 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
16720 + struct vcmd_ctx_flags_v0 vc_data;
16722 + vc_data.flagword = vxi->vx_flags;
16724 + /* special STATE flag handling */
16725 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
16727 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16732 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
16734 + struct vcmd_ctx_flags_v0 vc_data;
16735 + uint64_t mask, trigger;
16737 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16740 + /* special STATE flag handling */
16741 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
16742 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
16744 + if (vxi == current_vx_info()) {
16745 + /* if (trigger & VXF_STATE_SETUP)
16746 + vx_mask_cap_bset(vxi, current); */
16747 + if (trigger & VXF_STATE_INIT) {
16750 + ret = vx_set_init(vxi, current);
16753 + ret = vx_set_reaper(vxi, current);
16759 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
16760 + vc_data.flagword, mask);
16761 + if (trigger & VXF_PERSISTENT)
16762 + vx_update_persistent(vxi);
16768 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
16770 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
16772 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
16776 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
16778 + kernel_cap_t c = __cap_empty_set;
16780 + c.cap[0] = v & 0xFFFFFFFF;
16781 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
16783 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
16788 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
16791 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
16793 + *ccaps = vxi->vx_ccaps;
16798 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
16800 + struct vcmd_ctx_caps_v1 vc_data;
16803 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
16806 + vc_data.cmask = ~0ULL;
16808 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16813 +static int do_set_caps(struct vx_info *vxi,
16814 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
16816 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
16819 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
16820 + bcaps, bmask, ccaps, cmask);
16822 + vxi->vx_bcaps = cap_t_from_caps(
16823 + vs_mask_flags(bcold, bcaps, bmask));
16824 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
16829 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
16831 + struct vcmd_ctx_caps_v1 vc_data;
16833 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16836 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
16839 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
16841 + struct vcmd_bcaps vc_data;
16844 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
16847 + vc_data.bmask = ~0ULL;
16849 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16854 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
16856 + struct vcmd_bcaps vc_data;
16858 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16861 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
16865 +int vc_get_umask(struct vx_info *vxi, void __user *data)
16867 + struct vcmd_umask vc_data;
16869 + vc_data.umask = vxi->vx_umask;
16870 + vc_data.mask = ~0ULL;
16872 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16877 +int vc_set_umask(struct vx_info *vxi, void __user *data)
16879 + struct vcmd_umask vc_data;
16881 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16884 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
16885 + vc_data.umask, vc_data.mask);
16890 +int vc_get_wmask(struct vx_info *vxi, void __user *data)
16892 + struct vcmd_wmask vc_data;
16894 + vc_data.wmask = vxi->vx_wmask;
16895 + vc_data.mask = ~0ULL;
16897 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16902 +int vc_set_wmask(struct vx_info *vxi, void __user *data)
16904 + struct vcmd_wmask vc_data;
16906 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16909 + vxi->vx_wmask = vs_mask_flags(vxi->vx_wmask,
16910 + vc_data.wmask, vc_data.mask);
16915 +int vc_get_badness(struct vx_info *vxi, void __user *data)
16917 + struct vcmd_badness_v0 vc_data;
16919 + vc_data.bias = vxi->vx_badness_bias;
16921 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16926 +int vc_set_badness(struct vx_info *vxi, void __user *data)
16928 + struct vcmd_badness_v0 vc_data;
16930 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16933 + vxi->vx_badness_bias = vc_data.bias;
16937 +#include <linux/module.h>
16939 +EXPORT_SYMBOL_GPL(free_vx_info);
16941 diff -NurpP --minimal linux-3.6.10/kernel/vserver/cvirt.c linux-3.6.10-vs2.3.4.5/kernel/vserver/cvirt.c
16942 --- linux-3.6.10/kernel/vserver/cvirt.c 1970-01-01 01:00:00.000000000 +0100
16943 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/cvirt.c 2012-10-04 18:47:00.000000000 +0200
16946 + * linux/kernel/vserver/cvirt.c
16948 + * Virtual Server: Context Virtualization
16950 + * Copyright (C) 2004-2007 Herbert Pötzl
16952 + * V0.01 broken out from limit.c
16953 + * V0.02 added utsname stuff
16954 + * V0.03 changed vcmds to vxi arg
16958 +#include <linux/types.h>
16959 +#include <linux/utsname.h>
16960 +#include <linux/vs_cvirt.h>
16961 +#include <linux/vserver/switch.h>
16962 +#include <linux/vserver/cvirt_cmd.h>
16964 +#include <asm/uaccess.h>
16967 +void vx_vsi_boottime(struct timespec *boottime)
16969 + struct vx_info *vxi = current_vx_info();
16971 + set_normalized_timespec(boottime,
16972 + boottime->tv_sec + vxi->cvirt.bias_uptime.tv_sec,
16973 + boottime->tv_nsec + vxi->cvirt.bias_uptime.tv_nsec);
16977 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
16979 + struct vx_info *vxi = current_vx_info();
16981 + set_normalized_timespec(uptime,
16982 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
16983 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
16986 + set_normalized_timespec(idle,
16987 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
16988 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
16992 +uint64_t vx_idle_jiffies(void)
16994 + return init_task.utime + init_task.stime;
16999 +static inline uint32_t __update_loadavg(uint32_t load,
17000 + int wsize, int delta, int n)
17002 + unsigned long long calc, prev;
17004 + /* just set it to n */
17005 + if (unlikely(delta >= wsize))
17006 + return (n << FSHIFT);
17008 + calc = delta * n;
17010 + prev = (wsize - delta);
17013 + do_div(calc, wsize);
17018 +void vx_update_load(struct vx_info *vxi)
17020 + uint32_t now, last, delta;
17021 + unsigned int nr_running, nr_uninterruptible;
17022 + unsigned int total;
17023 + unsigned long flags;
17025 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
17028 + last = vxi->cvirt.load_last;
17029 + delta = now - last;
17031 + if (delta < 5*HZ)
17034 + nr_running = atomic_read(&vxi->cvirt.nr_running);
17035 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
17036 + total = nr_running + nr_uninterruptible;
17038 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
17039 + 60*HZ, delta, total);
17040 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
17041 + 5*60*HZ, delta, total);
17042 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
17043 + 15*60*HZ, delta, total);
17045 + vxi->cvirt.load_last = now;
17047 + atomic_inc(&vxi->cvirt.load_updates);
17048 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
17053 + * Commands to do_syslog:
17055 + * 0 -- Close the log. Currently a NOP.
17056 + * 1 -- Open the log. Currently a NOP.
17057 + * 2 -- Read from the log.
17058 + * 3 -- Read all messages remaining in the ring buffer.
17059 + * 4 -- Read and clear all messages remaining in the ring buffer
17060 + * 5 -- Clear ring buffer.
17061 + * 6 -- Disable printk's to console
17062 + * 7 -- Enable printk's to console
17063 + * 8 -- Set level of messages printed to console
17064 + * 9 -- Return number of unread characters in the log buffer
17065 + * 10 -- Return size of the log buffer
17067 +int vx_do_syslog(int type, char __user *buf, int len)
17070 + int do_clear = 0;
17071 + struct vx_info *vxi = current_vx_info();
17072 + struct _vx_syslog *log;
17076 + log = &vxi->cvirt.syslog;
17079 + case 0: /* Close log */
17080 + case 1: /* Open log */
17082 + case 2: /* Read from log */
17083 + error = wait_event_interruptible(log->log_wait,
17084 + (log->log_start - log->log_end));
17087 + spin_lock_irq(&log->logbuf_lock);
17088 + spin_unlock_irq(&log->logbuf_lock);
17090 + case 4: /* Read/clear last kernel messages */
17092 + /* fall through */
17093 + case 3: /* Read last kernel messages */
17096 + case 5: /* Clear ring buffer */
17099 + case 6: /* Disable logging to console */
17100 + case 7: /* Enable logging to console */
17101 + case 8: /* Set level of messages printed to console */
17104 + case 9: /* Number of chars in the log buffer */
17106 + case 10: /* Size of the log buffer */
17116 +/* virtual host info names */
17118 +static char *vx_vhi_name(struct vx_info *vxi, int id)
17120 + struct nsproxy *nsproxy;
17121 + struct uts_namespace *uts;
17123 + if (id == VHIN_CONTEXT)
17124 + return vxi->vx_name;
17126 + nsproxy = vxi->space[0].vx_nsproxy;
17130 + uts = nsproxy->uts_ns;
17135 + case VHIN_SYSNAME:
17136 + return uts->name.sysname;
17137 + case VHIN_NODENAME:
17138 + return uts->name.nodename;
17139 + case VHIN_RELEASE:
17140 + return uts->name.release;
17141 + case VHIN_VERSION:
17142 + return uts->name.version;
17143 + case VHIN_MACHINE:
17144 + return uts->name.machine;
17145 + case VHIN_DOMAINNAME:
17146 + return uts->name.domainname;
17153 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
17155 + struct vcmd_vhi_name_v0 vc_data;
17158 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17161 + name = vx_vhi_name(vxi, vc_data.field);
17165 + memcpy(name, vc_data.name, 65);
17169 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
17171 + struct vcmd_vhi_name_v0 vc_data;
17174 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17177 + name = vx_vhi_name(vxi, vc_data.field);
17181 + memcpy(vc_data.name, name, 65);
17182 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17188 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
17190 + struct vcmd_virt_stat_v0 vc_data;
17191 + struct _vx_cvirt *cvirt = &vxi->cvirt;
17192 + struct timespec uptime;
17194 + do_posix_clock_monotonic_gettime(&uptime);
17195 + set_normalized_timespec(&uptime,
17196 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
17197 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
17199 + vc_data.offset = timespec_to_ns(&cvirt->bias_ts);
17200 + vc_data.uptime = timespec_to_ns(&uptime);
17201 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
17202 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
17203 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
17204 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
17205 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
17206 + vc_data.load[0] = cvirt->load[0];
17207 + vc_data.load[1] = cvirt->load[1];
17208 + vc_data.load[2] = cvirt->load[2];
17210 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17216 +#ifdef CONFIG_VSERVER_VTIME
17218 +/* virtualized time base */
17220 +void vx_adjust_timespec(struct timespec *ts)
17222 + struct vx_info *vxi;
17224 + if (!vx_flags(VXF_VIRT_TIME, 0))
17227 + vxi = current_vx_info();
17228 + ts->tv_sec += vxi->cvirt.bias_ts.tv_sec;
17229 + ts->tv_nsec += vxi->cvirt.bias_ts.tv_nsec;
17231 + if (ts->tv_nsec >= NSEC_PER_SEC) {
17233 + ts->tv_nsec -= NSEC_PER_SEC;
17234 + } else if (ts->tv_nsec < 0) {
17236 + ts->tv_nsec += NSEC_PER_SEC;
17240 +int vx_settimeofday(const struct timespec *ts)
17242 + struct timespec ats, delta;
17243 + struct vx_info *vxi;
17245 + if (!vx_flags(VXF_VIRT_TIME, 0))
17246 + return do_settimeofday(ts);
17248 + getnstimeofday(&ats);
17249 + delta = timespec_sub(*ts, ats);
17251 + vxi = current_vx_info();
17252 + vxi->cvirt.bias_ts = timespec_add(vxi->cvirt.bias_ts, delta);
17258 diff -NurpP --minimal linux-3.6.10/kernel/vserver/cvirt_init.h linux-3.6.10-vs2.3.4.5/kernel/vserver/cvirt_init.h
17259 --- linux-3.6.10/kernel/vserver/cvirt_init.h 1970-01-01 01:00:00.000000000 +0100
17260 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/cvirt_init.h 2012-10-04 18:47:00.000000000 +0200
17264 +extern uint64_t vx_idle_jiffies(void);
17266 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
17268 + uint64_t idle_jiffies = vx_idle_jiffies();
17269 + uint64_t nsuptime;
17271 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
17272 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
17273 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
17274 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
17275 + cvirt->bias_ts.tv_sec = 0;
17276 + cvirt->bias_ts.tv_nsec = 0;
17278 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
17279 + atomic_set(&cvirt->nr_threads, 0);
17280 + atomic_set(&cvirt->nr_running, 0);
17281 + atomic_set(&cvirt->nr_uninterruptible, 0);
17282 + atomic_set(&cvirt->nr_onhold, 0);
17284 + spin_lock_init(&cvirt->load_lock);
17285 + cvirt->load_last = jiffies;
17286 + atomic_set(&cvirt->load_updates, 0);
17287 + cvirt->load[0] = 0;
17288 + cvirt->load[1] = 0;
17289 + cvirt->load[2] = 0;
17290 + atomic_set(&cvirt->total_forks, 0);
17292 + spin_lock_init(&cvirt->syslog.logbuf_lock);
17293 + init_waitqueue_head(&cvirt->syslog.log_wait);
17294 + cvirt->syslog.log_start = 0;
17295 + cvirt->syslog.log_end = 0;
17296 + cvirt->syslog.con_start = 0;
17297 + cvirt->syslog.logged_chars = 0;
17301 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17303 + // cvirt_pc->cpustat = { 0 };
17306 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
17308 +#ifdef CONFIG_VSERVER_WARN
17311 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
17312 + "!!! cvirt: %p[nr_threads] = %d on exit.",
17314 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
17315 + "!!! cvirt: %p[nr_running] = %d on exit.",
17317 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
17318 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
17320 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
17321 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
17327 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17332 diff -NurpP --minimal linux-3.6.10/kernel/vserver/cvirt_proc.h linux-3.6.10-vs2.3.4.5/kernel/vserver/cvirt_proc.h
17333 --- linux-3.6.10/kernel/vserver/cvirt_proc.h 1970-01-01 01:00:00.000000000 +0100
17334 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/cvirt_proc.h 2012-10-04 18:47:00.000000000 +0200
17336 +#ifndef _VX_CVIRT_PROC_H
17337 +#define _VX_CVIRT_PROC_H
17339 +#include <linux/nsproxy.h>
17340 +#include <linux/mnt_namespace.h>
17341 +#include <linux/ipc_namespace.h>
17342 +#include <linux/utsname.h>
17343 +#include <linux/ipc.h>
17345 +extern int vx_info_mnt_namespace(struct mnt_namespace *, char *);
17348 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
17350 + struct mnt_namespace *ns;
17351 + struct uts_namespace *uts;
17352 + struct ipc_namespace *ipc;
17358 + length += sprintf(buffer + length,
17359 + "NSProxy:\t%p [%p,%p,%p]\n",
17360 + nsproxy, nsproxy->mnt_ns,
17361 + nsproxy->uts_ns, nsproxy->ipc_ns);
17363 + ns = nsproxy->mnt_ns;
17367 + length += vx_info_mnt_namespace(ns, buffer + length);
17371 + uts = nsproxy->uts_ns;
17375 + length += sprintf(buffer + length,
17376 + "SysName:\t%.*s\n"
17377 + "NodeName:\t%.*s\n"
17378 + "Release:\t%.*s\n"
17379 + "Version:\t%.*s\n"
17380 + "Machine:\t%.*s\n"
17381 + "DomainName:\t%.*s\n",
17382 + __NEW_UTS_LEN, uts->name.sysname,
17383 + __NEW_UTS_LEN, uts->name.nodename,
17384 + __NEW_UTS_LEN, uts->name.release,
17385 + __NEW_UTS_LEN, uts->name.version,
17386 + __NEW_UTS_LEN, uts->name.machine,
17387 + __NEW_UTS_LEN, uts->name.domainname);
17390 + ipc = nsproxy->ipc_ns;
17394 + length += sprintf(buffer + length,
17395 + "SEMS:\t\t%d %d %d %d %d\n"
17396 + "MSG:\t\t%d %d %d\n"
17397 + "SHM:\t\t%lu %lu %d %d\n",
17398 + ipc->sem_ctls[0], ipc->sem_ctls[1],
17399 + ipc->sem_ctls[2], ipc->sem_ctls[3],
17401 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
17402 + (unsigned long)ipc->shm_ctlmax,
17403 + (unsigned long)ipc->shm_ctlall,
17404 + ipc->shm_ctlmni, ipc->shm_tot);
17411 +#include <linux/sched.h>
17413 +#define LOAD_INT(x) ((x) >> FSHIFT)
17414 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
17417 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
17422 + length += sprintf(buffer + length,
17423 + "BiasUptime:\t%lu.%02lu\n",
17424 + (unsigned long)cvirt->bias_uptime.tv_sec,
17425 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
17427 + a = cvirt->load[0] + (FIXED_1 / 200);
17428 + b = cvirt->load[1] + (FIXED_1 / 200);
17429 + c = cvirt->load[2] + (FIXED_1 / 200);
17430 + length += sprintf(buffer + length,
17431 + "nr_threads:\t%d\n"
17432 + "nr_running:\t%d\n"
17433 + "nr_unintr:\t%d\n"
17434 + "nr_onhold:\t%d\n"
17435 + "load_updates:\t%d\n"
17436 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
17437 + "total_forks:\t%d\n",
17438 + atomic_read(&cvirt->nr_threads),
17439 + atomic_read(&cvirt->nr_running),
17440 + atomic_read(&cvirt->nr_uninterruptible),
17441 + atomic_read(&cvirt->nr_onhold),
17442 + atomic_read(&cvirt->load_updates),
17443 + LOAD_INT(a), LOAD_FRAC(a),
17444 + LOAD_INT(b), LOAD_FRAC(b),
17445 + LOAD_INT(c), LOAD_FRAC(c),
17446 + atomic_read(&cvirt->total_forks));
17451 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
17452 + char *buffer, int cpu)
17458 +#endif /* _VX_CVIRT_PROC_H */
17459 diff -NurpP --minimal linux-3.6.10/kernel/vserver/debug.c linux-3.6.10-vs2.3.4.5/kernel/vserver/debug.c
17460 --- linux-3.6.10/kernel/vserver/debug.c 1970-01-01 01:00:00.000000000 +0100
17461 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/debug.c 2012-10-04 18:47:00.000000000 +0200
17464 + * kernel/vserver/debug.c
17466 + * Copyright (C) 2005-2007 Herbert Pötzl
17468 + * V0.01 vx_info dump support
17472 +#include <linux/module.h>
17474 +#include <linux/vserver/context.h>
17477 +void dump_vx_info(struct vx_info *vxi, int level)
17479 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
17480 + atomic_read(&vxi->vx_usecnt),
17481 + atomic_read(&vxi->vx_tasks),
17484 + __dump_vx_limit(&vxi->limit);
17485 + __dump_vx_sched(&vxi->sched);
17486 + __dump_vx_cvirt(&vxi->cvirt);
17487 + __dump_vx_cacct(&vxi->cacct);
17493 +EXPORT_SYMBOL_GPL(dump_vx_info);
17495 diff -NurpP --minimal linux-3.6.10/kernel/vserver/device.c linux-3.6.10-vs2.3.4.5/kernel/vserver/device.c
17496 --- linux-3.6.10/kernel/vserver/device.c 1970-01-01 01:00:00.000000000 +0100
17497 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/device.c 2012-10-04 18:47:00.000000000 +0200
17500 + * linux/kernel/vserver/device.c
17502 + * Linux-VServer: Device Support
17504 + * Copyright (C) 2006 Herbert Pötzl
17505 + * Copyright (C) 2007 Daniel Hokka Zakrisson
17507 + * V0.01 device mapping basics
17508 + * V0.02 added defaults
17512 +#include <linux/slab.h>
17513 +#include <linux/rcupdate.h>
17514 +#include <linux/fs.h>
17515 +#include <linux/namei.h>
17516 +#include <linux/hash.h>
17518 +#include <asm/errno.h>
17519 +#include <asm/uaccess.h>
17520 +#include <linux/vserver/base.h>
17521 +#include <linux/vserver/debug.h>
17522 +#include <linux/vserver/context.h>
17523 +#include <linux/vserver/device.h>
17524 +#include <linux/vserver/device_cmd.h>
17527 +#define DMAP_HASH_BITS 4
17530 +struct vs_mapping {
17532 + struct hlist_node hlist;
17533 + struct list_head list;
17535 +#define dm_hlist u.hlist
17536 +#define dm_list u.list
17539 + struct vx_dmap_target target;
17543 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
17545 +static DEFINE_SPINLOCK(dmap_main_hash_lock);
17547 +static struct vx_dmap_target dmap_defaults[2] = {
17548 + { .flags = DATTR_OPEN },
17549 + { .flags = DATTR_OPEN },
17553 +struct kmem_cache *dmap_cachep __read_mostly;
17555 +int __init dmap_cache_init(void)
17557 + dmap_cachep = kmem_cache_create("dmap_cache",
17558 + sizeof(struct vs_mapping), 0,
17559 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
17563 +__initcall(dmap_cache_init);
17566 +static inline unsigned int __hashval(dev_t dev, int bits)
17568 + return hash_long((unsigned long)dev, bits);
17572 +/* __hash_mapping()
17573 + * add the mapping to the hash table
17575 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
17577 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17578 + struct hlist_head *head, *hash = dmap_main_hash;
17579 + int device = vdm->device;
17581 + spin_lock(hash_lock);
17582 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
17583 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
17585 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
17586 + hlist_add_head(&vdm->dm_hlist, head);
17587 + spin_unlock(hash_lock);
17591 +static inline int __mode_to_default(umode_t mode)
17604 +/* __set_default()
17607 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
17608 + struct vx_dmap_target *vdmt)
17610 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17611 + spin_lock(hash_lock);
17614 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
17616 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
17619 + spin_unlock(hash_lock);
17621 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
17622 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
17626 +/* __remove_default()
17627 + * remove a default
17629 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
17631 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17632 + spin_lock(hash_lock);
17635 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
17636 + else /* remove == reset */
17637 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
17639 + spin_unlock(hash_lock);
17644 +/* __find_mapping()
17645 + * find a mapping in the hash table
17647 + * caller must hold hash_lock
17649 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
17650 + struct vs_mapping **local, struct vs_mapping **global)
17652 + struct hlist_head *hash = dmap_main_hash;
17653 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
17654 + struct hlist_node *pos;
17655 + struct vs_mapping *vdm;
17661 + hlist_for_each(pos, head) {
17662 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
17664 + if ((vdm->device == device) &&
17665 + !((vdm->target.flags ^ mode) & S_IFMT)) {
17666 + if (vdm->xid == xid) {
17669 + } else if (global && vdm->xid == 0)
17674 + if (global && *global)
17681 +/* __lookup_mapping()
17682 + * find a mapping and store the result in target and flags
17684 +static inline int __lookup_mapping(struct vx_info *vxi,
17685 + dev_t device, dev_t *target, int *flags, umode_t mode)
17687 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17688 + struct vs_mapping *vdm, *global;
17689 + struct vx_dmap_target *vdmt;
17691 + xid_t xid = vxi->vx_id;
17694 + spin_lock(hash_lock);
17695 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
17697 + vdmt = &vdm->target;
17701 + index = __mode_to_default(mode);
17702 + if (vxi && vxi->dmap.targets[index].flags) {
17704 + vdmt = &vxi->dmap.targets[index];
17705 + } else if (global) {
17707 + vdmt = &global->target;
17711 + vdmt = &dmap_defaults[index];
17715 + if (target && (vdmt->flags & DATTR_REMAP))
17716 + *target = vdmt->target;
17718 + *target = device;
17720 + *flags = vdmt->flags;
17722 + spin_unlock(hash_lock);
17728 +/* __remove_mapping()
17729 + * remove a mapping from the hash table
17731 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
17734 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17735 + struct vs_mapping *vdm = NULL;
17738 + spin_lock(hash_lock);
17740 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
17742 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
17743 + vxi, vxi ? vxi->vx_id : 0, device, mode);
17746 + hlist_del(&vdm->dm_hlist);
17749 + spin_unlock(hash_lock);
17751 + kmem_cache_free(dmap_cachep, vdm);
17757 +int vs_map_device(struct vx_info *vxi,
17758 + dev_t device, dev_t *target, umode_t mode)
17760 + int ret, flags = DATTR_MASK;
17764 + *target = device;
17767 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
17768 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
17769 + device, target ? *target : 0, flags, mode, ret);
17771 + return (flags & DATTR_MASK);
17776 +static int do_set_mapping(struct vx_info *vxi,
17777 + dev_t device, dev_t target, int flags, umode_t mode)
17780 + struct vs_mapping *new;
17782 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
17786 + INIT_HLIST_NODE(&new->dm_hlist);
17787 + new->device = device;
17788 + new->target.target = target;
17789 + new->target.flags = flags | mode;
17790 + new->xid = (vxi ? vxi->vx_id : 0);
17792 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
17793 + __hash_mapping(vxi, new);
17795 + struct vx_dmap_target new = {
17796 + .target = target,
17797 + .flags = flags | mode,
17799 + __set_default(vxi, mode, &new);
17805 +static int do_unset_mapping(struct vx_info *vxi,
17806 + dev_t device, dev_t target, int flags, umode_t mode)
17808 + int ret = -EINVAL;
17811 + ret = __remove_mapping(vxi, device, mode);
17815 + ret = __remove_default(vxi, mode);
17825 +static inline int __user_device(const char __user *name, dev_t *dev,
17828 + struct nameidata nd;
17835 + ret = user_lpath(name, &nd.path);
17838 + if (nd.path.dentry->d_inode) {
17839 + *dev = nd.path.dentry->d_inode->i_rdev;
17840 + *mode = nd.path.dentry->d_inode->i_mode;
17842 + path_put(&nd.path);
17846 +static inline int __mapping_mode(dev_t device, dev_t target,
17847 + umode_t device_mode, umode_t target_mode, umode_t *mode)
17850 + *mode = device_mode & S_IFMT;
17852 + *mode = target_mode & S_IFMT;
17856 + /* if both given, device and target mode have to match */
17857 + if (device && target &&
17858 + ((device_mode ^ target_mode) & S_IFMT))
17864 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
17865 + const char __user *target_path, int flags, int set)
17867 + dev_t device = ~0, target = ~0;
17868 + umode_t device_mode = 0, target_mode = 0, mode;
17871 + ret = __user_device(device_path, &device, &device_mode);
17874 + ret = __user_device(target_path, &target, &target_mode);
17878 + ret = __mapping_mode(device, target,
17879 + device_mode, target_mode, &mode);
17884 + return do_set_mapping(vxi, device, target,
17887 + return do_unset_mapping(vxi, device, target,
17892 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
17894 + struct vcmd_set_mapping_v0 vc_data;
17896 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17899 + return do_mapping(vxi, vc_data.device, vc_data.target,
17900 + vc_data.flags, 1);
17903 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
17905 + struct vcmd_set_mapping_v0 vc_data;
17907 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17910 + return do_mapping(vxi, vc_data.device, vc_data.target,
17911 + vc_data.flags, 0);
17915 +#ifdef CONFIG_COMPAT
17917 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
17919 + struct vcmd_set_mapping_v0_x32 vc_data;
17921 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17924 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
17925 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
17928 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
17930 + struct vcmd_set_mapping_v0_x32 vc_data;
17932 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17935 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
17936 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
17939 +#endif /* CONFIG_COMPAT */
17942 diff -NurpP --minimal linux-3.6.10/kernel/vserver/dlimit.c linux-3.6.10-vs2.3.4.5/kernel/vserver/dlimit.c
17943 --- linux-3.6.10/kernel/vserver/dlimit.c 1970-01-01 01:00:00.000000000 +0100
17944 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/dlimit.c 2012-10-04 18:47:00.000000000 +0200
17947 + * linux/kernel/vserver/dlimit.c
17949 + * Virtual Server: Context Disk Limits
17951 + * Copyright (C) 2004-2009 Herbert Pötzl
17953 + * V0.01 initial version
17954 + * V0.02 compat32 splitup
17955 + * V0.03 extended interface
17959 +#include <linux/statfs.h>
17960 +#include <linux/sched.h>
17961 +#include <linux/namei.h>
17962 +#include <linux/vs_tag.h>
17963 +#include <linux/vs_dlimit.h>
17964 +#include <linux/vserver/dlimit_cmd.h>
17965 +#include <linux/slab.h>
17966 +// #include <linux/gfp.h>
17968 +#include <asm/uaccess.h>
17970 +/* __alloc_dl_info()
17972 + * allocate an initialized dl_info struct
17973 + * doesn't make it visible (hash) */
17975 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
17977 + struct dl_info *new = NULL;
17979 + vxdprintk(VXD_CBIT(dlim, 5),
17980 + "alloc_dl_info(%p,%d)*", sb, tag);
17982 + /* would this benefit from a slab cache? */
17983 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
17987 + memset(new, 0, sizeof(struct dl_info));
17988 + new->dl_tag = tag;
17990 + // INIT_RCU_HEAD(&new->dl_rcu);
17991 + INIT_HLIST_NODE(&new->dl_hlist);
17992 + spin_lock_init(&new->dl_lock);
17993 + atomic_set(&new->dl_refcnt, 0);
17994 + atomic_set(&new->dl_usecnt, 0);
17996 + /* rest of init goes here */
17998 + vxdprintk(VXD_CBIT(dlim, 4),
17999 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
18003 +/* __dealloc_dl_info()
18005 + * final disposal of dl_info */
18007 +static void __dealloc_dl_info(struct dl_info *dli)
18009 + vxdprintk(VXD_CBIT(dlim, 4),
18010 + "dealloc_dl_info(%p)", dli);
18012 + dli->dl_hlist.next = LIST_POISON1;
18013 + dli->dl_tag = -1;
18016 + BUG_ON(atomic_read(&dli->dl_usecnt));
18017 + BUG_ON(atomic_read(&dli->dl_refcnt));
18023 +/* hash table for dl_info hash */
18025 +#define DL_HASH_SIZE 13
18027 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
18029 +static DEFINE_SPINLOCK(dl_info_hash_lock);
18032 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
18034 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
18039 +/* __hash_dl_info()
18041 + * add the dli to the global hash table
18042 + * requires the hash_lock to be held */
18044 +static inline void __hash_dl_info(struct dl_info *dli)
18046 + struct hlist_head *head;
18048 + vxdprintk(VXD_CBIT(dlim, 6),
18049 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
18050 + get_dl_info(dli);
18051 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
18052 + hlist_add_head_rcu(&dli->dl_hlist, head);
18055 +/* __unhash_dl_info()
18057 + * remove the dli from the global hash table
18058 + * requires the hash_lock to be held */
18060 +static inline void __unhash_dl_info(struct dl_info *dli)
18062 + vxdprintk(VXD_CBIT(dlim, 6),
18063 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
18064 + hlist_del_rcu(&dli->dl_hlist);
18065 + put_dl_info(dli);
18069 +/* __lookup_dl_info()
18071 + * requires the rcu_read_lock()
18072 + * doesn't increment the dl_refcnt */
18074 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
18076 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
18077 + struct hlist_node *pos;
18078 + struct dl_info *dli;
18080 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
18082 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
18090 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
18092 + struct dl_info *dli;
18095 + dli = get_dl_info(__lookup_dl_info(sb, tag));
18096 + vxdprintk(VXD_CBIT(dlim, 7),
18097 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
18098 + rcu_read_unlock();
18102 +void rcu_free_dl_info(struct rcu_head *head)
18104 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
18105 + int usecnt, refcnt;
18107 + BUG_ON(!dli || !head);
18109 + usecnt = atomic_read(&dli->dl_usecnt);
18110 + BUG_ON(usecnt < 0);
18112 + refcnt = atomic_read(&dli->dl_refcnt);
18113 + BUG_ON(refcnt < 0);
18115 + vxdprintk(VXD_CBIT(dlim, 3),
18116 + "rcu_free_dl_info(%p)", dli);
18118 + __dealloc_dl_info(dli);
18120 + printk("!!! rcu didn't free\n");
18126 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
18127 + uint32_t flags, int add)
18129 + struct path path;
18132 + ret = user_lpath(name, &path);
18134 + struct super_block *sb;
18135 + struct dl_info *dli;
18138 + if (!path.dentry->d_inode)
18139 + goto out_release;
18140 + if (!(sb = path.dentry->d_inode->i_sb))
18141 + goto out_release;
18144 + dli = __alloc_dl_info(sb, id);
18145 + spin_lock(&dl_info_hash_lock);
18148 + if (__lookup_dl_info(sb, id))
18150 + __hash_dl_info(dli);
18153 + spin_lock(&dl_info_hash_lock);
18154 + dli = __lookup_dl_info(sb, id);
18159 + __unhash_dl_info(dli);
18163 + spin_unlock(&dl_info_hash_lock);
18165 + __dealloc_dl_info(dli);
18172 +int vc_add_dlimit(uint32_t id, void __user *data)
18174 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18176 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18179 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
18182 +int vc_rem_dlimit(uint32_t id, void __user *data)
18184 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18186 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18189 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
18192 +#ifdef CONFIG_COMPAT
18194 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
18196 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18198 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18201 + return do_addrem_dlimit(id,
18202 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
18205 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
18207 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18209 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18212 + return do_addrem_dlimit(id,
18213 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
18216 +#endif /* CONFIG_COMPAT */
18220 +int do_set_dlimit(uint32_t id, const char __user *name,
18221 + uint32_t space_used, uint32_t space_total,
18222 + uint32_t inodes_used, uint32_t inodes_total,
18223 + uint32_t reserved, uint32_t flags)
18225 + struct path path;
18228 + ret = user_lpath(name, &path);
18230 + struct super_block *sb;
18231 + struct dl_info *dli;
18234 + if (!path.dentry->d_inode)
18235 + goto out_release;
18236 + if (!(sb = path.dentry->d_inode->i_sb))
18237 + goto out_release;
18239 + /* sanity checks */
18240 + if ((reserved != CDLIM_KEEP &&
18241 + reserved > 100) ||
18242 + (inodes_used != CDLIM_KEEP &&
18243 + inodes_used > inodes_total) ||
18244 + (space_used != CDLIM_KEEP &&
18245 + space_used > space_total))
18246 + goto out_release;
18249 + dli = locate_dl_info(sb, id);
18251 + goto out_release;
18253 + spin_lock(&dli->dl_lock);
18255 + if (inodes_used != CDLIM_KEEP)
18256 + dli->dl_inodes_used = inodes_used;
18257 + if (inodes_total != CDLIM_KEEP)
18258 + dli->dl_inodes_total = inodes_total;
18259 + if (space_used != CDLIM_KEEP)
18260 + dli->dl_space_used = dlimit_space_32to64(
18261 + space_used, flags, DLIMS_USED);
18263 + if (space_total == CDLIM_INFINITY)
18264 + dli->dl_space_total = DLIM_INFINITY;
18265 + else if (space_total != CDLIM_KEEP)
18266 + dli->dl_space_total = dlimit_space_32to64(
18267 + space_total, flags, DLIMS_TOTAL);
18269 + if (reserved != CDLIM_KEEP)
18270 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
18272 + spin_unlock(&dli->dl_lock);
18274 + put_dl_info(dli);
18283 +int vc_set_dlimit(uint32_t id, void __user *data)
18285 + struct vcmd_ctx_dlimit_v0 vc_data;
18287 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18290 + return do_set_dlimit(id, vc_data.name,
18291 + vc_data.space_used, vc_data.space_total,
18292 + vc_data.inodes_used, vc_data.inodes_total,
18293 + vc_data.reserved, vc_data.flags);
18296 +#ifdef CONFIG_COMPAT
18298 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
18300 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18302 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18305 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
18306 + vc_data.space_used, vc_data.space_total,
18307 + vc_data.inodes_used, vc_data.inodes_total,
18308 + vc_data.reserved, vc_data.flags);
18311 +#endif /* CONFIG_COMPAT */
18315 +int do_get_dlimit(uint32_t id, const char __user *name,
18316 + uint32_t *space_used, uint32_t *space_total,
18317 + uint32_t *inodes_used, uint32_t *inodes_total,
18318 + uint32_t *reserved, uint32_t *flags)
18320 + struct path path;
18323 + ret = user_lpath(name, &path);
18325 + struct super_block *sb;
18326 + struct dl_info *dli;
18329 + if (!path.dentry->d_inode)
18330 + goto out_release;
18331 + if (!(sb = path.dentry->d_inode->i_sb))
18332 + goto out_release;
18335 + dli = locate_dl_info(sb, id);
18337 + goto out_release;
18339 + spin_lock(&dli->dl_lock);
18340 + *inodes_used = dli->dl_inodes_used;
18341 + *inodes_total = dli->dl_inodes_total;
18343 + *space_used = dlimit_space_64to32(
18344 + dli->dl_space_used, flags, DLIMS_USED);
18346 + if (dli->dl_space_total == DLIM_INFINITY)
18347 + *space_total = CDLIM_INFINITY;
18349 + *space_total = dlimit_space_64to32(
18350 + dli->dl_space_total, flags, DLIMS_TOTAL);
18352 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
18353 + spin_unlock(&dli->dl_lock);
18355 + put_dl_info(dli);
18366 +int vc_get_dlimit(uint32_t id, void __user *data)
18368 + struct vcmd_ctx_dlimit_v0 vc_data;
18371 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18374 + ret = do_get_dlimit(id, vc_data.name,
18375 + &vc_data.space_used, &vc_data.space_total,
18376 + &vc_data.inodes_used, &vc_data.inodes_total,
18377 + &vc_data.reserved, &vc_data.flags);
18381 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18386 +#ifdef CONFIG_COMPAT
18388 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
18390 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18393 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18396 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
18397 + &vc_data.space_used, &vc_data.space_total,
18398 + &vc_data.inodes_used, &vc_data.inodes_total,
18399 + &vc_data.reserved, &vc_data.flags);
18403 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18408 +#endif /* CONFIG_COMPAT */
18411 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
18413 + struct dl_info *dli;
18414 + __u64 blimit, bfree, bavail;
18417 + dli = locate_dl_info(sb, dx_current_tag());
18421 + spin_lock(&dli->dl_lock);
18422 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
18425 + /* reduce max inodes available to limit */
18426 + if (buf->f_files > dli->dl_inodes_total)
18427 + buf->f_files = dli->dl_inodes_total;
18429 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
18430 + /* reduce free inodes to min */
18431 + if (ifree < buf->f_ffree)
18432 + buf->f_ffree = ifree;
18435 + if (dli->dl_space_total == DLIM_INFINITY)
18438 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
18440 + if (dli->dl_space_total < dli->dl_space_used)
18443 + bfree = (dli->dl_space_total - dli->dl_space_used)
18444 + >> sb->s_blocksize_bits;
18446 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
18447 + if (bavail < dli->dl_space_used)
18450 + bavail = (bavail - dli->dl_space_used)
18451 + >> sb->s_blocksize_bits;
18453 + /* reduce max space available to limit */
18454 + if (buf->f_blocks > blimit)
18455 + buf->f_blocks = blimit;
18457 + /* reduce free space to min */
18458 + if (bfree < buf->f_bfree)
18459 + buf->f_bfree = bfree;
18461 + /* reduce avail space to min */
18462 + if (bavail < buf->f_bavail)
18463 + buf->f_bavail = bavail;
18466 + spin_unlock(&dli->dl_lock);
18467 + put_dl_info(dli);
18472 +#include <linux/module.h>
18474 +EXPORT_SYMBOL_GPL(locate_dl_info);
18475 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
18477 diff -NurpP --minimal linux-3.6.10/kernel/vserver/helper.c linux-3.6.10-vs2.3.4.5/kernel/vserver/helper.c
18478 --- linux-3.6.10/kernel/vserver/helper.c 1970-01-01 01:00:00.000000000 +0100
18479 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/helper.c 2012-10-04 18:47:00.000000000 +0200
18482 + * linux/kernel/vserver/helper.c
18484 + * Virtual Context Support
18486 + * Copyright (C) 2004-2007 Herbert Pötzl
18488 + * V0.01 basic helper
18492 +#include <linux/kmod.h>
18493 +#include <linux/reboot.h>
18494 +#include <linux/vs_context.h>
18495 +#include <linux/vs_network.h>
18496 +#include <linux/vserver/signal.h>
18499 +char vshelper_path[255] = "/sbin/vshelper";
18501 +static int vshelper_init(struct subprocess_info *info, struct cred *new_cred)
18503 + current->flags &= ~PF_THREAD_BOUND;
18507 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
18511 + if ((ret = call_usermodehelper_fns(name, argv, envp,
18512 + sync ? UMH_WAIT_PROC : UMH_WAIT_EXEC,
18513 + vshelper_init, NULL, NULL))) {
18514 + printk(KERN_WARNING "%s: (%s %s) returned %s with %d\n",
18515 + name, argv[1], argv[2],
18516 + sync ? "sync" : "async", ret);
18518 + vxdprintk(VXD_CBIT(switch, 4),
18519 + "%s: (%s %s) returned %s with %d",
18520 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
18525 + * vshelper path is set via /proc/sys
18526 + * invoked by vserver sys_reboot(), with
18527 + * the following arguments
18529 + * argv [0] = vshelper_path;
18530 + * argv [1] = action: "restart", "halt", "poweroff", ...
18531 + * argv [2] = context identifier
18533 + * envp [*] = type-specific parameters
18536 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
18538 + char id_buf[8], cmd_buf[16];
18539 + char uid_buf[16], pid_buf[16];
18542 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18543 + char *envp[] = {"HOME=/", "TERM=linux",
18544 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
18545 + uid_buf, pid_buf, cmd_buf, 0};
18547 + if (vx_info_state(vxi, VXS_HELPER))
18549 + vxi->vx_state |= VXS_HELPER;
18551 + snprintf(id_buf, sizeof(id_buf), "%d", vxi->vx_id);
18553 + snprintf(cmd_buf, sizeof(cmd_buf), "VS_CMD=%08x", cmd);
18554 + snprintf(uid_buf, sizeof(uid_buf), "VS_UID=%d", current_uid());
18555 + snprintf(pid_buf, sizeof(pid_buf), "VS_PID=%d", current->pid);
18558 + case LINUX_REBOOT_CMD_RESTART:
18559 + argv[1] = "restart";
18562 + case LINUX_REBOOT_CMD_HALT:
18563 + argv[1] = "halt";
18566 + case LINUX_REBOOT_CMD_POWER_OFF:
18567 + argv[1] = "poweroff";
18570 + case LINUX_REBOOT_CMD_SW_SUSPEND:
18571 + argv[1] = "swsusp";
18574 + case LINUX_REBOOT_CMD_OOM:
18579 + vxi->vx_state &= ~VXS_HELPER;
18583 + ret = do_vshelper(vshelper_path, argv, envp, 0);
18584 + vxi->vx_state &= ~VXS_HELPER;
18585 + __wakeup_vx_info(vxi);
18586 + return (ret) ? -EPERM : 0;
18590 +long vs_reboot(unsigned int cmd, void __user *arg)
18592 + struct vx_info *vxi = current_vx_info();
18595 + vxdprintk(VXD_CBIT(misc, 5),
18596 + "vs_reboot(%p[#%d],%u)",
18597 + vxi, vxi ? vxi->vx_id : 0, cmd);
18599 + ret = vs_reboot_helper(vxi, cmd, arg);
18603 + vxi->reboot_cmd = cmd;
18604 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18606 + case LINUX_REBOOT_CMD_RESTART:
18607 + case LINUX_REBOOT_CMD_HALT:
18608 + case LINUX_REBOOT_CMD_POWER_OFF:
18609 + vx_info_kill(vxi, 0, SIGKILL);
18610 + vx_info_kill(vxi, 1, SIGKILL);
18618 +long vs_oom_action(unsigned int cmd)
18620 + struct vx_info *vxi = current_vx_info();
18623 + vxdprintk(VXD_CBIT(misc, 5),
18624 + "vs_oom_action(%p[#%d],%u)",
18625 + vxi, vxi ? vxi->vx_id : 0, cmd);
18627 + ret = vs_reboot_helper(vxi, cmd, NULL);
18631 + vxi->reboot_cmd = cmd;
18632 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18633 + vx_info_kill(vxi, 0, SIGKILL);
18634 + vx_info_kill(vxi, 1, SIGKILL);
18640 + * argv [0] = vshelper_path;
18641 + * argv [1] = action: "startup", "shutdown"
18642 + * argv [2] = context identifier
18644 + * envp [*] = type-specific parameters
18647 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
18649 + char id_buf[8], cmd_buf[16];
18650 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18651 + char *envp[] = {"HOME=/", "TERM=linux",
18652 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18654 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
18657 + snprintf(id_buf, sizeof(id_buf), "%d", vxi->vx_id);
18658 + snprintf(cmd_buf, sizeof(cmd_buf), "VS_CMD=%08x", cmd);
18661 + case VSC_STARTUP:
18662 + argv[1] = "startup";
18664 + case VSC_SHUTDOWN:
18665 + argv[1] = "shutdown";
18671 + return do_vshelper(vshelper_path, argv, envp, 1);
18676 + * argv [0] = vshelper_path;
18677 + * argv [1] = action: "netup", "netdown"
18678 + * argv [2] = context identifier
18680 + * envp [*] = type-specific parameters
18683 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
18685 + char id_buf[8], cmd_buf[16];
18686 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18687 + char *envp[] = {"HOME=/", "TERM=linux",
18688 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18690 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
18693 + snprintf(id_buf, sizeof(id_buf), "%d", nxi->nx_id);
18694 + snprintf(cmd_buf, sizeof(cmd_buf), "VS_CMD=%08x", cmd);
18698 + argv[1] = "netup";
18700 + case VSC_NETDOWN:
18701 + argv[1] = "netdown";
18707 + return do_vshelper(vshelper_path, argv, envp, 1);
18710 diff -NurpP --minimal linux-3.6.10/kernel/vserver/history.c linux-3.6.10-vs2.3.4.5/kernel/vserver/history.c
18711 --- linux-3.6.10/kernel/vserver/history.c 1970-01-01 01:00:00.000000000 +0100
18712 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/history.c 2012-10-04 18:47:00.000000000 +0200
18715 + * kernel/vserver/history.c
18717 + * Virtual Context History Backtrace
18719 + * Copyright (C) 2004-2007 Herbert Pötzl
18721 + * V0.01 basic structure
18722 + * V0.02 hash/unhash and trace
18723 + * V0.03 preemption fixes
18727 +#include <linux/module.h>
18728 +#include <asm/uaccess.h>
18730 +#include <linux/vserver/context.h>
18731 +#include <linux/vserver/debug.h>
18732 +#include <linux/vserver/debug_cmd.h>
18733 +#include <linux/vserver/history.h>
18736 +#ifdef CONFIG_VSERVER_HISTORY
18737 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
18739 +#define VXH_SIZE 64
18742 +struct _vx_history {
18743 + unsigned int counter;
18745 + struct _vx_hist_entry entry[VXH_SIZE + 1];
18749 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
18751 +unsigned volatile int vxh_active = 1;
18753 +static atomic_t sequence = ATOMIC_INIT(0);
18758 + * requires disabled preemption */
18760 +struct _vx_hist_entry *vxh_advance(void *loc)
18762 + unsigned int cpu = smp_processor_id();
18763 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
18764 + struct _vx_hist_entry *entry;
18765 + unsigned int index;
18767 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
18768 + entry = &hist->entry[index];
18770 + entry->seq = atomic_inc_return(&sequence);
18771 + entry->loc = loc;
18775 +EXPORT_SYMBOL_GPL(vxh_advance);
18778 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
18780 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
18783 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
18785 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
18786 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
18787 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
18788 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
18790 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
18792 + switch (e->type) {
18793 + case VXH_THROW_OOPS:
18794 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
18797 + case VXH_GET_VX_INFO:
18798 + case VXH_PUT_VX_INFO:
18799 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
18801 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
18802 + VXH_VXI_ARGS(e));
18805 + case VXH_INIT_VX_INFO:
18806 + case VXH_SET_VX_INFO:
18807 + case VXH_CLR_VX_INFO:
18808 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
18810 + (e->type == VXH_INIT_VX_INFO) ? "init" :
18811 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
18812 + VXH_VXI_ARGS(e), e->sc.data);
18815 + case VXH_CLAIM_VX_INFO:
18816 + case VXH_RELEASE_VX_INFO:
18817 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
18819 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
18820 + VXH_VXI_ARGS(e), e->sc.data);
18823 + case VXH_ALLOC_VX_INFO:
18824 + case VXH_DEALLOC_VX_INFO:
18825 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
18827 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
18828 + VXH_VXI_ARGS(e));
18831 + case VXH_HASH_VX_INFO:
18832 + case VXH_UNHASH_VX_INFO:
18833 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
18835 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
18836 + VXH_VXI_ARGS(e));
18839 + case VXH_LOC_VX_INFO:
18840 + case VXH_LOOKUP_VX_INFO:
18841 + case VXH_CREATE_VX_INFO:
18842 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
18844 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
18845 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
18846 + e->ll.arg, VXH_VXI_ARGS(e));
18851 +static void __vxh_dump_history(void)
18853 + unsigned int i, cpu;
18855 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
18856 + atomic_read(&sequence), NR_CPUS);
18858 + for (i = 0; i < VXH_SIZE; i++) {
18859 + for_each_online_cpu(cpu) {
18860 + struct _vx_history *hist =
18861 + &per_cpu(vx_history_buffer, cpu);
18862 + unsigned int index = (hist->counter - i) % VXH_SIZE;
18863 + struct _vx_hist_entry *entry = &hist->entry[index];
18865 + vxh_dump_entry(entry, cpu);
18870 +void vxh_dump_history(void)
18874 + local_irq_enable();
18876 + local_irq_disable();
18878 + __vxh_dump_history();
18882 +/* vserver syscall commands below here */
18885 +int vc_dump_history(uint32_t id)
18888 + __vxh_dump_history();
18895 +int do_read_history(struct __user _vx_hist_entry *data,
18896 + int cpu, uint32_t *index, uint32_t *count)
18898 + int pos, ret = 0;
18899 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
18900 + int end = hist->counter;
18901 + int start = end - VXH_SIZE + 2;
18902 + int idx = *index;
18904 + /* special case: get current pos */
18910 + /* have we lost some data? */
18914 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
18915 + struct _vx_hist_entry *entry =
18916 + &hist->entry[idx % VXH_SIZE];
18918 + /* send entry to userspace */
18919 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
18923 + /* save new index and count */
18926 + return ret ? ret : (*index < end);
18929 +int vc_read_history(uint32_t id, void __user *data)
18931 + struct vcmd_read_history_v0 vc_data;
18934 + if (id >= NR_CPUS)
18937 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18940 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
18941 + id, &vc_data.index, &vc_data.count);
18943 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18948 +#ifdef CONFIG_COMPAT
18950 +int vc_read_history_x32(uint32_t id, void __user *data)
18952 + struct vcmd_read_history_v0_x32 vc_data;
18955 + if (id >= NR_CPUS)
18958 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18961 + ret = do_read_history((struct __user _vx_hist_entry *)
18962 + compat_ptr(vc_data.data_ptr),
18963 + id, &vc_data.index, &vc_data.count);
18965 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18970 +#endif /* CONFIG_COMPAT */
18972 diff -NurpP --minimal linux-3.6.10/kernel/vserver/inet.c linux-3.6.10-vs2.3.4.5/kernel/vserver/inet.c
18973 --- linux-3.6.10/kernel/vserver/inet.c 1970-01-01 01:00:00.000000000 +0100
18974 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/inet.c 2012-10-04 18:47:00.000000000 +0200
18977 +#include <linux/in.h>
18978 +#include <linux/inetdevice.h>
18979 +#include <linux/export.h>
18980 +#include <linux/vs_inet.h>
18981 +#include <linux/vs_inet6.h>
18982 +#include <linux/vserver/debug.h>
18983 +#include <net/route.h>
18984 +#include <net/addrconf.h>
18987 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
18991 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
18994 + struct nx_addr_v4 *ptr;
18996 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
18997 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19004 + vxdprintk(VXD_CBIT(net, 2),
19005 + "nx_v4_addr_conflict(%p,%p): %d",
19006 + nxi1, nxi2, ret);
19012 +#ifdef CONFIG_IPV6
19014 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19018 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19021 + struct nx_addr_v6 *ptr;
19023 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
19024 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19031 + vxdprintk(VXD_CBIT(net, 2),
19032 + "nx_v6_addr_conflict(%p,%p): %d",
19033 + nxi1, nxi2, ret);
19040 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19042 + struct in_device *in_dev;
19043 + struct in_ifaddr **ifap;
19044 + struct in_ifaddr *ifa;
19049 + in_dev = in_dev_get(dev);
19053 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
19054 + ifap = &ifa->ifa_next) {
19055 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
19060 + in_dev_put(in_dev);
19066 +#ifdef CONFIG_IPV6
19068 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19070 + struct inet6_dev *in_dev;
19071 + struct inet6_ifaddr *ifa;
19076 + in_dev = in6_dev_get(dev);
19080 + // for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
19081 + list_for_each_entry(ifa, &in_dev->addr_list, if_list) {
19082 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
19087 + in6_dev_put(in_dev);
19094 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19100 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
19102 +#ifdef CONFIG_IPV6
19104 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
19109 + vxdprintk(VXD_CBIT(net, 3),
19110 + "dev_in_nx_info(%p,%p[#%d]) = %d",
19111 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
19115 +struct rtable *ip_v4_find_src(struct net *net, struct nx_info *nxi,
19116 + struct flowi4 *fl4)
19118 + struct rtable *rt;
19123 + /* FIXME: handle lback only case */
19124 + if (!NX_IPV4(nxi))
19125 + return ERR_PTR(-EPERM);
19127 + vxdprintk(VXD_CBIT(net, 4),
19128 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
19129 + nxi, nxi ? nxi->nx_id : 0,
19130 + NIPQUAD(fl4->saddr), NIPQUAD(fl4->daddr));
19132 + /* single IP is unconditional */
19133 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
19134 + (fl4->saddr == INADDR_ANY))
19135 + fl4->saddr = nxi->v4.ip[0].s_addr;
19137 + if (fl4->saddr == INADDR_ANY) {
19138 + struct nx_addr_v4 *ptr;
19139 + __be32 found = 0;
19141 + rt = __ip_route_output_key(net, fl4);
19142 + if (!IS_ERR(rt)) {
19143 + found = fl4->saddr;
19145 + vxdprintk(VXD_CBIT(net, 4),
19146 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19147 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(found));
19148 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
19152 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
19153 + __be32 primary = ptr->ip[0].s_addr;
19154 + __be32 mask = ptr->mask.s_addr;
19155 + __be32 neta = primary & mask;
19157 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
19158 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
19159 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
19160 + NIPQUAD(mask), NIPQUAD(neta));
19161 + if ((found & mask) != neta)
19164 + fl4->saddr = primary;
19165 + rt = __ip_route_output_key(net, fl4);
19166 + vxdprintk(VXD_CBIT(net, 4),
19167 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19168 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(primary));
19169 + if (!IS_ERR(rt)) {
19170 + found = fl4->saddr;
19172 + if (found == primary)
19176 + /* still no source ip? */
19177 + found = ipv4_is_loopback(fl4->daddr)
19178 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
19180 + /* assign src ip to flow */
19181 + fl4->saddr = found;
19184 + if (!v4_addr_in_nx_info(nxi, fl4->saddr, NXA_MASK_BIND))
19185 + return ERR_PTR(-EPERM);
19188 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
19189 + if (ipv4_is_loopback(fl4->daddr))
19190 + fl4->daddr = nxi->v4_lback.s_addr;
19191 + if (ipv4_is_loopback(fl4->saddr))
19192 + fl4->saddr = nxi->v4_lback.s_addr;
19193 + } else if (ipv4_is_loopback(fl4->daddr) &&
19194 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
19195 + return ERR_PTR(-EPERM);
19200 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
19202 diff -NurpP --minimal linux-3.6.10/kernel/vserver/init.c linux-3.6.10-vs2.3.4.5/kernel/vserver/init.c
19203 --- linux-3.6.10/kernel/vserver/init.c 1970-01-01 01:00:00.000000000 +0100
19204 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/init.c 2012-10-04 18:47:00.000000000 +0200
19207 + * linux/kernel/init.c
19209 + * Virtual Server Init
19211 + * Copyright (C) 2004-2007 Herbert Pötzl
19213 + * V0.01 basic structure
19217 +#include <linux/init.h>
19219 +int vserver_register_sysctl(void);
19220 +void vserver_unregister_sysctl(void);
19223 +static int __init init_vserver(void)
19227 +#ifdef CONFIG_VSERVER_DEBUG
19228 + vserver_register_sysctl();
19234 +static void __exit exit_vserver(void)
19237 +#ifdef CONFIG_VSERVER_DEBUG
19238 + vserver_unregister_sysctl();
19243 +/* FIXME: GFP_ZONETYPES gone
19244 +long vx_slab[GFP_ZONETYPES]; */
19248 +module_init(init_vserver);
19249 +module_exit(exit_vserver);
19251 diff -NurpP --minimal linux-3.6.10/kernel/vserver/inode.c linux-3.6.10-vs2.3.4.5/kernel/vserver/inode.c
19252 --- linux-3.6.10/kernel/vserver/inode.c 1970-01-01 01:00:00.000000000 +0100
19253 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/inode.c 2012-10-04 18:47:00.000000000 +0200
19256 + * linux/kernel/vserver/inode.c
19258 + * Virtual Server: File System Support
19260 + * Copyright (C) 2004-2007 Herbert Pötzl
19262 + * V0.01 separated from vcontext V0.05
19263 + * V0.02 moved to tag (instead of xid)
19267 +#include <linux/tty.h>
19268 +#include <linux/proc_fs.h>
19269 +#include <linux/devpts_fs.h>
19270 +#include <linux/fs.h>
19271 +#include <linux/file.h>
19272 +#include <linux/mount.h>
19273 +#include <linux/parser.h>
19274 +#include <linux/namei.h>
19275 +#include <linux/vserver/inode.h>
19276 +#include <linux/vserver/inode_cmd.h>
19277 +#include <linux/vs_base.h>
19278 +#include <linux/vs_tag.h>
19280 +#include <asm/uaccess.h>
19283 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19285 + struct proc_dir_entry *entry;
19287 + if (!in || !in->i_sb)
19290 + *flags = IATTR_TAG
19291 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
19292 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
19293 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
19294 + | (IS_COW(in) ? IATTR_COW : 0);
19295 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
19297 + if (S_ISDIR(in->i_mode))
19298 + *mask |= IATTR_BARRIER;
19300 + if (IS_TAGGED(in)) {
19301 + *tag = in->i_tag;
19302 + *mask |= IATTR_TAG;
19305 + switch (in->i_sb->s_magic) {
19306 + case PROC_SUPER_MAGIC:
19307 + entry = PROC_I(in)->pde;
19309 + /* check for specific inodes? */
19311 + *mask |= IATTR_FLAGS;
19313 + *flags |= (entry->vx_flags & IATTR_FLAGS);
19315 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
19318 + case DEVPTS_SUPER_MAGIC:
19319 + *tag = in->i_tag;
19320 + *mask |= IATTR_TAG;
19329 +int vc_get_iattr(void __user *data)
19331 + struct path path;
19332 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
19335 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19338 + ret = user_lpath(vc_data.name, &path);
19340 + ret = __vc_get_iattr(path.dentry->d_inode,
19341 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19347 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19352 +#ifdef CONFIG_COMPAT
19354 +int vc_get_iattr_x32(void __user *data)
19356 + struct path path;
19357 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
19360 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19363 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19365 + ret = __vc_get_iattr(path.dentry->d_inode,
19366 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19372 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19377 +#endif /* CONFIG_COMPAT */
19380 +int vc_fget_iattr(uint32_t fd, void __user *data)
19382 + struct file *filp;
19383 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
19386 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19390 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19393 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
19394 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19398 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19404 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19406 + struct inode *in = de->d_inode;
19407 + int error = 0, is_proc = 0, has_tag = 0;
19408 + struct iattr attr = { 0 };
19410 + if (!in || !in->i_sb)
19413 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
19414 + if ((*mask & IATTR_FLAGS) && !is_proc)
19417 + has_tag = IS_TAGGED(in) ||
19418 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
19419 + if ((*mask & IATTR_TAG) && !has_tag)
19422 + mutex_lock(&in->i_mutex);
19423 + if (*mask & IATTR_TAG) {
19424 + attr.ia_tag = *tag;
19425 + attr.ia_valid |= ATTR_TAG;
19428 + if (*mask & IATTR_FLAGS) {
19429 + struct proc_dir_entry *entry = PROC_I(in)->pde;
19430 + unsigned int iflags = PROC_I(in)->vx_flags;
19432 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
19433 + | (*flags & IATTR_FLAGS);
19434 + PROC_I(in)->vx_flags = iflags;
19436 + entry->vx_flags = iflags;
19439 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
19440 + IATTR_BARRIER | IATTR_COW)) {
19441 + int iflags = in->i_flags;
19442 + int vflags = in->i_vflags;
19444 + if (*mask & IATTR_IMMUTABLE) {
19445 + if (*flags & IATTR_IMMUTABLE)
19446 + iflags |= S_IMMUTABLE;
19448 + iflags &= ~S_IMMUTABLE;
19450 + if (*mask & IATTR_IXUNLINK) {
19451 + if (*flags & IATTR_IXUNLINK)
19452 + iflags |= S_IXUNLINK;
19454 + iflags &= ~S_IXUNLINK;
19456 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
19457 + if (*flags & IATTR_BARRIER)
19458 + vflags |= V_BARRIER;
19460 + vflags &= ~V_BARRIER;
19462 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
19463 + if (*flags & IATTR_COW)
19466 + vflags &= ~V_COW;
19468 + if (in->i_op && in->i_op->sync_flags) {
19469 + error = in->i_op->sync_flags(in, iflags, vflags);
19475 + if (attr.ia_valid) {
19476 + if (in->i_op && in->i_op->setattr)
19477 + error = in->i_op->setattr(de, &attr);
19479 + error = inode_change_ok(in, &attr);
19481 + setattr_copy(in, &attr);
19482 + mark_inode_dirty(in);
19488 + mutex_unlock(&in->i_mutex);
19492 +int vc_set_iattr(void __user *data)
19494 + struct path path;
19495 + struct vcmd_ctx_iattr_v1 vc_data;
19498 + if (!capable(CAP_LINUX_IMMUTABLE))
19500 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19503 + ret = user_lpath(vc_data.name, &path);
19505 + ret = __vc_set_iattr(path.dentry,
19506 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19510 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19515 +#ifdef CONFIG_COMPAT
19517 +int vc_set_iattr_x32(void __user *data)
19519 + struct path path;
19520 + struct vcmd_ctx_iattr_v1_x32 vc_data;
19523 + if (!capable(CAP_LINUX_IMMUTABLE))
19525 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19528 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19530 + ret = __vc_set_iattr(path.dentry,
19531 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19535 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19540 +#endif /* CONFIG_COMPAT */
19542 +int vc_fset_iattr(uint32_t fd, void __user *data)
19544 + struct file *filp;
19545 + struct vcmd_ctx_fiattr_v0 vc_data;
19548 + if (!capable(CAP_LINUX_IMMUTABLE))
19550 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19554 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19557 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
19558 + &vc_data.flags, &vc_data.mask);
19562 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19568 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
19570 +static match_table_t tokens = {
19571 + {Opt_notagcheck, "notagcheck"},
19572 +#ifdef CONFIG_PROPAGATE
19573 + {Opt_notag, "notag"},
19574 + {Opt_tag, "tag"},
19575 + {Opt_tagid, "tagid=%u"},
19581 +static void __dx_parse_remove(char *string, char *opt)
19583 + char *p = strstr(string, opt);
19587 + while (*q != '\0' && *q != ',')
19596 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
19597 + unsigned long *flags)
19600 + substring_t args[MAX_OPT_ARGS];
19602 + char *s, *p, *opts;
19603 +#if defined(CONFIG_PROPAGATE) || defined(CONFIG_VSERVER_DEBUG)
19609 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
19614 + while ((p = strsep(&opts, ",")) != NULL) {
19615 + token = match_token(p, tokens, args);
19618 +#ifdef CONFIG_PROPAGATE
19623 + __dx_parse_remove(s, "tag");
19624 + *mnt_flags |= MNT_TAGID;
19625 + set |= MNT_TAGID;
19629 + __dx_parse_remove(s, "notag");
19630 + *mnt_flags |= MNT_NOTAG;
19631 + set |= MNT_NOTAG;
19634 + if (tag && !match_int(args, &option))
19637 + __dx_parse_remove(s, "tagid");
19638 + *mnt_flags |= MNT_TAGID;
19639 + set |= MNT_TAGID;
19641 +#endif /* CONFIG_PROPAGATE */
19642 + case Opt_notagcheck:
19644 + __dx_parse_remove(s, "notagcheck");
19645 + *flags |= MS_NOTAGCHECK;
19646 + set |= MS_NOTAGCHECK;
19649 + vxdprintk(VXD_CBIT(tag, 7),
19650 + "dx_parse_tag(" VS_Q("%s") "): %d:#%d",
19651 + p, token, option);
19654 + strcpy(string, s);
19659 +#ifdef CONFIG_PROPAGATE
19661 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
19663 + tag_t new_tag = 0;
19664 + struct vfsmount *mnt;
19669 + mnt = nd->path.mnt;
19673 + propagate = (mnt->mnt_flags & MNT_TAGID);
19675 + new_tag = mnt->mnt_tag;
19677 + vxdprintk(VXD_CBIT(tag, 7),
19678 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
19679 + inode, inode->i_ino, inode->i_tag,
19680 + new_tag, (propagate) ? 1 : 0);
19683 + inode->i_tag = new_tag;
19686 +#include <linux/module.h>
19688 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
19690 +#endif /* CONFIG_PROPAGATE */
19692 diff -NurpP --minimal linux-3.6.10/kernel/vserver/limit.c linux-3.6.10-vs2.3.4.5/kernel/vserver/limit.c
19693 --- linux-3.6.10/kernel/vserver/limit.c 1970-01-01 01:00:00.000000000 +0100
19694 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/limit.c 2012-10-04 18:47:00.000000000 +0200
19697 + * linux/kernel/vserver/limit.c
19699 + * Virtual Server: Context Limits
19701 + * Copyright (C) 2004-2010 Herbert Pötzl
19703 + * V0.01 broken out from vcontext V0.05
19704 + * V0.02 changed vcmds to vxi arg
19705 + * V0.03 added memory cgroup support
19709 +#include <linux/sched.h>
19710 +#include <linux/module.h>
19711 +#include <linux/memcontrol.h>
19712 +#include <linux/res_counter.h>
19713 +#include <linux/vs_limit.h>
19714 +#include <linux/vserver/limit.h>
19715 +#include <linux/vserver/limit_cmd.h>
19717 +#include <asm/uaccess.h>
19720 +const char *vlimit_name[NUM_LIMITS] = {
19721 + [RLIMIT_CPU] = "CPU",
19722 + [RLIMIT_NPROC] = "NPROC",
19723 + [RLIMIT_NOFILE] = "NOFILE",
19724 + [RLIMIT_LOCKS] = "LOCKS",
19725 + [RLIMIT_SIGPENDING] = "SIGP",
19726 + [RLIMIT_MSGQUEUE] = "MSGQ",
19728 + [VLIMIT_NSOCK] = "NSOCK",
19729 + [VLIMIT_OPENFD] = "OPENFD",
19730 + [VLIMIT_SHMEM] = "SHMEM",
19731 + [VLIMIT_DENTRY] = "DENTRY",
19734 +EXPORT_SYMBOL_GPL(vlimit_name);
19736 +#define MASK_ENTRY(x) (1 << (x))
19738 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
19741 + , /* softlimit */
19744 + MASK_ENTRY( RLIMIT_NPROC ) |
19745 + MASK_ENTRY( RLIMIT_NOFILE ) |
19746 + MASK_ENTRY( RLIMIT_LOCKS ) |
19747 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
19749 + MASK_ENTRY( VLIMIT_NSOCK ) |
19750 + MASK_ENTRY( VLIMIT_OPENFD ) |
19751 + MASK_ENTRY( VLIMIT_SHMEM ) |
19752 + MASK_ENTRY( VLIMIT_DENTRY ) |
19755 + /* accounting only */
19756 +uint32_t account_mask =
19757 + MASK_ENTRY( VLIMIT_SEMARY ) |
19758 + MASK_ENTRY( VLIMIT_NSEMS ) |
19759 + MASK_ENTRY( VLIMIT_MAPPED ) |
19763 +static int is_valid_vlimit(int id)
19765 + uint32_t mask = vlimit_mask.minimum |
19766 + vlimit_mask.softlimit | vlimit_mask.maximum;
19767 + return mask & (1 << id);
19770 +static int is_accounted_vlimit(int id)
19772 + if (is_valid_vlimit(id))
19774 + return account_mask & (1 << id);
19778 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
19780 + rlim_t limit = __rlim_soft(&vxi->limit, id);
19781 + return VX_VLIM(limit);
19784 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
19786 + rlim_t limit = __rlim_hard(&vxi->limit, id);
19787 + return VX_VLIM(limit);
19790 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
19791 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
19793 + if (!is_valid_vlimit(id))
19797 + *minimum = CRLIM_UNSET;
19799 + *softlimit = vc_get_soft(vxi, id);
19801 + *maximum = vc_get_hard(vxi, id);
19805 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
19807 + struct vcmd_ctx_rlimit_v0 vc_data;
19810 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19813 + ret = do_get_rlimit(vxi, vc_data.id,
19814 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
19818 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19823 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
19824 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
19826 + if (!is_valid_vlimit(id))
19829 + if (maximum != CRLIM_KEEP)
19830 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
19831 + if (softlimit != CRLIM_KEEP)
19832 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
19834 + /* clamp soft limit */
19835 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
19836 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
19841 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
19843 + struct vcmd_ctx_rlimit_v0 vc_data;
19845 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19848 + return do_set_rlimit(vxi, vc_data.id,
19849 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
19852 +#ifdef CONFIG_IA32_EMULATION
19854 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
19856 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
19858 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19861 + return do_set_rlimit(vxi, vc_data.id,
19862 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
19865 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
19867 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
19870 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19873 + ret = do_get_rlimit(vxi, vc_data.id,
19874 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
19878 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19883 +#endif /* CONFIG_IA32_EMULATION */
19886 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
19888 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
19894 +static inline void vx_reset_hits(struct _vx_limit *limit)
19898 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19899 + atomic_set(&__rlim_lhit(limit, lim), 0);
19903 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
19905 + vx_reset_hits(&vxi->limit);
19909 +static inline void vx_reset_minmax(struct _vx_limit *limit)
19914 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19915 + value = __rlim_get(limit, lim);
19916 + __rlim_rmax(limit, lim) = value;
19917 + __rlim_rmin(limit, lim) = value;
19921 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
19923 + vx_reset_minmax(&vxi->limit);
19928 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
19930 + struct vcmd_rlimit_stat_v0 vc_data;
19931 + struct _vx_limit *limit = &vxi->limit;
19934 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19938 + if (!is_accounted_vlimit(id))
19941 + vx_limit_fixup(limit, id);
19942 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
19943 + vc_data.value = __rlim_get(limit, id);
19944 + vc_data.minimum = __rlim_rmin(limit, id);
19945 + vc_data.maximum = __rlim_rmax(limit, id);
19947 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19953 +void vx_vsi_meminfo(struct sysinfo *val)
19955 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
19956 + struct mem_cgroup *mcg;
19957 + u64 res_limit, res_usage;
19960 + mcg = mem_cgroup_from_task(current);
19961 + rcu_read_unlock();
19965 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
19966 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
19968 + if (res_limit != RESOURCE_MAX)
19969 + val->totalram = (res_limit >> PAGE_SHIFT);
19970 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
19971 + val->bufferram = 0;
19972 + val->totalhigh = 0;
19973 + val->freehigh = 0;
19975 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
19979 +void vx_vsi_swapinfo(struct sysinfo *val)
19981 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
19982 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
19983 + struct mem_cgroup *mcg;
19984 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
19985 + s64 swap_limit, swap_usage;
19988 + mcg = mem_cgroup_from_task(current);
19989 + rcu_read_unlock();
19993 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
19994 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
19995 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
19996 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
19998 + /* memory unlimited */
19999 + if (res_limit == RESOURCE_MAX)
20002 + swap_limit = memsw_limit - res_limit;
20003 + /* we have a swap limit? */
20004 + if (memsw_limit != RESOURCE_MAX)
20005 + val->totalswap = swap_limit >> PAGE_SHIFT;
20007 + /* calculate swap part */
20008 + swap_usage = (memsw_usage > res_usage) ?
20009 + memsw_usage - res_usage : 0;
20011 + /* total shown minus usage gives free swap */
20012 + val->freeswap = (swap_usage < swap_limit) ?
20013 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
20015 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20016 + val->totalswap = 0;
20017 + val->freeswap = 0;
20018 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20019 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20023 +long vx_vsi_cached(struct sysinfo *val)
20026 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20027 + struct mem_cgroup *mcg;
20030 + mcg = mem_cgroup_from_task(current);
20031 + rcu_read_unlock();
20035 + cache = mem_cgroup_stat_read_cache(mcg);
20041 diff -NurpP --minimal linux-3.6.10/kernel/vserver/limit_init.h linux-3.6.10-vs2.3.4.5/kernel/vserver/limit_init.h
20042 --- linux-3.6.10/kernel/vserver/limit_init.h 1970-01-01 01:00:00.000000000 +0100
20043 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/limit_init.h 2012-10-04 18:47:00.000000000 +0200
20047 +static inline void vx_info_init_limit(struct _vx_limit *limit)
20051 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20052 + __rlim_soft(limit, lim) = RLIM_INFINITY;
20053 + __rlim_hard(limit, lim) = RLIM_INFINITY;
20054 + __rlim_set(limit, lim, 0);
20055 + atomic_set(&__rlim_lhit(limit, lim), 0);
20056 + __rlim_rmin(limit, lim) = 0;
20057 + __rlim_rmax(limit, lim) = 0;
20061 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
20066 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20067 + if ((1 << lim) & VLIM_NOCHECK)
20069 + value = __rlim_get(limit, lim);
20070 + vxwprintk_xid(value,
20071 + "!!! limit: %p[%s,%d] = %ld on exit.",
20072 + limit, vlimit_name[lim], lim, (long)value);
20076 diff -NurpP --minimal linux-3.6.10/kernel/vserver/limit_proc.h linux-3.6.10-vs2.3.4.5/kernel/vserver/limit_proc.h
20077 --- linux-3.6.10/kernel/vserver/limit_proc.h 1970-01-01 01:00:00.000000000 +0100
20078 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/limit_proc.h 2012-10-04 18:47:00.000000000 +0200
20080 +#ifndef _VX_LIMIT_PROC_H
20081 +#define _VX_LIMIT_PROC_H
20083 +#include <linux/vserver/limit_int.h>
20086 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
20087 +#define VX_LIMIT_TOP \
20088 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
20090 +#define VX_LIMIT_ARG(r) \
20091 + (unsigned long)__rlim_get(limit, r), \
20092 + (unsigned long)__rlim_rmin(limit, r), \
20093 + (unsigned long)__rlim_rmax(limit, r), \
20094 + VX_VLIM(__rlim_soft(limit, r)), \
20095 + VX_VLIM(__rlim_hard(limit, r)), \
20096 + atomic_read(&__rlim_lhit(limit, r))
20098 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
20100 + vx_limit_fixup(limit, -1);
20101 + return sprintf(buffer, VX_LIMIT_TOP
20102 + "PROC" VX_LIMIT_FMT
20103 + "VM" VX_LIMIT_FMT
20104 + "VML" VX_LIMIT_FMT
20105 + "RSS" VX_LIMIT_FMT
20106 + "ANON" VX_LIMIT_FMT
20107 + "RMAP" VX_LIMIT_FMT
20108 + "FILES" VX_LIMIT_FMT
20109 + "OFD" VX_LIMIT_FMT
20110 + "LOCKS" VX_LIMIT_FMT
20111 + "SOCK" VX_LIMIT_FMT
20112 + "MSGQ" VX_LIMIT_FMT
20113 + "SHM" VX_LIMIT_FMT
20114 + "SEMA" VX_LIMIT_FMT
20115 + "SEMS" VX_LIMIT_FMT
20116 + "DENT" VX_LIMIT_FMT,
20117 + VX_LIMIT_ARG(RLIMIT_NPROC),
20118 + VX_LIMIT_ARG(RLIMIT_AS),
20119 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
20120 + VX_LIMIT_ARG(RLIMIT_RSS),
20121 + VX_LIMIT_ARG(VLIMIT_ANON),
20122 + VX_LIMIT_ARG(VLIMIT_MAPPED),
20123 + VX_LIMIT_ARG(RLIMIT_NOFILE),
20124 + VX_LIMIT_ARG(VLIMIT_OPENFD),
20125 + VX_LIMIT_ARG(RLIMIT_LOCKS),
20126 + VX_LIMIT_ARG(VLIMIT_NSOCK),
20127 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
20128 + VX_LIMIT_ARG(VLIMIT_SHMEM),
20129 + VX_LIMIT_ARG(VLIMIT_SEMARY),
20130 + VX_LIMIT_ARG(VLIMIT_NSEMS),
20131 + VX_LIMIT_ARG(VLIMIT_DENTRY));
20134 +#endif /* _VX_LIMIT_PROC_H */
20137 diff -NurpP --minimal linux-3.6.10/kernel/vserver/network.c linux-3.6.10-vs2.3.4.5/kernel/vserver/network.c
20138 --- linux-3.6.10/kernel/vserver/network.c 1970-01-01 01:00:00.000000000 +0100
20139 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/network.c 2012-10-04 18:47:00.000000000 +0200
20142 + * linux/kernel/vserver/network.c
20144 + * Virtual Server: Network Support
20146 + * Copyright (C) 2003-2007 Herbert Pötzl
20148 + * V0.01 broken out from vcontext V0.05
20149 + * V0.02 cleaned up implementation
20150 + * V0.03 added equiv nx commands
20151 + * V0.04 switch to RCU based hash
20152 + * V0.05 and back to locking again
20153 + * V0.06 changed vcmds to nxi arg
20154 + * V0.07 have __create claim() the nxi
20158 +#include <linux/err.h>
20159 +#include <linux/slab.h>
20160 +#include <linux/rcupdate.h>
20162 +#include <linux/vs_network.h>
20163 +#include <linux/vs_pid.h>
20164 +#include <linux/vserver/network_cmd.h>
20167 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
20168 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
20170 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
20171 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
20174 +static int __init init_network(void)
20176 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
20177 + sizeof(struct nx_addr_v4), 0,
20178 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20179 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
20180 + sizeof(struct nx_addr_v6), 0,
20181 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20186 +/* __alloc_nx_addr_v4() */
20188 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
20190 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
20191 + nx_addr_v4_cachep, GFP_KERNEL);
20193 + if (!IS_ERR(nxa))
20194 + memset(nxa, 0, sizeof(*nxa));
20198 +/* __dealloc_nx_addr_v4() */
20200 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
20202 + kmem_cache_free(nx_addr_v4_cachep, nxa);
20205 +/* __dealloc_nx_addr_v4_all() */
20207 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
20210 + struct nx_addr_v4 *next = nxa->next;
20212 + __dealloc_nx_addr_v4(nxa);
20218 +#ifdef CONFIG_IPV6
20220 +/* __alloc_nx_addr_v6() */
20222 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
20224 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
20225 + nx_addr_v6_cachep, GFP_KERNEL);
20227 + if (!IS_ERR(nxa))
20228 + memset(nxa, 0, sizeof(*nxa));
20232 +/* __dealloc_nx_addr_v6() */
20234 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
20236 + kmem_cache_free(nx_addr_v6_cachep, nxa);
20239 +/* __dealloc_nx_addr_v6_all() */
20241 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
20244 + struct nx_addr_v6 *next = nxa->next;
20246 + __dealloc_nx_addr_v6(nxa);
20251 +#endif /* CONFIG_IPV6 */
20253 +/* __alloc_nx_info()
20255 + * allocate an initialized nx_info struct
20256 + * doesn't make it visible (hash) */
20258 +static struct nx_info *__alloc_nx_info(nid_t nid)
20260 + struct nx_info *new = NULL;
20262 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
20264 + /* would this benefit from a slab cache? */
20265 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
20269 + memset(new, 0, sizeof(struct nx_info));
20270 + new->nx_id = nid;
20271 + INIT_HLIST_NODE(&new->nx_hlist);
20272 + atomic_set(&new->nx_usecnt, 0);
20273 + atomic_set(&new->nx_tasks, 0);
20274 + new->nx_state = 0;
20276 + new->nx_flags = NXF_INIT_SET;
20278 + /* rest of init goes here */
20280 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
20281 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
20283 + vxdprintk(VXD_CBIT(nid, 0),
20284 + "alloc_nx_info(%d) = %p", nid, new);
20285 + atomic_inc(&nx_global_ctotal);
20289 +/* __dealloc_nx_info()
20291 + * final disposal of nx_info */
20293 +static void __dealloc_nx_info(struct nx_info *nxi)
20295 + vxdprintk(VXD_CBIT(nid, 0),
20296 + "dealloc_nx_info(%p)", nxi);
20298 + nxi->nx_hlist.next = LIST_POISON1;
20301 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20302 + BUG_ON(atomic_read(&nxi->nx_tasks));
20304 + __dealloc_nx_addr_v4_all(nxi->v4.next);
20306 + nxi->nx_state |= NXS_RELEASED;
20308 + atomic_dec(&nx_global_ctotal);
20311 +static void __shutdown_nx_info(struct nx_info *nxi)
20313 + nxi->nx_state |= NXS_SHUTDOWN;
20314 + vs_net_change(nxi, VSC_NETDOWN);
20317 +/* exported stuff */
20319 +void free_nx_info(struct nx_info *nxi)
20321 + /* context shutdown is mandatory */
20322 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
20324 + /* context must not be hashed */
20325 + BUG_ON(nxi->nx_state & NXS_HASHED);
20327 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20328 + BUG_ON(atomic_read(&nxi->nx_tasks));
20330 + __dealloc_nx_info(nxi);
20334 +void __nx_set_lback(struct nx_info *nxi)
20336 + int nid = nxi->nx_id;
20337 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
20339 + nxi->v4_lback.s_addr = lback;
20342 +extern int __nx_inet_add_lback(__be32 addr);
20343 +extern int __nx_inet_del_lback(__be32 addr);
20346 +/* hash table for nx_info hash */
20348 +#define NX_HASH_SIZE 13
20350 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
20352 +static DEFINE_SPINLOCK(nx_info_hash_lock);
20355 +static inline unsigned int __hashval(nid_t nid)
20357 + return (nid % NX_HASH_SIZE);
20362 +/* __hash_nx_info()
20364 + * add the nxi to the global hash table
20365 + * requires the hash_lock to be held */
20367 +static inline void __hash_nx_info(struct nx_info *nxi)
20369 + struct hlist_head *head;
20371 + vxd_assert_lock(&nx_info_hash_lock);
20372 + vxdprintk(VXD_CBIT(nid, 4),
20373 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
20375 + /* context must not be hashed */
20376 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
20378 + nxi->nx_state |= NXS_HASHED;
20379 + head = &nx_info_hash[__hashval(nxi->nx_id)];
20380 + hlist_add_head(&nxi->nx_hlist, head);
20381 + atomic_inc(&nx_global_cactive);
20384 +/* __unhash_nx_info()
20386 + * remove the nxi from the global hash table
20387 + * requires the hash_lock to be held */
20389 +static inline void __unhash_nx_info(struct nx_info *nxi)
20391 + vxd_assert_lock(&nx_info_hash_lock);
20392 + vxdprintk(VXD_CBIT(nid, 4),
20393 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
20394 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
20396 + /* context must be hashed */
20397 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
20398 + /* but without tasks */
20399 + BUG_ON(atomic_read(&nxi->nx_tasks));
20401 + nxi->nx_state &= ~NXS_HASHED;
20402 + hlist_del(&nxi->nx_hlist);
20403 + atomic_dec(&nx_global_cactive);
20407 +/* __lookup_nx_info()
20409 + * requires the hash_lock to be held
20410 + * doesn't increment the nx_refcnt */
20412 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
20414 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
20415 + struct hlist_node *pos;
20416 + struct nx_info *nxi;
20418 + vxd_assert_lock(&nx_info_hash_lock);
20419 + hlist_for_each(pos, head) {
20420 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20422 + if (nxi->nx_id == nid)
20427 + vxdprintk(VXD_CBIT(nid, 0),
20428 + "__lookup_nx_info(#%u): %p[#%u]",
20429 + nid, nxi, nxi ? nxi->nx_id : 0);
20434 +/* __create_nx_info()
20436 + * create the requested context
20437 + * get(), claim() and hash it */
20439 +static struct nx_info *__create_nx_info(int id)
20441 + struct nx_info *new, *nxi = NULL;
20443 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
20445 + if (!(new = __alloc_nx_info(id)))
20446 + return ERR_PTR(-ENOMEM);
20448 + /* required to make dynamic xids unique */
20449 + spin_lock(&nx_info_hash_lock);
20451 + /* static context requested */
20452 + if ((nxi = __lookup_nx_info(id))) {
20453 + vxdprintk(VXD_CBIT(nid, 0),
20454 + "create_nx_info(%d) = %p (already there)", id, nxi);
20455 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20456 + nxi = ERR_PTR(-EBUSY);
20458 + nxi = ERR_PTR(-EEXIST);
20461 + /* new context */
20462 + vxdprintk(VXD_CBIT(nid, 0),
20463 + "create_nx_info(%d) = %p (new)", id, new);
20464 + claim_nx_info(new, NULL);
20465 + __nx_set_lback(new);
20466 + __hash_nx_info(get_nx_info(new));
20467 + nxi = new, new = NULL;
20470 + spin_unlock(&nx_info_hash_lock);
20472 + __dealloc_nx_info(new);
20478 +/* exported stuff */
20481 +void unhash_nx_info(struct nx_info *nxi)
20483 + __shutdown_nx_info(nxi);
20484 + spin_lock(&nx_info_hash_lock);
20485 + __unhash_nx_info(nxi);
20486 + spin_unlock(&nx_info_hash_lock);
20489 +/* lookup_nx_info()
20491 + * search for a nx_info and get() it
20492 + * negative id means current */
20494 +struct nx_info *lookup_nx_info(int id)
20496 + struct nx_info *nxi = NULL;
20499 + nxi = get_nx_info(current_nx_info());
20500 + } else if (id > 1) {
20501 + spin_lock(&nx_info_hash_lock);
20502 + nxi = get_nx_info(__lookup_nx_info(id));
20503 + spin_unlock(&nx_info_hash_lock);
20508 +/* nid_is_hashed()
20510 + * verify that nid is still hashed */
20512 +int nid_is_hashed(nid_t nid)
20516 + spin_lock(&nx_info_hash_lock);
20517 + hashed = (__lookup_nx_info(nid) != NULL);
20518 + spin_unlock(&nx_info_hash_lock);
20523 +#ifdef CONFIG_PROC_FS
20527 + * get a subset of hashed nids for proc
20528 + * assumes size is at least one */
20530 +int get_nid_list(int index, unsigned int *nids, int size)
20532 + int hindex, nr_nids = 0;
20534 + /* only show current and children */
20535 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
20538 + nids[nr_nids] = nx_current_nid();
20542 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
20543 + struct hlist_head *head = &nx_info_hash[hindex];
20544 + struct hlist_node *pos;
20546 + spin_lock(&nx_info_hash_lock);
20547 + hlist_for_each(pos, head) {
20548 + struct nx_info *nxi;
20553 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20554 + nids[nr_nids] = nxi->nx_id;
20555 + if (++nr_nids >= size) {
20556 + spin_unlock(&nx_info_hash_lock);
20560 + /* keep the lock time short */
20561 + spin_unlock(&nx_info_hash_lock);
20570 + * migrate task to new network
20571 + * gets nxi, puts old_nxi on change
20574 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
20576 + struct nx_info *old_nxi;
20582 + vxdprintk(VXD_CBIT(nid, 5),
20583 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
20584 + p, nxi, nxi->nx_id,
20585 + atomic_read(&nxi->nx_usecnt),
20586 + atomic_read(&nxi->nx_tasks));
20588 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
20589 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20592 + if (nx_info_state(nxi, NXS_SHUTDOWN))
20595 + /* maybe disallow this completely? */
20596 + old_nxi = task_get_nx_info(p);
20597 + if (old_nxi == nxi)
20602 + clr_nx_info(&p->nx_info);
20603 + claim_nx_info(nxi, p);
20604 + set_nx_info(&p->nx_info, nxi);
20605 + p->nid = nxi->nx_id;
20608 + vxdprintk(VXD_CBIT(nid, 5),
20609 + "moved task %p into nxi:%p[#%d]",
20610 + p, nxi, nxi->nx_id);
20613 + release_nx_info(old_nxi, p);
20616 + put_nx_info(old_nxi);
20621 +void nx_set_persistent(struct nx_info *nxi)
20623 + vxdprintk(VXD_CBIT(nid, 6),
20624 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
20626 + get_nx_info(nxi);
20627 + claim_nx_info(nxi, NULL);
20630 +void nx_clear_persistent(struct nx_info *nxi)
20632 + vxdprintk(VXD_CBIT(nid, 6),
20633 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
20635 + release_nx_info(nxi, NULL);
20636 + put_nx_info(nxi);
20639 +void nx_update_persistent(struct nx_info *nxi)
20641 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
20642 + nx_set_persistent(nxi);
20644 + nx_clear_persistent(nxi);
20647 +/* vserver syscall commands below here */
20649 +/* taks nid and nx_info functions */
20651 +#include <asm/uaccess.h>
20654 +int vc_task_nid(uint32_t id)
20659 + struct task_struct *tsk;
20662 + tsk = find_task_by_real_pid(id);
20663 + nid = (tsk) ? tsk->nid : -ESRCH;
20664 + rcu_read_unlock();
20666 + nid = nx_current_nid();
20671 +int vc_nx_info(struct nx_info *nxi, void __user *data)
20673 + struct vcmd_nx_info_v0 vc_data;
20675 + vc_data.nid = nxi->nx_id;
20677 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20683 +/* network functions */
20685 +int vc_net_create(uint32_t nid, void __user *data)
20687 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
20688 + struct nx_info *new_nxi;
20691 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20694 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
20697 + new_nxi = __create_nx_info(nid);
20698 + if (IS_ERR(new_nxi))
20699 + return PTR_ERR(new_nxi);
20701 + /* initial flags */
20702 + new_nxi->nx_flags = vc_data.flagword;
20705 + if (vs_net_change(new_nxi, VSC_NETUP))
20708 + ret = nx_migrate_task(current, new_nxi);
20712 + /* return context id on success */
20713 + ret = new_nxi->nx_id;
20715 + /* get a reference for persistent contexts */
20716 + if ((vc_data.flagword & NXF_PERSISTENT))
20717 + nx_set_persistent(new_nxi);
20719 + release_nx_info(new_nxi, NULL);
20720 + put_nx_info(new_nxi);
20725 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
20727 + return nx_migrate_task(current, nxi);
20732 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
20733 + uint16_t type, uint16_t flags)
20735 + struct nx_addr_v4 *nxa = &nxi->v4;
20737 + if (NX_IPV4(nxi)) {
20738 + /* locate last entry */
20739 + for (; nxa->next; nxa = nxa->next);
20740 + nxa->next = __alloc_nx_addr_v4();
20744 + return PTR_ERR(nxa);
20747 + if (nxi->v4.next)
20748 + /* remove single ip for ip list */
20749 + nxi->nx_flags &= ~NXF_SINGLE_IP;
20751 + nxa->ip[0].s_addr = ip;
20752 + nxa->ip[1].s_addr = ip2;
20753 + nxa->mask.s_addr = mask;
20754 + nxa->type = type;
20755 + nxa->flags = flags;
20759 +int do_remove_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
20760 + uint16_t type, uint16_t flags)
20762 + struct nx_addr_v4 *nxa = &nxi->v4;
20765 +/* case NXA_TYPE_ADDR:
20768 + case NXA_TYPE_ANY:
20769 + __dealloc_nx_addr_v4_all(xchg(&nxa->next, NULL));
20770 + memset(nxa, 0, sizeof(*nxa));
20780 +int vc_net_add(struct nx_info *nxi, void __user *data)
20782 + struct vcmd_net_addr_v0 vc_data;
20783 + int index, ret = 0;
20785 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20788 + switch (vc_data.type) {
20789 + case NXA_TYPE_IPV4:
20790 + if ((vc_data.count < 1) || (vc_data.count > 4))
20794 + while (index < vc_data.count) {
20795 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
20796 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
20804 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
20805 + nxi->v4_bcast = vc_data.ip[0];
20809 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
20810 + nxi->v4_lback = vc_data.ip[0];
20821 +int vc_net_remove(struct nx_info *nxi, void __user *data)
20823 + struct vcmd_net_addr_v0 vc_data;
20825 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20828 + switch (vc_data.type) {
20829 + case NXA_TYPE_ANY:
20830 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
20831 + memset(&nxi->v4, 0, sizeof(nxi->v4));
20841 +int vc_net_add_ipv4_v1(struct nx_info *nxi, void __user *data)
20843 + struct vcmd_net_addr_ipv4_v1 vc_data;
20845 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20848 + switch (vc_data.type) {
20849 + case NXA_TYPE_ADDR:
20850 + case NXA_TYPE_MASK:
20851 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
20852 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20854 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
20855 + nxi->v4_bcast = vc_data.ip;
20858 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
20859 + nxi->v4_lback = vc_data.ip;
20868 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
20870 + struct vcmd_net_addr_ipv4_v2 vc_data;
20872 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20875 + switch (vc_data.type) {
20876 + case NXA_TYPE_ADDR:
20877 + case NXA_TYPE_MASK:
20878 + case NXA_TYPE_RANGE:
20879 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
20880 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20882 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
20883 + nxi->v4_bcast = vc_data.ip;
20886 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
20887 + nxi->v4_lback = vc_data.ip;
20896 +int vc_net_rem_ipv4_v1(struct nx_info *nxi, void __user *data)
20898 + struct vcmd_net_addr_ipv4_v1 vc_data;
20900 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20903 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, 0,
20904 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20907 +int vc_net_rem_ipv4(struct nx_info *nxi, void __user *data)
20909 + struct vcmd_net_addr_ipv4_v2 vc_data;
20911 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20914 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
20915 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20918 +#ifdef CONFIG_IPV6
20920 +int do_add_v6_addr(struct nx_info *nxi,
20921 + struct in6_addr *ip, struct in6_addr *mask,
20922 + uint32_t prefix, uint16_t type, uint16_t flags)
20924 + struct nx_addr_v6 *nxa = &nxi->v6;
20926 + if (NX_IPV6(nxi)) {
20927 + /* locate last entry */
20928 + for (; nxa->next; nxa = nxa->next);
20929 + nxa->next = __alloc_nx_addr_v6();
20933 + return PTR_ERR(nxa);
20937 + nxa->mask = *mask;
20938 + nxa->prefix = prefix;
20939 + nxa->type = type;
20940 + nxa->flags = flags;
20945 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
20947 + struct vcmd_net_addr_ipv6_v1 vc_data;
20949 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20952 + switch (vc_data.type) {
20953 + case NXA_TYPE_ADDR:
20954 + memset(&vc_data.mask, ~0, sizeof(vc_data.mask));
20955 + /* fallthrough */
20956 + case NXA_TYPE_MASK:
20957 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
20958 + vc_data.prefix, vc_data.type, vc_data.flags);
20965 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
20967 + struct vcmd_net_addr_ipv6_v1 vc_data;
20969 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20972 + switch (vc_data.type) {
20973 + case NXA_TYPE_ANY:
20974 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
20975 + memset(&nxi->v6, 0, sizeof(nxi->v6));
20984 +#endif /* CONFIG_IPV6 */
20987 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
20989 + struct vcmd_net_flags_v0 vc_data;
20991 + vc_data.flagword = nxi->nx_flags;
20993 + /* special STATE flag handling */
20994 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
20996 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21001 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
21003 + struct vcmd_net_flags_v0 vc_data;
21004 + uint64_t mask, trigger;
21006 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21009 + /* special STATE flag handling */
21010 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
21011 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
21013 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
21014 + vc_data.flagword, mask);
21015 + if (trigger & NXF_PERSISTENT)
21016 + nx_update_persistent(nxi);
21021 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
21023 + struct vcmd_net_caps_v0 vc_data;
21025 + vc_data.ncaps = nxi->nx_ncaps;
21026 + vc_data.cmask = ~0ULL;
21028 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21033 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
21035 + struct vcmd_net_caps_v0 vc_data;
21037 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21040 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
21041 + vc_data.ncaps, vc_data.cmask);
21046 +#include <linux/module.h>
21048 +module_init(init_network);
21050 +EXPORT_SYMBOL_GPL(free_nx_info);
21051 +EXPORT_SYMBOL_GPL(unhash_nx_info);
21053 diff -NurpP --minimal linux-3.6.10/kernel/vserver/proc.c linux-3.6.10-vs2.3.4.5/kernel/vserver/proc.c
21054 --- linux-3.6.10/kernel/vserver/proc.c 1970-01-01 01:00:00.000000000 +0100
21055 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/proc.c 2012-10-09 14:19:59.000000000 +0200
21058 + * linux/kernel/vserver/proc.c
21060 + * Virtual Context Support
21062 + * Copyright (C) 2003-2011 Herbert Pötzl
21064 + * V0.01 basic structure
21065 + * V0.02 adaptation vs1.3.0
21066 + * V0.03 proc permissions
21067 + * V0.04 locking/generic
21068 + * V0.05 next generation procfs
21069 + * V0.06 inode validation
21070 + * V0.07 generic rewrite vid
21071 + * V0.08 remove inode type
21072 + * V0.09 added u/wmask info
21076 +#include <linux/proc_fs.h>
21077 +#include <linux/fs_struct.h>
21078 +#include <linux/mount.h>
21079 +#include <linux/namei.h>
21080 +#include <asm/unistd.h>
21082 +#include <linux/vs_context.h>
21083 +#include <linux/vs_network.h>
21084 +#include <linux/vs_cvirt.h>
21086 +#include <linux/in.h>
21087 +#include <linux/inetdevice.h>
21088 +#include <linux/vs_inet.h>
21089 +#include <linux/vs_inet6.h>
21091 +#include <linux/vserver/global.h>
21093 +#include "cvirt_proc.h"
21094 +#include "cacct_proc.h"
21095 +#include "limit_proc.h"
21096 +#include "sched_proc.h"
21097 +#include "vci_config.h"
21100 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
21104 + CAP_FOR_EACH_U32(__capi) {
21105 + buffer += sprintf(buffer, "%08x",
21106 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
21112 +static struct proc_dir_entry *proc_virtual;
21114 +static struct proc_dir_entry *proc_virtnet;
21117 +/* first the actual feeds */
21120 +static int proc_vci(char *buffer)
21122 + return sprintf(buffer,
21123 + "VCIVersion:\t%04x:%04x\n"
21124 + "VCISyscall:\t%d\n"
21125 + "VCIKernel:\t%08x\n",
21126 + VCI_VERSION >> 16,
21127 + VCI_VERSION & 0xFFFF,
21129 + vci_kernel_config());
21132 +static int proc_virtual_info(char *buffer)
21134 + return proc_vci(buffer);
21137 +static int proc_virtual_status(char *buffer)
21139 + return sprintf(buffer,
21141 + "#CActive:\t%d\n"
21142 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
21143 + "#InitTask:\t%d\t%d %d\n",
21144 + atomic_read(&vx_global_ctotal),
21145 + atomic_read(&vx_global_cactive),
21146 + atomic_read(&vs_global_nsproxy),
21147 + atomic_read(&vs_global_fs),
21148 + atomic_read(&vs_global_mnt_ns),
21149 + atomic_read(&vs_global_uts_ns),
21150 + atomic_read(&nr_ipc_ns),
21151 + atomic_read(&vs_global_user_ns),
21152 + atomic_read(&vs_global_pid_ns),
21153 + atomic_read(&init_task.usage),
21154 + atomic_read(&init_task.nsproxy->count),
21155 + init_task.fs->users);
21159 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
21163 + length = sprintf(buffer,
21171 + vxi->vx_badness_bias);
21175 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
21177 + char *orig = buffer;
21179 + buffer += sprintf(buffer,
21182 + "Flags:\t%016llx\n",
21183 + atomic_read(&vxi->vx_usecnt),
21184 + atomic_read(&vxi->vx_tasks),
21185 + (unsigned long long)vxi->vx_flags);
21187 + buffer += sprintf(buffer, "BCaps:\t");
21188 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
21189 + buffer += sprintf(buffer, "\n");
21191 + buffer += sprintf(buffer,
21192 + "CCaps:\t%016llx\n"
21193 + "Umask:\t%16llx\n"
21194 + "Wmask:\t%16llx\n"
21195 + "Spaces:\t%08lx %08lx\n",
21196 + (unsigned long long)vxi->vx_ccaps,
21197 + (unsigned long long)vxi->vx_umask,
21198 + (unsigned long long)vxi->vx_wmask,
21199 + vxi->space[0].vx_nsmask, vxi->space[1].vx_nsmask);
21200 + return buffer - orig;
21203 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
21205 + return vx_info_proc_limit(&vxi->limit, buffer);
21208 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
21212 + length = vx_info_proc_sched(&vxi->sched, buffer);
21213 + for_each_online_cpu(cpu) {
21214 + length += vx_info_proc_sched_pc(
21215 + &vx_per_cpu(vxi, sched_pc, cpu),
21216 + buffer + length, cpu);
21221 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
21223 + return vx_info_proc_nsproxy(vxi->space[0].vx_nsproxy, buffer);
21226 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
21228 + return vx_info_proc_nsproxy(vxi->space[1].vx_nsproxy, buffer);
21231 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
21235 + vx_update_load(vxi);
21236 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
21237 + for_each_online_cpu(cpu) {
21238 + length += vx_info_proc_cvirt_pc(
21239 + &vx_per_cpu(vxi, cvirt_pc, cpu),
21240 + buffer + length, cpu);
21245 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
21247 + return vx_info_proc_cacct(&vxi->cacct, buffer);
21251 +static int proc_virtnet_info(char *buffer)
21253 + return proc_vci(buffer);
21256 +static int proc_virtnet_status(char *buffer)
21258 + return sprintf(buffer,
21260 + "#CActive:\t%d\n",
21261 + atomic_read(&nx_global_ctotal),
21262 + atomic_read(&nx_global_cactive));
21265 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
21267 + struct nx_addr_v4 *v4a;
21268 +#ifdef CONFIG_IPV6
21269 + struct nx_addr_v6 *v6a;
21273 + length = sprintf(buffer,
21276 + "Bcast:\t" NIPQUAD_FMT "\n"
21277 + "Lback:\t" NIPQUAD_FMT "\n",
21280 + NIPQUAD(nxi->v4_bcast.s_addr),
21281 + NIPQUAD(nxi->v4_lback.s_addr));
21283 + if (!NX_IPV4(nxi))
21285 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
21286 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
21289 +#ifdef CONFIG_IPV6
21290 + if (!NX_IPV6(nxi))
21292 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
21293 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
21300 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
21304 + length = sprintf(buffer,
21307 + "Flags:\t%016llx\n"
21308 + "NCaps:\t%016llx\n",
21309 + atomic_read(&nxi->nx_usecnt),
21310 + atomic_read(&nxi->nx_tasks),
21311 + (unsigned long long)nxi->nx_flags,
21312 + (unsigned long long)nxi->nx_ncaps);
21318 +/* here the inode helpers */
21324 + struct inode_operations *iop;
21325 + struct file_operations *fop;
21326 + union proc_op op;
21329 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
21331 + struct inode *inode = new_inode(sb);
21336 + inode->i_mode = p->mode;
21338 + inode->i_op = p->iop;
21340 + inode->i_fop = p->fop;
21342 + set_nlink(inode, (p->mode & S_IFDIR) ? 2 : 1);
21343 + inode->i_flags |= S_IMMUTABLE;
21345 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
21347 + inode->i_uid = 0;
21348 + inode->i_gid = 0;
21349 + inode->i_tag = 0;
21354 +static struct dentry *vs_proc_instantiate(struct inode *dir,
21355 + struct dentry *dentry, int id, void *ptr)
21357 + struct vs_entry *p = ptr;
21358 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
21359 + struct dentry *error = ERR_PTR(-EINVAL);
21364 + PROC_I(inode)->op = p->op;
21365 + PROC_I(inode)->fd = id;
21366 + d_add(dentry, inode);
21374 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
21377 + * Fill a directory entry.
21379 + * If possible create the dcache entry and derive our inode number and
21380 + * file type from dcache entry.
21382 + * Since all of the proc inode numbers are dynamically generated, the inode
21383 + * numbers do not exist until the inode is cache. This means creating the
21384 + * the dcache entry in readdir is necessary to keep the inode numbers
21385 + * reported by readdir in sync with the inode numbers reported
21388 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
21389 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
21391 + struct dentry *child, *dir = filp->f_dentry;
21392 + struct inode *inode;
21393 + struct qstr qname;
21395 + unsigned type = DT_UNKNOWN;
21397 + qname.name = name;
21399 + qname.hash = full_name_hash(name, len);
21401 + child = d_lookup(dir, &qname);
21403 + struct dentry *new;
21404 + new = d_alloc(dir, &qname);
21406 + child = instantiate(dir->d_inode, new, id, ptr);
21413 + if (!child || IS_ERR(child) || !child->d_inode)
21414 + goto end_instantiate;
21415 + inode = child->d_inode;
21417 + ino = inode->i_ino;
21418 + type = inode->i_mode >> 12;
21423 + ino = find_inode_number(dir, &qname);
21426 + return filldir(dirent, name, len, filp->f_pos, ino, type);
21431 +/* get and revalidate vx_info/xid */
21434 +struct vx_info *get_proc_vx_info(struct inode *inode)
21436 + return lookup_vx_info(PROC_I(inode)->fd);
21439 +static int proc_xid_revalidate(struct dentry *dentry, unsigned int flags)
21441 + struct inode *inode = dentry->d_inode;
21442 + xid_t xid = PROC_I(inode)->fd;
21444 + if (flags & LOOKUP_RCU) /* FIXME: can be dropped? */
21447 + if (!xid || xid_is_hashed(xid))
21454 +/* get and revalidate nx_info/nid */
21456 +static int proc_nid_revalidate(struct dentry *dentry, unsigned int flags)
21458 + struct inode *inode = dentry->d_inode;
21459 + nid_t nid = PROC_I(inode)->fd;
21461 + if (flags & LOOKUP_RCU) /* FIXME: can be dropped? */
21464 + if (!nid || nid_is_hashed(nid))
21472 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
21474 +static ssize_t proc_vs_info_read(struct file *file, char __user *buf,
21475 + size_t count, loff_t *ppos)
21477 + struct inode *inode = file->f_dentry->d_inode;
21478 + unsigned long page;
21479 + ssize_t length = 0;
21481 + if (count > PROC_BLOCK_SIZE)
21482 + count = PROC_BLOCK_SIZE;
21484 + /* fade that out as soon as stable */
21485 + WARN_ON(PROC_I(inode)->fd);
21487 + if (!(page = __get_free_page(GFP_KERNEL)))
21490 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
21491 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
21494 + length = simple_read_from_buffer(buf, count, ppos,
21495 + (char *)page, length);
21501 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
21502 + size_t count, loff_t *ppos)
21504 + struct inode *inode = file->f_dentry->d_inode;
21505 + struct vx_info *vxi = NULL;
21506 + xid_t xid = PROC_I(inode)->fd;
21507 + unsigned long page;
21508 + ssize_t length = 0;
21510 + if (count > PROC_BLOCK_SIZE)
21511 + count = PROC_BLOCK_SIZE;
21513 + /* fade that out as soon as stable */
21515 + vxi = lookup_vx_info(xid);
21519 + length = -ENOMEM;
21520 + if (!(page = __get_free_page(GFP_KERNEL)))
21523 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
21524 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
21527 + length = simple_read_from_buffer(buf, count, ppos,
21528 + (char *)page, length);
21532 + put_vx_info(vxi);
21537 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
21538 + size_t count, loff_t *ppos)
21540 + struct inode *inode = file->f_dentry->d_inode;
21541 + struct nx_info *nxi = NULL;
21542 + nid_t nid = PROC_I(inode)->fd;
21543 + unsigned long page;
21544 + ssize_t length = 0;
21546 + if (count > PROC_BLOCK_SIZE)
21547 + count = PROC_BLOCK_SIZE;
21549 + /* fade that out as soon as stable */
21551 + nxi = lookup_nx_info(nid);
21555 + length = -ENOMEM;
21556 + if (!(page = __get_free_page(GFP_KERNEL)))
21559 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
21560 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
21563 + length = simple_read_from_buffer(buf, count, ppos,
21564 + (char *)page, length);
21568 + put_nx_info(nxi);
21575 +/* here comes the lower level */
21578 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
21579 + .len = sizeof(NAME) - 1, \
21580 + .name = (NAME), \
21588 +#define DIR(NAME, MODE, OTYPE) \
21589 + NOD(NAME, (S_IFDIR | (MODE)), \
21590 + &proc_ ## OTYPE ## _inode_operations, \
21591 + &proc_ ## OTYPE ## _file_operations, { } )
21593 +#define INF(NAME, MODE, OTYPE) \
21594 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21595 + &proc_vs_info_file_operations, \
21596 + { .proc_vs_read = &proc_##OTYPE } )
21598 +#define VINF(NAME, MODE, OTYPE) \
21599 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21600 + &proc_vx_info_file_operations, \
21601 + { .proc_vxi_read = &proc_##OTYPE } )
21603 +#define NINF(NAME, MODE, OTYPE) \
21604 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21605 + &proc_nx_info_file_operations, \
21606 + { .proc_nxi_read = &proc_##OTYPE } )
21609 +static struct file_operations proc_vs_info_file_operations = {
21610 + .read = proc_vs_info_read,
21613 +static struct file_operations proc_vx_info_file_operations = {
21614 + .read = proc_vx_info_read,
21617 +static struct dentry_operations proc_xid_dentry_operations = {
21618 + .d_revalidate = proc_xid_revalidate,
21621 +static struct vs_entry vx_base_stuff[] = {
21622 + VINF("info", S_IRUGO, vxi_info),
21623 + VINF("status", S_IRUGO, vxi_status),
21624 + VINF("limit", S_IRUGO, vxi_limit),
21625 + VINF("sched", S_IRUGO, vxi_sched),
21626 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
21627 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
21628 + VINF("cvirt", S_IRUGO, vxi_cvirt),
21629 + VINF("cacct", S_IRUGO, vxi_cacct),
21636 +static struct dentry *proc_xid_instantiate(struct inode *dir,
21637 + struct dentry *dentry, int id, void *ptr)
21639 + dentry->d_op = &proc_xid_dentry_operations;
21640 + return vs_proc_instantiate(dir, dentry, id, ptr);
21643 +static struct dentry *proc_xid_lookup(struct inode *dir,
21644 + struct dentry *dentry, unsigned int flags)
21646 + struct vs_entry *p = vx_base_stuff;
21647 + struct dentry *error = ERR_PTR(-ENOENT);
21649 + for (; p->name; p++) {
21650 + if (p->len != dentry->d_name.len)
21652 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21658 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
21663 +static int proc_xid_readdir(struct file *filp,
21664 + void *dirent, filldir_t filldir)
21666 + struct dentry *dentry = filp->f_dentry;
21667 + struct inode *inode = dentry->d_inode;
21668 + struct vs_entry *p = vx_base_stuff;
21669 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
21673 + pos = filp->f_pos;
21676 + ino = inode->i_ino;
21677 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21680 + /* fall through */
21682 + ino = parent_ino(dentry);
21683 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21686 + /* fall through */
21689 + if (index >= size)
21691 + for (p += index; p->name; p++) {
21692 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21693 + vs_proc_instantiate, PROC_I(inode)->fd, p))
21699 + filp->f_pos = pos;
21705 +static struct file_operations proc_nx_info_file_operations = {
21706 + .read = proc_nx_info_read,
21709 +static struct dentry_operations proc_nid_dentry_operations = {
21710 + .d_revalidate = proc_nid_revalidate,
21713 +static struct vs_entry nx_base_stuff[] = {
21714 + NINF("info", S_IRUGO, nxi_info),
21715 + NINF("status", S_IRUGO, nxi_status),
21720 +static struct dentry *proc_nid_instantiate(struct inode *dir,
21721 + struct dentry *dentry, int id, void *ptr)
21723 + dentry->d_op = &proc_nid_dentry_operations;
21724 + return vs_proc_instantiate(dir, dentry, id, ptr);
21727 +static struct dentry *proc_nid_lookup(struct inode *dir,
21728 + struct dentry *dentry, unsigned int flags)
21730 + struct vs_entry *p = nx_base_stuff;
21731 + struct dentry *error = ERR_PTR(-ENOENT);
21733 + for (; p->name; p++) {
21734 + if (p->len != dentry->d_name.len)
21736 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21742 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
21747 +static int proc_nid_readdir(struct file *filp,
21748 + void *dirent, filldir_t filldir)
21750 + struct dentry *dentry = filp->f_dentry;
21751 + struct inode *inode = dentry->d_inode;
21752 + struct vs_entry *p = nx_base_stuff;
21753 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
21757 + pos = filp->f_pos;
21760 + ino = inode->i_ino;
21761 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21764 + /* fall through */
21766 + ino = parent_ino(dentry);
21767 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21770 + /* fall through */
21773 + if (index >= size)
21775 + for (p += index; p->name; p++) {
21776 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21777 + vs_proc_instantiate, PROC_I(inode)->fd, p))
21783 + filp->f_pos = pos;
21788 +#define MAX_MULBY10 ((~0U - 9) / 10)
21790 +static inline int atovid(const char *str, int len)
21795 + while (len-- > 0) {
21800 + if (vid >= MAX_MULBY10)
21810 +/* now the upper level (virtual) */
21813 +static struct file_operations proc_xid_file_operations = {
21814 + .read = generic_read_dir,
21815 + .readdir = proc_xid_readdir,
21818 +static struct inode_operations proc_xid_inode_operations = {
21819 + .lookup = proc_xid_lookup,
21822 +static struct vs_entry vx_virtual_stuff[] = {
21823 + INF("info", S_IRUGO, virtual_info),
21824 + INF("status", S_IRUGO, virtual_status),
21825 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
21829 +static struct dentry *proc_virtual_lookup(struct inode *dir,
21830 + struct dentry *dentry, unsigned int flags)
21832 + struct vs_entry *p = vx_virtual_stuff;
21833 + struct dentry *error = ERR_PTR(-ENOENT);
21836 + for (; p->name; p++) {
21837 + if (p->len != dentry->d_name.len)
21839 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21843 + goto instantiate;
21845 + id = atovid(dentry->d_name.name, dentry->d_name.len);
21846 + if ((id < 0) || !xid_is_hashed(id))
21850 + error = proc_xid_instantiate(dir, dentry, id, p);
21855 +static struct file_operations proc_nid_file_operations = {
21856 + .read = generic_read_dir,
21857 + .readdir = proc_nid_readdir,
21860 +static struct inode_operations proc_nid_inode_operations = {
21861 + .lookup = proc_nid_lookup,
21864 +static struct vs_entry nx_virtnet_stuff[] = {
21865 + INF("info", S_IRUGO, virtnet_info),
21866 + INF("status", S_IRUGO, virtnet_status),
21867 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
21871 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
21872 + struct dentry *dentry, unsigned int flags)
21874 + struct vs_entry *p = nx_virtnet_stuff;
21875 + struct dentry *error = ERR_PTR(-ENOENT);
21878 + for (; p->name; p++) {
21879 + if (p->len != dentry->d_name.len)
21881 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21885 + goto instantiate;
21887 + id = atovid(dentry->d_name.name, dentry->d_name.len);
21888 + if ((id < 0) || !nid_is_hashed(id))
21892 + error = proc_nid_instantiate(dir, dentry, id, p);
21898 +#define PROC_MAXVIDS 32
21900 +int proc_virtual_readdir(struct file *filp,
21901 + void *dirent, filldir_t filldir)
21903 + struct dentry *dentry = filp->f_dentry;
21904 + struct inode *inode = dentry->d_inode;
21905 + struct vs_entry *p = vx_virtual_stuff;
21906 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
21908 + unsigned int xid_array[PROC_MAXVIDS];
21909 + char buf[PROC_NUMBUF];
21910 + unsigned int nr_xids, i;
21913 + pos = filp->f_pos;
21916 + ino = inode->i_ino;
21917 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21920 + /* fall through */
21922 + ino = parent_ino(dentry);
21923 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21926 + /* fall through */
21929 + if (index >= size)
21931 + for (p += index; p->name; p++) {
21932 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21933 + vs_proc_instantiate, 0, p))
21938 + index = pos - size;
21939 + p = &vx_virtual_stuff[size - 1];
21940 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
21941 + for (i = 0; i < nr_xids; i++) {
21942 + int n, xid = xid_array[i];
21943 + unsigned int j = PROC_NUMBUF;
21947 + buf[--j] = '0' + (n % 10);
21950 + if (proc_fill_cache(filp, dirent, filldir,
21951 + buf + j, PROC_NUMBUF - j,
21952 + vs_proc_instantiate, xid, p))
21958 + filp->f_pos = pos;
21962 +static int proc_virtual_getattr(struct vfsmount *mnt,
21963 + struct dentry *dentry, struct kstat *stat)
21965 + struct inode *inode = dentry->d_inode;
21967 + generic_fillattr(inode, stat);
21968 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
21972 +static struct file_operations proc_virtual_dir_operations = {
21973 + .read = generic_read_dir,
21974 + .readdir = proc_virtual_readdir,
21977 +static struct inode_operations proc_virtual_dir_inode_operations = {
21978 + .getattr = proc_virtual_getattr,
21979 + .lookup = proc_virtual_lookup,
21986 +int proc_virtnet_readdir(struct file *filp,
21987 + void *dirent, filldir_t filldir)
21989 + struct dentry *dentry = filp->f_dentry;
21990 + struct inode *inode = dentry->d_inode;
21991 + struct vs_entry *p = nx_virtnet_stuff;
21992 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
21994 + unsigned int nid_array[PROC_MAXVIDS];
21995 + char buf[PROC_NUMBUF];
21996 + unsigned int nr_nids, i;
21999 + pos = filp->f_pos;
22002 + ino = inode->i_ino;
22003 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22006 + /* fall through */
22008 + ino = parent_ino(dentry);
22009 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22012 + /* fall through */
22015 + if (index >= size)
22017 + for (p += index; p->name; p++) {
22018 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22019 + vs_proc_instantiate, 0, p))
22024 + index = pos - size;
22025 + p = &nx_virtnet_stuff[size - 1];
22026 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
22027 + for (i = 0; i < nr_nids; i++) {
22028 + int n, nid = nid_array[i];
22029 + unsigned int j = PROC_NUMBUF;
22033 + buf[--j] = '0' + (n % 10);
22036 + if (proc_fill_cache(filp, dirent, filldir,
22037 + buf + j, PROC_NUMBUF - j,
22038 + vs_proc_instantiate, nid, p))
22044 + filp->f_pos = pos;
22048 +static int proc_virtnet_getattr(struct vfsmount *mnt,
22049 + struct dentry *dentry, struct kstat *stat)
22051 + struct inode *inode = dentry->d_inode;
22053 + generic_fillattr(inode, stat);
22054 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
22058 +static struct file_operations proc_virtnet_dir_operations = {
22059 + .read = generic_read_dir,
22060 + .readdir = proc_virtnet_readdir,
22063 +static struct inode_operations proc_virtnet_dir_inode_operations = {
22064 + .getattr = proc_virtnet_getattr,
22065 + .lookup = proc_virtnet_lookup,
22070 +void proc_vx_init(void)
22072 + struct proc_dir_entry *ent;
22074 + ent = proc_mkdir("virtual", 0);
22076 + ent->proc_fops = &proc_virtual_dir_operations;
22077 + ent->proc_iops = &proc_virtual_dir_inode_operations;
22079 + proc_virtual = ent;
22081 + ent = proc_mkdir("virtnet", 0);
22083 + ent->proc_fops = &proc_virtnet_dir_operations;
22084 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
22086 + proc_virtnet = ent;
22092 +/* per pid info */
22095 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
22097 + struct vx_info *vxi;
22098 + char *orig = buffer;
22100 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
22102 + vxi = task_get_vx_info(p);
22106 + buffer += sprintf(buffer, "BCaps:\t");
22107 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
22108 + buffer += sprintf(buffer, "\n");
22109 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
22110 + (unsigned long long)vxi->vx_ccaps);
22111 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
22112 + (unsigned long long)vxi->vx_flags);
22113 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
22115 + put_vx_info(vxi);
22117 + return buffer - orig;
22121 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
22123 + struct nx_info *nxi;
22124 + struct nx_addr_v4 *v4a;
22125 +#ifdef CONFIG_IPV6
22126 + struct nx_addr_v6 *v6a;
22128 + char *orig = buffer;
22131 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
22133 + nxi = task_get_nx_info(p);
22137 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
22138 + (unsigned long long)nxi->nx_ncaps);
22139 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
22140 + (unsigned long long)nxi->nx_flags);
22142 + buffer += sprintf(buffer,
22143 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
22144 + NIPQUAD(nxi->v4_bcast.s_addr));
22145 + buffer += sprintf (buffer,
22146 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
22147 + NIPQUAD(nxi->v4_lback.s_addr));
22148 + if (!NX_IPV4(nxi))
22150 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
22151 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
22154 +#ifdef CONFIG_IPV6
22155 + if (!NX_IPV6(nxi))
22157 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
22158 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
22162 + put_nx_info(nxi);
22164 + return buffer - orig;
22167 diff -NurpP --minimal linux-3.6.10/kernel/vserver/sched.c linux-3.6.10-vs2.3.4.5/kernel/vserver/sched.c
22168 --- linux-3.6.10/kernel/vserver/sched.c 1970-01-01 01:00:00.000000000 +0100
22169 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/sched.c 2012-10-04 18:47:00.000000000 +0200
22172 + * linux/kernel/vserver/sched.c
22174 + * Virtual Server: Scheduler Support
22176 + * Copyright (C) 2004-2010 Herbert Pötzl
22178 + * V0.01 adapted Sam Vilains version to 2.6.3
22179 + * V0.02 removed legacy interface
22180 + * V0.03 changed vcmds to vxi arg
22181 + * V0.04 removed older and legacy interfaces
22182 + * V0.05 removed scheduler code/commands
22186 +#include <linux/vs_context.h>
22187 +#include <linux/vs_sched.h>
22188 +#include <linux/cpumask.h>
22189 +#include <linux/vserver/sched_cmd.h>
22191 +#include <asm/uaccess.h>
22194 +void vx_update_sched_param(struct _vx_sched *sched,
22195 + struct _vx_sched_pc *sched_pc)
22197 + sched_pc->prio_bias = sched->prio_bias;
22200 +static int do_set_prio_bias(struct vx_info *vxi, struct vcmd_prio_bias *data)
22204 + if (data->prio_bias > MAX_PRIO_BIAS)
22205 + data->prio_bias = MAX_PRIO_BIAS;
22206 + if (data->prio_bias < MIN_PRIO_BIAS)
22207 + data->prio_bias = MIN_PRIO_BIAS;
22209 + if (data->cpu_id != ~0) {
22210 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
22211 + cpumask_and(&vxi->sched.update, &vxi->sched.update,
22212 + cpu_online_mask);
22214 + cpumask_copy(&vxi->sched.update, cpu_online_mask);
22216 + for_each_cpu_mask(cpu, vxi->sched.update)
22217 + vx_update_sched_param(&vxi->sched,
22218 + &vx_per_cpu(vxi, sched_pc, cpu));
22222 +int vc_set_prio_bias(struct vx_info *vxi, void __user *data)
22224 + struct vcmd_prio_bias vc_data;
22226 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22229 + return do_set_prio_bias(vxi, &vc_data);
22232 +int vc_get_prio_bias(struct vx_info *vxi, void __user *data)
22234 + struct vcmd_prio_bias vc_data;
22235 + struct _vx_sched_pc *pcd;
22238 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22241 + cpu = vc_data.cpu_id;
22243 + if (!cpu_possible(cpu))
22246 + pcd = &vx_per_cpu(vxi, sched_pc, cpu);
22247 + vc_data.prio_bias = pcd->prio_bias;
22249 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22254 diff -NurpP --minimal linux-3.6.10/kernel/vserver/sched_init.h linux-3.6.10-vs2.3.4.5/kernel/vserver/sched_init.h
22255 --- linux-3.6.10/kernel/vserver/sched_init.h 1970-01-01 01:00:00.000000000 +0100
22256 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/sched_init.h 2012-10-04 18:47:00.000000000 +0200
22259 +static inline void vx_info_init_sched(struct _vx_sched *sched)
22261 + /* scheduling; hard code starting values as constants */
22262 + sched->prio_bias = 0;
22266 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22268 + sched_pc->prio_bias = 0;
22270 + sched_pc->user_ticks = 0;
22271 + sched_pc->sys_ticks = 0;
22272 + sched_pc->hold_ticks = 0;
22275 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
22281 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22285 diff -NurpP --minimal linux-3.6.10/kernel/vserver/sched_proc.h linux-3.6.10-vs2.3.4.5/kernel/vserver/sched_proc.h
22286 --- linux-3.6.10/kernel/vserver/sched_proc.h 1970-01-01 01:00:00.000000000 +0100
22287 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/sched_proc.h 2012-10-04 18:47:00.000000000 +0200
22289 +#ifndef _VX_SCHED_PROC_H
22290 +#define _VX_SCHED_PROC_H
22294 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
22298 + length += sprintf(buffer,
22299 + "PrioBias:\t%8d\n",
22300 + sched->prio_bias);
22305 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
22306 + char *buffer, int cpu)
22310 + length += sprintf(buffer + length,
22311 + "cpu %d: %lld %lld %lld", cpu,
22312 + (unsigned long long)sched_pc->user_ticks,
22313 + (unsigned long long)sched_pc->sys_ticks,
22314 + (unsigned long long)sched_pc->hold_ticks);
22315 + length += sprintf(buffer + length,
22316 + " %d\n", sched_pc->prio_bias);
22320 +#endif /* _VX_SCHED_PROC_H */
22321 diff -NurpP --minimal linux-3.6.10/kernel/vserver/signal.c linux-3.6.10-vs2.3.4.5/kernel/vserver/signal.c
22322 --- linux-3.6.10/kernel/vserver/signal.c 1970-01-01 01:00:00.000000000 +0100
22323 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/signal.c 2012-10-04 18:47:00.000000000 +0200
22326 + * linux/kernel/vserver/signal.c
22328 + * Virtual Server: Signal Support
22330 + * Copyright (C) 2003-2007 Herbert Pötzl
22332 + * V0.01 broken out from vcontext V0.05
22333 + * V0.02 changed vcmds to vxi arg
22334 + * V0.03 adjusted siginfo for kill
22338 +#include <asm/uaccess.h>
22340 +#include <linux/vs_context.h>
22341 +#include <linux/vs_pid.h>
22342 +#include <linux/vserver/signal_cmd.h>
22345 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
22347 + int retval, count = 0;
22348 + struct task_struct *p;
22349 + struct siginfo *sip = SEND_SIG_PRIV;
22352 + vxdprintk(VXD_CBIT(misc, 4),
22353 + "vx_info_kill(%p[#%d],%d,%d)*",
22354 + vxi, vxi->vx_id, pid, sig);
22355 + read_lock(&tasklist_lock);
22359 + for_each_process(p) {
22362 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
22363 + (pid && vxi->vx_initpid == p->pid))
22366 + err = group_send_sig_info(sig, sip, p);
22368 + if (err != -EPERM)
22374 + if (vxi->vx_initpid) {
22375 + pid = vxi->vx_initpid;
22376 + /* for now, only SIGINT to private init ... */
22377 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22378 + /* ... as long as there are tasks left */
22379 + (atomic_read(&vxi->vx_tasks) > 1))
22382 + /* fallthrough */
22385 + p = find_task_by_real_pid(pid);
22386 + rcu_read_unlock();
22388 + if (vx_task_xid(p) == vxi->vx_id)
22389 + retval = group_send_sig_info(sig, sip, p);
22393 + read_unlock(&tasklist_lock);
22394 + vxdprintk(VXD_CBIT(misc, 4),
22395 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
22396 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
22400 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
22402 + struct vcmd_ctx_kill_v0 vc_data;
22404 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22407 + /* special check to allow guest shutdown */
22408 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22409 + /* forbid killall pid=0 when init is present */
22410 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
22411 + (vc_data.pid > 1)))
22414 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
22418 +static int __wait_exit(struct vx_info *vxi)
22420 + DECLARE_WAITQUEUE(wait, current);
22423 + add_wait_queue(&vxi->vx_wait, &wait);
22424 + set_current_state(TASK_INTERRUPTIBLE);
22427 + if (vx_info_state(vxi,
22428 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
22430 + if (signal_pending(current)) {
22431 + ret = -ERESTARTSYS;
22438 + set_current_state(TASK_RUNNING);
22439 + remove_wait_queue(&vxi->vx_wait, &wait);
22445 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
22447 + struct vcmd_wait_exit_v0 vc_data;
22450 + ret = __wait_exit(vxi);
22451 + vc_data.reboot_cmd = vxi->reboot_cmd;
22452 + vc_data.exit_code = vxi->exit_code;
22454 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22459 diff -NurpP --minimal linux-3.6.10/kernel/vserver/space.c linux-3.6.10-vs2.3.4.5/kernel/vserver/space.c
22460 --- linux-3.6.10/kernel/vserver/space.c 1970-01-01 01:00:00.000000000 +0100
22461 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/space.c 2012-10-04 18:47:00.000000000 +0200
22464 + * linux/kernel/vserver/space.c
22466 + * Virtual Server: Context Space Support
22468 + * Copyright (C) 2003-2010 Herbert Pötzl
22470 + * V0.01 broken out from context.c 0.07
22471 + * V0.02 added task locking for namespace
22472 + * V0.03 broken out vx_enter_namespace
22473 + * V0.04 added *space support and commands
22474 + * V0.05 added credential support
22478 +#include <linux/utsname.h>
22479 +#include <linux/nsproxy.h>
22480 +#include <linux/err.h>
22481 +#include <linux/fs_struct.h>
22482 +#include <linux/cred.h>
22483 +#include <asm/uaccess.h>
22485 +#include <linux/vs_context.h>
22486 +#include <linux/vserver/space.h>
22487 +#include <linux/vserver/space_cmd.h>
22489 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
22490 +atomic_t vs_global_fs = ATOMIC_INIT(0);
22491 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
22492 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
22493 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
22494 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
22497 +/* namespace functions */
22499 +#include <linux/mnt_namespace.h>
22500 +#include <linux/user_namespace.h>
22501 +#include <linux/pid_namespace.h>
22502 +#include <linux/ipc_namespace.h>
22503 +#include <net/net_namespace.h>
22504 +#include "../fs/mount.h"
22507 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
22508 + .mask = CLONE_FS |
22510 +#ifdef CONFIG_UTS_NS
22513 +#ifdef CONFIG_IPC_NS
22516 +#ifdef CONFIG_USER_NS
22522 +static const struct vcmd_space_mask_v1 space_mask = {
22523 + .mask = CLONE_FS |
22525 +#ifdef CONFIG_UTS_NS
22528 +#ifdef CONFIG_IPC_NS
22531 +#ifdef CONFIG_USER_NS
22534 +#ifdef CONFIG_PID_NS
22537 +#ifdef CONFIG_NET_NS
22543 +static const struct vcmd_space_mask_v1 default_space_mask = {
22544 + .mask = CLONE_FS |
22546 +#ifdef CONFIG_UTS_NS
22549 +#ifdef CONFIG_IPC_NS
22552 +#ifdef CONFIG_USER_NS
22555 +#ifdef CONFIG_PID_NS
22562 + * build a new nsproxy mix
22563 + * assumes that both proxies are 'const'
22564 + * does not touch nsproxy refcounts
22565 + * will hold a reference on the result.
22568 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
22569 + struct nsproxy *new_nsproxy, unsigned long mask)
22571 + struct mnt_namespace *old_ns;
22572 + struct uts_namespace *old_uts;
22573 + struct ipc_namespace *old_ipc;
22574 +#ifdef CONFIG_PID_NS
22575 + struct pid_namespace *old_pid;
22577 +#ifdef CONFIG_NET_NS
22578 + struct net *old_net;
22580 + struct nsproxy *nsproxy;
22582 + nsproxy = copy_nsproxy(old_nsproxy);
22586 + if (mask & CLONE_NEWNS) {
22587 + old_ns = nsproxy->mnt_ns;
22588 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
22589 + if (nsproxy->mnt_ns)
22590 + get_mnt_ns(nsproxy->mnt_ns);
22594 + if (mask & CLONE_NEWUTS) {
22595 + old_uts = nsproxy->uts_ns;
22596 + nsproxy->uts_ns = new_nsproxy->uts_ns;
22597 + if (nsproxy->uts_ns)
22598 + get_uts_ns(nsproxy->uts_ns);
22602 + if (mask & CLONE_NEWIPC) {
22603 + old_ipc = nsproxy->ipc_ns;
22604 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
22605 + if (nsproxy->ipc_ns)
22606 + get_ipc_ns(nsproxy->ipc_ns);
22610 +#ifdef CONFIG_PID_NS
22611 + if (mask & CLONE_NEWPID) {
22612 + old_pid = nsproxy->pid_ns;
22613 + nsproxy->pid_ns = new_nsproxy->pid_ns;
22614 + if (nsproxy->pid_ns)
22615 + get_pid_ns(nsproxy->pid_ns);
22619 +#ifdef CONFIG_NET_NS
22620 + if (mask & CLONE_NEWNET) {
22621 + old_net = nsproxy->net_ns;
22622 + nsproxy->net_ns = new_nsproxy->net_ns;
22623 + if (nsproxy->net_ns)
22624 + get_net(nsproxy->net_ns);
22629 + put_mnt_ns(old_ns);
22631 + put_uts_ns(old_uts);
22633 + put_ipc_ns(old_ipc);
22634 +#ifdef CONFIG_PID_NS
22636 + put_pid_ns(old_pid);
22638 +#ifdef CONFIG_NET_NS
22640 + put_net(old_net);
22648 + * merge two nsproxy structs into a new one.
22649 + * will hold a reference on the result.
22653 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
22654 + struct nsproxy *proxy, unsigned long mask)
22656 + struct nsproxy null_proxy = { .mnt_ns = NULL };
22662 + /* vs_mix_nsproxy returns with reference */
22663 + return vs_mix_nsproxy(old ? old : &null_proxy,
22666 + get_nsproxy(proxy);
22671 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
22673 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
22674 + struct fs_struct *fs_cur, *fs = NULL;
22675 + struct _vx_space *space;
22676 + int ret, kill = 0;
22678 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
22679 + vxi, vxi->vx_id, mask, index);
22681 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
22684 + if (index >= VX_SPACES)
22687 + space = &vxi->space[index];
22690 + mask = space->vx_nsmask;
22692 + if ((mask & space->vx_nsmask) != mask)
22695 + if (mask & CLONE_FS) {
22696 + fs = copy_fs_struct(space->vx_fs);
22700 + proxy = space->vx_nsproxy;
22702 + vxdprintk(VXD_CBIT(space, 9),
22703 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
22704 + vxi, vxi->vx_id, mask, index, proxy, fs);
22706 + task_lock(current);
22707 + fs_cur = current->fs;
22709 + if (mask & CLONE_FS) {
22710 + spin_lock(&fs_cur->lock);
22711 + current->fs = fs;
22712 + kill = !--fs_cur->users;
22713 + spin_unlock(&fs_cur->lock);
22716 + proxy_cur = current->nsproxy;
22717 + get_nsproxy(proxy_cur);
22718 + task_unlock(current);
22721 + free_fs_struct(fs_cur);
22723 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
22724 + if (IS_ERR(proxy_new)) {
22725 + ret = PTR_ERR(proxy_new);
22729 + proxy_new = xchg(¤t->nsproxy, proxy_new);
22731 + if (mask & CLONE_NEWUSER) {
22732 + struct cred *cred;
22734 + vxdprintk(VXD_CBIT(space, 10),
22735 + "vx_enter_space(%p[#%u],%p) cred (%p,%p)",
22736 + vxi, vxi->vx_id, space->vx_cred,
22737 + current->real_cred, current->cred);
22739 + if (space->vx_cred) {
22740 + cred = __prepare_creds(space->vx_cred);
22742 + commit_creds(cred);
22749 + put_nsproxy(proxy_new);
22752 + put_nsproxy(proxy_cur);
22757 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
22759 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
22760 + struct fs_struct *fs_vxi, *fs;
22761 + struct _vx_space *space;
22762 + int ret, kill = 0;
22764 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
22765 + vxi, vxi->vx_id, mask, index);
22767 + if ((mask & space_mask.mask) != mask)
22770 + if (index >= VX_SPACES)
22773 + space = &vxi->space[index];
22775 + proxy_vxi = space->vx_nsproxy;
22776 + fs_vxi = space->vx_fs;
22778 + if (mask & CLONE_FS) {
22779 + fs = copy_fs_struct(current->fs);
22784 + task_lock(current);
22786 + if (mask & CLONE_FS) {
22787 + spin_lock(&fs_vxi->lock);
22788 + space->vx_fs = fs;
22789 + kill = !--fs_vxi->users;
22790 + spin_unlock(&fs_vxi->lock);
22793 + proxy_cur = current->nsproxy;
22794 + get_nsproxy(proxy_cur);
22795 + task_unlock(current);
22798 + free_fs_struct(fs_vxi);
22800 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
22801 + if (IS_ERR(proxy_new)) {
22802 + ret = PTR_ERR(proxy_new);
22806 + proxy_new = xchg(&space->vx_nsproxy, proxy_new);
22807 + space->vx_nsmask |= mask;
22809 + if (mask & CLONE_NEWUSER) {
22810 + struct cred *cred;
22812 + vxdprintk(VXD_CBIT(space, 10),
22813 + "vx_set_space(%p[#%u],%p) cred (%p,%p)",
22814 + vxi, vxi->vx_id, space->vx_cred,
22815 + current->real_cred, current->cred);
22817 + cred = prepare_creds();
22818 + cred = (struct cred *)xchg(&space->vx_cred, cred);
22820 + abort_creds(cred);
22826 + put_nsproxy(proxy_new);
22829 + put_nsproxy(proxy_cur);
22834 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
22836 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
22838 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22841 + return vx_enter_space(vxi, vc_data.mask, 0);
22844 +int vc_enter_space(struct vx_info *vxi, void __user *data)
22846 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
22848 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22851 + if (vc_data.index >= VX_SPACES)
22854 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
22857 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
22859 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
22861 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22864 + return vx_set_space(vxi, vc_data.mask, 0);
22867 +int vc_set_space(struct vx_info *vxi, void __user *data)
22869 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
22871 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22874 + if (vc_data.index >= VX_SPACES)
22877 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
22880 +int vc_get_space_mask(void __user *data, int type)
22882 + const struct vcmd_space_mask_v1 *mask;
22885 + mask = &space_mask_v0;
22886 + else if (type == 1)
22887 + mask = &space_mask;
22889 + mask = &default_space_mask;
22891 + vxdprintk(VXD_CBIT(space, 10),
22892 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
22894 + if (copy_to_user(data, mask, sizeof(*mask)))
22899 diff -NurpP --minimal linux-3.6.10/kernel/vserver/switch.c linux-3.6.10-vs2.3.4.5/kernel/vserver/switch.c
22900 --- linux-3.6.10/kernel/vserver/switch.c 1970-01-01 01:00:00.000000000 +0100
22901 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/switch.c 2012-10-04 18:47:00.000000000 +0200
22904 + * linux/kernel/vserver/switch.c
22906 + * Virtual Server: Syscall Switch
22908 + * Copyright (C) 2003-2011 Herbert Pötzl
22910 + * V0.01 syscall switch
22911 + * V0.02 added signal to context
22912 + * V0.03 added rlimit functions
22913 + * V0.04 added iattr, task/xid functions
22914 + * V0.05 added debug/history stuff
22915 + * V0.06 added compat32 layer
22916 + * V0.07 vcmd args and perms
22917 + * V0.08 added status commands
22918 + * V0.09 added tag commands
22919 + * V0.10 added oom bias
22920 + * V0.11 added device commands
22921 + * V0.12 added warn mask
22925 +#include <linux/vs_context.h>
22926 +#include <linux/vs_network.h>
22927 +#include <linux/vserver/switch.h>
22929 +#include "vci_config.h"
22933 +int vc_get_version(uint32_t id)
22935 + return VCI_VERSION;
22939 +int vc_get_vci(uint32_t id)
22941 + return vci_kernel_config();
22944 +#include <linux/vserver/context_cmd.h>
22945 +#include <linux/vserver/cvirt_cmd.h>
22946 +#include <linux/vserver/cacct_cmd.h>
22947 +#include <linux/vserver/limit_cmd.h>
22948 +#include <linux/vserver/network_cmd.h>
22949 +#include <linux/vserver/sched_cmd.h>
22950 +#include <linux/vserver/debug_cmd.h>
22951 +#include <linux/vserver/inode_cmd.h>
22952 +#include <linux/vserver/dlimit_cmd.h>
22953 +#include <linux/vserver/signal_cmd.h>
22954 +#include <linux/vserver/space_cmd.h>
22955 +#include <linux/vserver/tag_cmd.h>
22956 +#include <linux/vserver/device_cmd.h>
22958 +#include <linux/vserver/inode.h>
22959 +#include <linux/vserver/dlimit.h>
22962 +#ifdef CONFIG_COMPAT
22963 +#define __COMPAT(name, id, data, compat) \
22964 + (compat) ? name ## _x32(id, data) : name(id, data)
22965 +#define __COMPAT_NO_ID(name, data, compat) \
22966 + (compat) ? name ## _x32(data) : name(data)
22968 +#define __COMPAT(name, id, data, compat) \
22970 +#define __COMPAT_NO_ID(name, data, compat) \
22976 +long do_vcmd(uint32_t cmd, uint32_t id,
22977 + struct vx_info *vxi, struct nx_info *nxi,
22978 + void __user *data, int compat)
22982 + case VCMD_get_version:
22983 + return vc_get_version(id);
22984 + case VCMD_get_vci:
22985 + return vc_get_vci(id);
22987 + case VCMD_task_xid:
22988 + return vc_task_xid(id);
22989 + case VCMD_vx_info:
22990 + return vc_vx_info(vxi, data);
22992 + case VCMD_task_nid:
22993 + return vc_task_nid(id);
22994 + case VCMD_nx_info:
22995 + return vc_nx_info(nxi, data);
22997 + case VCMD_task_tag:
22998 + return vc_task_tag(id);
23000 + case VCMD_set_space_v1:
23001 + return vc_set_space_v1(vxi, data);
23002 + /* this is version 2 */
23003 + case VCMD_set_space:
23004 + return vc_set_space(vxi, data);
23006 + case VCMD_get_space_mask_v0:
23007 + return vc_get_space_mask(data, 0);
23008 + /* this is version 1 */
23009 + case VCMD_get_space_mask:
23010 + return vc_get_space_mask(data, 1);
23012 + case VCMD_get_space_default:
23013 + return vc_get_space_mask(data, -1);
23015 + case VCMD_set_umask:
23016 + return vc_set_umask(vxi, data);
23018 + case VCMD_get_umask:
23019 + return vc_get_umask(vxi, data);
23021 + case VCMD_set_wmask:
23022 + return vc_set_wmask(vxi, data);
23024 + case VCMD_get_wmask:
23025 + return vc_get_wmask(vxi, data);
23026 +#ifdef CONFIG_IA32_EMULATION
23027 + case VCMD_get_rlimit:
23028 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
23029 + case VCMD_set_rlimit:
23030 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
23032 + case VCMD_get_rlimit:
23033 + return vc_get_rlimit(vxi, data);
23034 + case VCMD_set_rlimit:
23035 + return vc_set_rlimit(vxi, data);
23037 + case VCMD_get_rlimit_mask:
23038 + return vc_get_rlimit_mask(id, data);
23039 + case VCMD_reset_hits:
23040 + return vc_reset_hits(vxi, data);
23041 + case VCMD_reset_minmax:
23042 + return vc_reset_minmax(vxi, data);
23044 + case VCMD_get_vhi_name:
23045 + return vc_get_vhi_name(vxi, data);
23046 + case VCMD_set_vhi_name:
23047 + return vc_set_vhi_name(vxi, data);
23049 + case VCMD_ctx_stat:
23050 + return vc_ctx_stat(vxi, data);
23051 + case VCMD_virt_stat:
23052 + return vc_virt_stat(vxi, data);
23053 + case VCMD_sock_stat:
23054 + return vc_sock_stat(vxi, data);
23055 + case VCMD_rlimit_stat:
23056 + return vc_rlimit_stat(vxi, data);
23058 + case VCMD_set_cflags:
23059 + return vc_set_cflags(vxi, data);
23060 + case VCMD_get_cflags:
23061 + return vc_get_cflags(vxi, data);
23063 + /* this is version 1 */
23064 + case VCMD_set_ccaps:
23065 + return vc_set_ccaps(vxi, data);
23066 + /* this is version 1 */
23067 + case VCMD_get_ccaps:
23068 + return vc_get_ccaps(vxi, data);
23069 + case VCMD_set_bcaps:
23070 + return vc_set_bcaps(vxi, data);
23071 + case VCMD_get_bcaps:
23072 + return vc_get_bcaps(vxi, data);
23074 + case VCMD_set_badness:
23075 + return vc_set_badness(vxi, data);
23076 + case VCMD_get_badness:
23077 + return vc_get_badness(vxi, data);
23079 + case VCMD_set_nflags:
23080 + return vc_set_nflags(nxi, data);
23081 + case VCMD_get_nflags:
23082 + return vc_get_nflags(nxi, data);
23084 + case VCMD_set_ncaps:
23085 + return vc_set_ncaps(nxi, data);
23086 + case VCMD_get_ncaps:
23087 + return vc_get_ncaps(nxi, data);
23089 + case VCMD_set_prio_bias:
23090 + return vc_set_prio_bias(vxi, data);
23091 + case VCMD_get_prio_bias:
23092 + return vc_get_prio_bias(vxi, data);
23093 + case VCMD_add_dlimit:
23094 + return __COMPAT(vc_add_dlimit, id, data, compat);
23095 + case VCMD_rem_dlimit:
23096 + return __COMPAT(vc_rem_dlimit, id, data, compat);
23097 + case VCMD_set_dlimit:
23098 + return __COMPAT(vc_set_dlimit, id, data, compat);
23099 + case VCMD_get_dlimit:
23100 + return __COMPAT(vc_get_dlimit, id, data, compat);
23102 + case VCMD_ctx_kill:
23103 + return vc_ctx_kill(vxi, data);
23105 + case VCMD_wait_exit:
23106 + return vc_wait_exit(vxi, data);
23108 + case VCMD_get_iattr:
23109 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
23110 + case VCMD_set_iattr:
23111 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
23113 + case VCMD_fget_iattr:
23114 + return vc_fget_iattr(id, data);
23115 + case VCMD_fset_iattr:
23116 + return vc_fset_iattr(id, data);
23118 + case VCMD_enter_space_v0:
23119 + return vc_enter_space_v1(vxi, NULL);
23120 + case VCMD_enter_space_v1:
23121 + return vc_enter_space_v1(vxi, data);
23122 + /* this is version 2 */
23123 + case VCMD_enter_space:
23124 + return vc_enter_space(vxi, data);
23126 + case VCMD_ctx_create_v0:
23127 + return vc_ctx_create(id, NULL);
23128 + case VCMD_ctx_create:
23129 + return vc_ctx_create(id, data);
23130 + case VCMD_ctx_migrate_v0:
23131 + return vc_ctx_migrate(vxi, NULL);
23132 + case VCMD_ctx_migrate:
23133 + return vc_ctx_migrate(vxi, data);
23135 + case VCMD_net_create_v0:
23136 + return vc_net_create(id, NULL);
23137 + case VCMD_net_create:
23138 + return vc_net_create(id, data);
23139 + case VCMD_net_migrate:
23140 + return vc_net_migrate(nxi, data);
23142 + case VCMD_tag_migrate:
23143 + return vc_tag_migrate(id);
23145 + case VCMD_net_add:
23146 + return vc_net_add(nxi, data);
23147 + case VCMD_net_remove:
23148 + return vc_net_remove(nxi, data);
23150 + case VCMD_net_add_ipv4_v1:
23151 + return vc_net_add_ipv4_v1(nxi, data);
23152 + /* this is version 2 */
23153 + case VCMD_net_add_ipv4:
23154 + return vc_net_add_ipv4(nxi, data);
23156 + case VCMD_net_rem_ipv4_v1:
23157 + return vc_net_rem_ipv4_v1(nxi, data);
23158 + /* this is version 2 */
23159 + case VCMD_net_rem_ipv4:
23160 + return vc_net_rem_ipv4(nxi, data);
23161 +#ifdef CONFIG_IPV6
23162 + case VCMD_net_add_ipv6:
23163 + return vc_net_add_ipv6(nxi, data);
23164 + case VCMD_net_remove_ipv6:
23165 + return vc_net_remove_ipv6(nxi, data);
23167 +/* case VCMD_add_match_ipv4:
23168 + return vc_add_match_ipv4(nxi, data);
23169 + case VCMD_get_match_ipv4:
23170 + return vc_get_match_ipv4(nxi, data);
23171 +#ifdef CONFIG_IPV6
23172 + case VCMD_add_match_ipv6:
23173 + return vc_add_match_ipv6(nxi, data);
23174 + case VCMD_get_match_ipv6:
23175 + return vc_get_match_ipv6(nxi, data);
23178 +#ifdef CONFIG_VSERVER_DEVICE
23179 + case VCMD_set_mapping:
23180 + return __COMPAT(vc_set_mapping, vxi, data, compat);
23181 + case VCMD_unset_mapping:
23182 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
23184 +#ifdef CONFIG_VSERVER_HISTORY
23185 + case VCMD_dump_history:
23186 + return vc_dump_history(id);
23187 + case VCMD_read_history:
23188 + return __COMPAT(vc_read_history, id, data, compat);
23191 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
23192 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
23198 +#define __VCMD(vcmd, _perm, _args, _flags) \
23199 + case VCMD_ ## vcmd: perm = _perm; \
23200 + args = _args; flags = _flags; break
23203 +#define VCA_NONE 0x00
23204 +#define VCA_VXI 0x01
23205 +#define VCA_NXI 0x02
23207 +#define VCF_NONE 0x00
23208 +#define VCF_INFO 0x01
23209 +#define VCF_ADMIN 0x02
23210 +#define VCF_ARES 0x06 /* includes admin */
23211 +#define VCF_SETUP 0x08
23213 +#define VCF_ZIDOK 0x10 /* zero id okay */
23217 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
23220 + int permit = -1, state = 0;
23221 + int perm = -1, args = 0, flags = 0;
23222 + struct vx_info *vxi = NULL;
23223 + struct nx_info *nxi = NULL;
23226 + /* unpriviledged commands */
23227 + __VCMD(get_version, 0, VCA_NONE, 0);
23228 + __VCMD(get_vci, 0, VCA_NONE, 0);
23229 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
23230 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
23231 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
23232 + __VCMD(get_space_default,0, VCA_NONE, 0);
23234 + /* info commands */
23235 + __VCMD(task_xid, 2, VCA_NONE, 0);
23236 + __VCMD(reset_hits, 2, VCA_VXI, 0);
23237 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
23238 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
23239 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
23240 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
23241 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
23242 + __VCMD(get_umask, 3, VCA_VXI, VCF_INFO);
23243 + __VCMD(get_wmask, 3, VCA_VXI, VCF_INFO);
23244 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
23245 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
23246 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
23248 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
23249 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
23250 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
23251 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
23253 + __VCMD(task_nid, 2, VCA_NONE, 0);
23254 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
23255 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
23256 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
23258 + __VCMD(task_tag, 2, VCA_NONE, 0);
23260 + __VCMD(get_iattr, 2, VCA_NONE, 0);
23261 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
23262 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
23263 + __VCMD(get_prio_bias, 3, VCA_VXI, VCF_INFO);
23265 + /* lower admin commands */
23266 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
23267 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
23268 + __VCMD(ctx_create, 5, VCA_NONE, 0);
23269 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
23270 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
23271 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
23272 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
23273 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
23275 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
23276 + __VCMD(net_create, 5, VCA_NONE, 0);
23277 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
23279 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
23281 + /* higher admin commands */
23282 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
23283 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23284 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23286 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23287 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23288 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23289 + __VCMD(set_umask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23290 + __VCMD(set_wmask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23291 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23293 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23294 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23295 + __VCMD(set_prio_bias, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23297 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23298 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23299 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23300 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23301 + __VCMD(net_add_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23302 + __VCMD(net_rem_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23303 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23304 + __VCMD(net_rem_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23305 +#ifdef CONFIG_IPV6
23306 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23307 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23309 + __VCMD(set_iattr, 7, VCA_NONE, 0);
23310 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
23311 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
23312 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
23313 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
23315 +#ifdef CONFIG_VSERVER_DEVICE
23316 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23317 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23319 + /* debug level admin commands */
23320 +#ifdef CONFIG_VSERVER_HISTORY
23321 + __VCMD(dump_history, 9, VCA_NONE, 0);
23322 + __VCMD(read_history, 9, VCA_NONE, 0);
23329 + vxdprintk(VXD_CBIT(switch, 0),
23330 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
23331 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23332 + VC_VERSION(cmd), id, data, compat,
23333 + perm, args, flags);
23340 + if (!capable(CAP_CONTEXT))
23344 + /* moved here from the individual commands */
23346 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
23350 + /* vcmd involves resource management */
23352 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
23356 + /* various legacy exceptions */
23358 + /* will go away when spectator is a cap */
23359 + case VCMD_ctx_migrate_v0:
23360 + case VCMD_ctx_migrate:
23362 + current->xid = 1;
23368 + /* will go away when spectator is a cap */
23369 + case VCMD_net_migrate:
23371 + current->nid = 1;
23378 + /* vcmds are fine by default */
23381 + /* admin type vcmds require admin ... */
23382 + if (flags & VCF_ADMIN)
23383 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
23385 + /* ... but setup type vcmds override that */
23386 + if (!permit && (flags & VCF_SETUP))
23387 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
23395 + if (!id && (flags & VCF_ZIDOK))
23399 + if (args & VCA_VXI) {
23400 + vxi = lookup_vx_info(id);
23404 + if ((flags & VCF_ADMIN) &&
23405 + /* special case kill for shutdown */
23406 + (cmd != VCMD_ctx_kill) &&
23407 + /* can context be administrated? */
23408 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
23414 + if (args & VCA_NXI) {
23415 + nxi = lookup_nx_info(id);
23419 + if ((flags & VCF_ADMIN) &&
23420 + /* can context be administrated? */
23421 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
23428 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
23431 + if ((args & VCA_NXI) && nxi)
23432 + put_nx_info(nxi);
23434 + if ((args & VCA_VXI) && vxi)
23435 + put_vx_info(vxi);
23437 + vxdprintk(VXD_CBIT(switch, 1),
23438 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
23439 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23440 + VC_VERSION(cmd), ret, ret, state, permit);
23445 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
23447 + return do_vserver(cmd, id, data, 0);
23450 +#ifdef CONFIG_COMPAT
23453 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
23455 + return do_vserver(cmd, id, data, 1);
23458 +#endif /* CONFIG_COMPAT */
23459 diff -NurpP --minimal linux-3.6.10/kernel/vserver/sysctl.c linux-3.6.10-vs2.3.4.5/kernel/vserver/sysctl.c
23460 --- linux-3.6.10/kernel/vserver/sysctl.c 1970-01-01 01:00:00.000000000 +0100
23461 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/sysctl.c 2012-10-04 18:47:00.000000000 +0200
23464 + * kernel/vserver/sysctl.c
23466 + * Virtual Context Support
23468 + * Copyright (C) 2004-2007 Herbert Pötzl
23470 + * V0.01 basic structure
23474 +#include <linux/module.h>
23475 +#include <linux/ctype.h>
23476 +#include <linux/sysctl.h>
23477 +#include <linux/parser.h>
23478 +#include <asm/uaccess.h>
23481 + CTL_DEBUG_ERROR = 0,
23482 + CTL_DEBUG_SWITCH = 1,
23498 +unsigned int vs_debug_switch = 0;
23499 +unsigned int vs_debug_xid = 0;
23500 +unsigned int vs_debug_nid = 0;
23501 +unsigned int vs_debug_tag = 0;
23502 +unsigned int vs_debug_net = 0;
23503 +unsigned int vs_debug_limit = 0;
23504 +unsigned int vs_debug_cres = 0;
23505 +unsigned int vs_debug_dlim = 0;
23506 +unsigned int vs_debug_quota = 0;
23507 +unsigned int vs_debug_cvirt = 0;
23508 +unsigned int vs_debug_space = 0;
23509 +unsigned int vs_debug_perm = 0;
23510 +unsigned int vs_debug_misc = 0;
23513 +static struct ctl_table_header *vserver_table_header;
23514 +static ctl_table vserver_root_table[];
23517 +void vserver_register_sysctl(void)
23519 + if (!vserver_table_header) {
23520 + vserver_table_header = register_sysctl_table(vserver_root_table);
23525 +void vserver_unregister_sysctl(void)
23527 + if (vserver_table_header) {
23528 + unregister_sysctl_table(vserver_table_header);
23529 + vserver_table_header = NULL;
23534 +static int proc_dodebug(ctl_table *table, int write,
23535 + void __user *buffer, size_t *lenp, loff_t *ppos)
23537 + char tmpbuf[20], *p, c;
23538 + unsigned int value;
23539 + size_t left, len;
23541 + if ((*ppos && !write) || !*lenp) {
23549 + if (!access_ok(VERIFY_READ, buffer, left))
23551 + p = (char *)buffer;
23552 + while (left && __get_user(c, p) >= 0 && isspace(c))
23557 + if (left > sizeof(tmpbuf) - 1)
23559 + if (copy_from_user(tmpbuf, p, left))
23561 + tmpbuf[left] = '\0';
23563 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
23564 + value = 10 * value + (*p - '0');
23565 + if (*p && !isspace(*p))
23567 + while (left && isspace(*p))
23569 + *(unsigned int *)table->data = value;
23571 + if (!access_ok(VERIFY_WRITE, buffer, left))
23573 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
23576 + if (__copy_to_user(buffer, tmpbuf, len))
23578 + if ((left -= len) > 0) {
23579 + if (put_user('\n', (char *)buffer + len))
23593 +#define CTL_ENTRY(ctl, name) \
23595 + .procname = #name, \
23596 + .data = &vs_ ## name, \
23597 + .maxlen = sizeof(int), \
23599 + .proc_handler = &proc_dodebug, \
23600 + .extra1 = &zero, \
23601 + .extra2 = &zero, \
23604 +static ctl_table vserver_debug_table[] = {
23605 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
23606 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
23607 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
23608 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
23609 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
23610 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
23611 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
23612 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
23613 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
23614 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
23615 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
23616 + CTL_ENTRY(CTL_DEBUG_PERM, debug_perm),
23617 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
23621 +static ctl_table vserver_root_table[] = {
23623 + .procname = "vserver",
23625 + .child = vserver_debug_table
23631 +static match_table_t tokens = {
23632 + { CTL_DEBUG_SWITCH, "switch=%x" },
23633 + { CTL_DEBUG_XID, "xid=%x" },
23634 + { CTL_DEBUG_NID, "nid=%x" },
23635 + { CTL_DEBUG_TAG, "tag=%x" },
23636 + { CTL_DEBUG_NET, "net=%x" },
23637 + { CTL_DEBUG_LIMIT, "limit=%x" },
23638 + { CTL_DEBUG_CRES, "cres=%x" },
23639 + { CTL_DEBUG_DLIM, "dlim=%x" },
23640 + { CTL_DEBUG_QUOTA, "quota=%x" },
23641 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
23642 + { CTL_DEBUG_SPACE, "space=%x" },
23643 + { CTL_DEBUG_PERM, "perm=%x" },
23644 + { CTL_DEBUG_MISC, "misc=%x" },
23645 + { CTL_DEBUG_ERROR, NULL }
23648 +#define HANDLE_CASE(id, name, val) \
23649 + case CTL_DEBUG_ ## id: \
23650 + vs_debug_ ## name = val; \
23651 + printk("vs_debug_" #name "=0x%x\n", val); \
23655 +static int __init vs_debug_setup(char *str)
23660 + printk("vs_debug_setup(%s)\n", str);
23661 + while ((p = strsep(&str, ",")) != NULL) {
23662 + substring_t args[MAX_OPT_ARGS];
23663 + unsigned int value;
23668 + token = match_token(p, tokens, args);
23669 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
23672 + HANDLE_CASE(SWITCH, switch, value);
23673 + HANDLE_CASE(XID, xid, value);
23674 + HANDLE_CASE(NID, nid, value);
23675 + HANDLE_CASE(TAG, tag, value);
23676 + HANDLE_CASE(NET, net, value);
23677 + HANDLE_CASE(LIMIT, limit, value);
23678 + HANDLE_CASE(CRES, cres, value);
23679 + HANDLE_CASE(DLIM, dlim, value);
23680 + HANDLE_CASE(QUOTA, quota, value);
23681 + HANDLE_CASE(CVIRT, cvirt, value);
23682 + HANDLE_CASE(SPACE, space, value);
23683 + HANDLE_CASE(PERM, perm, value);
23684 + HANDLE_CASE(MISC, misc, value);
23693 +__setup("vsdebug=", vs_debug_setup);
23697 +EXPORT_SYMBOL_GPL(vs_debug_switch);
23698 +EXPORT_SYMBOL_GPL(vs_debug_xid);
23699 +EXPORT_SYMBOL_GPL(vs_debug_nid);
23700 +EXPORT_SYMBOL_GPL(vs_debug_net);
23701 +EXPORT_SYMBOL_GPL(vs_debug_limit);
23702 +EXPORT_SYMBOL_GPL(vs_debug_cres);
23703 +EXPORT_SYMBOL_GPL(vs_debug_dlim);
23704 +EXPORT_SYMBOL_GPL(vs_debug_quota);
23705 +EXPORT_SYMBOL_GPL(vs_debug_cvirt);
23706 +EXPORT_SYMBOL_GPL(vs_debug_space);
23707 +EXPORT_SYMBOL_GPL(vs_debug_perm);
23708 +EXPORT_SYMBOL_GPL(vs_debug_misc);
23710 diff -NurpP --minimal linux-3.6.10/kernel/vserver/tag.c linux-3.6.10-vs2.3.4.5/kernel/vserver/tag.c
23711 --- linux-3.6.10/kernel/vserver/tag.c 1970-01-01 01:00:00.000000000 +0100
23712 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/tag.c 2012-10-04 18:47:00.000000000 +0200
23715 + * linux/kernel/vserver/tag.c
23717 + * Virtual Server: Shallow Tag Space
23719 + * Copyright (C) 2007 Herbert Pötzl
23721 + * V0.01 basic implementation
23725 +#include <linux/sched.h>
23726 +#include <linux/vserver/debug.h>
23727 +#include <linux/vs_pid.h>
23728 +#include <linux/vs_tag.h>
23730 +#include <linux/vserver/tag_cmd.h>
23733 +int dx_migrate_task(struct task_struct *p, tag_t tag)
23738 + vxdprintk(VXD_CBIT(tag, 5),
23739 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
23745 + vxdprintk(VXD_CBIT(tag, 5),
23746 + "moved task %p into [#%d]", p, tag);
23750 +/* vserver syscall commands below here */
23752 +/* taks xid and vx_info functions */
23755 +int vc_task_tag(uint32_t id)
23760 + struct task_struct *tsk;
23762 + tsk = find_task_by_real_pid(id);
23763 + tag = (tsk) ? tsk->tag : -ESRCH;
23764 + rcu_read_unlock();
23766 + tag = dx_current_tag();
23771 +int vc_tag_migrate(uint32_t tag)
23773 + return dx_migrate_task(current, tag & 0xFFFF);
23777 diff -NurpP --minimal linux-3.6.10/kernel/vserver/vci_config.h linux-3.6.10-vs2.3.4.5/kernel/vserver/vci_config.h
23778 --- linux-3.6.10/kernel/vserver/vci_config.h 1970-01-01 01:00:00.000000000 +0100
23779 +++ linux-3.6.10-vs2.3.4.5/kernel/vserver/vci_config.h 2012-10-04 18:47:00.000000000 +0200
23782 +/* interface version */
23784 +#define VCI_VERSION 0x00020308
23788 + VCI_KCBIT_NO_DYNAMIC = 0,
23790 + VCI_KCBIT_PROC_SECURE = 4,
23791 + /* VCI_KCBIT_HARDCPU = 5, */
23792 + /* VCI_KCBIT_IDLELIMIT = 6, */
23793 + /* VCI_KCBIT_IDLETIME = 7, */
23795 + VCI_KCBIT_COWBL = 8,
23796 + VCI_KCBIT_FULLCOWBL = 9,
23797 + VCI_KCBIT_SPACES = 10,
23798 + VCI_KCBIT_NETV2 = 11,
23799 + VCI_KCBIT_MEMCG = 12,
23801 + VCI_KCBIT_DEBUG = 16,
23802 + VCI_KCBIT_HISTORY = 20,
23803 + VCI_KCBIT_TAGGED = 24,
23804 + VCI_KCBIT_PPTAG = 28,
23806 + VCI_KCBIT_MORE = 31,
23810 +static inline uint32_t vci_kernel_config(void)
23813 + (1 << VCI_KCBIT_NO_DYNAMIC) |
23815 + /* configured features */
23816 +#ifdef CONFIG_VSERVER_PROC_SECURE
23817 + (1 << VCI_KCBIT_PROC_SECURE) |
23819 +#ifdef CONFIG_VSERVER_COWBL
23820 + (1 << VCI_KCBIT_COWBL) |
23821 + (1 << VCI_KCBIT_FULLCOWBL) |
23823 + (1 << VCI_KCBIT_SPACES) |
23824 + (1 << VCI_KCBIT_NETV2) |
23825 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
23826 + (1 << VCI_KCBIT_MEMCG) |
23829 + /* debug options */
23830 +#ifdef CONFIG_VSERVER_DEBUG
23831 + (1 << VCI_KCBIT_DEBUG) |
23833 +#ifdef CONFIG_VSERVER_HISTORY
23834 + (1 << VCI_KCBIT_HISTORY) |
23837 + /* inode context tagging */
23838 +#if defined(CONFIG_TAGGING_NONE)
23839 + (0 << VCI_KCBIT_TAGGED) |
23840 +#elif defined(CONFIG_TAGGING_UID16)
23841 + (1 << VCI_KCBIT_TAGGED) |
23842 +#elif defined(CONFIG_TAGGING_GID16)
23843 + (2 << VCI_KCBIT_TAGGED) |
23844 +#elif defined(CONFIG_TAGGING_ID24)
23845 + (3 << VCI_KCBIT_TAGGED) |
23846 +#elif defined(CONFIG_TAGGING_INTERN)
23847 + (4 << VCI_KCBIT_TAGGED) |
23848 +#elif defined(CONFIG_TAGGING_RUNTIME)
23849 + (5 << VCI_KCBIT_TAGGED) |
23851 + (7 << VCI_KCBIT_TAGGED) |
23853 + (1 << VCI_KCBIT_PPTAG) |
23857 diff -NurpP --minimal linux-3.6.10/mm/memcontrol.c linux-3.6.10-vs2.3.4.5/mm/memcontrol.c
23858 --- linux-3.6.10/mm/memcontrol.c 2012-12-11 12:37:02.000000000 +0100
23859 +++ linux-3.6.10-vs2.3.4.5/mm/memcontrol.c 2012-12-08 01:36:33.000000000 +0100
23860 @@ -885,6 +885,31 @@ struct mem_cgroup *mem_cgroup_from_task(
23861 return mem_cgroup_from_css(task_subsys_state(p, mem_cgroup_subsys_id));
23864 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
23866 + return res_counter_read_u64(&mem->res, member);
23869 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
23871 + return res_counter_read_u64(&mem->memsw, member);
23874 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
23876 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE);
23879 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
23881 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS);
23884 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
23886 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_FILE_MAPPED);
23889 struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
23891 struct mem_cgroup *memcg = NULL;
23892 diff -NurpP --minimal linux-3.6.10/mm/oom_kill.c linux-3.6.10-vs2.3.4.5/mm/oom_kill.c
23893 --- linux-3.6.10/mm/oom_kill.c 2012-10-04 15:27:48.000000000 +0200
23894 +++ linux-3.6.10-vs2.3.4.5/mm/oom_kill.c 2012-10-04 18:53:46.000000000 +0200
23896 #include <linux/freezer.h>
23897 #include <linux/ftrace.h>
23898 #include <linux/ratelimit.h>
23899 +#include <linux/reboot.h>
23900 +#include <linux/vs_context.h>
23902 #define CREATE_TRACE_POINTS
23903 #include <trace/events/oom.h>
23904 @@ -155,11 +157,18 @@ struct task_struct *find_lock_task_mm(st
23905 static bool oom_unkillable_task(struct task_struct *p,
23906 const struct mem_cgroup *memcg, const nodemask_t *nodemask)
23908 - if (is_global_init(p))
23909 + unsigned xid = vx_current_xid();
23911 + /* skip the init task, global and per guest */
23912 + if (task_is_init(p))
23914 if (p->flags & PF_KTHREAD)
23917 + /* skip other guest and host processes if oom in guest */
23918 + if (xid && vx_task_xid(p) != xid)
23921 /* When mem_cgroup_out_of_memory() and p is not member of the group */
23922 if (memcg && !task_in_mem_cgroup(p, memcg))
23924 @@ -472,8 +481,8 @@ void oom_kill_process(struct task_struct
23925 dump_header(p, gfp_mask, order, memcg, nodemask);
23928 - pr_err("%s: Kill process %d (%s) score %d or sacrifice child\n",
23929 - message, task_pid_nr(p), p->comm, points);
23930 + pr_err("%s: Kill process %d:#%u (%s) score %d or sacrifice child\n",
23931 + message, task_pid_nr(p), p->xid, p->comm, points);
23935 @@ -518,8 +527,8 @@ void oom_kill_process(struct task_struct
23937 /* mm cannot safely be dereferenced after task_unlock(victim) */
23939 - pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
23940 - task_pid_nr(victim), victim->comm, K(victim->mm->total_vm),
23941 + pr_err("Killed process %d:#%u (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
23942 + task_pid_nr(victim), victim->xid, victim->comm, K(victim->mm->total_vm),
23943 K(get_mm_counter(victim->mm, MM_ANONPAGES)),
23944 K(get_mm_counter(victim->mm, MM_FILEPAGES)));
23945 task_unlock(victim);
23946 @@ -589,6 +598,8 @@ int unregister_oom_notifier(struct notif
23948 EXPORT_SYMBOL_GPL(unregister_oom_notifier);
23950 +long vs_oom_action(unsigned int);
23953 * Try to acquire the OOM killer lock for the zones in zonelist. Returns zero
23954 * if a parallel OOM killing is already taking place that includes a zone in
23955 @@ -738,7 +749,12 @@ void out_of_memory(struct zonelist *zone
23956 /* Found nothing?!?! Either we hang forever, or we panic. */
23958 dump_header(NULL, gfp_mask, order, NULL, mpol_mask);
23959 - panic("Out of memory and no killable processes...\n");
23961 + /* avoid panic for guest OOM */
23962 + if (current->xid)
23963 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
23965 + panic("Out of memory and no killable processes...\n");
23967 if (PTR_ERR(p) != -1UL) {
23968 oom_kill_process(p, gfp_mask, order, points, totalpages, NULL,
23969 diff -NurpP --minimal linux-3.6.10/mm/page_alloc.c linux-3.6.10-vs2.3.4.5/mm/page_alloc.c
23970 --- linux-3.6.10/mm/page_alloc.c 2012-12-11 12:37:02.000000000 +0100
23971 +++ linux-3.6.10-vs2.3.4.5/mm/page_alloc.c 2012-12-08 01:36:33.000000000 +0100
23973 #include <linux/prefetch.h>
23974 #include <linux/migrate.h>
23975 #include <linux/page-debug-flags.h>
23976 +#include <linux/vs_base.h>
23977 +#include <linux/vs_limit.h>
23979 #include <asm/tlbflush.h>
23980 #include <asm/div64.h>
23981 @@ -2773,6 +2775,9 @@ void si_meminfo(struct sysinfo *val)
23982 val->totalhigh = totalhigh_pages;
23983 val->freehigh = nr_free_highpages();
23984 val->mem_unit = PAGE_SIZE;
23986 + if (vx_flags(VXF_VIRT_MEM, 0))
23987 + vx_vsi_meminfo(val);
23990 EXPORT_SYMBOL(si_meminfo);
23991 @@ -2793,6 +2798,9 @@ void si_meminfo_node(struct sysinfo *val
23994 val->mem_unit = PAGE_SIZE;
23996 + if (vx_flags(VXF_VIRT_MEM, 0))
23997 + vx_vsi_meminfo(val);
24001 diff -NurpP --minimal linux-3.6.10/mm/pgtable-generic.c linux-3.6.10-vs2.3.4.5/mm/pgtable-generic.c
24002 --- linux-3.6.10/mm/pgtable-generic.c 2012-07-22 23:39:47.000000000 +0200
24003 +++ linux-3.6.10-vs2.3.4.5/mm/pgtable-generic.c 2012-10-04 18:47:00.000000000 +0200
24005 * Copyright (C) 2010 Linus Torvalds
24008 +#include <linux/mm.h>
24010 #include <linux/pagemap.h>
24011 #include <asm/tlb.h>
24012 #include <asm-generic/pgtable.h>
24013 diff -NurpP --minimal linux-3.6.10/mm/shmem.c linux-3.6.10-vs2.3.4.5/mm/shmem.c
24014 --- linux-3.6.10/mm/shmem.c 2012-12-11 12:37:02.000000000 +0100
24015 +++ linux-3.6.10-vs2.3.4.5/mm/shmem.c 2012-12-08 01:36:33.000000000 +0100
24016 @@ -1826,7 +1826,7 @@ static int shmem_statfs(struct dentry *d
24018 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
24020 - buf->f_type = TMPFS_MAGIC;
24021 + buf->f_type = TMPFS_SUPER_MAGIC;
24022 buf->f_bsize = PAGE_CACHE_SIZE;
24023 buf->f_namelen = NAME_MAX;
24024 if (sbinfo->max_blocks) {
24025 @@ -2644,7 +2644,7 @@ int shmem_fill_super(struct super_block
24026 sb->s_maxbytes = MAX_LFS_FILESIZE;
24027 sb->s_blocksize = PAGE_CACHE_SIZE;
24028 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
24029 - sb->s_magic = TMPFS_MAGIC;
24030 + sb->s_magic = TMPFS_SUPER_MAGIC;
24031 sb->s_op = &shmem_ops;
24032 sb->s_time_gran = 1;
24033 #ifdef CONFIG_TMPFS_XATTR
24034 diff -NurpP --minimal linux-3.6.10/mm/slab.c linux-3.6.10-vs2.3.4.5/mm/slab.c
24035 --- linux-3.6.10/mm/slab.c 2012-12-11 12:37:03.000000000 +0100
24036 +++ linux-3.6.10-vs2.3.4.5/mm/slab.c 2012-11-06 18:43:41.000000000 +0100
24037 @@ -445,6 +445,8 @@ static void kmem_list3_init(struct kmem_
24038 #define STATS_INC_FREEMISS(x) do { } while (0)
24041 +#include "slab_vs.h"
24046 @@ -3539,6 +3541,7 @@ retry:
24048 obj = slab_get_obj(cachep, slabp, nodeid);
24049 check_slabp(cachep, slabp);
24050 + vx_slab_alloc(cachep, flags);
24051 l3->free_objects--;
24052 /* move slabp to correct slabp list: */
24053 list_del(&slabp->list);
24054 @@ -3616,6 +3619,7 @@ __cache_alloc_node(struct kmem_cache *ca
24055 /* ___cache_alloc_node can fall back to other nodes */
24056 ptr = ____cache_alloc_node(cachep, flags, nodeid);
24058 + vx_slab_alloc(cachep, flags);
24059 local_irq_restore(save_flags);
24060 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
24061 kmemleak_alloc_recursive(ptr, cachep->object_size, 1, cachep->flags,
24062 @@ -3806,6 +3810,7 @@ static inline void __cache_free(struct k
24064 kmemleak_free_recursive(objp, cachep->flags);
24065 objp = cache_free_debugcheck(cachep, objp, caller);
24066 + vx_slab_free(cachep);
24068 kmemcheck_slab_free(cachep, objp, cachep->object_size);
24070 diff -NurpP --minimal linux-3.6.10/mm/slab_vs.h linux-3.6.10-vs2.3.4.5/mm/slab_vs.h
24071 --- linux-3.6.10/mm/slab_vs.h 1970-01-01 01:00:00.000000000 +0100
24072 +++ linux-3.6.10-vs2.3.4.5/mm/slab_vs.h 2012-10-09 16:28:11.000000000 +0200
24075 +#include <linux/vserver/context.h>
24077 +#include <linux/vs_context.h>
24080 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
24082 + int what = gfp_zone(cachep->allocflags);
24083 + struct vx_info *vxi = current_vx_info();
24088 + atomic_add(cachep->size, &vxi->cacct.slab[what]);
24092 +void vx_slab_free(struct kmem_cache *cachep)
24094 + int what = gfp_zone(cachep->allocflags);
24095 + struct vx_info *vxi = current_vx_info();
24100 + atomic_sub(cachep->size, &vxi->cacct.slab[what]);
24103 diff -NurpP --minimal linux-3.6.10/mm/swapfile.c linux-3.6.10-vs2.3.4.5/mm/swapfile.c
24104 --- linux-3.6.10/mm/swapfile.c 2012-10-04 15:27:48.000000000 +0200
24105 +++ linux-3.6.10-vs2.3.4.5/mm/swapfile.c 2012-10-04 18:47:00.000000000 +0200
24107 #include <asm/tlbflush.h>
24108 #include <linux/swapops.h>
24109 #include <linux/page_cgroup.h>
24110 +#include <linux/vs_base.h>
24112 static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
24114 @@ -1686,6 +1687,16 @@ static int swap_show(struct seq_file *sw
24116 if (si == SEQ_START_TOKEN) {
24117 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
24118 + if (vx_flags(VXF_VIRT_MEM, 0)) {
24119 + struct sysinfo si;
24121 + vx_vsi_swapinfo(&si);
24122 + if (si.totalswap < (1 << 10))
24124 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
24125 + "hdv0", "partition", si.totalswap >> 10,
24126 + (si.totalswap - si.freeswap) >> 10, -1);
24131 @@ -2113,6 +2124,8 @@ void si_swapinfo(struct sysinfo *val)
24132 val->freeswap = nr_swap_pages + nr_to_be_unused;
24133 val->totalswap = total_swap_pages + nr_to_be_unused;
24134 spin_unlock(&swap_lock);
24135 + if (vx_flags(VXF_VIRT_MEM, 0))
24136 + vx_vsi_swapinfo(val);
24140 diff -NurpP --minimal linux-3.6.10/net/bridge/br_multicast.c linux-3.6.10-vs2.3.4.5/net/bridge/br_multicast.c
24141 --- linux-3.6.10/net/bridge/br_multicast.c 2012-10-04 15:27:49.000000000 +0200
24142 +++ linux-3.6.10-vs2.3.4.5/net/bridge/br_multicast.c 2012-10-04 18:47:00.000000000 +0200
24143 @@ -447,7 +447,7 @@ static struct sk_buff *br_ip6_multicast_
24144 ip6h->hop_limit = 1;
24145 ipv6_addr_set(&ip6h->daddr, htonl(0xff020000), 0, 0, htonl(1));
24146 if (ipv6_dev_get_saddr(dev_net(br->dev), br->dev, &ip6h->daddr, 0,
24148 + &ip6h->saddr, NULL)) {
24152 diff -NurpP --minimal linux-3.6.10/net/core/dev.c linux-3.6.10-vs2.3.4.5/net/core/dev.c
24153 --- linux-3.6.10/net/core/dev.c 2012-12-11 12:37:03.000000000 +0100
24154 +++ linux-3.6.10-vs2.3.4.5/net/core/dev.c 2012-12-08 01:36:33.000000000 +0100
24155 @@ -126,6 +126,7 @@
24156 #include <linux/in.h>
24157 #include <linux/jhash.h>
24158 #include <linux/random.h>
24159 +#include <linux/vs_inet.h>
24160 #include <trace/events/napi.h>
24161 #include <trace/events/net.h>
24162 #include <trace/events/skb.h>
24163 @@ -620,7 +621,8 @@ struct net_device *__dev_get_by_name(str
24164 struct hlist_head *head = dev_name_hash(net, name);
24166 hlist_for_each_entry(dev, p, head, name_hlist)
24167 - if (!strncmp(dev->name, name, IFNAMSIZ))
24168 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24169 + nx_dev_visible(current_nx_info(), dev))
24173 @@ -646,7 +648,8 @@ struct net_device *dev_get_by_name_rcu(s
24174 struct hlist_head *head = dev_name_hash(net, name);
24176 hlist_for_each_entry_rcu(dev, p, head, name_hlist)
24177 - if (!strncmp(dev->name, name, IFNAMSIZ))
24178 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24179 + nx_dev_visible(current_nx_info(), dev))
24183 @@ -697,7 +700,8 @@ struct net_device *__dev_get_by_index(st
24184 struct hlist_head *head = dev_index_hash(net, ifindex);
24186 hlist_for_each_entry(dev, p, head, index_hlist)
24187 - if (dev->ifindex == ifindex)
24188 + if ((dev->ifindex == ifindex) &&
24189 + nx_dev_visible(current_nx_info(), dev))
24193 @@ -715,7 +719,7 @@ EXPORT_SYMBOL(__dev_get_by_index);
24194 * about locking. The caller must hold RCU lock.
24197 -struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
24198 +struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex)
24200 struct hlist_node *p;
24201 struct net_device *dev;
24202 @@ -727,6 +731,16 @@ struct net_device *dev_get_by_index_rcu(
24206 +EXPORT_SYMBOL(dev_get_by_index_real_rcu);
24208 +struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
24210 + struct net_device *dev = dev_get_by_index_real_rcu(net, ifindex);
24212 + if (nx_dev_visible(current_nx_info(), dev))
24216 EXPORT_SYMBOL(dev_get_by_index_rcu);
24219 @@ -775,7 +789,8 @@ struct net_device *dev_getbyhwaddr_rcu(s
24221 for_each_netdev_rcu(net, dev)
24222 if (dev->type == type &&
24223 - !memcmp(dev->dev_addr, ha, dev->addr_len))
24224 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
24225 + nx_dev_visible(current_nx_info(), dev))
24229 @@ -787,9 +802,11 @@ struct net_device *__dev_getfirstbyhwtyp
24230 struct net_device *dev;
24233 - for_each_netdev(net, dev)
24234 - if (dev->type == type)
24235 + for_each_netdev(net, dev) {
24236 + if ((dev->type == type) &&
24237 + nx_dev_visible(current_nx_info(), dev))
24243 @@ -907,6 +924,8 @@ static int __dev_alloc_name(struct net *
24245 if (i < 0 || i >= max_netdevices)
24247 + if (!nx_dev_visible(current_nx_info(), d))
24250 /* avoid cases where sscanf is not exact inverse of printf */
24251 snprintf(buf, IFNAMSIZ, name, i);
24252 @@ -4076,6 +4095,8 @@ static int dev_ifconf(struct net *net, c
24255 for_each_netdev(net, dev) {
24256 + if (!nx_dev_visible(current_nx_info(), dev))
24258 for (i = 0; i < NPROTO; i++) {
24259 if (gifconf_list[i]) {
24261 @@ -4178,6 +4199,10 @@ static void dev_seq_printf_stats(struct
24262 struct rtnl_link_stats64 temp;
24263 const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
24265 + /* device visible inside network context? */
24266 + if (!nx_dev_visible(current_nx_info(), dev))
24269 seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
24270 "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
24271 dev->name, stats->rx_bytes, stats->rx_packets,
24272 diff -NurpP --minimal linux-3.6.10/net/core/rtnetlink.c linux-3.6.10-vs2.3.4.5/net/core/rtnetlink.c
24273 --- linux-3.6.10/net/core/rtnetlink.c 2012-10-04 15:27:49.000000000 +0200
24274 +++ linux-3.6.10-vs2.3.4.5/net/core/rtnetlink.c 2012-10-04 18:47:00.000000000 +0200
24275 @@ -1080,6 +1080,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
24276 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
24279 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
24281 if (rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
24282 NETLINK_CB(cb->skb).pid,
24283 cb->nlh->nlmsg_seq, 0,
24284 @@ -1969,6 +1971,9 @@ void rtmsg_ifinfo(int type, struct net_d
24285 int err = -ENOBUFS;
24286 size_t if_info_size;
24288 + if (!nx_dev_visible(current_nx_info(), dev))
24291 skb = nlmsg_new((if_info_size = if_nlmsg_size(dev, 0)), GFP_KERNEL);
24294 diff -NurpP --minimal linux-3.6.10/net/core/sock.c linux-3.6.10-vs2.3.4.5/net/core/sock.c
24295 --- linux-3.6.10/net/core/sock.c 2012-10-04 15:27:49.000000000 +0200
24296 +++ linux-3.6.10-vs2.3.4.5/net/core/sock.c 2012-10-04 18:47:00.000000000 +0200
24297 @@ -132,6 +132,10 @@
24298 #include <net/netprio_cgroup.h>
24300 #include <linux/filter.h>
24301 +#include <linux/vs_socket.h>
24302 +#include <linux/vs_limit.h>
24303 +#include <linux/vs_context.h>
24304 +#include <linux/vs_network.h>
24306 #include <trace/events/sock.h>
24308 @@ -1194,6 +1198,8 @@ static struct sock *sk_prot_alloc(struct
24310 sk_tx_queue_clear(sk);
24312 + sock_vx_init(sk);
24313 + sock_nx_init(sk);
24317 @@ -1302,6 +1308,11 @@ static void __sk_free(struct sock *sk)
24318 put_cred(sk->sk_peer_cred);
24319 put_pid(sk->sk_peer_pid);
24320 put_net(sock_net(sk));
24322 + clr_vx_info(&sk->sk_vx_info);
24324 + clr_nx_info(&sk->sk_nx_info);
24326 sk_prot_free(sk->sk_prot_creator, sk);
24329 @@ -1362,6 +1373,8 @@ struct sock *sk_clone_lock(const struct
24332 get_net(sock_net(newsk));
24333 + sock_vx_init(newsk);
24334 + sock_nx_init(newsk);
24335 sk_node_init(&newsk->sk_node);
24336 sock_lock_init(newsk);
24337 bh_lock_sock(newsk);
24338 @@ -1418,6 +1431,12 @@ struct sock *sk_clone_lock(const struct
24340 atomic_set(&newsk->sk_refcnt, 2);
24342 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
24343 + newsk->sk_xid = sk->sk_xid;
24344 + vx_sock_inc(newsk);
24345 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
24346 + newsk->sk_nid = sk->sk_nid;
24349 * Increment the counter in the same struct proto as the master
24350 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
24351 @@ -2187,6 +2206,12 @@ void sock_init_data(struct socket *sock,
24353 sk->sk_stamp = ktime_set(-1L, 0);
24355 + set_vx_info(&sk->sk_vx_info, current_vx_info());
24356 + sk->sk_xid = vx_current_xid();
24358 + set_nx_info(&sk->sk_nx_info, current_nx_info());
24359 + sk->sk_nid = nx_current_nid();
24362 * Before updating sk_refcnt, we must commit prior changes to memory
24363 * (Documentation/RCU/rculist_nulls.txt for details)
24364 diff -NurpP --minimal linux-3.6.10/net/ipv4/af_inet.c linux-3.6.10-vs2.3.4.5/net/ipv4/af_inet.c
24365 --- linux-3.6.10/net/ipv4/af_inet.c 2012-10-04 15:27:49.000000000 +0200
24366 +++ linux-3.6.10-vs2.3.4.5/net/ipv4/af_inet.c 2012-10-04 18:47:00.000000000 +0200
24367 @@ -118,6 +118,7 @@
24368 #ifdef CONFIG_IP_MROUTE
24369 #include <linux/mroute.h>
24371 +#include <linux/vs_limit.h>
24374 /* The inetsw table contains everything that inet_create needs to
24375 @@ -326,9 +327,13 @@ lookup_protocol:
24379 + if ((protocol == IPPROTO_ICMP) &&
24380 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
24383 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
24384 goto out_rcu_unlock;
24387 err = -EAFNOSUPPORT;
24388 if (!inet_netns_ok(net, protocol))
24389 goto out_rcu_unlock;
24390 @@ -453,6 +458,7 @@ int inet_bind(struct socket *sock, struc
24391 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
24392 struct sock *sk = sock->sk;
24393 struct inet_sock *inet = inet_sk(sk);
24394 + struct nx_v4_sock_addr nsa;
24395 unsigned short snum;
24398 @@ -476,7 +482,11 @@ int inet_bind(struct socket *sock, struc
24402 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
24403 + err = v4_map_sock_addr(inet, addr, &nsa);
24407 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
24409 /* Not specified by any standard per-se, however it breaks too
24410 * many applications when removed. It is unfortunate since
24411 @@ -488,7 +498,7 @@ int inet_bind(struct socket *sock, struc
24412 err = -EADDRNOTAVAIL;
24413 if (!sysctl_ip_nonlocal_bind &&
24414 !(inet->freebind || inet->transparent) &&
24415 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
24416 + nsa.saddr != htonl(INADDR_ANY) &&
24417 chk_addr_ret != RTN_LOCAL &&
24418 chk_addr_ret != RTN_MULTICAST &&
24419 chk_addr_ret != RTN_BROADCAST)
24420 @@ -513,7 +523,7 @@ int inet_bind(struct socket *sock, struc
24421 if (sk->sk_state != TCP_CLOSE || inet->inet_num)
24422 goto out_release_sock;
24424 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24425 + v4_set_sock_addr(inet, &nsa);
24426 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24427 inet->inet_saddr = 0; /* Use device */
24429 @@ -731,11 +741,13 @@ int inet_getname(struct socket *sock, st
24432 sin->sin_port = inet->inet_dport;
24433 - sin->sin_addr.s_addr = inet->inet_daddr;
24434 + sin->sin_addr.s_addr =
24435 + nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
24437 __be32 addr = inet->inet_rcv_saddr;
24439 addr = inet->inet_saddr;
24440 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
24441 sin->sin_port = inet->inet_sport;
24442 sin->sin_addr.s_addr = addr;
24444 diff -NurpP --minimal linux-3.6.10/net/ipv4/arp.c linux-3.6.10-vs2.3.4.5/net/ipv4/arp.c
24445 --- linux-3.6.10/net/ipv4/arp.c 2012-10-04 15:27:49.000000000 +0200
24446 +++ linux-3.6.10-vs2.3.4.5/net/ipv4/arp.c 2012-10-04 18:47:00.000000000 +0200
24447 @@ -1318,6 +1318,7 @@ static void arp_format_neigh_entry(struc
24448 struct net_device *dev = n->dev;
24449 int hatype = dev->type;
24451 + /* FIXME: check for network context */
24452 read_lock(&n->lock);
24453 /* Convert hardware address to XX:XX:XX:XX ... form. */
24454 #if IS_ENABLED(CONFIG_AX25)
24455 @@ -1349,6 +1350,7 @@ static void arp_format_pneigh_entry(stru
24456 int hatype = dev ? dev->type : 0;
24459 + /* FIXME: check for network context */
24460 sprintf(tbuf, "%pI4", n->key);
24461 seq_printf(seq, "%-16s 0x%-10x0x%-10x%s * %s\n",
24462 tbuf, hatype, ATF_PUBL | ATF_PERM, "00:00:00:00:00:00",
24463 diff -NurpP --minimal linux-3.6.10/net/ipv4/devinet.c linux-3.6.10-vs2.3.4.5/net/ipv4/devinet.c
24464 --- linux-3.6.10/net/ipv4/devinet.c 2012-10-04 15:27:49.000000000 +0200
24465 +++ linux-3.6.10-vs2.3.4.5/net/ipv4/devinet.c 2012-10-04 18:47:00.000000000 +0200
24466 @@ -516,6 +516,7 @@ struct in_device *inetdev_by_index(struc
24468 EXPORT_SYMBOL(inetdev_by_index);
24471 /* Called only from RTNL semaphored context. No locks. */
24473 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
24474 @@ -757,6 +758,8 @@ int devinet_ioctl(struct net *net, unsig
24476 in_dev = __in_dev_get_rtnl(dev);
24478 + struct nx_info *nxi = current_nx_info();
24480 if (tryaddrmatch) {
24481 /* Matthias Andree */
24482 /* compare label and address (4.4BSD style) */
24483 @@ -765,6 +768,8 @@ int devinet_ioctl(struct net *net, unsig
24484 This is checked above. */
24485 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24486 ifap = &ifa->ifa_next) {
24487 + if (!nx_v4_ifa_visible(nxi, ifa))
24489 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
24490 sin_orig.sin_addr.s_addr ==
24492 @@ -777,9 +782,12 @@ int devinet_ioctl(struct net *net, unsig
24493 comparing just the label */
24495 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24496 - ifap = &ifa->ifa_next)
24497 + ifap = &ifa->ifa_next) {
24498 + if (!nx_v4_ifa_visible(nxi, ifa))
24500 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
24506 @@ -932,6 +940,8 @@ static int inet_gifconf(struct net_devic
24509 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
24510 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
24513 done += sizeof(ifr);
24515 @@ -1291,6 +1301,7 @@ static int inet_dump_ifaddr(struct sk_bu
24516 struct net_device *dev;
24517 struct in_device *in_dev;
24518 struct in_ifaddr *ifa;
24519 + struct sock *sk = skb->sk;
24520 struct hlist_head *head;
24521 struct hlist_node *node;
24523 @@ -1313,6 +1324,8 @@ static int inet_dump_ifaddr(struct sk_bu
24525 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
24526 ifa = ifa->ifa_next, ip_idx++) {
24527 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
24529 if (ip_idx < s_ip_idx)
24531 if (inet_fill_ifaddr(skb, ifa,
24532 diff -NurpP --minimal linux-3.6.10/net/ipv4/fib_trie.c linux-3.6.10-vs2.3.4.5/net/ipv4/fib_trie.c
24533 --- linux-3.6.10/net/ipv4/fib_trie.c 2012-10-04 15:27:49.000000000 +0200
24534 +++ linux-3.6.10-vs2.3.4.5/net/ipv4/fib_trie.c 2012-10-04 18:47:00.000000000 +0200
24535 @@ -2554,6 +2554,7 @@ static int fib_route_seq_show(struct seq
24536 || fa->fa_type == RTN_MULTICAST)
24539 + /* FIXME: check for network context? */
24542 "%s\t%08X\t%08X\t%04X\t%d\t%u\t"
24543 diff -NurpP --minimal linux-3.6.10/net/ipv4/inet_connection_sock.c linux-3.6.10-vs2.3.4.5/net/ipv4/inet_connection_sock.c
24544 --- linux-3.6.10/net/ipv4/inet_connection_sock.c 2012-12-11 12:37:03.000000000 +0100
24545 +++ linux-3.6.10-vs2.3.4.5/net/ipv4/inet_connection_sock.c 2012-11-06 18:43:41.000000000 +0100
24546 @@ -53,6 +53,37 @@ void inet_get_local_port_range(int *low,
24548 EXPORT_SYMBOL(inet_get_local_port_range);
24550 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
24552 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1),
24553 + sk2_rcv_saddr = sk_rcv_saddr(sk2);
24555 + if (inet_v6_ipv6only(sk2))
24558 + if (sk1_rcv_saddr &&
24560 + sk1_rcv_saddr == sk2_rcv_saddr)
24563 + if (sk1_rcv_saddr &&
24564 + !sk2_rcv_saddr &&
24565 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
24568 + if (sk2_rcv_saddr &&
24569 + !sk1_rcv_saddr &&
24570 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
24573 + if (!sk1_rcv_saddr &&
24574 + !sk2_rcv_saddr &&
24575 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
24581 int inet_csk_bind_conflict(const struct sock *sk,
24582 const struct inet_bind_bucket *tb, bool relax)
24584 @@ -75,9 +106,7 @@ int inet_csk_bind_conflict(const struct
24585 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
24586 if (!reuse || !sk2->sk_reuse ||
24587 sk2->sk_state == TCP_LISTEN) {
24588 - const __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
24589 - if (!sk2_rcv_saddr || !sk_rcv_saddr(sk) ||
24590 - sk2_rcv_saddr == sk_rcv_saddr(sk))
24591 + if (ipv4_rcv_saddr_equal(sk, sk2))
24594 if (!relax && reuse && sk2->sk_reuse &&
24595 diff -NurpP --minimal linux-3.6.10/net/ipv4/inet_diag.c linux-3.6.10-vs2.3.4.5/net/ipv4/inet_diag.c
24596 --- linux-3.6.10/net/ipv4/inet_diag.c 2012-12-11 12:37:03.000000000 +0100
24597 +++ linux-3.6.10-vs2.3.4.5/net/ipv4/inet_diag.c 2012-12-08 01:36:33.000000000 +0100
24600 #include <linux/inet.h>
24601 #include <linux/stddef.h>
24602 +#include <linux/vs_network.h>
24603 +#include <linux/vs_inet.h>
24605 #include <linux/inet_diag.h>
24606 #include <linux/sock_diag.h>
24607 @@ -101,8 +103,10 @@ int inet_sk_diag_fill(struct sock *sk, s
24609 r->id.idiag_sport = inet->inet_sport;
24610 r->id.idiag_dport = inet->inet_dport;
24611 - r->id.idiag_src[0] = inet->inet_rcv_saddr;
24612 - r->id.idiag_dst[0] = inet->inet_daddr;
24613 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
24614 + inet->inet_rcv_saddr);
24615 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
24616 + inet->inet_daddr);
24618 /* IPv6 dual-stack sockets use inet->tos for IPv4 connections,
24619 * hence this needs to be included regardless of socket family.
24620 @@ -233,8 +237,8 @@ static int inet_twsk_diag_fill(struct in
24621 sock_diag_save_cookie(tw, r->id.idiag_cookie);
24622 r->id.idiag_sport = tw->tw_sport;
24623 r->id.idiag_dport = tw->tw_dport;
24624 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
24625 - r->id.idiag_dst[0] = tw->tw_daddr;
24626 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
24627 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
24628 r->idiag_state = tw->tw_substate;
24629 r->idiag_timer = 3;
24630 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
24631 @@ -276,12 +280,14 @@ int inet_diag_dump_one_icsk(struct inet_
24634 if (req->sdiag_family == AF_INET) {
24635 + /* TODO: lback */
24636 sk = inet_lookup(net, hashinfo, req->id.idiag_dst[0],
24637 req->id.idiag_dport, req->id.idiag_src[0],
24638 req->id.idiag_sport, req->id.idiag_if);
24640 #if IS_ENABLED(CONFIG_IPV6)
24641 else if (req->sdiag_family == AF_INET6) {
24642 + /* TODO: lback */
24643 sk = inet6_lookup(net, hashinfo,
24644 (struct in6_addr *)req->id.idiag_dst,
24645 req->id.idiag_dport,
24646 @@ -476,6 +482,7 @@ int inet_diag_bc_sk(const struct nlattr
24650 + /* TODO: lback */
24651 entry.saddr = &inet->inet_rcv_saddr;
24652 entry.daddr = &inet->inet_daddr;
24654 @@ -574,6 +581,7 @@ static int inet_twsk_diag_dump(struct in
24658 + /* TODO: lback */
24659 entry.saddr = &tw->tw_rcv_saddr;
24660 entry.daddr = &tw->tw_daddr;
24662 @@ -620,8 +628,8 @@ static int inet_diag_fill_req(struct sk_
24664 r->id.idiag_sport = inet->inet_sport;
24665 r->id.idiag_dport = ireq->rmt_port;
24666 - r->id.idiag_src[0] = ireq->loc_addr;
24667 - r->id.idiag_dst[0] = ireq->rmt_addr;
24668 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
24669 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
24670 r->idiag_expires = jiffies_to_msecs(tmo);
24671 r->idiag_rqueue = 0;
24672 r->idiag_wqueue = 0;
24673 @@ -683,6 +691,7 @@ static int inet_diag_dump_reqs(struct sk
24677 + /* TODO: lback */
24679 #if IS_ENABLED(CONFIG_IPV6)
24680 (entry.family == AF_INET6) ?
24681 @@ -748,6 +757,8 @@ void inet_diag_dump_icsk(struct inet_has
24682 if (!net_eq(sock_net(sk), net))
24685 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24690 @@ -820,6 +831,8 @@ skip_listen_ht:
24692 if (!net_eq(sock_net(sk), net))
24694 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24698 if (!(r->idiag_states & (1 << sk->sk_state)))
24699 @@ -848,7 +861,8 @@ next_normal:
24701 if (!net_eq(twsk_net(tw), net))
24704 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
24708 if (r->sdiag_family != AF_UNSPEC &&
24709 diff -NurpP --minimal linux-3.6.10/net/ipv4/inet_hashtables.c linux-3.6.10-vs2.3.4.5/net/ipv4/inet_hashtables.c
24710 --- linux-3.6.10/net/ipv4/inet_hashtables.c 2012-07-22 23:39:48.000000000 +0200
24711 +++ linux-3.6.10-vs2.3.4.5/net/ipv4/inet_hashtables.c 2012-10-04 18:47:00.000000000 +0200
24713 #include <net/inet_connection_sock.h>
24714 #include <net/inet_hashtables.h>
24715 #include <net/secure_seq.h>
24716 +#include <net/route.h>
24717 #include <net/ip.h>
24720 @@ -156,6 +157,11 @@ static inline int compute_score(struct s
24721 if (rcv_saddr != daddr)
24725 + /* block non nx_info ips */
24726 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
24727 + daddr, NXA_MASK_BIND))
24730 if (sk->sk_bound_dev_if) {
24731 if (sk->sk_bound_dev_if != dif)
24732 @@ -173,7 +179,6 @@ static inline int compute_score(struct s
24733 * wildcarded during the search since they can never be otherwise.
24737 struct sock *__inet_lookup_listener(struct net *net,
24738 struct inet_hashinfo *hashinfo,
24739 const __be32 daddr, const unsigned short hnum,
24740 @@ -196,6 +201,7 @@ begin:
24746 * if the nulls value we got at the end of this lookup is
24747 * not the expected one, we must restart lookup.
24748 diff -NurpP --minimal linux-3.6.10/net/ipv4/netfilter/nf_nat_helper.c linux-3.6.10-vs2.3.4.5/net/ipv4/netfilter/nf_nat_helper.c
24749 --- linux-3.6.10/net/ipv4/netfilter/nf_nat_helper.c 2012-10-04 15:27:50.000000000 +0200
24750 +++ linux-3.6.10-vs2.3.4.5/net/ipv4/netfilter/nf_nat_helper.c 2012-10-04 18:47:00.000000000 +0200
24752 #include <net/route.h>
24754 #include <linux/netfilter_ipv4.h>
24755 +#include <net/route.h>
24756 #include <net/netfilter/nf_conntrack.h>
24757 #include <net/netfilter/nf_conntrack_helper.h>
24758 #include <net/netfilter/nf_conntrack_ecache.h>
24759 diff -NurpP --minimal linux-3.6.10/net/ipv4/netfilter.c linux-3.6.10-vs2.3.4.5/net/ipv4/netfilter.c
24760 --- linux-3.6.10/net/ipv4/netfilter.c 2012-07-22 23:39:48.000000000 +0200
24761 +++ linux-3.6.10-vs2.3.4.5/net/ipv4/netfilter.c 2012-10-04 18:47:00.000000000 +0200
24763 #include <linux/skbuff.h>
24764 #include <linux/gfp.h>
24765 #include <linux/export.h>
24766 -#include <net/route.h>
24767 +// #include <net/route.h>
24768 #include <net/xfrm.h>
24769 #include <net/ip.h>
24770 #include <net/netfilter/nf_queue.h>
24771 diff -NurpP --minimal linux-3.6.10/net/ipv4/raw.c linux-3.6.10-vs2.3.4.5/net/ipv4/raw.c
24772 --- linux-3.6.10/net/ipv4/raw.c 2012-10-04 15:27:50.000000000 +0200
24773 +++ linux-3.6.10-vs2.3.4.5/net/ipv4/raw.c 2012-10-04 18:47:00.000000000 +0200
24774 @@ -118,7 +118,7 @@ static struct sock *__raw_v4_lookup(stru
24776 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
24777 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
24778 - !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
24779 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
24780 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
24781 goto found; /* gotcha */
24783 @@ -397,6 +397,12 @@ static int raw_send_hdrinc(struct sock *
24784 icmp_out_count(net, ((struct icmphdr *)
24785 skb_transport_header(skb))->type);
24788 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
24789 + sk->sk_nx_info &&
24790 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
24793 err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL,
24794 rt->dst.dev, dst_output);
24796 @@ -582,6 +588,16 @@ static int raw_sendmsg(struct kiocb *ioc
24800 + if (sk->sk_nx_info) {
24801 + rt = ip_v4_find_src(sock_net(sk), sk->sk_nx_info, &fl4);
24802 + if (IS_ERR(rt)) {
24803 + err = PTR_ERR(rt);
24810 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4));
24811 rt = ip_route_output_flow(sock_net(sk), &fl4, sk);
24813 @@ -658,17 +674,19 @@ static int raw_bind(struct sock *sk, str
24815 struct inet_sock *inet = inet_sk(sk);
24816 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
24817 + struct nx_v4_sock_addr nsa = { 0 };
24821 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
24823 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
24824 + v4_map_sock_addr(inet, addr, &nsa);
24825 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
24826 ret = -EADDRNOTAVAIL;
24827 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
24828 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
24829 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
24831 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24832 + v4_set_sock_addr(inet, &nsa);
24833 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24834 inet->inet_saddr = 0; /* Use device */
24836 @@ -720,7 +738,8 @@ static int raw_recvmsg(struct kiocb *ioc
24837 /* Copy the address. */
24839 sin->sin_family = AF_INET;
24840 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
24841 + sin->sin_addr.s_addr =
24842 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
24844 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
24846 @@ -916,7 +935,8 @@ static struct sock *raw_get_first(struct
24847 struct hlist_node *node;
24849 sk_for_each(sk, node, &state->h->ht[state->bucket])
24850 - if (sock_net(sk) == seq_file_net(seq))
24851 + if ((sock_net(sk) == seq_file_net(seq)) &&
24852 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24856 @@ -932,7 +952,8 @@ static struct sock *raw_get_next(struct
24860 - } while (sk && sock_net(sk) != seq_file_net(seq));
24861 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
24862 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
24864 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
24865 sk = sk_head(&state->h->ht[state->bucket]);
24866 diff -NurpP --minimal linux-3.6.10/net/ipv4/route.c linux-3.6.10-vs2.3.4.5/net/ipv4/route.c
24867 --- linux-3.6.10/net/ipv4/route.c 2012-12-11 12:37:03.000000000 +0100
24868 +++ linux-3.6.10-vs2.3.4.5/net/ipv4/route.c 2012-12-08 01:36:33.000000000 +0100
24869 @@ -1949,7 +1949,7 @@ struct rtable *__ip_route_output_key(str
24872 if (fl4->flowi4_oif) {
24873 - dev_out = dev_get_by_index_rcu(net, fl4->flowi4_oif);
24874 + dev_out = dev_get_by_index_real_rcu(net, fl4->flowi4_oif);
24875 rth = ERR_PTR(-ENODEV);
24876 if (dev_out == NULL)
24878 diff -NurpP --minimal linux-3.6.10/net/ipv4/tcp.c linux-3.6.10-vs2.3.4.5/net/ipv4/tcp.c
24879 --- linux-3.6.10/net/ipv4/tcp.c 2012-12-11 12:37:03.000000000 +0100
24880 +++ linux-3.6.10-vs2.3.4.5/net/ipv4/tcp.c 2012-12-08 01:36:33.000000000 +0100
24881 @@ -268,6 +268,7 @@
24882 #include <linux/crypto.h>
24883 #include <linux/time.h>
24884 #include <linux/slab.h>
24885 +#include <linux/in.h>
24887 #include <net/icmp.h>
24888 #include <net/inet_common.h>
24889 diff -NurpP --minimal linux-3.6.10/net/ipv4/tcp_ipv4.c linux-3.6.10-vs2.3.4.5/net/ipv4/tcp_ipv4.c
24890 --- linux-3.6.10/net/ipv4/tcp_ipv4.c 2012-12-11 12:37:03.000000000 +0100
24891 +++ linux-3.6.10-vs2.3.4.5/net/ipv4/tcp_ipv4.c 2012-11-06 18:43:41.000000000 +0100
24892 @@ -2034,6 +2034,12 @@ static void *listening_get_next(struct s
24893 req = req->dl_next;
24896 + vxdprintk(VXD_CBIT(net, 6),
24897 + "sk,req: %p [#%d] (from %d)", req->sk,
24898 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
24900 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
24902 if (req->rsk_ops->family == st->family) {
24905 @@ -2058,6 +2064,10 @@ get_req:
24908 sk_nulls_for_each_from(sk, node) {
24909 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
24910 + sk, sk->sk_nid, nx_current_nid());
24911 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24913 if (!net_eq(sock_net(sk), net))
24915 if (sk->sk_family == st->family) {
24916 @@ -2134,6 +2144,11 @@ static void *established_get_first(struc
24918 spin_lock_bh(lock);
24919 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
24920 + vxdprintk(VXD_CBIT(net, 6),
24921 + "sk,egf: %p [#%d] (from %d)",
24922 + sk, sk->sk_nid, nx_current_nid());
24923 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24925 if (sk->sk_family != st->family ||
24926 !net_eq(sock_net(sk), net)) {
24928 @@ -2144,6 +2159,11 @@ static void *established_get_first(struc
24929 st->state = TCP_SEQ_STATE_TIME_WAIT;
24930 inet_twsk_for_each(tw, node,
24931 &tcp_hashinfo.ehash[st->bucket].twchain) {
24932 + vxdprintk(VXD_CBIT(net, 6),
24933 + "tw: %p [#%d] (from %d)",
24934 + tw, tw->tw_nid, nx_current_nid());
24935 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
24937 if (tw->tw_family != st->family ||
24938 !net_eq(twsk_net(tw), net)) {
24940 @@ -2173,7 +2193,9 @@ static void *established_get_next(struct
24944 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
24945 + while (tw && (tw->tw_family != st->family ||
24946 + !net_eq(twsk_net(tw), net) ||
24947 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
24951 @@ -2197,6 +2219,11 @@ get_tw:
24952 sk = sk_nulls_next(sk);
24954 sk_nulls_for_each_from(sk, node) {
24955 + vxdprintk(VXD_CBIT(net, 6),
24956 + "sk,egn: %p [#%d] (from %d)",
24957 + sk, sk->sk_nid, nx_current_nid());
24958 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24960 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
24963 @@ -2402,9 +2429,9 @@ static void get_openreq4(const struct so
24964 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
24965 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %pK%n",
24968 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
24969 ntohs(inet_sk(sk)->inet_sport),
24971 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
24972 ntohs(ireq->rmt_port),
24974 0, 0, /* could print option size, but that is af dependent. */
24975 @@ -2426,8 +2453,8 @@ static void get_tcp4_sock(struct sock *s
24976 const struct tcp_sock *tp = tcp_sk(sk);
24977 const struct inet_connection_sock *icsk = inet_csk(sk);
24978 const struct inet_sock *inet = inet_sk(sk);
24979 - __be32 dest = inet->inet_daddr;
24980 - __be32 src = inet->inet_rcv_saddr;
24981 + __be32 dest = nx_map_sock_lback(current_nx_info(), inet->inet_daddr);
24982 + __be32 src = nx_map_sock_lback(current_nx_info(), inet->inet_rcv_saddr);
24983 __u16 destp = ntohs(inet->inet_dport);
24984 __u16 srcp = ntohs(inet->inet_sport);
24986 @@ -2484,8 +2511,8 @@ static void get_timewait4_sock(const str
24990 - dest = tw->tw_daddr;
24991 - src = tw->tw_rcv_saddr;
24992 + dest = nx_map_sock_lback(current_nx_info(), tw->tw_daddr);
24993 + src = nx_map_sock_lback(current_nx_info(), tw->tw_rcv_saddr);
24994 destp = ntohs(tw->tw_dport);
24995 srcp = ntohs(tw->tw_sport);
24997 diff -NurpP --minimal linux-3.6.10/net/ipv4/tcp_minisocks.c linux-3.6.10-vs2.3.4.5/net/ipv4/tcp_minisocks.c
24998 --- linux-3.6.10/net/ipv4/tcp_minisocks.c 2012-10-04 15:27:50.000000000 +0200
24999 +++ linux-3.6.10-vs2.3.4.5/net/ipv4/tcp_minisocks.c 2012-10-04 18:47:00.000000000 +0200
25001 #include <linux/slab.h>
25002 #include <linux/sysctl.h>
25003 #include <linux/workqueue.h>
25004 +#include <linux/vs_limit.h>
25005 +#include <linux/vs_socket.h>
25006 +#include <linux/vs_context.h>
25007 #include <net/tcp.h>
25008 #include <net/inet_common.h>
25009 #include <net/xfrm.h>
25010 @@ -287,6 +290,11 @@ void tcp_time_wait(struct sock *sk, int
25011 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
25012 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
25014 + tw->tw_xid = sk->sk_xid;
25015 + tw->tw_vx_info = NULL;
25016 + tw->tw_nid = sk->sk_nid;
25017 + tw->tw_nx_info = NULL;
25019 #if IS_ENABLED(CONFIG_IPV6)
25020 if (tw->tw_family == PF_INET6) {
25021 struct ipv6_pinfo *np = inet6_sk(sk);
25022 diff -NurpP --minimal linux-3.6.10/net/ipv4/udp.c linux-3.6.10-vs2.3.4.5/net/ipv4/udp.c
25023 --- linux-3.6.10/net/ipv4/udp.c 2012-10-04 15:27:50.000000000 +0200
25024 +++ linux-3.6.10-vs2.3.4.5/net/ipv4/udp.c 2012-10-04 18:47:00.000000000 +0200
25025 @@ -300,14 +300,7 @@ fail:
25027 EXPORT_SYMBOL(udp_lib_get_port);
25029 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25031 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
25033 - return (!ipv6_only_sock(sk2) &&
25034 - (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
25035 - inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
25037 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
25039 static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
25041 @@ -342,6 +335,11 @@ static inline int compute_score(struct s
25042 if (inet->inet_rcv_saddr != daddr)
25046 + /* block non nx_info ips */
25047 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
25048 + daddr, NXA_MASK_BIND))
25051 if (inet->inet_daddr) {
25052 if (inet->inet_daddr != saddr)
25053 @@ -445,6 +443,7 @@ exact_match:
25058 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
25059 * harder than this. -DaveM
25061 @@ -490,6 +489,11 @@ begin:
25062 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
25063 score = compute_score(sk, net, saddr, hnum, sport,
25064 daddr, dport, dif);
25065 + /* FIXME: disabled?
25066 + if (score == 9) {
25070 if (score > badness) {
25073 @@ -503,6 +507,7 @@ begin:
25074 if (get_nulls_value(node) != slot)
25079 if (unlikely(!atomic_inc_not_zero_hint(&result->sk_refcnt, 2)))
25081 @@ -512,6 +517,7 @@ begin:
25089 @@ -555,8 +561,7 @@ static inline struct sock *udp_v4_mcast_
25090 udp_sk(s)->udp_port_hash != hnum ||
25091 (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
25092 (inet->inet_dport != rmt_port && inet->inet_dport) ||
25093 - (inet->inet_rcv_saddr &&
25094 - inet->inet_rcv_saddr != loc_addr) ||
25095 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
25096 ipv6_only_sock(s) ||
25097 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
25099 @@ -939,6 +944,16 @@ int udp_sendmsg(struct kiocb *iocb, stru
25100 inet_sk_flowi_flags(sk)|FLOWI_FLAG_CAN_SLEEP,
25101 faddr, saddr, dport, inet->inet_sport);
25103 + if (sk->sk_nx_info) {
25104 + rt = ip_v4_find_src(net, sk->sk_nx_info, fl4);
25105 + if (IS_ERR(rt)) {
25106 + err = PTR_ERR(rt);
25113 security_sk_classify_flow(sk, flowi4_to_flowi(fl4));
25114 rt = ip_route_output_flow(net, fl4, sk);
25116 @@ -1244,7 +1259,8 @@ try_again:
25118 sin->sin_family = AF_INET;
25119 sin->sin_port = udp_hdr(skb)->source;
25120 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25121 + sin->sin_addr.s_addr = nx_map_sock_lback(
25122 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
25123 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
25125 if (inet->cmsg_flags)
25126 @@ -1992,6 +2008,8 @@ static struct sock *udp_get_first(struct
25127 sk_nulls_for_each(sk, node, &hslot->head) {
25128 if (!net_eq(sock_net(sk), net))
25130 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25132 if (sk->sk_family == state->family)
25135 @@ -2009,7 +2027,9 @@ static struct sock *udp_get_next(struct
25138 sk = sk_nulls_next(sk);
25139 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
25140 + } while (sk && (!net_eq(sock_net(sk), net) ||
25141 + sk->sk_family != state->family ||
25142 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25145 if (state->bucket <= state->udp_table->mask)
25146 @@ -2105,8 +2125,8 @@ static void udp4_format_sock(struct sock
25147 int bucket, int *len)
25149 struct inet_sock *inet = inet_sk(sp);
25150 - __be32 dest = inet->inet_daddr;
25151 - __be32 src = inet->inet_rcv_saddr;
25152 + __be32 dest = nx_map_sock_lback(current_nx_info(), inet->inet_daddr);
25153 + __be32 src = nx_map_sock_lback(current_nx_info(), inet->inet_rcv_saddr);
25154 __u16 destp = ntohs(inet->inet_dport);
25155 __u16 srcp = ntohs(inet->inet_sport);
25157 diff -NurpP --minimal linux-3.6.10/net/ipv6/Kconfig linux-3.6.10-vs2.3.4.5/net/ipv6/Kconfig
25158 --- linux-3.6.10/net/ipv6/Kconfig 2012-07-22 23:39:48.000000000 +0200
25159 +++ linux-3.6.10-vs2.3.4.5/net/ipv6/Kconfig 2012-10-04 18:47:00.000000000 +0200
25162 # IPv6 as module will cause a CRASH if you try to unload it
25164 - tristate "The IPv6 protocol"
25166 + bool "The IPv6 protocol"
25169 This is complemental support for the IP version 6.
25170 You will still be able to do traditional IPv4 networking as well.
25171 diff -NurpP --minimal linux-3.6.10/net/ipv6/addrconf.c linux-3.6.10-vs2.3.4.5/net/ipv6/addrconf.c
25172 --- linux-3.6.10/net/ipv6/addrconf.c 2012-12-11 12:37:04.000000000 +0100
25173 +++ linux-3.6.10-vs2.3.4.5/net/ipv6/addrconf.c 2012-11-06 18:43:41.000000000 +0100
25175 #include <linux/proc_fs.h>
25176 #include <linux/seq_file.h>
25177 #include <linux/export.h>
25178 +#include <linux/vs_network.h>
25179 +#include <linux/vs_inet6.h>
25181 /* Set to 3 to get tracing... */
25182 #define ACONF_DEBUG 2
25183 @@ -1101,7 +1103,7 @@ out:
25185 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
25186 const struct in6_addr *daddr, unsigned int prefs,
25187 - struct in6_addr *saddr)
25188 + struct in6_addr *saddr, struct nx_info *nxi)
25190 struct ipv6_saddr_score scores[2],
25191 *score = &scores[0], *hiscore = &scores[1];
25192 @@ -1173,6 +1175,8 @@ int ipv6_dev_get_saddr(struct net *net,
25196 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
25200 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
25201 @@ -3159,7 +3163,10 @@ static void if6_seq_stop(struct seq_file
25202 static int if6_seq_show(struct seq_file *seq, void *v)
25204 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
25205 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25207 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
25208 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
25209 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25211 ifp->idev->dev->ifindex,
25213 @@ -3665,6 +3672,11 @@ static int in6_dump_addrs(struct inet6_d
25214 struct ifacaddr6 *ifaca;
25216 int ip_idx = *p_ip_idx;
25217 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25219 + /* disable ipv6 on non v6 guests */
25220 + if (nxi && !nx_info_has_v6(nxi))
25223 read_lock_bh(&idev->lock);
25225 @@ -3675,6 +3687,8 @@ static int in6_dump_addrs(struct inet6_d
25226 list_for_each_entry(ifa, &idev->addr_list, if_list) {
25227 if (++ip_idx < s_ip_idx)
25229 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
25231 err = inet6_fill_ifaddr(skb, ifa,
25232 NETLINK_CB(cb->skb).pid,
25233 cb->nlh->nlmsg_seq,
25234 @@ -3691,6 +3705,8 @@ static int in6_dump_addrs(struct inet6_d
25235 ifmca = ifmca->next, ip_idx++) {
25236 if (ip_idx < s_ip_idx)
25238 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
25240 err = inet6_fill_ifmcaddr(skb, ifmca,
25241 NETLINK_CB(cb->skb).pid,
25242 cb->nlh->nlmsg_seq,
25243 @@ -3706,6 +3722,8 @@ static int in6_dump_addrs(struct inet6_d
25244 ifaca = ifaca->aca_next, ip_idx++) {
25245 if (ip_idx < s_ip_idx)
25247 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
25249 err = inet6_fill_ifacaddr(skb, ifaca,
25250 NETLINK_CB(cb->skb).pid,
25251 cb->nlh->nlmsg_seq,
25252 @@ -4089,6 +4107,11 @@ static int inet6_dump_ifinfo(struct sk_b
25253 struct inet6_dev *idev;
25254 struct hlist_head *head;
25255 struct hlist_node *node;
25256 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25258 + /* FIXME: maybe disable ipv6 on non v6 guests?
25259 + if (skb->sk && skb->sk->sk_vx_info)
25260 + return skb->len; */
25263 s_idx = cb->args[1];
25264 @@ -4100,6 +4123,8 @@ static int inet6_dump_ifinfo(struct sk_b
25265 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
25268 + if (!v6_dev_in_nx_info(dev, nxi))
25270 idev = __in6_dev_get(dev);
25273 diff -NurpP --minimal linux-3.6.10/net/ipv6/af_inet6.c linux-3.6.10-vs2.3.4.5/net/ipv6/af_inet6.c
25274 --- linux-3.6.10/net/ipv6/af_inet6.c 2012-12-11 12:37:04.000000000 +0100
25275 +++ linux-3.6.10-vs2.3.4.5/net/ipv6/af_inet6.c 2012-11-06 18:43:41.000000000 +0100
25277 #include <linux/netdevice.h>
25278 #include <linux/icmpv6.h>
25279 #include <linux/netfilter_ipv6.h>
25280 +#include <linux/vs_inet.h>
25281 +#include <linux/vs_inet6.h>
25283 #include <net/ip.h>
25284 #include <net/ipv6.h>
25285 @@ -160,9 +162,12 @@ lookup_protocol:
25289 + if ((protocol == IPPROTO_ICMPV6) &&
25290 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
25292 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
25293 goto out_rcu_unlock;
25296 sock->ops = answer->ops;
25297 answer_prot = answer->prot;
25298 answer_no_check = answer->no_check;
25299 @@ -262,6 +267,7 @@ int inet6_bind(struct socket *sock, stru
25300 struct inet_sock *inet = inet_sk(sk);
25301 struct ipv6_pinfo *np = inet6_sk(sk);
25302 struct net *net = sock_net(sk);
25303 + struct nx_v6_sock_addr nsa;
25305 unsigned short snum;
25307 @@ -277,6 +283,10 @@ int inet6_bind(struct socket *sock, stru
25308 if (addr->sin6_family != AF_INET6)
25309 return -EAFNOSUPPORT;
25311 + err = v6_map_sock_addr(inet, addr, &nsa);
25315 addr_type = ipv6_addr_type(&addr->sin6_addr);
25316 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
25318 @@ -308,6 +318,7 @@ int inet6_bind(struct socket *sock, stru
25319 /* Reproduce AF_INET checks to make the bindings consistent */
25320 v4addr = addr->sin6_addr.s6_addr32[3];
25321 chk_addr_ret = inet_addr_type(net, v4addr);
25323 if (!sysctl_ip_nonlocal_bind &&
25324 !(inet->freebind || inet->transparent) &&
25325 v4addr != htonl(INADDR_ANY) &&
25326 @@ -317,6 +328,10 @@ int inet6_bind(struct socket *sock, stru
25327 err = -EADDRNOTAVAIL;
25330 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
25331 + err = -EADDRNOTAVAIL;
25335 if (addr_type != IPV6_ADDR_ANY) {
25336 struct net_device *dev = NULL;
25337 @@ -343,6 +358,11 @@ int inet6_bind(struct socket *sock, stru
25341 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25342 + err = -EADDRNOTAVAIL;
25346 /* ipv4 addr of the socket is invalid. Only the
25347 * unspecified and mapped address have a v4 equivalent.
25349 @@ -359,6 +379,9 @@ int inet6_bind(struct socket *sock, stru
25353 + /* what's that for? */
25354 + v6_set_sock_addr(inet, &nsa);
25356 inet->inet_rcv_saddr = v4addr;
25357 inet->inet_saddr = v4addr;
25359 @@ -460,9 +483,11 @@ int inet6_getname(struct socket *sock, s
25361 sin->sin6_port = inet->inet_dport;
25362 sin->sin6_addr = np->daddr;
25363 + /* FIXME: remap lback? */
25365 sin->sin6_flowinfo = np->flow_label;
25367 + /* FIXME: remap lback? */
25368 if (ipv6_addr_any(&np->rcv_saddr))
25369 sin->sin6_addr = np->saddr;
25371 diff -NurpP --minimal linux-3.6.10/net/ipv6/datagram.c linux-3.6.10-vs2.3.4.5/net/ipv6/datagram.c
25372 --- linux-3.6.10/net/ipv6/datagram.c 2012-07-22 23:39:48.000000000 +0200
25373 +++ linux-3.6.10-vs2.3.4.5/net/ipv6/datagram.c 2012-10-04 18:47:00.000000000 +0200
25374 @@ -645,7 +645,7 @@ int datagram_send_ctl(struct net *net, s
25377 if (fl6->flowi6_oif) {
25378 - dev = dev_get_by_index_rcu(net, fl6->flowi6_oif);
25379 + dev = dev_get_by_index_real_rcu(net, fl6->flowi6_oif);
25383 diff -NurpP --minimal linux-3.6.10/net/ipv6/fib6_rules.c linux-3.6.10-vs2.3.4.5/net/ipv6/fib6_rules.c
25384 --- linux-3.6.10/net/ipv6/fib6_rules.c 2012-07-22 23:39:48.000000000 +0200
25385 +++ linux-3.6.10-vs2.3.4.5/net/ipv6/fib6_rules.c 2012-10-04 18:47:00.000000000 +0200
25386 @@ -90,7 +90,7 @@ static int fib6_rule_action(struct fib_r
25387 ip6_dst_idev(&rt->dst)->dev,
25389 rt6_flags2srcprefs(flags),
25393 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
25395 diff -NurpP --minimal linux-3.6.10/net/ipv6/inet6_hashtables.c linux-3.6.10-vs2.3.4.5/net/ipv6/inet6_hashtables.c
25396 --- linux-3.6.10/net/ipv6/inet6_hashtables.c 2011-10-24 18:45:34.000000000 +0200
25397 +++ linux-3.6.10-vs2.3.4.5/net/ipv6/inet6_hashtables.c 2012-10-04 18:47:00.000000000 +0200
25400 #include <linux/module.h>
25401 #include <linux/random.h>
25402 +#include <linux/vs_inet6.h>
25404 #include <net/inet_connection_sock.h>
25405 #include <net/inet_hashtables.h>
25406 @@ -83,7 +84,6 @@ struct sock *__inet6_lookup_established(
25407 unsigned int slot = hash & hashinfo->ehash_mask;
25408 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
25413 sk_nulls_for_each_rcu(sk, node, &head->chain) {
25414 @@ -95,7 +95,7 @@ begin:
25422 if (get_nulls_value(node) != slot)
25423 @@ -141,6 +141,9 @@ static inline int compute_score(struct s
25424 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25428 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25431 if (sk->sk_bound_dev_if) {
25432 if (sk->sk_bound_dev_if != dif)
25433 diff -NurpP --minimal linux-3.6.10/net/ipv6/ip6_output.c linux-3.6.10-vs2.3.4.5/net/ipv6/ip6_output.c
25434 --- linux-3.6.10/net/ipv6/ip6_output.c 2012-10-04 15:27:50.000000000 +0200
25435 +++ linux-3.6.10-vs2.3.4.5/net/ipv6/ip6_output.c 2012-10-04 18:47:00.000000000 +0200
25436 @@ -966,7 +966,8 @@ static int ip6_dst_lookup_tail(struct so
25437 struct rt6_info *rt = (struct rt6_info *) *dst;
25438 err = ip6_route_get_saddr(net, rt, &fl6->daddr,
25439 sk ? inet6_sk(sk)->srcprefs : 0,
25442 + sk ? sk->sk_nx_info : NULL);
25444 goto out_err_release;
25446 diff -NurpP --minimal linux-3.6.10/net/ipv6/ndisc.c linux-3.6.10-vs2.3.4.5/net/ipv6/ndisc.c
25447 --- linux-3.6.10/net/ipv6/ndisc.c 2012-12-11 12:37:04.000000000 +0100
25448 +++ linux-3.6.10-vs2.3.4.5/net/ipv6/ndisc.c 2012-12-08 01:36:33.000000000 +0100
25449 @@ -517,7 +517,7 @@ static void ndisc_send_na(struct net_dev
25451 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
25452 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
25456 src_addr = &tmpaddr;
25458 diff -NurpP --minimal linux-3.6.10/net/ipv6/raw.c linux-3.6.10-vs2.3.4.5/net/ipv6/raw.c
25459 --- linux-3.6.10/net/ipv6/raw.c 2012-10-04 15:27:50.000000000 +0200
25460 +++ linux-3.6.10-vs2.3.4.5/net/ipv6/raw.c 2012-10-04 18:47:00.000000000 +0200
25462 #include <linux/icmpv6.h>
25463 #include <linux/netfilter.h>
25464 #include <linux/netfilter_ipv6.h>
25465 +#include <linux/vs_inet6.h>
25466 #include <linux/skbuff.h>
25467 #include <linux/compat.h>
25468 #include <asm/uaccess.h>
25469 @@ -284,6 +285,13 @@ static int rawv6_bind(struct sock *sk, s
25473 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25474 + err = -EADDRNOTAVAIL;
25480 /* ipv4 addr of the socket is invalid. Only the
25481 * unspecified and mapped address have a v4 equivalent.
25483 diff -NurpP --minimal linux-3.6.10/net/ipv6/route.c linux-3.6.10-vs2.3.4.5/net/ipv6/route.c
25484 --- linux-3.6.10/net/ipv6/route.c 2012-12-11 12:37:04.000000000 +0100
25485 +++ linux-3.6.10-vs2.3.4.5/net/ipv6/route.c 2012-12-08 01:36:33.000000000 +0100
25487 #include <net/xfrm.h>
25488 #include <net/netevent.h>
25489 #include <net/netlink.h>
25490 +#include <linux/vs_inet6.h>
25492 #include <asm/uaccess.h>
25494 @@ -2112,15 +2113,17 @@ int ip6_route_get_saddr(struct net *net,
25495 struct rt6_info *rt,
25496 const struct in6_addr *daddr,
25497 unsigned int prefs,
25498 - struct in6_addr *saddr)
25499 + struct in6_addr *saddr,
25500 + struct nx_info *nxi)
25502 struct inet6_dev *idev = ip6_dst_idev((struct dst_entry*)rt);
25504 - if (rt->rt6i_prefsrc.plen)
25505 + if (rt->rt6i_prefsrc.plen && (!nxi ||
25506 + v6_addr_in_nx_info(nxi, &rt->rt6i_prefsrc.addr, NXA_TYPE_ADDR)))
25507 *saddr = rt->rt6i_prefsrc.addr;
25509 err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
25510 - daddr, prefs, saddr);
25511 + daddr, prefs, saddr, nxi);
25515 @@ -2456,7 +2459,8 @@ static int rt6_fill_node(struct net *net
25516 goto nla_put_failure;
25518 struct in6_addr saddr_buf;
25519 - if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf) == 0 &&
25520 + if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf,
25521 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0 &&
25522 nla_put(skb, RTA_PREFSRC, 16, &saddr_buf))
25523 goto nla_put_failure;
25525 @@ -2674,6 +2678,7 @@ static int rt6_info_route(struct rt6_inf
25526 struct seq_file *m = p_arg;
25527 struct neighbour *n;
25529 + /* FIXME: check for network context? */
25530 seq_printf(m, "%pi6 %02x ", &rt->rt6i_dst.addr, rt->rt6i_dst.plen);
25532 #ifdef CONFIG_IPV6_SUBTREES
25533 diff -NurpP --minimal linux-3.6.10/net/ipv6/tcp_ipv6.c linux-3.6.10-vs2.3.4.5/net/ipv6/tcp_ipv6.c
25534 --- linux-3.6.10/net/ipv6/tcp_ipv6.c 2012-12-11 12:37:04.000000000 +0100
25535 +++ linux-3.6.10-vs2.3.4.5/net/ipv6/tcp_ipv6.c 2012-11-06 18:43:41.000000000 +0100
25538 #include <linux/crypto.h>
25539 #include <linux/scatterlist.h>
25540 +#include <linux/vs_inet6.h>
25542 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
25543 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
25544 @@ -175,8 +176,15 @@ static int tcp_v6_connect(struct sock *s
25545 * connect() to INADDR_ANY means loopback (BSD'ism).
25548 - if(ipv6_addr_any(&usin->sin6_addr))
25549 - usin->sin6_addr.s6_addr[15] = 0x1;
25550 + if(ipv6_addr_any(&usin->sin6_addr)) {
25551 + struct nx_info *nxi = sk->sk_nx_info;
25553 + if (nxi && nx_info_has_v6(nxi))
25554 + /* FIXME: remap lback? */
25555 + usin->sin6_addr = nxi->v6.ip;
25557 + usin->sin6_addr.s6_addr[15] = 0x1;
25560 addr_type = ipv6_addr_type(&usin->sin6_addr);
25562 diff -NurpP --minimal linux-3.6.10/net/ipv6/udp.c linux-3.6.10-vs2.3.4.5/net/ipv6/udp.c
25563 --- linux-3.6.10/net/ipv6/udp.c 2012-10-04 15:27:50.000000000 +0200
25564 +++ linux-3.6.10-vs2.3.4.5/net/ipv6/udp.c 2012-10-04 18:56:03.000000000 +0200
25565 @@ -45,42 +45,68 @@
25566 #include <net/tcp_states.h>
25567 #include <net/ip6_checksum.h>
25568 #include <net/xfrm.h>
25569 +#include <linux/vs_inet6.h>
25571 #include <linux/proc_fs.h>
25572 #include <linux/seq_file.h>
25573 #include <trace/events/skb.h>
25574 #include "udp_impl.h"
25576 -int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
25577 +int ipv6_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25579 - const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
25580 + const struct in6_addr *sk1_rcv_saddr6 = &inet6_sk(sk1)->rcv_saddr;
25581 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
25582 - __be32 sk1_rcv_saddr = sk_rcv_saddr(sk);
25583 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1);
25584 __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
25585 - int sk_ipv6only = ipv6_only_sock(sk);
25586 + int sk1_ipv6only = ipv6_only_sock(sk1);
25587 int sk2_ipv6only = inet_v6_ipv6only(sk2);
25588 - int addr_type = ipv6_addr_type(sk_rcv_saddr6);
25589 + int addr_type = ipv6_addr_type(sk1_rcv_saddr6);
25590 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
25592 /* if both are mapped, treat as IPv4 */
25593 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
25594 - return (!sk2_ipv6only &&
25595 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
25596 + if (!sk2_ipv6only &&
25597 (!sk1_rcv_saddr || !sk2_rcv_saddr ||
25598 - sk1_rcv_saddr == sk2_rcv_saddr));
25599 + sk1_rcv_saddr == sk2_rcv_saddr))
25605 if (addr_type2 == IPV6_ADDR_ANY &&
25606 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
25610 if (addr_type == IPV6_ADDR_ANY &&
25611 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
25613 + !(sk1_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
25616 if (sk2_rcv_saddr6 &&
25617 - ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
25619 + ipv6_addr_equal(sk1_rcv_saddr6, sk2_rcv_saddr6))
25625 + if (!sk1_rcv_saddr && !sk2_rcv_saddr)
25626 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25627 + if (!sk2_rcv_saddr)
25628 + return v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, -1);
25629 + if (!sk1_rcv_saddr)
25630 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, -1);
25633 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
25634 + return nx_v6_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25635 + else if (addr_type2 == IPV6_ADDR_ANY)
25636 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr6, -1);
25637 + else if (addr_type == IPV6_ADDR_ANY) {
25638 + if (addr_type2 == IPV6_ADDR_MAPPED)
25639 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25641 + return v6_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr6, -1);
25646 static unsigned int udp6_portaddr_hash(struct net *net,
25647 @@ -144,6 +170,10 @@ static inline int compute_score(struct s
25648 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25652 + /* block non nx_info ips */
25653 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25656 if (!ipv6_addr_any(&np->daddr)) {
25657 if (!ipv6_addr_equal(&np->daddr, saddr))
25658 diff -NurpP --minimal linux-3.6.10/net/ipv6/xfrm6_policy.c linux-3.6.10-vs2.3.4.5/net/ipv6/xfrm6_policy.c
25659 --- linux-3.6.10/net/ipv6/xfrm6_policy.c 2012-10-04 15:27:50.000000000 +0200
25660 +++ linux-3.6.10-vs2.3.4.5/net/ipv6/xfrm6_policy.c 2012-10-04 18:47:00.000000000 +0200
25661 @@ -63,7 +63,7 @@ static int xfrm6_get_saddr(struct net *n
25662 dev = ip6_dst_idev(dst)->dev;
25663 ipv6_dev_get_saddr(dev_net(dev), dev,
25664 (struct in6_addr *)&daddr->a6, 0,
25665 - (struct in6_addr *)&saddr->a6);
25666 + (struct in6_addr *)&saddr->a6, NULL);
25670 diff -NurpP --minimal linux-3.6.10/net/netfilter/ipvs/ip_vs_xmit.c linux-3.6.10-vs2.3.4.5/net/netfilter/ipvs/ip_vs_xmit.c
25671 --- linux-3.6.10/net/netfilter/ipvs/ip_vs_xmit.c 2012-12-11 12:37:04.000000000 +0100
25672 +++ linux-3.6.10-vs2.3.4.5/net/netfilter/ipvs/ip_vs_xmit.c 2012-11-06 18:43:41.000000000 +0100
25673 @@ -231,7 +231,7 @@ __ip_vs_route_output_v6(struct net *net,
25675 if (ipv6_addr_any(&fl6.saddr) &&
25676 ipv6_dev_get_saddr(net, ip6_dst_idev(dst)->dev,
25677 - &fl6.daddr, 0, &fl6.saddr) < 0)
25678 + &fl6.daddr, 0, &fl6.saddr, NULL) < 0)
25681 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
25682 diff -NurpP --minimal linux-3.6.10/net/netlink/af_netlink.c linux-3.6.10-vs2.3.4.5/net/netlink/af_netlink.c
25683 --- linux-3.6.10/net/netlink/af_netlink.c 2012-12-11 12:37:04.000000000 +0100
25684 +++ linux-3.6.10-vs2.3.4.5/net/netlink/af_netlink.c 2012-12-08 01:36:33.000000000 +0100
25686 #include <linux/types.h>
25687 #include <linux/audit.h>
25688 #include <linux/mutex.h>
25689 +#include <linux/vs_context.h>
25690 +#include <linux/vs_network.h>
25691 +#include <linux/vs_limit.h>
25693 #include <net/net_namespace.h>
25694 #include <net/sock.h>
25695 @@ -1983,6 +1986,8 @@ static struct sock *netlink_seq_socket_i
25696 sk_for_each(s, node, &hash->table[j]) {
25697 if (sock_net(s) != seq_file_net(seq))
25699 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
25703 iter->hash_idx = j;
25704 @@ -2017,7 +2022,8 @@ static void *netlink_seq_next(struct seq
25708 - } while (s && sock_net(s) != seq_file_net(seq));
25709 + } while (s && (sock_net(s) != seq_file_net(seq) ||
25710 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
25714 @@ -2029,7 +2035,8 @@ static void *netlink_seq_next(struct seq
25716 for (; j <= hash->mask; j++) {
25717 s = sk_head(&hash->table[j]);
25718 - while (s && sock_net(s) != seq_file_net(seq))
25719 + while (s && (sock_net(s) != seq_file_net(seq) ||
25720 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
25724 diff -NurpP --minimal linux-3.6.10/net/socket.c linux-3.6.10-vs2.3.4.5/net/socket.c
25725 --- linux-3.6.10/net/socket.c 2012-10-04 15:27:51.000000000 +0200
25726 +++ linux-3.6.10-vs2.3.4.5/net/socket.c 2012-10-04 18:47:00.000000000 +0200
25729 #include <net/sock.h>
25730 #include <linux/netfilter.h>
25731 +#include <linux/vs_base.h>
25732 +#include <linux/vs_socket.h>
25733 +#include <linux/vs_inet.h>
25734 +#include <linux/vs_inet6.h>
25736 #include <linux/if_tun.h>
25737 #include <linux/ipv6_route.h>
25738 @@ -552,6 +556,7 @@ static inline int __sock_sendmsg_nosec(s
25739 struct msghdr *msg, size_t size)
25741 struct sock_iocb *si = kiocb_to_siocb(iocb);
25744 sock_update_classid(sock->sk);
25746 @@ -560,7 +565,22 @@ static inline int __sock_sendmsg_nosec(s
25750 - return sock->ops->sendmsg(iocb, sock, msg, size);
25751 + len = sock->ops->sendmsg(iocb, sock, msg, size);
25754 + vx_sock_send(sock->sk, size);
25756 + vx_sock_fail(sock->sk, size);
25758 + vxdprintk(VXD_CBIT(net, 7),
25759 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%zu",
25761 + (sock->sk)?sock->sk->sk_nx_info:0,
25762 + (sock->sk)?sock->sk->sk_vx_info:0,
25763 + (sock->sk)?sock->sk->sk_xid:0,
25764 + (sock->sk)?sock->sk->sk_nid:0,
25765 + (unsigned int)size, len);
25769 static inline int __sock_sendmsg(struct kiocb *iocb, struct socket *sock,
25770 @@ -716,6 +736,7 @@ static inline int __sock_recvmsg_nosec(s
25771 struct msghdr *msg, size_t size, int flags)
25773 struct sock_iocb *si = kiocb_to_siocb(iocb);
25776 sock_update_classid(sock->sk);
25778 @@ -725,7 +746,18 @@ static inline int __sock_recvmsg_nosec(s
25782 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
25783 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
25784 + if ((len >= 0) && sock->sk)
25785 + vx_sock_recv(sock->sk, len);
25786 + vxdprintk(VXD_CBIT(net, 7),
25787 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
25789 + (sock->sk)?sock->sk->sk_nx_info:0,
25790 + (sock->sk)?sock->sk->sk_vx_info:0,
25791 + (sock->sk)?sock->sk->sk_xid:0,
25792 + (sock->sk)?sock->sk->sk_nid:0,
25793 + (unsigned int)size, len);
25797 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
25798 @@ -1210,6 +1242,13 @@ int __sock_create(struct net *net, int f
25799 if (type < 0 || type >= SOCK_MAX)
25802 + if (!nx_check(0, VS_ADMIN)) {
25803 + if (family == PF_INET && !current_nx_info_has_v4())
25804 + return -EAFNOSUPPORT;
25805 + if (family == PF_INET6 && !current_nx_info_has_v6())
25806 + return -EAFNOSUPPORT;
25811 This uglymoron is moved from INET layer to here to avoid
25812 @@ -1344,6 +1383,7 @@ SYSCALL_DEFINE3(socket, int, family, int
25816 + set_bit(SOCK_USER_SOCKET, &sock->flags);
25817 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
25820 @@ -1385,10 +1425,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
25821 err = sock_create(family, type, protocol, &sock1);
25824 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
25826 err = sock_create(family, type, protocol, &sock2);
25828 goto out_release_1;
25829 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
25831 err = sock1->ops->socketpair(sock1, sock2);
25833 diff -NurpP --minimal linux-3.6.10/net/sunrpc/auth.c linux-3.6.10-vs2.3.4.5/net/sunrpc/auth.c
25834 --- linux-3.6.10/net/sunrpc/auth.c 2012-10-04 15:27:51.000000000 +0200
25835 +++ linux-3.6.10-vs2.3.4.5/net/sunrpc/auth.c 2012-10-04 18:47:00.000000000 +0200
25837 #include <linux/sunrpc/clnt.h>
25838 #include <linux/sunrpc/gss_api.h>
25839 #include <linux/spinlock.h>
25840 +#include <linux/vs_tag.h>
25843 # define RPCDBG_FACILITY RPCDBG_AUTH
25844 @@ -481,6 +482,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
25845 memset(&acred, 0, sizeof(acred));
25846 acred.uid = cred->fsuid;
25847 acred.gid = cred->fsgid;
25848 + acred.tag = dx_current_tag();
25849 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
25851 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
25852 @@ -521,6 +523,7 @@ rpcauth_bind_root_cred(struct rpc_task *
25853 struct auth_cred acred = {
25856 + .tag = dx_current_tag(),
25859 dprintk("RPC: %5u looking up %s cred\n",
25860 diff -NurpP --minimal linux-3.6.10/net/sunrpc/auth_unix.c linux-3.6.10-vs2.3.4.5/net/sunrpc/auth_unix.c
25861 --- linux-3.6.10/net/sunrpc/auth_unix.c 2012-07-22 23:39:49.000000000 +0200
25862 +++ linux-3.6.10-vs2.3.4.5/net/sunrpc/auth_unix.c 2012-10-04 18:47:00.000000000 +0200
25863 @@ -13,11 +13,13 @@
25864 #include <linux/sunrpc/clnt.h>
25865 #include <linux/sunrpc/auth.h>
25866 #include <linux/user_namespace.h>
25867 +#include <linux/vs_tag.h>
25869 #define NFS_NGROUPS 16
25872 struct rpc_cred uc_base;
25875 gid_t uc_gids[NFS_NGROUPS];
25877 @@ -79,6 +81,7 @@ unx_create_cred(struct rpc_auth *auth, s
25878 groups = NFS_NGROUPS;
25880 cred->uc_gid = acred->gid;
25881 + cred->uc_tag = acred->tag;
25882 for (i = 0; i < groups; i++) {
25884 gid = from_kgid(&init_user_ns, GROUP_AT(acred->group_info, i));
25885 @@ -123,7 +126,9 @@ unx_match(struct auth_cred *acred, struc
25889 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
25890 + if (cred->uc_uid != acred->uid ||
25891 + cred->uc_gid != acred->gid ||
25892 + cred->uc_tag != acred->tag)
25895 if (acred->group_info != NULL)
25896 @@ -152,7 +157,7 @@ unx_marshal(struct rpc_task *task, __be3
25897 struct rpc_clnt *clnt = task->tk_client;
25898 struct unx_cred *cred = container_of(task->tk_rqstp->rq_cred, struct unx_cred, uc_base);
25899 __be32 *base, *hold;
25903 *p++ = htonl(RPC_AUTH_UNIX);
25905 @@ -162,9 +167,12 @@ unx_marshal(struct rpc_task *task, __be3
25906 * Copy the UTS nodename captured when the client was created.
25908 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
25909 + tag = task->tk_client->cl_tag;
25911 - *p++ = htonl((u32) cred->uc_uid);
25912 - *p++ = htonl((u32) cred->uc_gid);
25913 + *p++ = htonl((u32) TAGINO_UID(tag,
25914 + cred->uc_uid, cred->uc_tag));
25915 + *p++ = htonl((u32) TAGINO_GID(tag,
25916 + cred->uc_gid, cred->uc_tag));
25918 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
25919 *p++ = htonl((u32) cred->uc_gids[i]);
25920 diff -NurpP --minimal linux-3.6.10/net/sunrpc/clnt.c linux-3.6.10-vs2.3.4.5/net/sunrpc/clnt.c
25921 --- linux-3.6.10/net/sunrpc/clnt.c 2012-10-04 15:27:51.000000000 +0200
25922 +++ linux-3.6.10-vs2.3.4.5/net/sunrpc/clnt.c 2012-10-04 18:47:00.000000000 +0200
25924 #include <linux/in6.h>
25925 #include <linux/un.h>
25926 #include <linux/rcupdate.h>
25927 +#include <linux/vs_cvirt.h>
25929 #include <linux/sunrpc/clnt.h>
25930 #include <linux/sunrpc/rpc_pipe_fs.h>
25931 @@ -481,6 +482,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
25932 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
25933 clnt->cl_chatty = 1;
25935 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
25936 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
25937 + clnt->cl_tag = 1; */
25940 EXPORT_SYMBOL_GPL(rpc_create);
25941 diff -NurpP --minimal linux-3.6.10/net/unix/af_unix.c linux-3.6.10-vs2.3.4.5/net/unix/af_unix.c
25942 --- linux-3.6.10/net/unix/af_unix.c 2012-10-04 15:27:51.000000000 +0200
25943 +++ linux-3.6.10-vs2.3.4.5/net/unix/af_unix.c 2012-10-04 18:59:36.000000000 +0200
25944 @@ -114,6 +114,8 @@
25945 #include <linux/mount.h>
25946 #include <net/checksum.h>
25947 #include <linux/security.h>
25948 +#include <linux/vs_context.h>
25949 +#include <linux/vs_limit.h>
25951 struct hlist_head unix_socket_table[2 * UNIX_HASH_SIZE];
25952 EXPORT_SYMBOL_GPL(unix_socket_table);
25953 @@ -271,6 +273,8 @@ static struct sock *__unix_find_socket_b
25954 if (!net_eq(sock_net(s), net))
25957 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
25959 if (u->addr->len == len &&
25960 !memcmp(u->addr->name, sunname, len))
25962 @@ -2258,6 +2262,8 @@ static struct sock *unix_from_bucket(str
25963 for (sk = sk_head(&unix_socket_table[bucket]); sk; sk = sk_next(sk)) {
25964 if (sock_net(sk) != seq_file_net(seq))
25966 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25968 if (++count == offset)
25971 @@ -2275,6 +2281,8 @@ static struct sock *unix_next_socket(str
25975 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25977 if (sock_net(sk) == seq_file_net(seq))
25980 diff -NurpP --minimal linux-3.6.10/scripts/checksyscalls.sh linux-3.6.10-vs2.3.4.5/scripts/checksyscalls.sh
25981 --- linux-3.6.10/scripts/checksyscalls.sh 2012-10-04 15:27:51.000000000 +0200
25982 +++ linux-3.6.10-vs2.3.4.5/scripts/checksyscalls.sh 2012-10-04 18:47:00.000000000 +0200
25983 @@ -193,7 +193,6 @@ cat << EOF
25984 #define __IGNORE_afs_syscall
25985 #define __IGNORE_getpmsg
25986 #define __IGNORE_putpmsg
25987 -#define __IGNORE_vserver
25991 diff -NurpP --minimal linux-3.6.10/security/commoncap.c linux-3.6.10-vs2.3.4.5/security/commoncap.c
25992 --- linux-3.6.10/security/commoncap.c 2012-07-22 23:39:51.000000000 +0200
25993 +++ linux-3.6.10-vs2.3.4.5/security/commoncap.c 2012-10-04 18:47:00.000000000 +0200
25994 @@ -76,14 +76,20 @@ int cap_netlink_send(struct sock *sk, st
25995 int cap_capable(const struct cred *cred, struct user_namespace *targ_ns,
25996 int cap, int audit)
25998 + struct vx_info *vxi = current_vx_info(); /* FIXME: get vxi from cred? */
26001 /* The owner of the user namespace has all caps. */
26002 if (targ_ns != &init_user_ns && uid_eq(targ_ns->owner, cred->euid))
26005 /* Do we have the necessary capabilities? */
26006 - if (targ_ns == cred->user_ns)
26007 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
26008 + if (targ_ns == cred->user_ns) {
26009 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
26010 + cap_raised(cred->cap_effective, cap))
26012 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
26015 /* Have we tried all of the parent namespaces? */
26016 if (targ_ns == &init_user_ns)
26017 @@ -619,7 +625,7 @@ int cap_inode_setxattr(struct dentry *de
26019 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26020 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26021 - !capable(CAP_SYS_ADMIN))
26022 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26026 @@ -645,7 +651,7 @@ int cap_inode_removexattr(struct dentry
26028 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26029 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26030 - !capable(CAP_SYS_ADMIN))
26031 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26035 diff -NurpP --minimal linux-3.6.10/security/selinux/hooks.c linux-3.6.10-vs2.3.4.5/security/selinux/hooks.c
26036 --- linux-3.6.10/security/selinux/hooks.c 2012-10-04 15:27:53.000000000 +0200
26037 +++ linux-3.6.10-vs2.3.4.5/security/selinux/hooks.c 2012-10-04 18:47:00.000000000 +0200
26039 #include <linux/dccp.h>
26040 #include <linux/quota.h>
26041 #include <linux/un.h> /* for Unix socket types */
26042 -#include <net/af_unix.h> /* for Unix socket types */
26043 #include <linux/parser.h>
26044 #include <linux/nfs_mount.h>
26045 #include <net/ipv6.h>