1 diff -NurpP --minimal linux-3.4.103/Documentation/vserver/debug.txt linux-3.4.103-vs2.3.3.9/Documentation/vserver/debug.txt
2 --- linux-3.4.103/Documentation/vserver/debug.txt 1970-01-01 00:00:00.000000000 +0000
3 +++ linux-3.4.103-vs2.3.3.9/Documentation/vserver/debug.txt 2012-05-21 16:15:04.000000000 +0000
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.4.103/arch/alpha/Kconfig linux-3.4.103-vs2.3.3.9/arch/alpha/Kconfig
160 --- linux-3.4.103/arch/alpha/Kconfig 2012-05-21 16:06:12.000000000 +0000
161 +++ linux-3.4.103-vs2.3.3.9/arch/alpha/Kconfig 2012-05-21 16:15:04.000000000 +0000
162 @@ -662,6 +662,8 @@ config DUMMY_CONSOLE
166 +source "kernel/vserver/Kconfig"
168 source "security/Kconfig"
170 source "crypto/Kconfig"
171 diff -NurpP --minimal linux-3.4.103/arch/alpha/kernel/entry.S linux-3.4.103-vs2.3.3.9/arch/alpha/kernel/entry.S
172 --- linux-3.4.103/arch/alpha/kernel/entry.S 2010-10-21 11:06:45.000000000 +0000
173 +++ linux-3.4.103-vs2.3.3.9/arch/alpha/kernel/entry.S 2012-05-21 16:15:04.000000000 +0000
174 @@ -860,24 +860,15 @@ sys_getxgid:
181 - ldq $2, TI_TASK($8)
183 - /* See linux/kernel/timer.c sys_getppid for discussion
184 - about this loop. */
185 - ldq $3, TASK_GROUP_LEADER($2)
186 - ldq $4, TASK_REAL_PARENT($3)
187 - ldl $0, TASK_TGID($2)
188 -1: ldl $1, TASK_TGID($4)
192 - ldq $3, TASK_GROUP_LEADER($2)
193 - ldq $4, TASK_REAL_PARENT($3)
199 + jsr $26, do_getxpid
206 diff -NurpP --minimal linux-3.4.103/arch/alpha/kernel/ptrace.c linux-3.4.103-vs2.3.3.9/arch/alpha/kernel/ptrace.c
207 --- linux-3.4.103/arch/alpha/kernel/ptrace.c 2012-05-21 16:06:12.000000000 +0000
208 +++ linux-3.4.103-vs2.3.3.9/arch/alpha/kernel/ptrace.c 2012-05-21 16:15:04.000000000 +0000
210 #include <linux/user.h>
211 #include <linux/security.h>
212 #include <linux/signal.h>
213 +#include <linux/vs_base.h>
215 #include <asm/uaccess.h>
216 #include <asm/pgtable.h>
217 diff -NurpP --minimal linux-3.4.103/arch/alpha/kernel/systbls.S linux-3.4.103-vs2.3.3.9/arch/alpha/kernel/systbls.S
218 --- linux-3.4.103/arch/alpha/kernel/systbls.S 2012-01-09 15:13:54.000000000 +0000
219 +++ linux-3.4.103-vs2.3.3.9/arch/alpha/kernel/systbls.S 2012-05-21 16:15:04.000000000 +0000
220 @@ -446,7 +446,7 @@ sys_call_table:
221 .quad sys_stat64 /* 425 */
224 - .quad sys_ni_syscall /* sys_vserver */
225 + .quad sys_vserver /* sys_vserver */
226 .quad sys_ni_syscall /* sys_mbind */
227 .quad sys_ni_syscall /* sys_get_mempolicy */
228 .quad sys_ni_syscall /* sys_set_mempolicy */
229 diff -NurpP --minimal linux-3.4.103/arch/alpha/kernel/traps.c linux-3.4.103-vs2.3.3.9/arch/alpha/kernel/traps.c
230 --- linux-3.4.103/arch/alpha/kernel/traps.c 2012-05-21 16:06:12.000000000 +0000
231 +++ linux-3.4.103-vs2.3.3.9/arch/alpha/kernel/traps.c 2012-05-21 16:15:04.000000000 +0000
232 @@ -184,7 +184,8 @@ die_if_kernel(char * str, struct pt_regs
234 printk("CPU %d ", hard_smp_processor_id());
236 - printk("%s(%d): %s %ld\n", current->comm, task_pid_nr(current), str, err);
237 + printk("%s(%d[#%u]): %s %ld\n", current->comm,
238 + task_pid_nr(current), current->xid, str, err);
239 dik_show_regs(regs, r9_15);
240 add_taint(TAINT_DIE);
241 dik_show_trace((unsigned long *)(regs+1));
242 diff -NurpP --minimal linux-3.4.103/arch/arm/Kconfig linux-3.4.103-vs2.3.3.9/arch/arm/Kconfig
243 --- linux-3.4.103/arch/arm/Kconfig 2014-08-30 13:36:20.000000000 +0000
244 +++ linux-3.4.103-vs2.3.3.9/arch/arm/Kconfig 2014-04-21 18:56:34.000000000 +0000
245 @@ -2310,6 +2310,8 @@ source "fs/Kconfig"
247 source "arch/arm/Kconfig.debug"
249 +source "kernel/vserver/Kconfig"
251 source "security/Kconfig"
253 source "crypto/Kconfig"
254 diff -NurpP --minimal linux-3.4.103/arch/arm/kernel/calls.S linux-3.4.103-vs2.3.3.9/arch/arm/kernel/calls.S
255 --- linux-3.4.103/arch/arm/kernel/calls.S 2012-01-09 15:13:54.000000000 +0000
256 +++ linux-3.4.103-vs2.3.3.9/arch/arm/kernel/calls.S 2012-05-21 16:15:04.000000000 +0000
258 /* 310 */ CALL(sys_request_key)
260 CALL(ABI(sys_semtimedop, sys_oabi_semtimedop))
261 -/* vserver */ CALL(sys_ni_syscall)
264 /* 315 */ CALL(sys_ioprio_get)
265 CALL(sys_inotify_init)
266 diff -NurpP --minimal linux-3.4.103/arch/arm/kernel/process.c linux-3.4.103-vs2.3.3.9/arch/arm/kernel/process.c
267 --- linux-3.4.103/arch/arm/kernel/process.c 2014-08-30 13:36:21.000000000 +0000
268 +++ linux-3.4.103-vs2.3.3.9/arch/arm/kernel/process.c 2014-03-12 09:55:28.000000000 +0000
269 @@ -357,7 +357,8 @@ void __show_regs(struct pt_regs *regs)
270 void show_regs(struct pt_regs * regs)
273 - printk("Pid: %d, comm: %20s\n", task_pid_nr(current), current->comm);
274 + printk("Pid: %d[#%u], comm: %20s\n",
275 + task_pid_nr(current), current->xid, current->comm);
279 diff -NurpP --minimal linux-3.4.103/arch/arm/kernel/traps.c linux-3.4.103-vs2.3.3.9/arch/arm/kernel/traps.c
280 --- linux-3.4.103/arch/arm/kernel/traps.c 2014-08-30 13:36:21.000000000 +0000
281 +++ linux-3.4.103-vs2.3.3.9/arch/arm/kernel/traps.c 2014-03-12 09:55:28.000000000 +0000
282 @@ -255,8 +255,8 @@ static int __die(const char *str, int er
286 - printk(KERN_EMERG "Process %.*s (pid: %d, stack limit = 0x%p)\n",
287 - TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), thread + 1);
288 + printk(KERN_EMERG "Process %.*s (pid: %d:#%u, stack limit = 0x%p)\n",
289 + TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), tsk->xid, thread + 1);
291 if (!user_mode(regs) || in_interrupt()) {
292 dump_mem(KERN_EMERG, "Stack: ", regs->ARM_sp,
293 diff -NurpP --minimal linux-3.4.103/arch/cris/Kconfig linux-3.4.103-vs2.3.3.9/arch/cris/Kconfig
294 --- linux-3.4.103/arch/cris/Kconfig 2012-03-19 18:46:39.000000000 +0000
295 +++ linux-3.4.103-vs2.3.3.9/arch/cris/Kconfig 2012-05-21 16:15:04.000000000 +0000
296 @@ -675,6 +675,8 @@ source "drivers/staging/Kconfig"
298 source "arch/cris/Kconfig.debug"
300 +source "kernel/vserver/Kconfig"
302 source "security/Kconfig"
304 source "crypto/Kconfig"
305 diff -NurpP --minimal linux-3.4.103/arch/frv/kernel/kernel_thread.S linux-3.4.103-vs2.3.3.9/arch/frv/kernel/kernel_thread.S
306 --- linux-3.4.103/arch/frv/kernel/kernel_thread.S 2008-12-24 23:26:37.000000000 +0000
307 +++ linux-3.4.103-vs2.3.3.9/arch/frv/kernel/kernel_thread.S 2012-05-21 16:15:04.000000000 +0000
308 @@ -37,7 +37,7 @@ kernel_thread:
310 # start by forking the current process, but with shared VM
311 setlos.p #__NR_clone,gr7 ; syscall number
312 - ori gr10,#CLONE_VM,gr8 ; first syscall arg [clone_flags]
313 + ori gr10,#CLONE_KT,gr8 ; first syscall arg [clone_flags]
314 sethi.p #0xe4e4,gr9 ; second syscall arg [newsp]
316 setlos.p #0,gr10 ; third syscall arg [parent_tidptr]
317 diff -NurpP --minimal linux-3.4.103/arch/h8300/Kconfig linux-3.4.103-vs2.3.3.9/arch/h8300/Kconfig
318 --- linux-3.4.103/arch/h8300/Kconfig 2012-03-19 18:46:39.000000000 +0000
319 +++ linux-3.4.103-vs2.3.3.9/arch/h8300/Kconfig 2012-05-21 16:15:04.000000000 +0000
320 @@ -214,6 +214,8 @@ source "fs/Kconfig"
322 source "arch/h8300/Kconfig.debug"
324 +source "kernel/vserver/Kconfig"
326 source "security/Kconfig"
328 source "crypto/Kconfig"
329 diff -NurpP --minimal linux-3.4.103/arch/ia64/Kconfig linux-3.4.103-vs2.3.3.9/arch/ia64/Kconfig
330 --- linux-3.4.103/arch/ia64/Kconfig 2012-03-19 18:46:39.000000000 +0000
331 +++ linux-3.4.103-vs2.3.3.9/arch/ia64/Kconfig 2012-05-21 16:15:04.000000000 +0000
332 @@ -654,6 +654,8 @@ source "fs/Kconfig"
334 source "arch/ia64/Kconfig.debug"
336 +source "kernel/vserver/Kconfig"
338 source "security/Kconfig"
340 source "crypto/Kconfig"
341 diff -NurpP --minimal linux-3.4.103/arch/ia64/kernel/entry.S linux-3.4.103-vs2.3.3.9/arch/ia64/kernel/entry.S
342 --- linux-3.4.103/arch/ia64/kernel/entry.S 2012-03-19 18:46:40.000000000 +0000
343 +++ linux-3.4.103-vs2.3.3.9/arch/ia64/kernel/entry.S 2012-05-21 16:15:04.000000000 +0000
344 @@ -1714,7 +1714,7 @@ sys_call_table:
346 data8 sys_mq_getsetattr
348 - data8 sys_ni_syscall // reserved for vserver
350 data8 sys_waitid // 1270
352 data8 sys_request_key
353 diff -NurpP --minimal linux-3.4.103/arch/ia64/kernel/process.c linux-3.4.103-vs2.3.3.9/arch/ia64/kernel/process.c
354 --- linux-3.4.103/arch/ia64/kernel/process.c 2014-08-30 13:36:24.000000000 +0000
355 +++ linux-3.4.103-vs2.3.3.9/arch/ia64/kernel/process.c 2012-10-22 13:09:53.000000000 +0000
356 @@ -111,8 +111,8 @@ show_regs (struct pt_regs *regs)
357 unsigned long ip = regs->cr_iip + ia64_psr(regs)->ri;
360 - printk("\nPid: %d, CPU %d, comm: %20s\n", task_pid_nr(current),
361 - smp_processor_id(), current->comm);
362 + printk("\nPid: %d[#%u], CPU %d, comm: %20s\n", task_pid_nr(current),
363 + current->xid, smp_processor_id(), current->comm);
364 printk("psr : %016lx ifs : %016lx ip : [<%016lx>] %s (%s)\n",
365 regs->cr_ipsr, regs->cr_ifs, ip, print_tainted(),
366 init_utsname()->release);
367 diff -NurpP --minimal linux-3.4.103/arch/ia64/kernel/ptrace.c linux-3.4.103-vs2.3.3.9/arch/ia64/kernel/ptrace.c
368 --- linux-3.4.103/arch/ia64/kernel/ptrace.c 2012-05-21 16:06:26.000000000 +0000
369 +++ linux-3.4.103-vs2.3.3.9/arch/ia64/kernel/ptrace.c 2012-05-21 16:15:04.000000000 +0000
371 #include <linux/regset.h>
372 #include <linux/elf.h>
373 #include <linux/tracehook.h>
374 +#include <linux/vs_base.h>
376 #include <asm/pgtable.h>
377 #include <asm/processor.h>
378 diff -NurpP --minimal linux-3.4.103/arch/ia64/kernel/traps.c linux-3.4.103-vs2.3.3.9/arch/ia64/kernel/traps.c
379 --- linux-3.4.103/arch/ia64/kernel/traps.c 2012-05-21 16:06:26.000000000 +0000
380 +++ linux-3.4.103-vs2.3.3.9/arch/ia64/kernel/traps.c 2012-05-21 16:15:04.000000000 +0000
381 @@ -60,8 +60,9 @@ die (const char *str, struct pt_regs *re
384 if (++die.lock_owner_depth < 3) {
385 - printk("%s[%d]: %s %ld [%d]\n",
386 - current->comm, task_pid_nr(current), str, err, ++die_counter);
387 + printk("%s[%d[#%u]]: %s %ld [%d]\n",
388 + current->comm, task_pid_nr(current), current->xid,
389 + str, err, ++die_counter);
390 if (notify_die(DIE_OOPS, str, regs, err, 255, SIGSEGV)
393 @@ -324,8 +325,9 @@ handle_fpu_swa (int fp_fault, struct pt_
394 if ((last.count & 15) < 5 && (ia64_fetchadd(1, &last.count, acq) & 15) < 5) {
395 last.time = current_jiffies + 5 * HZ;
397 - "%s(%d): floating-point assist fault at ip %016lx, isr %016lx\n",
398 - current->comm, task_pid_nr(current), regs->cr_iip + ia64_psr(regs)->ri, isr);
399 + "%s(%d[#%u]): floating-point assist fault at ip %016lx, isr %016lx\n",
400 + current->comm, task_pid_nr(current), current->xid,
401 + regs->cr_iip + ia64_psr(regs)->ri, isr);
405 diff -NurpP --minimal linux-3.4.103/arch/m32r/kernel/traps.c linux-3.4.103-vs2.3.3.9/arch/m32r/kernel/traps.c
406 --- linux-3.4.103/arch/m32r/kernel/traps.c 2012-05-21 16:06:26.000000000 +0000
407 +++ linux-3.4.103-vs2.3.3.9/arch/m32r/kernel/traps.c 2012-05-21 16:15:04.000000000 +0000
408 @@ -195,8 +195,9 @@ static void show_registers(struct pt_reg
410 printk("SPI: %08lx\n", sp);
412 - printk("Process %s (pid: %d, process nr: %d, stackpage=%08lx)",
413 - current->comm, task_pid_nr(current), 0xffff & i, 4096+(unsigned long)current);
414 + printk("Process %s (pid: %d[#%u], process nr: %d, stackpage=%08lx)",
415 + current->comm, task_pid_nr(current), current->xid,
416 + 0xffff & i, 4096+(unsigned long)current);
419 * When in-kernel, we also print out the stack and code at the
420 diff -NurpP --minimal linux-3.4.103/arch/m68k/Kconfig linux-3.4.103-vs2.3.3.9/arch/m68k/Kconfig
421 --- linux-3.4.103/arch/m68k/Kconfig 2012-05-21 16:06:26.000000000 +0000
422 +++ linux-3.4.103-vs2.3.3.9/arch/m68k/Kconfig 2012-05-21 16:15:04.000000000 +0000
423 @@ -146,6 +146,8 @@ source "fs/Kconfig"
425 source "arch/m68k/Kconfig.debug"
427 +source "kernel/vserver/Kconfig"
429 source "security/Kconfig"
431 source "crypto/Kconfig"
432 diff -NurpP --minimal linux-3.4.103/arch/mips/Kconfig linux-3.4.103-vs2.3.3.9/arch/mips/Kconfig
433 --- linux-3.4.103/arch/mips/Kconfig 2014-08-30 13:36:27.000000000 +0000
434 +++ linux-3.4.103-vs2.3.3.9/arch/mips/Kconfig 2013-10-26 18:10:20.000000000 +0000
435 @@ -2516,6 +2516,8 @@ source "fs/Kconfig"
437 source "arch/mips/Kconfig.debug"
439 +source "kernel/vserver/Kconfig"
441 source "security/Kconfig"
443 source "crypto/Kconfig"
444 diff -NurpP --minimal linux-3.4.103/arch/mips/kernel/ptrace.c linux-3.4.103-vs2.3.3.9/arch/mips/kernel/ptrace.c
445 --- linux-3.4.103/arch/mips/kernel/ptrace.c 2012-05-21 16:06:27.000000000 +0000
446 +++ linux-3.4.103-vs2.3.3.9/arch/mips/kernel/ptrace.c 2012-05-21 16:15:04.000000000 +0000
448 #include <linux/security.h>
449 #include <linux/audit.h>
450 #include <linux/seccomp.h>
451 +#include <linux/vs_base.h>
453 #include <asm/byteorder.h>
455 @@ -262,6 +263,9 @@ long arch_ptrace(struct task_struct *chi
456 void __user *datavp = (void __user *) data;
457 unsigned long __user *datalp = (void __user *) data;
459 + if (!vx_check(vx_task_xid(child), VS_WATCH_P | VS_IDENT))
463 /* when I and D space are separate, these will need to be fixed. */
464 case PTRACE_PEEKTEXT: /* read word at location addr. */
465 diff -NurpP --minimal linux-3.4.103/arch/mips/kernel/scall32-o32.S linux-3.4.103-vs2.3.3.9/arch/mips/kernel/scall32-o32.S
466 --- linux-3.4.103/arch/mips/kernel/scall32-o32.S 2012-01-09 15:14:05.000000000 +0000
467 +++ linux-3.4.103-vs2.3.3.9/arch/mips/kernel/scall32-o32.S 2012-05-21 16:15:04.000000000 +0000
468 @@ -523,7 +523,7 @@ einval: li v0, -ENOSYS
469 sys sys_mq_timedreceive 5
470 sys sys_mq_notify 2 /* 4275 */
471 sys sys_mq_getsetattr 3
472 - sys sys_ni_syscall 0 /* sys_vserver */
475 sys sys_ni_syscall 0 /* available, was setaltroot */
476 sys sys_add_key 5 /* 4280 */
477 diff -NurpP --minimal linux-3.4.103/arch/mips/kernel/scall64-64.S linux-3.4.103-vs2.3.3.9/arch/mips/kernel/scall64-64.S
478 --- linux-3.4.103/arch/mips/kernel/scall64-64.S 2012-01-09 15:14:05.000000000 +0000
479 +++ linux-3.4.103-vs2.3.3.9/arch/mips/kernel/scall64-64.S 2012-05-21 16:15:04.000000000 +0000
480 @@ -362,7 +362,7 @@ sys_call_table:
481 PTR sys_mq_timedreceive
483 PTR sys_mq_getsetattr /* 5235 */
484 - PTR sys_ni_syscall /* sys_vserver */
487 PTR sys_ni_syscall /* available, was setaltroot */
489 diff -NurpP --minimal linux-3.4.103/arch/mips/kernel/scall64-n32.S linux-3.4.103-vs2.3.3.9/arch/mips/kernel/scall64-n32.S
490 --- linux-3.4.103/arch/mips/kernel/scall64-n32.S 2012-01-09 15:14:05.000000000 +0000
491 +++ linux-3.4.103-vs2.3.3.9/arch/mips/kernel/scall64-n32.S 2012-05-21 16:15:04.000000000 +0000
492 @@ -361,7 +361,7 @@ EXPORT(sysn32_call_table)
493 PTR compat_sys_mq_timedreceive
494 PTR compat_sys_mq_notify
495 PTR compat_sys_mq_getsetattr
496 - PTR sys_ni_syscall /* 6240, sys_vserver */
497 + PTR sys32_vserver /* 6240 */
498 PTR compat_sys_waitid
499 PTR sys_ni_syscall /* available, was setaltroot */
501 diff -NurpP --minimal linux-3.4.103/arch/mips/kernel/scall64-o32.S linux-3.4.103-vs2.3.3.9/arch/mips/kernel/scall64-o32.S
502 --- linux-3.4.103/arch/mips/kernel/scall64-o32.S 2012-01-09 15:14:05.000000000 +0000
503 +++ linux-3.4.103-vs2.3.3.9/arch/mips/kernel/scall64-o32.S 2012-05-21 16:15:04.000000000 +0000
504 @@ -480,7 +480,7 @@ sys_call_table:
505 PTR compat_sys_mq_timedreceive
506 PTR compat_sys_mq_notify /* 4275 */
507 PTR compat_sys_mq_getsetattr
508 - PTR sys_ni_syscall /* sys_vserver */
511 PTR sys_ni_syscall /* available, was setaltroot */
512 PTR sys_add_key /* 4280 */
513 diff -NurpP --minimal linux-3.4.103/arch/mips/kernel/traps.c linux-3.4.103-vs2.3.3.9/arch/mips/kernel/traps.c
514 --- linux-3.4.103/arch/mips/kernel/traps.c 2012-05-21 16:06:27.000000000 +0000
515 +++ linux-3.4.103-vs2.3.3.9/arch/mips/kernel/traps.c 2012-05-21 16:15:04.000000000 +0000
516 @@ -343,9 +343,10 @@ void show_registers(struct pt_regs *regs
520 - printk("Process %s (pid: %d, threadinfo=%p, task=%p, tls=%0*lx)\n",
521 - current->comm, current->pid, current_thread_info(), current,
522 - field, current_thread_info()->tp_value);
523 + printk("Process %s (pid: %d:#%u, threadinfo=%p, task=%p, tls=%0*lx)\n",
524 + current->comm, task_pid_nr(current), current->xid,
525 + current_thread_info(), current,
526 + field, current_thread_info()->tp_value);
527 if (cpu_has_userlocal) {
530 diff -NurpP --minimal linux-3.4.103/arch/parisc/Kconfig linux-3.4.103-vs2.3.3.9/arch/parisc/Kconfig
531 --- linux-3.4.103/arch/parisc/Kconfig 2012-03-19 18:46:44.000000000 +0000
532 +++ linux-3.4.103-vs2.3.3.9/arch/parisc/Kconfig 2012-05-21 16:15:04.000000000 +0000
533 @@ -279,6 +279,8 @@ source "fs/Kconfig"
535 source "arch/parisc/Kconfig.debug"
537 +source "kernel/vserver/Kconfig"
539 source "security/Kconfig"
541 source "crypto/Kconfig"
542 diff -NurpP --minimal linux-3.4.103/arch/parisc/kernel/syscall_table.S linux-3.4.103-vs2.3.3.9/arch/parisc/kernel/syscall_table.S
543 --- linux-3.4.103/arch/parisc/kernel/syscall_table.S 2014-08-30 13:36:29.000000000 +0000
544 +++ linux-3.4.103-vs2.3.3.9/arch/parisc/kernel/syscall_table.S 2014-06-12 11:34:32.000000000 +0000
546 ENTRY_COMP(mbind) /* 260 */
547 ENTRY_COMP(get_mempolicy)
548 ENTRY_COMP(set_mempolicy)
549 - ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */
550 + ENTRY_DIFF(vserver)
552 ENTRY_SAME(request_key) /* 265 */
554 diff -NurpP --minimal linux-3.4.103/arch/parisc/kernel/traps.c linux-3.4.103-vs2.3.3.9/arch/parisc/kernel/traps.c
555 --- linux-3.4.103/arch/parisc/kernel/traps.c 2014-08-30 13:36:29.000000000 +0000
556 +++ linux-3.4.103-vs2.3.3.9/arch/parisc/kernel/traps.c 2013-10-26 18:10:20.000000000 +0000
557 @@ -235,8 +235,9 @@ void die_if_kernel(char *str, struct pt_
561 - printk(KERN_CRIT "%s (pid %d): %s (code %ld) at " RFMT "\n",
562 - current->comm, task_pid_nr(current), str, err, regs->iaoq[0]);
563 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld) at " RFMT "\n",
564 + current->comm, task_pid_nr(current), current->xid,
565 + str, err, regs->iaoq[0]);
566 #ifdef PRINT_USER_FAULTS
567 /* XXX for debugging only */
569 @@ -269,8 +270,8 @@ void die_if_kernel(char *str, struct pt_
570 pdc_console_restart();
573 - printk(KERN_CRIT "%s (pid %d): %s (code %ld)\n",
574 - current->comm, task_pid_nr(current), str, err);
575 + printk(KERN_CRIT "%s (pid %d:#%u): %s (code %ld)\n",
576 + current->comm, task_pid_nr(current), current->xid, str, err);
578 /* Wot's wrong wif bein' racy? */
579 if (current->thread.flags & PARISC_KERNEL_DEATH) {
580 diff -NurpP --minimal linux-3.4.103/arch/parisc/mm/fault.c linux-3.4.103-vs2.3.3.9/arch/parisc/mm/fault.c
581 --- linux-3.4.103/arch/parisc/mm/fault.c 2010-08-02 14:52:06.000000000 +0000
582 +++ linux-3.4.103-vs2.3.3.9/arch/parisc/mm/fault.c 2012-05-21 16:15:04.000000000 +0000
583 @@ -237,8 +237,9 @@ bad_area:
585 #ifdef PRINT_USER_FAULTS
586 printk(KERN_DEBUG "\n");
587 - printk(KERN_DEBUG "do_page_fault() pid=%d command='%s' type=%lu address=0x%08lx\n",
588 - task_pid_nr(tsk), tsk->comm, code, address);
589 + printk(KERN_DEBUG "do_page_fault() pid=%d:#%u "
590 + "command='%s' type=%lu address=0x%08lx\n",
591 + task_pid_nr(tsk), tsk->xid, tsk->comm, code, address);
593 printk(KERN_DEBUG "vm_start = 0x%08lx, vm_end = 0x%08lx\n",
594 vma->vm_start, vma->vm_end);
595 diff -NurpP --minimal linux-3.4.103/arch/powerpc/Kconfig linux-3.4.103-vs2.3.3.9/arch/powerpc/Kconfig
596 --- linux-3.4.103/arch/powerpc/Kconfig 2014-08-30 13:36:29.000000000 +0000
597 +++ linux-3.4.103-vs2.3.3.9/arch/powerpc/Kconfig 2013-10-26 18:10:20.000000000 +0000
598 @@ -1003,6 +1003,8 @@ source "lib/Kconfig"
600 source "arch/powerpc/Kconfig.debug"
602 +source "kernel/vserver/Kconfig"
604 source "security/Kconfig"
607 diff -NurpP --minimal linux-3.4.103/arch/powerpc/include/asm/unistd.h linux-3.4.103-vs2.3.3.9/arch/powerpc/include/asm/unistd.h
608 --- linux-3.4.103/arch/powerpc/include/asm/unistd.h 2012-01-09 15:14:05.000000000 +0000
609 +++ linux-3.4.103-vs2.3.3.9/arch/powerpc/include/asm/unistd.h 2012-05-21 16:15:04.000000000 +0000
612 #define __NR_rtas 255
613 #define __NR_sys_debug_setcontext 256
614 -/* Number 257 is reserved for vserver */
615 +#define __NR_vserver 257
616 #define __NR_migrate_pages 258
617 #define __NR_mbind 259
618 #define __NR_get_mempolicy 260
619 diff -NurpP --minimal linux-3.4.103/arch/powerpc/kernel/process.c linux-3.4.103-vs2.3.3.9/arch/powerpc/kernel/process.c
620 --- linux-3.4.103/arch/powerpc/kernel/process.c 2014-08-30 13:36:29.000000000 +0000
621 +++ linux-3.4.103-vs2.3.3.9/arch/powerpc/kernel/process.c 2013-07-14 13:38:26.000000000 +0000
622 @@ -661,8 +661,9 @@ void show_regs(struct pt_regs * regs)
624 printk("DAR: "REG", DSISR: %08lx\n", regs->dar, regs->dsisr);
626 - printk("TASK = %p[%d] '%s' THREAD: %p",
627 - current, task_pid_nr(current), current->comm, task_thread_info(current));
628 + printk("TASK = %p[%d,#%u] '%s' THREAD: %p",
629 + current, task_pid_nr(current), current->xid,
630 + current->comm, task_thread_info(current));
633 printk(" CPU: %d", raw_smp_processor_id());
634 diff -NurpP --minimal linux-3.4.103/arch/powerpc/kernel/traps.c linux-3.4.103-vs2.3.3.9/arch/powerpc/kernel/traps.c
635 --- linux-3.4.103/arch/powerpc/kernel/traps.c 2014-08-30 13:36:29.000000000 +0000
636 +++ linux-3.4.103-vs2.3.3.9/arch/powerpc/kernel/traps.c 2014-08-30 13:55:46.000000000 +0000
637 @@ -1135,8 +1135,9 @@ void nonrecoverable_exception(struct pt_
639 void trace_syscall(struct pt_regs *regs)
641 - printk("Task: %p(%d), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
642 - current, task_pid_nr(current), regs->nip, regs->link, regs->gpr[0],
643 + printk("Task: %p(%d[#%u]), PC: %08lX/%08lX, Syscall: %3ld, Result: %s%ld %s\n",
644 + current, task_pid_nr(current), current->xid,
645 + regs->nip, regs->link, regs->gpr[0],
646 regs->ccr&0x10000000?"Error=":"", regs->gpr[3], print_tainted());
649 diff -NurpP --minimal linux-3.4.103/arch/s390/Kconfig linux-3.4.103-vs2.3.3.9/arch/s390/Kconfig
650 --- linux-3.4.103/arch/s390/Kconfig 2012-05-21 16:06:32.000000000 +0000
651 +++ linux-3.4.103-vs2.3.3.9/arch/s390/Kconfig 2012-05-21 16:15:04.000000000 +0000
652 @@ -639,6 +639,8 @@ source "fs/Kconfig"
654 source "arch/s390/Kconfig.debug"
656 +source "kernel/vserver/Kconfig"
658 source "security/Kconfig"
660 source "crypto/Kconfig"
661 diff -NurpP --minimal linux-3.4.103/arch/s390/include/asm/tlb.h linux-3.4.103-vs2.3.3.9/arch/s390/include/asm/tlb.h
662 --- linux-3.4.103/arch/s390/include/asm/tlb.h 2012-05-21 16:06:32.000000000 +0000
663 +++ linux-3.4.103-vs2.3.3.9/arch/s390/include/asm/tlb.h 2012-05-21 16:15:04.000000000 +0000
665 #include <linux/mm.h>
666 #include <linux/pagemap.h>
667 #include <linux/swap.h>
669 #include <asm/processor.h>
670 #include <asm/pgalloc.h>
671 #include <asm/tlbflush.h>
672 diff -NurpP --minimal linux-3.4.103/arch/s390/include/asm/unistd.h linux-3.4.103-vs2.3.3.9/arch/s390/include/asm/unistd.h
673 --- linux-3.4.103/arch/s390/include/asm/unistd.h 2012-03-19 18:46:48.000000000 +0000
674 +++ linux-3.4.103-vs2.3.3.9/arch/s390/include/asm/unistd.h 2012-05-21 16:15:04.000000000 +0000
676 #define __NR_clock_gettime (__NR_timer_create+6)
677 #define __NR_clock_getres (__NR_timer_create+7)
678 #define __NR_clock_nanosleep (__NR_timer_create+8)
679 -/* Number 263 is reserved for vserver */
680 +#define __NR_vserver 263
681 #define __NR_statfs64 265
682 #define __NR_fstatfs64 266
683 #define __NR_remap_file_pages 267
684 diff -NurpP --minimal linux-3.4.103/arch/s390/kernel/ptrace.c linux-3.4.103-vs2.3.3.9/arch/s390/kernel/ptrace.c
685 --- linux-3.4.103/arch/s390/kernel/ptrace.c 2014-08-30 13:36:31.000000000 +0000
686 +++ linux-3.4.103-vs2.3.3.9/arch/s390/kernel/ptrace.c 2014-08-30 13:55:46.000000000 +0000
688 #include <linux/tracehook.h>
689 #include <linux/seccomp.h>
690 #include <linux/compat.h>
691 +#include <linux/vs_base.h>
692 #include <trace/syscall.h>
693 #include <asm/segment.h>
694 #include <asm/page.h>
695 diff -NurpP --minimal linux-3.4.103/arch/s390/kernel/syscalls.S linux-3.4.103-vs2.3.3.9/arch/s390/kernel/syscalls.S
696 --- linux-3.4.103/arch/s390/kernel/syscalls.S 2012-01-09 15:14:06.000000000 +0000
697 +++ linux-3.4.103-vs2.3.3.9/arch/s390/kernel/syscalls.S 2012-05-21 16:15:04.000000000 +0000
698 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett
699 SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */
700 SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper)
701 SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper)
702 -NI_SYSCALL /* reserved for vserver */
703 +SYSCALL(sys_vserver,sys_vserver,sys32_vserver)
704 SYSCALL(sys_s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper)
705 SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper)
706 SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper)
707 diff -NurpP --minimal linux-3.4.103/arch/sh/Kconfig linux-3.4.103-vs2.3.3.9/arch/sh/Kconfig
708 --- linux-3.4.103/arch/sh/Kconfig 2012-05-21 16:06:33.000000000 +0000
709 +++ linux-3.4.103-vs2.3.3.9/arch/sh/Kconfig 2012-05-21 16:15:04.000000000 +0000
710 @@ -905,6 +905,8 @@ source "fs/Kconfig"
712 source "arch/sh/Kconfig.debug"
714 +source "kernel/vserver/Kconfig"
716 source "security/Kconfig"
718 source "crypto/Kconfig"
719 diff -NurpP --minimal linux-3.4.103/arch/sh/kernel/irq.c linux-3.4.103-vs2.3.3.9/arch/sh/kernel/irq.c
720 --- linux-3.4.103/arch/sh/kernel/irq.c 2011-07-22 09:17:41.000000000 +0000
721 +++ linux-3.4.103-vs2.3.3.9/arch/sh/kernel/irq.c 2012-05-21 16:15:04.000000000 +0000
723 #include <linux/ftrace.h>
724 #include <linux/delay.h>
725 #include <linux/ratelimit.h>
726 +// #include <linux/vs_context.h>
727 #include <asm/processor.h>
728 #include <asm/machvec.h>
729 #include <asm/uaccess.h>
730 diff -NurpP --minimal linux-3.4.103/arch/sparc/Kconfig linux-3.4.103-vs2.3.3.9/arch/sparc/Kconfig
731 --- linux-3.4.103/arch/sparc/Kconfig 2014-08-30 13:36:32.000000000 +0000
732 +++ linux-3.4.103-vs2.3.3.9/arch/sparc/Kconfig 2014-05-20 04:30:31.000000000 +0000
733 @@ -599,6 +599,8 @@ source "fs/Kconfig"
735 source "arch/sparc/Kconfig.debug"
737 +source "kernel/vserver/Kconfig"
739 source "security/Kconfig"
741 source "crypto/Kconfig"
742 diff -NurpP --minimal linux-3.4.103/arch/sparc/include/asm/unistd.h linux-3.4.103-vs2.3.3.9/arch/sparc/include/asm/unistd.h
743 --- linux-3.4.103/arch/sparc/include/asm/unistd.h 2012-01-09 15:14:07.000000000 +0000
744 +++ linux-3.4.103-vs2.3.3.9/arch/sparc/include/asm/unistd.h 2012-05-21 16:15:04.000000000 +0000
746 #define __NR_timer_getoverrun 264
747 #define __NR_timer_delete 265
748 #define __NR_timer_create 266
749 -/* #define __NR_vserver 267 Reserved for VSERVER */
750 +#define __NR_vserver 267
751 #define __NR_io_setup 268
752 #define __NR_io_destroy 269
753 #define __NR_io_submit 270
754 diff -NurpP --minimal linux-3.4.103/arch/sparc/kernel/systbls_32.S linux-3.4.103-vs2.3.3.9/arch/sparc/kernel/systbls_32.S
755 --- linux-3.4.103/arch/sparc/kernel/systbls_32.S 2012-01-09 15:14:09.000000000 +0000
756 +++ linux-3.4.103-vs2.3.3.9/arch/sparc/kernel/systbls_32.S 2012-05-21 16:15:04.000000000 +0000
757 @@ -70,7 +70,7 @@ sys_call_table:
758 /*250*/ .long sys_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_ni_syscall
759 /*255*/ .long sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
760 /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
761 -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy
762 +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
763 /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
764 /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
765 /*280*/ .long sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
766 diff -NurpP --minimal linux-3.4.103/arch/sparc/kernel/systbls_64.S linux-3.4.103-vs2.3.3.9/arch/sparc/kernel/systbls_64.S
767 --- linux-3.4.103/arch/sparc/kernel/systbls_64.S 2014-08-30 13:36:32.000000000 +0000
768 +++ linux-3.4.103-vs2.3.3.9/arch/sparc/kernel/systbls_64.S 2012-06-08 13:57:24.000000000 +0000
769 @@ -71,7 +71,7 @@ sys_call_table32:
770 /*250*/ .word sys_mremap, compat_sys_sysctl, sys32_getsid, sys_fdatasync, sys_nis_syscall
771 .word sys32_sync_file_range, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep
772 /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun
773 - .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy
774 + .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy
775 /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink
776 .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid
777 /*280*/ .word sys32_tee, sys_add_key, sys_request_key, compat_sys_keyctl, compat_sys_openat
778 @@ -148,7 +148,7 @@ sys_call_table:
779 /*250*/ .word sys_64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nis_syscall
780 .word sys_sync_file_range, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep
781 /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun
782 - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy
783 + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy
784 /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink
785 .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid
786 /*280*/ .word sys_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
787 diff -NurpP --minimal linux-3.4.103/arch/um/Kconfig.rest linux-3.4.103-vs2.3.3.9/arch/um/Kconfig.rest
788 --- linux-3.4.103/arch/um/Kconfig.rest 2012-01-09 15:14:09.000000000 +0000
789 +++ linux-3.4.103-vs2.3.3.9/arch/um/Kconfig.rest 2012-05-21 16:15:04.000000000 +0000
790 @@ -12,6 +12,8 @@ source "arch/um/Kconfig.net"
794 +source "kernel/vserver/Kconfig"
796 source "security/Kconfig"
798 source "crypto/Kconfig"
799 diff -NurpP --minimal linux-3.4.103/arch/x86/Kconfig linux-3.4.103-vs2.3.3.9/arch/x86/Kconfig
800 --- linux-3.4.103/arch/x86/Kconfig 2014-08-30 13:36:32.000000000 +0000
801 +++ linux-3.4.103-vs2.3.3.9/arch/x86/Kconfig 2014-08-30 13:55:46.000000000 +0000
802 @@ -2239,6 +2239,8 @@ source "fs/Kconfig"
804 source "arch/x86/Kconfig.debug"
806 +source "kernel/vserver/Kconfig"
808 source "security/Kconfig"
810 source "crypto/Kconfig"
811 diff -NurpP --minimal linux-3.4.103/arch/x86/syscalls/syscall_32.tbl linux-3.4.103-vs2.3.3.9/arch/x86/syscalls/syscall_32.tbl
812 --- linux-3.4.103/arch/x86/syscalls/syscall_32.tbl 2012-05-21 16:06:42.000000000 +0000
813 +++ linux-3.4.103-vs2.3.3.9/arch/x86/syscalls/syscall_32.tbl 2012-05-21 16:15:04.000000000 +0000
815 270 i386 tgkill sys_tgkill
816 271 i386 utimes sys_utimes compat_sys_utimes
817 272 i386 fadvise64_64 sys_fadvise64_64 sys32_fadvise64_64
819 +273 i386 vserver sys_vserver sys32_vserver
820 274 i386 mbind sys_mbind
821 275 i386 get_mempolicy sys_get_mempolicy compat_sys_get_mempolicy
822 276 i386 set_mempolicy sys_set_mempolicy
823 diff -NurpP --minimal linux-3.4.103/arch/x86/syscalls/syscall_64.tbl linux-3.4.103-vs2.3.3.9/arch/x86/syscalls/syscall_64.tbl
824 --- linux-3.4.103/arch/x86/syscalls/syscall_64.tbl 2014-08-30 13:36:34.000000000 +0000
825 +++ linux-3.4.103-vs2.3.3.9/arch/x86/syscalls/syscall_64.tbl 2014-08-30 13:55:46.000000000 +0000
827 233 common epoll_ctl sys_epoll_ctl
828 234 common tgkill sys_tgkill
829 235 common utimes sys_utimes
831 +236 64 vserver sys_vserver
832 237 common mbind sys_mbind
833 238 common set_mempolicy sys_set_mempolicy
834 239 common get_mempolicy sys_get_mempolicy
835 diff -NurpP --minimal linux-3.4.103/drivers/block/Kconfig linux-3.4.103-vs2.3.3.9/drivers/block/Kconfig
836 --- linux-3.4.103/drivers/block/Kconfig 2012-05-21 16:06:43.000000000 +0000
837 +++ linux-3.4.103-vs2.3.3.9/drivers/block/Kconfig 2012-05-21 16:15:04.000000000 +0000
838 @@ -290,6 +290,13 @@ config BLK_DEV_CRYPTOLOOP
840 source "drivers/block/drbd/Kconfig"
842 +config BLK_DEV_VROOT
843 + tristate "Virtual Root device support"
844 + depends on QUOTACTL
846 + Saying Y here will allow you to use quota/fs ioctls on a shared
847 + partition within a virtual server without compromising security.
850 tristate "Network block device support"
852 diff -NurpP --minimal linux-3.4.103/drivers/block/Makefile linux-3.4.103-vs2.3.3.9/drivers/block/Makefile
853 --- linux-3.4.103/drivers/block/Makefile 2012-03-19 18:46:52.000000000 +0000
854 +++ linux-3.4.103-vs2.3.3.9/drivers/block/Makefile 2012-05-21 16:15:04.000000000 +0000
855 @@ -35,6 +35,7 @@ obj-$(CONFIG_VIODASD) += viodasd.o
856 obj-$(CONFIG_BLK_DEV_SX8) += sx8.o
857 obj-$(CONFIG_BLK_DEV_UB) += ub.o
858 obj-$(CONFIG_BLK_DEV_HD) += hd.o
859 +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o
861 obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o
862 obj-$(CONFIG_XEN_BLKDEV_BACKEND) += xen-blkback/
863 diff -NurpP --minimal linux-3.4.103/drivers/block/loop.c linux-3.4.103-vs2.3.3.9/drivers/block/loop.c
864 --- linux-3.4.103/drivers/block/loop.c 2014-08-30 13:36:37.000000000 +0000
865 +++ linux-3.4.103-vs2.3.3.9/drivers/block/loop.c 2014-03-12 09:55:28.000000000 +0000
867 #include <linux/sysfs.h>
868 #include <linux/miscdevice.h>
869 #include <linux/falloc.h>
870 +#include <linux/vs_context.h>
872 #include <asm/uaccess.h>
874 @@ -869,6 +870,7 @@ static int loop_set_fd(struct loop_devic
875 lo->lo_blocksize = lo_blocksize;
876 lo->lo_device = bdev;
877 lo->lo_flags = lo_flags;
878 + lo->lo_xid = vx_current_xid();
879 lo->lo_backing_file = file;
880 lo->transfer = transfer_none;
882 @@ -1006,6 +1008,7 @@ static int loop_clr_fd(struct loop_devic
883 lo->lo_sizelimit = 0;
884 lo->lo_encrypt_key_size = 0;
885 lo->lo_thread = NULL;
887 memset(lo->lo_encrypt_key, 0, LO_KEY_SIZE);
888 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
889 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
890 @@ -1049,7 +1052,7 @@ loop_set_status(struct loop_device *lo,
892 if (lo->lo_encrypt_key_size &&
893 lo->lo_key_owner != uid &&
894 - !capable(CAP_SYS_ADMIN))
895 + !vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP))
897 if (lo->lo_state != Lo_bound)
899 @@ -1139,7 +1142,8 @@ loop_get_status(struct loop_device *lo,
900 memcpy(info->lo_crypt_name, lo->lo_crypt_name, LO_NAME_SIZE);
901 info->lo_encrypt_type =
902 lo->lo_encryption ? lo->lo_encryption->number : 0;
903 - if (lo->lo_encrypt_key_size && capable(CAP_SYS_ADMIN)) {
904 + if (lo->lo_encrypt_key_size &&
905 + vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_CLOOP)) {
906 info->lo_encrypt_key_size = lo->lo_encrypt_key_size;
907 memcpy(info->lo_encrypt_key, lo->lo_encrypt_key,
908 lo->lo_encrypt_key_size);
909 @@ -1497,6 +1501,11 @@ static int lo_open(struct block_device *
913 + if (!vx_check(lo->lo_xid, VS_IDENT|VS_HOSTID|VS_ADMIN_P)) {
918 mutex_lock(&lo->lo_ctl_mutex);
920 mutex_unlock(&lo->lo_ctl_mutex);
921 diff -NurpP --minimal linux-3.4.103/drivers/block/vroot.c linux-3.4.103-vs2.3.3.9/drivers/block/vroot.c
922 --- linux-3.4.103/drivers/block/vroot.c 1970-01-01 00:00:00.000000000 +0000
923 +++ linux-3.4.103-vs2.3.3.9/drivers/block/vroot.c 2012-05-21 16:15:04.000000000 +0000
926 + * linux/drivers/block/vroot.c
928 + * written by Herbert Pötzl, 9/11/2002
929 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004
931 + * based on the loop.c code by Theodore Ts'o.
933 + * Copyright (C) 2002-2007 by Herbert Pötzl.
934 + * Redistribution of this file is permitted under the
935 + * GNU General Public License.
939 +#include <linux/module.h>
940 +#include <linux/moduleparam.h>
941 +#include <linux/file.h>
942 +#include <linux/major.h>
943 +#include <linux/blkdev.h>
944 +#include <linux/slab.h>
946 +#include <linux/vroot.h>
947 +#include <linux/vs_context.h>
950 +static int max_vroot = 8;
952 +static struct vroot_device *vroot_dev;
953 +static struct gendisk **disks;
956 +static int vroot_set_dev(
957 + struct vroot_device *vr,
958 + struct block_device *bdev,
961 + struct block_device *real_bdev;
963 + struct inode *inode;
967 + if (vr->vr_state != Vr_unbound)
976 + inode = file->f_dentry->d_inode;
979 + if (S_ISBLK(inode->i_mode)) {
980 + real_bdev = inode->i_bdev;
981 + vr->vr_device = real_bdev;
982 + __iget(real_bdev->bd_inode);
986 + vxdprintk(VXD_CBIT(misc, 0),
987 + "vroot[%d]_set_dev: dev=" VXF_DEV,
988 + vr->vr_number, VXD_DEV(real_bdev));
990 + vr->vr_state = Vr_bound;
999 +static int vroot_clr_dev(
1000 + struct vroot_device *vr,
1001 + struct block_device *bdev)
1003 + struct block_device *real_bdev;
1005 + if (vr->vr_state != Vr_bound)
1007 + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */
1010 + real_bdev = vr->vr_device;
1012 + vxdprintk(VXD_CBIT(misc, 0),
1013 + "vroot[%d]_clr_dev: dev=" VXF_DEV,
1014 + vr->vr_number, VXD_DEV(real_bdev));
1017 + vr->vr_state = Vr_unbound;
1018 + vr->vr_device = NULL;
1023 +static int vr_ioctl(struct block_device *bdev, fmode_t mode,
1024 + unsigned int cmd, unsigned long arg)
1026 + struct vroot_device *vr = bdev->bd_disk->private_data;
1029 + down(&vr->vr_ctl_mutex);
1031 + case VROOT_SET_DEV:
1032 + err = vroot_set_dev(vr, bdev, arg);
1034 + case VROOT_CLR_DEV:
1035 + err = vroot_clr_dev(vr, bdev);
1041 + up(&vr->vr_ctl_mutex);
1045 +static int vr_open(struct block_device *bdev, fmode_t mode)
1047 + struct vroot_device *vr = bdev->bd_disk->private_data;
1049 + down(&vr->vr_ctl_mutex);
1051 + up(&vr->vr_ctl_mutex);
1055 +static int vr_release(struct gendisk *disk, fmode_t mode)
1057 + struct vroot_device *vr = disk->private_data;
1059 + down(&vr->vr_ctl_mutex);
1061 + up(&vr->vr_ctl_mutex);
1065 +static struct block_device_operations vr_fops = {
1066 + .owner = THIS_MODULE,
1068 + .release = vr_release,
1069 + .ioctl = vr_ioctl,
1072 +static void vroot_make_request(struct request_queue *q, struct bio *bio)
1074 + printk("vroot_make_request %p, %p\n", q, bio);
1075 + bio_io_error(bio);
1078 +struct block_device *__vroot_get_real_bdev(struct block_device *bdev)
1080 + struct inode *inode = bdev->bd_inode;
1081 + struct vroot_device *vr;
1082 + struct block_device *real_bdev;
1083 + int minor = iminor(inode);
1085 + vr = &vroot_dev[minor];
1086 + real_bdev = vr->vr_device;
1088 + vxdprintk(VXD_CBIT(misc, 0),
1089 + "vroot[%d]_get_real_bdev: dev=" VXF_DEV,
1090 + vr->vr_number, VXD_DEV(real_bdev));
1092 + if (vr->vr_state != Vr_bound)
1093 + return ERR_PTR(-ENXIO);
1095 + __iget(real_bdev->bd_inode);
1102 + * And now the modules code and kernel interface.
1105 +module_param(max_vroot, int, 0);
1107 +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)");
1108 +MODULE_LICENSE("GPL");
1109 +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR);
1111 +MODULE_AUTHOR ("Herbert Pötzl");
1112 +MODULE_DESCRIPTION ("Virtual Root Device Mapper");
1115 +int __init vroot_init(void)
1119 + if (max_vroot < 1 || max_vroot > 256) {
1120 + max_vroot = MAX_VROOT_DEFAULT;
1121 + printk(KERN_WARNING "vroot: invalid max_vroot "
1122 + "(must be between 1 and 256), "
1123 + "using default (%d)\n", max_vroot);
1126 + if (register_blkdev(VROOT_MAJOR, "vroot"))
1130 + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL);
1133 + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device));
1135 + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL);
1139 + for (i = 0; i < max_vroot; i++) {
1140 + disks[i] = alloc_disk(1);
1143 + disks[i]->queue = blk_alloc_queue(GFP_KERNEL);
1144 + if (!disks[i]->queue)
1146 + blk_queue_make_request(disks[i]->queue, vroot_make_request);
1149 + for (i = 0; i < max_vroot; i++) {
1150 + struct vroot_device *vr = &vroot_dev[i];
1151 + struct gendisk *disk = disks[i];
1153 + memset(vr, 0, sizeof(*vr));
1154 + sema_init(&vr->vr_ctl_mutex, 1);
1155 + vr->vr_number = i;
1156 + disk->major = VROOT_MAJOR;
1157 + disk->first_minor = i;
1158 + disk->fops = &vr_fops;
1159 + sprintf(disk->disk_name, "vroot%d", i);
1160 + disk->private_data = vr;
1163 + err = register_vroot_grb(&__vroot_get_real_bdev);
1167 + for (i = 0; i < max_vroot; i++)
1168 + add_disk(disks[i]);
1169 + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot);
1174 + put_disk(disks[i]);
1179 + unregister_blkdev(VROOT_MAJOR, "vroot");
1180 + printk(KERN_ERR "vroot: ran out of memory\n");
1184 +void vroot_exit(void)
1188 + if (unregister_vroot_grb(&__vroot_get_real_bdev))
1189 + printk(KERN_WARNING "vroot: cannot unregister grb\n");
1191 + for (i = 0; i < max_vroot; i++) {
1192 + del_gendisk(disks[i]);
1193 + put_disk(disks[i]);
1195 + unregister_blkdev(VROOT_MAJOR, "vroot");
1201 +module_init(vroot_init);
1202 +module_exit(vroot_exit);
1206 +static int __init max_vroot_setup(char *str)
1208 + max_vroot = simple_strtol(str, NULL, 0);
1212 +__setup("max_vroot=", max_vroot_setup);
1216 diff -NurpP --minimal linux-3.4.103/drivers/infiniband/Kconfig linux-3.4.103-vs2.3.3.9/drivers/infiniband/Kconfig
1217 --- linux-3.4.103/drivers/infiniband/Kconfig 2012-03-19 18:46:54.000000000 +0000
1218 +++ linux-3.4.103-vs2.3.3.9/drivers/infiniband/Kconfig 2012-05-21 16:15:04.000000000 +0000
1219 @@ -39,7 +39,7 @@ config INFINIBAND_USER_MEM
1220 config INFINIBAND_ADDR_TRANS
1223 - depends on !(INFINIBAND = y && IPV6 = m)
1224 + depends on !(INFINIBAND = y && IPV6 = y)
1227 source "drivers/infiniband/hw/mthca/Kconfig"
1228 diff -NurpP --minimal linux-3.4.103/drivers/infiniband/core/addr.c linux-3.4.103-vs2.3.3.9/drivers/infiniband/core/addr.c
1229 --- linux-3.4.103/drivers/infiniband/core/addr.c 2012-05-21 16:06:46.000000000 +0000
1230 +++ linux-3.4.103-vs2.3.3.9/drivers/infiniband/core/addr.c 2012-05-21 16:15:04.000000000 +0000
1231 @@ -263,7 +263,7 @@ static int addr6_resolve(struct sockaddr
1233 if (ipv6_addr_any(&fl6.saddr)) {
1234 ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
1235 - &fl6.daddr, 0, &fl6.saddr);
1236 + &fl6.daddr, 0, &fl6.saddr, NULL);
1240 diff -NurpP --minimal linux-3.4.103/drivers/md/dm-ioctl.c linux-3.4.103-vs2.3.3.9/drivers/md/dm-ioctl.c
1241 --- linux-3.4.103/drivers/md/dm-ioctl.c 2014-08-30 13:36:47.000000000 +0000
1242 +++ linux-3.4.103-vs2.3.3.9/drivers/md/dm-ioctl.c 2014-03-12 09:55:28.000000000 +0000
1244 #include <linux/dm-ioctl.h>
1245 #include <linux/hdreg.h>
1246 #include <linux/compat.h>
1247 +#include <linux/vs_context.h>
1249 #include <asm/uaccess.h>
1251 @@ -106,7 +107,8 @@ static struct hash_cell *__get_name_cell
1252 unsigned int h = hash_str(str);
1254 list_for_each_entry (hc, _name_buckets + h, name_list)
1255 - if (!strcmp(hc->name, str)) {
1256 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1257 + !strcmp(hc->name, str)) {
1261 @@ -120,7 +122,8 @@ static struct hash_cell *__get_uuid_cell
1262 unsigned int h = hash_str(str);
1264 list_for_each_entry (hc, _uuid_buckets + h, uuid_list)
1265 - if (!strcmp(hc->uuid, str)) {
1266 + if (vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT) &&
1267 + !strcmp(hc->uuid, str)) {
1271 @@ -131,13 +134,15 @@ static struct hash_cell *__get_uuid_cell
1272 static struct hash_cell *__get_dev_cell(uint64_t dev)
1274 struct mapped_device *md;
1275 - struct hash_cell *hc;
1276 + struct hash_cell *hc = NULL;
1278 md = dm_get_md(huge_decode_dev(dev));
1282 - hc = dm_get_mdptr(md);
1283 + if (vx_check(dm_get_xid(md), VS_WATCH_P | VS_IDENT))
1284 + hc = dm_get_mdptr(md);
1289 @@ -445,6 +450,9 @@ typedef int (*ioctl_fn)(struct dm_ioctl
1291 static int remove_all(struct dm_ioctl *param, size_t param_size)
1293 + if (!vx_check(0, VS_ADMIN))
1296 dm_hash_remove_all(1);
1297 param->data_size = 0;
1299 @@ -492,6 +500,8 @@ static int list_devices(struct dm_ioctl
1301 for (i = 0; i < NUM_BUCKETS; i++) {
1302 list_for_each_entry (hc, _name_buckets + i, name_list) {
1303 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1305 needed += sizeof(struct dm_name_list);
1306 needed += strlen(hc->name) + 1;
1307 needed += ALIGN_MASK;
1308 @@ -515,6 +525,8 @@ static int list_devices(struct dm_ioctl
1310 for (i = 0; i < NUM_BUCKETS; i++) {
1311 list_for_each_entry (hc, _name_buckets + i, name_list) {
1312 + if (!vx_check(dm_get_xid(hc->md), VS_WATCH_P | VS_IDENT))
1315 old_nl->next = (uint32_t) ((void *) nl -
1317 @@ -1628,8 +1640,8 @@ static int ctl_ioctl(uint command, struc
1319 size_t input_param_size;
1321 - /* only root can play with this */
1322 - if (!capable(CAP_SYS_ADMIN))
1323 + /* only root and certain contexts can play with this */
1324 + if (!vx_capable(CAP_SYS_ADMIN, VXC_ADMIN_MAPPER))
1327 if (_IOC_TYPE(command) != DM_IOCTL)
1328 diff -NurpP --minimal linux-3.4.103/drivers/md/dm.c linux-3.4.103-vs2.3.3.9/drivers/md/dm.c
1329 --- linux-3.4.103/drivers/md/dm.c 2014-08-30 13:36:47.000000000 +0000
1330 +++ linux-3.4.103-vs2.3.3.9/drivers/md/dm.c 2014-03-12 09:55:28.000000000 +0000
1332 #include <linux/idr.h>
1333 #include <linux/hdreg.h>
1334 #include <linux/delay.h>
1335 +#include <linux/vs_base.h>
1337 #include <trace/events/block.h>
1339 @@ -131,6 +132,7 @@ struct mapped_device {
1342 atomic_t open_count;
1345 unsigned long flags;
1347 @@ -343,6 +345,7 @@ int dm_deleting_md(struct mapped_device
1348 static int dm_blk_open(struct block_device *bdev, fmode_t mode)
1350 struct mapped_device *md;
1353 spin_lock(&_minor_lock);
1355 @@ -351,18 +354,19 @@ static int dm_blk_open(struct block_devi
1358 if (test_bit(DMF_FREEING, &md->flags) ||
1359 - dm_deleting_md(md)) {
1361 + dm_deleting_md(md))
1365 + if (!vx_check(md->xid, VS_IDENT|VS_HOSTID))
1370 atomic_inc(&md->open_count);
1374 spin_unlock(&_minor_lock);
1376 - return md ? 0 : -ENXIO;
1380 static int dm_blk_close(struct gendisk *disk, fmode_t mode)
1381 @@ -583,6 +587,14 @@ int dm_set_geometry(struct mapped_device
1386 + * Get the xid associated with a dm device
1388 +xid_t dm_get_xid(struct mapped_device *md)
1393 /*-----------------------------------------------------------------
1395 * A more elegant soln is in the works that uses the queue
1396 @@ -1876,6 +1888,7 @@ static struct mapped_device *alloc_dev(i
1397 INIT_LIST_HEAD(&md->uevent_list);
1398 spin_lock_init(&md->uevent_lock);
1400 + md->xid = vx_current_xid();
1401 md->queue = blk_alloc_queue(GFP_KERNEL);
1404 diff -NurpP --minimal linux-3.4.103/drivers/md/dm.h linux-3.4.103-vs2.3.3.9/drivers/md/dm.h
1405 --- linux-3.4.103/drivers/md/dm.h 2014-08-30 13:36:47.000000000 +0000
1406 +++ linux-3.4.103-vs2.3.3.9/drivers/md/dm.h 2014-03-12 09:55:28.000000000 +0000
1407 @@ -43,6 +43,8 @@ struct dm_dev_internal {
1409 struct dm_md_mempools;
1411 +xid_t dm_get_xid(struct mapped_device *md);
1413 /*-----------------------------------------------------------------
1414 * Internal table functions.
1415 *---------------------------------------------------------------*/
1416 diff -NurpP --minimal linux-3.4.103/drivers/net/tun.c linux-3.4.103-vs2.3.3.9/drivers/net/tun.c
1417 --- linux-3.4.103/drivers/net/tun.c 2014-08-30 13:36:58.000000000 +0000
1418 +++ linux-3.4.103-vs2.3.3.9/drivers/net/tun.c 2014-03-12 09:55:28.000000000 +0000
1420 #include <linux/nsproxy.h>
1421 #include <linux/virtio_net.h>
1422 #include <linux/rcupdate.h>
1423 +#include <linux/vs_network.h>
1424 #include <net/ipv6.h>
1425 #include <net/net_namespace.h>
1426 #include <net/netns/generic.h>
1427 @@ -120,6 +121,7 @@ struct tun_struct {
1433 struct net_device *dev;
1434 netdev_features_t set_features;
1435 @@ -916,6 +918,7 @@ static void tun_setup(struct net_device
1439 + tun->nid = current->nid;
1441 dev->ethtool_ops = &tun_ethtool_ops;
1442 dev->destructor = tun_free_netdev;
1443 @@ -1074,7 +1077,7 @@ static int tun_set_iff(struct net *net,
1445 if (((tun->owner != -1 && cred->euid != tun->owner) ||
1446 (tun->group != -1 && !in_egroup_p(tun->group))) &&
1447 - !capable(CAP_NET_ADMIN))
1448 + !cap_raised(current_cap(), CAP_NET_ADMIN))
1450 err = security_tun_dev_attach(tun->socket.sk);
1452 @@ -1088,7 +1091,7 @@ static int tun_set_iff(struct net *net,
1454 unsigned long flags = 0;
1456 - if (!capable(CAP_NET_ADMIN))
1457 + if (!nx_capable(CAP_NET_ADMIN, NXC_TUN_CREATE))
1459 err = security_tun_dev_create();
1461 @@ -1158,6 +1161,9 @@ static int tun_set_iff(struct net *net,
1463 sk->sk_destruct = tun_sock_destruct;
1465 + if (!nx_check(tun->nid, VS_IDENT | VS_HOSTID | VS_ADMIN_P))
1468 err = tun_attach(tun, file);
1471 @@ -1341,6 +1347,16 @@ static long __tun_chr_ioctl(struct file
1472 tun_debug(KERN_INFO, tun, "group set to %d\n", tun->group);
1476 + if (!capable(CAP_CONTEXT))
1479 + /* Set nid owner of the device */
1480 + tun->nid = (nid_t) arg;
1482 + tun_debug(KERN_INFO, tun, "nid owner set to %u\n", tun->nid);
1486 /* Only allow setting the type when the interface is down */
1487 if (tun->dev->flags & IFF_UP) {
1488 diff -NurpP --minimal linux-3.4.103/drivers/tty/sysrq.c linux-3.4.103-vs2.3.3.9/drivers/tty/sysrq.c
1489 --- linux-3.4.103/drivers/tty/sysrq.c 2012-05-21 16:07:16.000000000 +0000
1490 +++ linux-3.4.103-vs2.3.3.9/drivers/tty/sysrq.c 2012-05-21 16:15:04.000000000 +0000
1492 #include <linux/slab.h>
1493 #include <linux/input.h>
1494 #include <linux/uaccess.h>
1495 +#include <linux/vserver/debug.h>
1497 #include <asm/ptrace.h>
1498 #include <asm/irq_regs.h>
1499 @@ -398,6 +399,21 @@ static struct sysrq_key_op sysrq_unrt_op
1500 .enable_mask = SYSRQ_ENABLE_RTNICE,
1504 +#ifdef CONFIG_VSERVER_DEBUG
1505 +static void sysrq_handle_vxinfo(int key)
1507 + dump_vx_info_inactive((key == 'x') ? 0 : 1);
1510 +static struct sysrq_key_op sysrq_showvxinfo_op = {
1511 + .handler = sysrq_handle_vxinfo,
1512 + .help_msg = "conteXt",
1513 + .action_msg = "Show Context Info",
1514 + .enable_mask = SYSRQ_ENABLE_DUMP,
1518 /* Key Operations table and lock */
1519 static DEFINE_SPINLOCK(sysrq_key_table_lock);
1521 @@ -452,7 +468,11 @@ static struct sysrq_key_op *sysrq_key_ta
1523 &sysrq_showstate_blocked_op, /* w */
1524 /* x: May be registered on ppc/powerpc for xmon */
1525 +#ifdef CONFIG_VSERVER_DEBUG
1526 + &sysrq_showvxinfo_op, /* x */
1530 /* y: May be registered on sparc64 for global register dump */
1532 &sysrq_ftrace_dump_op, /* z */
1533 @@ -467,6 +487,8 @@ static int sysrq_key_table_key2index(int
1535 else if ((key >= 'a') && (key <= 'z'))
1536 retval = key + 10 - 'a';
1537 + else if ((key >= 'A') && (key <= 'Z'))
1538 + retval = key + 10 - 'A';
1542 diff -NurpP --minimal linux-3.4.103/drivers/tty/tty_io.c linux-3.4.103-vs2.3.3.9/drivers/tty/tty_io.c
1543 --- linux-3.4.103/drivers/tty/tty_io.c 2014-08-30 13:37:08.000000000 +0000
1544 +++ linux-3.4.103-vs2.3.3.9/drivers/tty/tty_io.c 2013-07-14 13:38:33.000000000 +0000
1547 #include <linux/kmod.h>
1548 #include <linux/nsproxy.h>
1549 +#include <linux/vs_pid.h>
1551 #undef TTY_DEBUG_HANGUP
1553 @@ -2128,7 +2129,8 @@ static int tiocsti(struct tty_struct *tt
1555 struct tty_ldisc *ld;
1557 - if ((current->signal->tty != tty) && !capable(CAP_SYS_ADMIN))
1558 + if (((current->signal->tty != tty) &&
1559 + !vx_capable(CAP_SYS_ADMIN, VXC_TIOCSTI)))
1561 if (get_user(ch, p))
1563 @@ -2416,6 +2418,7 @@ static int tiocspgrp(struct tty_struct *
1565 if (get_user(pgrp_nr, p))
1567 + pgrp_nr = vx_rmap_pid(pgrp_nr);
1571 diff -NurpP --minimal linux-3.4.103/fs/attr.c linux-3.4.103-vs2.3.3.9/fs/attr.c
1572 --- linux-3.4.103/fs/attr.c 2014-08-30 13:37:12.000000000 +0000
1573 +++ linux-3.4.103-vs2.3.3.9/fs/attr.c 2012-06-28 14:45:07.000000000 +0000
1575 #include <linux/fcntl.h>
1576 #include <linux/security.h>
1577 #include <linux/evm.h>
1578 +#include <linux/proc_fs.h>
1579 +#include <linux/devpts_fs.h>
1580 +#include <linux/vs_tag.h>
1583 * inode_change_ok - check if attribute changes to an inode are allowed
1584 @@ -74,6 +77,10 @@ int inode_change_ok(const struct inode *
1588 + /* check for inode tag permission */
1589 + if (dx_permission(inode, MAY_WRITE))
1594 EXPORT_SYMBOL(inode_change_ok);
1595 @@ -144,6 +151,8 @@ void setattr_copy(struct inode *inode, c
1596 inode->i_uid = attr->ia_uid;
1597 if (ia_valid & ATTR_GID)
1598 inode->i_gid = attr->ia_gid;
1599 + if ((ia_valid & ATTR_TAG) && IS_TAGGED(inode))
1600 + inode->i_tag = attr->ia_tag;
1601 if (ia_valid & ATTR_ATIME)
1602 inode->i_atime = timespec_trunc(attr->ia_atime,
1603 inode->i_sb->s_time_gran);
1604 @@ -171,7 +180,8 @@ int notify_change(struct dentry * dentry
1605 struct timespec now;
1606 unsigned int ia_valid = attr->ia_valid;
1608 - if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) {
1609 + if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
1610 + ATTR_TAG | ATTR_TIMES_SET)) {
1611 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1614 diff -NurpP --minimal linux-3.4.103/fs/block_dev.c linux-3.4.103-vs2.3.3.9/fs/block_dev.c
1615 --- linux-3.4.103/fs/block_dev.c 2014-08-30 13:37:12.000000000 +0000
1616 +++ linux-3.4.103-vs2.3.3.9/fs/block_dev.c 2013-08-13 17:07:36.000000000 +0000
1618 #include <linux/namei.h>
1619 #include <linux/log2.h>
1620 #include <linux/cleancache.h>
1621 +#include <linux/vs_device.h>
1622 #include <asm/uaccess.h>
1623 #include "internal.h"
1625 @@ -588,6 +589,7 @@ struct block_device *bdget(dev_t dev)
1626 bdev->bd_invalidated = 0;
1627 inode->i_mode = S_IFBLK;
1628 inode->i_rdev = dev;
1629 + inode->i_mdev = dev;
1630 inode->i_bdev = bdev;
1631 inode->i_data.a_ops = &def_blk_aops;
1632 mapping_set_gfp_mask(&inode->i_data, GFP_USER);
1633 @@ -635,6 +637,11 @@ EXPORT_SYMBOL(bdput);
1634 static struct block_device *bd_acquire(struct inode *inode)
1636 struct block_device *bdev;
1639 + if (!vs_map_blkdev(inode->i_rdev, &mdev, DATTR_OPEN))
1641 + inode->i_mdev = mdev;
1643 spin_lock(&bdev_lock);
1644 bdev = inode->i_bdev;
1645 @@ -645,7 +652,7 @@ static struct block_device *bd_acquire(s
1647 spin_unlock(&bdev_lock);
1649 - bdev = bdget(inode->i_rdev);
1650 + bdev = bdget(mdev);
1652 spin_lock(&bdev_lock);
1653 if (!inode->i_bdev) {
1654 diff -NurpP --minimal linux-3.4.103/fs/btrfs/ctree.h linux-3.4.103-vs2.3.3.9/fs/btrfs/ctree.h
1655 --- linux-3.4.103/fs/btrfs/ctree.h 2012-05-21 16:07:18.000000000 +0000
1656 +++ linux-3.4.103-vs2.3.3.9/fs/btrfs/ctree.h 2012-05-21 16:15:04.000000000 +0000
1657 @@ -668,11 +668,14 @@ struct btrfs_inode_item {
1658 /* modification sequence number for NFS */
1663 * a little future expansion, for more than this we can
1664 * just grow the inode item and version it
1666 - __le64 reserved[4];
1667 + __le16 reserved16;
1668 + __le32 reserved32;
1669 + __le64 reserved[3];
1670 struct btrfs_timespec atime;
1671 struct btrfs_timespec ctime;
1672 struct btrfs_timespec mtime;
1673 @@ -1542,6 +1545,8 @@ struct btrfs_ioctl_defrag_range_args {
1674 #define BTRFS_MOUNT_CHECK_INTEGRITY_INCLUDING_EXTENT_DATA (1 << 21)
1675 #define BTRFS_MOUNT_PANIC_ON_FATAL_ERROR (1 << 22)
1677 +#define BTRFS_MOUNT_TAGGED (1 << 24)
1679 #define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
1680 #define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
1681 #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \
1682 @@ -1762,6 +1767,7 @@ BTRFS_SETGET_FUNCS(inode_block_group, st
1683 BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32);
1684 BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32);
1685 BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32);
1686 +BTRFS_SETGET_FUNCS(inode_tag, struct btrfs_inode_item, tag, 16);
1687 BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32);
1688 BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64);
1689 BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
1690 @@ -1815,6 +1821,10 @@ BTRFS_SETGET_FUNCS(extent_flags, struct
1692 BTRFS_SETGET_FUNCS(extent_refs_v0, struct btrfs_extent_item_v0, refs, 32);
1694 +#define BTRFS_INODE_IXUNLINK (1 << 24)
1695 +#define BTRFS_INODE_BARRIER (1 << 25)
1696 +#define BTRFS_INODE_COW (1 << 26)
1699 BTRFS_SETGET_FUNCS(tree_block_level, struct btrfs_tree_block_info, level, 8);
1701 @@ -2959,6 +2969,7 @@ extern const struct dentry_operations bt
1702 long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1703 void btrfs_update_iflags(struct inode *inode);
1704 void btrfs_inherit_iflags(struct inode *inode, struct inode *dir);
1705 +int btrfs_sync_flags(struct inode *inode, int, int);
1706 int btrfs_defrag_file(struct inode *inode, struct file *file,
1707 struct btrfs_ioctl_defrag_range_args *range,
1708 u64 newer_than, unsigned long max_pages);
1709 diff -NurpP --minimal linux-3.4.103/fs/btrfs/disk-io.c linux-3.4.103-vs2.3.3.9/fs/btrfs/disk-io.c
1710 --- linux-3.4.103/fs/btrfs/disk-io.c 2012-05-21 16:07:18.000000000 +0000
1711 +++ linux-3.4.103-vs2.3.3.9/fs/btrfs/disk-io.c 2012-05-21 16:15:04.000000000 +0000
1712 @@ -2083,6 +2083,9 @@ int open_ctree(struct super_block *sb,
1716 + if (btrfs_test_opt(tree_root, TAGGED))
1717 + sb->s_flags |= MS_TAGGED;
1719 features = btrfs_super_incompat_flags(disk_super) &
1720 ~BTRFS_FEATURE_INCOMPAT_SUPP;
1722 diff -NurpP --minimal linux-3.4.103/fs/btrfs/inode.c linux-3.4.103-vs2.3.3.9/fs/btrfs/inode.c
1723 --- linux-3.4.103/fs/btrfs/inode.c 2014-08-30 13:37:13.000000000 +0000
1724 +++ linux-3.4.103-vs2.3.3.9/fs/btrfs/inode.c 2013-07-14 13:38:34.000000000 +0000
1726 #include <linux/slab.h>
1727 #include <linux/ratelimit.h>
1728 #include <linux/mount.h>
1729 +#include <linux/vs_tag.h>
1732 #include "disk-io.h"
1733 @@ -2482,6 +2483,8 @@ static void btrfs_read_locked_inode(stru
1734 struct btrfs_key location;
1740 bool filled = false;
1742 @@ -2509,8 +2512,13 @@ static void btrfs_read_locked_inode(stru
1743 struct btrfs_inode_item);
1744 inode->i_mode = btrfs_inode_mode(leaf, inode_item);
1745 set_nlink(inode, btrfs_inode_nlink(leaf, inode_item));
1746 - inode->i_uid = btrfs_inode_uid(leaf, inode_item);
1747 - inode->i_gid = btrfs_inode_gid(leaf, inode_item);
1749 + uid = btrfs_inode_uid(leaf, inode_item);
1750 + gid = btrfs_inode_gid(leaf, inode_item);
1751 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
1752 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
1753 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
1754 + btrfs_inode_tag(leaf, inode_item));
1755 btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item));
1757 tspec = btrfs_inode_atime(inode_item);
1758 @@ -2588,8 +2596,14 @@ static void fill_inode_item(struct btrfs
1759 struct btrfs_inode_item *item,
1760 struct inode *inode)
1762 - btrfs_set_inode_uid(leaf, item, inode->i_uid);
1763 - btrfs_set_inode_gid(leaf, item, inode->i_gid);
1764 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
1765 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
1767 + btrfs_set_inode_uid(leaf, item, uid);
1768 + btrfs_set_inode_gid(leaf, item, gid);
1769 +#ifdef CONFIG_TAGGING_INTERN
1770 + btrfs_set_inode_tag(leaf, item, inode->i_tag);
1772 btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
1773 btrfs_set_inode_mode(leaf, item, inode->i_mode);
1774 btrfs_set_inode_nlink(leaf, item, inode->i_nlink);
1775 @@ -7590,11 +7604,13 @@ static const struct inode_operations btr
1776 .listxattr = btrfs_listxattr,
1777 .removexattr = btrfs_removexattr,
1778 .permission = btrfs_permission,
1779 + .sync_flags = btrfs_sync_flags,
1780 .get_acl = btrfs_get_acl,
1782 static const struct inode_operations btrfs_dir_ro_inode_operations = {
1783 .lookup = btrfs_lookup,
1784 .permission = btrfs_permission,
1785 + .sync_flags = btrfs_sync_flags,
1786 .get_acl = btrfs_get_acl,
1789 diff -NurpP --minimal linux-3.4.103/fs/btrfs/ioctl.c linux-3.4.103-vs2.3.3.9/fs/btrfs/ioctl.c
1790 --- linux-3.4.103/fs/btrfs/ioctl.c 2014-08-30 13:37:13.000000000 +0000
1791 +++ linux-3.4.103-vs2.3.3.9/fs/btrfs/ioctl.c 2013-07-14 13:38:34.000000000 +0000
1792 @@ -71,10 +71,13 @@ static unsigned int btrfs_flags_to_ioctl
1794 unsigned int iflags = 0;
1796 - if (flags & BTRFS_INODE_SYNC)
1797 - iflags |= FS_SYNC_FL;
1798 if (flags & BTRFS_INODE_IMMUTABLE)
1799 iflags |= FS_IMMUTABLE_FL;
1800 + if (flags & BTRFS_INODE_IXUNLINK)
1801 + iflags |= FS_IXUNLINK_FL;
1803 + if (flags & BTRFS_INODE_SYNC)
1804 + iflags |= FS_SYNC_FL;
1805 if (flags & BTRFS_INODE_APPEND)
1806 iflags |= FS_APPEND_FL;
1807 if (flags & BTRFS_INODE_NODUMP)
1808 @@ -91,28 +94,78 @@ static unsigned int btrfs_flags_to_ioctl
1809 else if (flags & BTRFS_INODE_NOCOMPRESS)
1810 iflags |= FS_NOCOMP_FL;
1812 + if (flags & BTRFS_INODE_BARRIER)
1813 + iflags |= FS_BARRIER_FL;
1814 + if (flags & BTRFS_INODE_COW)
1815 + iflags |= FS_COW_FL;
1820 - * Update inode->i_flags based on the btrfs internal flags.
1821 + * Update inode->i_(v)flags based on the btrfs internal flags.
1823 void btrfs_update_iflags(struct inode *inode)
1825 struct btrfs_inode *ip = BTRFS_I(inode);
1827 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
1828 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
1829 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
1831 - if (ip->flags & BTRFS_INODE_SYNC)
1832 - inode->i_flags |= S_SYNC;
1833 if (ip->flags & BTRFS_INODE_IMMUTABLE)
1834 inode->i_flags |= S_IMMUTABLE;
1835 + if (ip->flags & BTRFS_INODE_IXUNLINK)
1836 + inode->i_flags |= S_IXUNLINK;
1838 + if (ip->flags & BTRFS_INODE_SYNC)
1839 + inode->i_flags |= S_SYNC;
1840 if (ip->flags & BTRFS_INODE_APPEND)
1841 inode->i_flags |= S_APPEND;
1842 if (ip->flags & BTRFS_INODE_NOATIME)
1843 inode->i_flags |= S_NOATIME;
1844 if (ip->flags & BTRFS_INODE_DIRSYNC)
1845 inode->i_flags |= S_DIRSYNC;
1847 + inode->i_vflags &= ~(V_BARRIER | V_COW);
1849 + if (ip->flags & BTRFS_INODE_BARRIER)
1850 + inode->i_vflags |= V_BARRIER;
1851 + if (ip->flags & BTRFS_INODE_COW)
1852 + inode->i_vflags |= V_COW;
1856 + * Update btrfs internal flags from inode->i_(v)flags.
1858 +void btrfs_update_flags(struct inode *inode)
1860 + struct btrfs_inode *ip = BTRFS_I(inode);
1862 + unsigned int flags = inode->i_flags;
1863 + unsigned int vflags = inode->i_vflags;
1865 + ip->flags &= ~(BTRFS_INODE_SYNC | BTRFS_INODE_APPEND |
1866 + BTRFS_INODE_IMMUTABLE | BTRFS_INODE_IXUNLINK |
1867 + BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC |
1868 + BTRFS_INODE_BARRIER | BTRFS_INODE_COW);
1870 + if (flags & S_IMMUTABLE)
1871 + ip->flags |= BTRFS_INODE_IMMUTABLE;
1872 + if (flags & S_IXUNLINK)
1873 + ip->flags |= BTRFS_INODE_IXUNLINK;
1875 + if (flags & S_SYNC)
1876 + ip->flags |= BTRFS_INODE_SYNC;
1877 + if (flags & S_APPEND)
1878 + ip->flags |= BTRFS_INODE_APPEND;
1879 + if (flags & S_NOATIME)
1880 + ip->flags |= BTRFS_INODE_NOATIME;
1881 + if (flags & S_DIRSYNC)
1882 + ip->flags |= BTRFS_INODE_DIRSYNC;
1884 + if (vflags & V_BARRIER)
1885 + ip->flags |= BTRFS_INODE_BARRIER;
1886 + if (vflags & V_COW)
1887 + ip->flags |= BTRFS_INODE_COW;
1891 @@ -128,6 +181,7 @@ void btrfs_inherit_iflags(struct inode *
1894 flags = BTRFS_I(dir)->flags;
1895 + flags &= ~BTRFS_INODE_BARRIER;
1897 if (flags & BTRFS_INODE_NOCOMPRESS) {
1898 BTRFS_I(inode)->flags &= ~BTRFS_INODE_COMPRESS;
1899 @@ -143,6 +197,30 @@ void btrfs_inherit_iflags(struct inode *
1900 btrfs_update_iflags(inode);
1903 +int btrfs_sync_flags(struct inode *inode, int flags, int vflags)
1905 + struct btrfs_inode *ip = BTRFS_I(inode);
1906 + struct btrfs_root *root = ip->root;
1907 + struct btrfs_trans_handle *trans;
1910 + trans = btrfs_join_transaction(root);
1913 + inode->i_flags = flags;
1914 + inode->i_vflags = vflags;
1915 + btrfs_update_flags(inode);
1917 + ret = btrfs_update_inode(trans, root, inode);
1920 + btrfs_update_iflags(inode);
1921 + inode->i_ctime = CURRENT_TIME;
1922 + btrfs_end_transaction(trans, root);
1927 static int btrfs_ioctl_getflags(struct file *file, void __user *arg)
1929 struct btrfs_inode *ip = BTRFS_I(file->f_path.dentry->d_inode);
1930 @@ -199,7 +277,8 @@ static int btrfs_ioctl_setflags(struct f
1932 flags = btrfs_mask_flags(inode->i_mode, flags);
1933 oldflags = btrfs_flags_to_ioctl(ip->flags);
1934 - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) {
1935 + if ((flags ^ oldflags) & (FS_APPEND_FL |
1936 + FS_IMMUTABLE_FL | FS_IXUNLINK_FL)) {
1937 if (!capable(CAP_LINUX_IMMUTABLE)) {
1940 @@ -210,14 +289,19 @@ static int btrfs_ioctl_setflags(struct f
1944 - if (flags & FS_SYNC_FL)
1945 - ip->flags |= BTRFS_INODE_SYNC;
1947 - ip->flags &= ~BTRFS_INODE_SYNC;
1948 if (flags & FS_IMMUTABLE_FL)
1949 ip->flags |= BTRFS_INODE_IMMUTABLE;
1951 ip->flags &= ~BTRFS_INODE_IMMUTABLE;
1952 + if (flags & FS_IXUNLINK_FL)
1953 + ip->flags |= BTRFS_INODE_IXUNLINK;
1955 + ip->flags &= ~BTRFS_INODE_IXUNLINK;
1957 + if (flags & FS_SYNC_FL)
1958 + ip->flags |= BTRFS_INODE_SYNC;
1960 + ip->flags &= ~BTRFS_INODE_SYNC;
1961 if (flags & FS_APPEND_FL)
1962 ip->flags |= BTRFS_INODE_APPEND;
1964 diff -NurpP --minimal linux-3.4.103/fs/btrfs/super.c linux-3.4.103-vs2.3.3.9/fs/btrfs/super.c
1965 --- linux-3.4.103/fs/btrfs/super.c 2012-05-21 16:07:19.000000000 +0000
1966 +++ linux-3.4.103-vs2.3.3.9/fs/btrfs/super.c 2012-05-21 16:15:04.000000000 +0000
1967 @@ -279,7 +279,7 @@ enum {
1968 Opt_no_space_cache, Opt_recovery, Opt_skip_balance,
1969 Opt_check_integrity, Opt_check_integrity_including_extent_data,
1970 Opt_check_integrity_print_mask, Opt_fatal_errors,
1972 + Opt_tag, Opt_notag, Opt_tagid, Opt_err,
1975 static match_table_t tokens = {
1976 @@ -319,6 +319,9 @@ static match_table_t tokens = {
1977 {Opt_check_integrity_including_extent_data, "check_int_data"},
1978 {Opt_check_integrity_print_mask, "check_int_print_mask=%d"},
1979 {Opt_fatal_errors, "fatal_errors=%s"},
1981 + {Opt_notag, "notag"},
1982 + {Opt_tagid, "tagid=%u"},
1986 @@ -564,6 +567,22 @@ int btrfs_parse_options(struct btrfs_roo
1990 +#ifndef CONFIG_TAGGING_NONE
1992 + printk(KERN_INFO "btrfs: use tagging\n");
1993 + btrfs_set_opt(info->mount_opt, TAGGED);
1996 + printk(KERN_INFO "btrfs: disabled tagging\n");
1997 + btrfs_clear_opt(info->mount_opt, TAGGED);
2000 +#ifdef CONFIG_PROPAGATE
2003 + btrfs_set_opt(info->mount_opt, TAGGED);
2007 printk(KERN_INFO "btrfs: unrecognized mount option "
2009 @@ -1137,6 +1156,12 @@ static int btrfs_remount(struct super_bl
2013 + if (btrfs_test_opt(root, TAGGED) && !(sb->s_flags & MS_TAGGED)) {
2014 + printk("btrfs: %s: tagging not permitted on remount.\n",
2019 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
2022 diff -NurpP --minimal linux-3.4.103/fs/char_dev.c linux-3.4.103-vs2.3.3.9/fs/char_dev.c
2023 --- linux-3.4.103/fs/char_dev.c 2012-03-19 18:47:25.000000000 +0000
2024 +++ linux-3.4.103-vs2.3.3.9/fs/char_dev.c 2012-05-21 16:15:04.000000000 +0000
2026 #include <linux/mutex.h>
2027 #include <linux/backing-dev.h>
2028 #include <linux/tty.h>
2029 +#include <linux/vs_context.h>
2030 +#include <linux/vs_device.h>
2032 #include "internal.h"
2034 @@ -371,14 +373,21 @@ static int chrdev_open(struct inode *ino
2036 struct cdev *new = NULL;
2040 + if (!vs_map_chrdev(inode->i_rdev, &mdev, DATTR_OPEN))
2042 + inode->i_mdev = mdev;
2044 spin_lock(&cdev_lock);
2047 struct kobject *kobj;
2050 spin_unlock(&cdev_lock);
2051 - kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
2053 + kobj = kobj_lookup(cdev_map, mdev, &idx);
2056 new = container_of(kobj, struct cdev, kobj);
2057 diff -NurpP --minimal linux-3.4.103/fs/dcache.c linux-3.4.103-vs2.3.3.9/fs/dcache.c
2058 --- linux-3.4.103/fs/dcache.c 2014-08-30 13:37:13.000000000 +0000
2059 +++ linux-3.4.103-vs2.3.3.9/fs/dcache.c 2014-03-12 09:55:28.000000000 +0000
2061 #include <linux/rculist_bl.h>
2062 #include <linux/prefetch.h>
2063 #include <linux/ratelimit.h>
2064 +#include <linux/vs_limit.h>
2065 #include "internal.h"
2068 @@ -601,6 +602,8 @@ int d_invalidate(struct dentry * dentry)
2069 spin_lock(&dentry->d_lock);
2072 + vx_dentry_dec(dentry);
2075 * Somebody else still using it?
2077 @@ -630,6 +633,7 @@ EXPORT_SYMBOL(d_invalidate);
2078 static inline void __dget_dlock(struct dentry *dentry)
2081 + vx_dentry_inc(dentry);
2084 static inline void __dget(struct dentry *dentry)
2085 @@ -1260,6 +1264,9 @@ struct dentry *__d_alloc(struct super_bl
2086 struct dentry *dentry;
2089 + if (!vx_dentry_avail(1))
2092 dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
2095 @@ -1282,6 +1289,7 @@ struct dentry *__d_alloc(struct super_bl
2097 dentry->d_count = 1;
2098 dentry->d_flags = 0;
2099 + vx_dentry_inc(dentry);
2100 spin_lock_init(&dentry->d_lock);
2101 seqcount_init(&dentry->d_seq);
2102 dentry->d_inode = NULL;
2103 @@ -1943,6 +1951,7 @@ struct dentry *__d_lookup(struct dentry
2107 + vx_dentry_inc(dentry);
2109 spin_unlock(&dentry->d_lock);
2111 diff -NurpP --minimal linux-3.4.103/fs/devpts/inode.c linux-3.4.103-vs2.3.3.9/fs/devpts/inode.c
2112 --- linux-3.4.103/fs/devpts/inode.c 2014-08-30 13:37:13.000000000 +0000
2113 +++ linux-3.4.103-vs2.3.3.9/fs/devpts/inode.c 2014-03-12 09:55:28.000000000 +0000
2115 #include <linux/parser.h>
2116 #include <linux/fsnotify.h>
2117 #include <linux/seq_file.h>
2118 +#include <linux/vs_base.h>
2120 #define DEVPTS_DEFAULT_MODE 0600
2123 #define DEVPTS_DEFAULT_PTMX_MODE 0000
2124 #define PTMX_MINOR 2
2126 +static int devpts_permission(struct inode *inode, int mask)
2128 + int ret = -EACCES;
2130 + /* devpts is xid tagged */
2131 + if (vx_check((xid_t)inode->i_tag, VS_WATCH_P | VS_IDENT))
2132 + ret = generic_permission(inode, mask);
2136 +static struct inode_operations devpts_file_inode_operations = {
2137 + .permission = devpts_permission,
2142 * sysctl support for setting limits on the number of Unix98 ptys allocated.
2143 * Otherwise one can eat up all kernel memory by opening /dev/ptmx repeatedly.
2144 @@ -328,6 +344,34 @@ static int devpts_show_options(struct se
2148 +static int devpts_filter(struct dentry *de)
2152 + /* devpts is xid tagged */
2153 + if (de && de->d_inode)
2154 + xid = (xid_t)de->d_inode->i_tag;
2155 +#ifdef CONFIG_VSERVER_WARN_DEVPTS
2157 + vxwprintk_task(1, "devpts " VS_Q("%.*s") " without inode.",
2158 + de->d_name.len, de->d_name.name);
2160 + return vx_check(xid, VS_WATCH_P | VS_IDENT);
2163 +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir)
2165 + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter);
2168 +static struct file_operations devpts_dir_operations = {
2169 + .open = dcache_dir_open,
2170 + .release = dcache_dir_close,
2171 + .llseek = dcache_dir_lseek,
2172 + .read = generic_read_dir,
2173 + .readdir = devpts_readdir,
2176 static const struct super_operations devpts_sops = {
2177 .statfs = simple_statfs,
2178 .remount_fs = devpts_remount,
2179 @@ -371,8 +415,10 @@ devpts_fill_super(struct super_block *s,
2180 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2181 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
2182 inode->i_op = &simple_dir_inode_operations;
2183 - inode->i_fop = &simple_dir_operations;
2184 + inode->i_fop = &devpts_dir_operations;
2185 set_nlink(inode, 2);
2186 + /* devpts is xid tagged */
2187 + inode->i_tag = (tag_t)vx_current_xid();
2189 s->s_root = d_make_root(inode);
2191 @@ -565,6 +611,9 @@ int devpts_pty_new(struct inode *ptmx_in
2192 inode->i_gid = opts->setgid ? opts->gid : current_fsgid();
2193 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
2194 init_special_inode(inode, S_IFCHR|opts->mode, device);
2195 + /* devpts is xid tagged */
2196 + inode->i_tag = (tag_t)vx_current_xid();
2197 + inode->i_op = &devpts_file_inode_operations;
2198 inode->i_private = tty;
2199 tty->driver_data = inode;
2201 diff -NurpP --minimal linux-3.4.103/fs/ext2/balloc.c linux-3.4.103-vs2.3.3.9/fs/ext2/balloc.c
2202 --- linux-3.4.103/fs/ext2/balloc.c 2012-01-09 15:14:54.000000000 +0000
2203 +++ linux-3.4.103-vs2.3.3.9/fs/ext2/balloc.c 2012-05-21 16:15:04.000000000 +0000
2204 @@ -701,7 +701,6 @@ ext2_try_to_allocate(struct super_block
2206 end = EXT2_BLOCKS_PER_GROUP(sb);
2209 BUG_ON(start > EXT2_BLOCKS_PER_GROUP(sb));
2212 diff -NurpP --minimal linux-3.4.103/fs/ext2/ext2.h linux-3.4.103-vs2.3.3.9/fs/ext2/ext2.h
2213 --- linux-3.4.103/fs/ext2/ext2.h 2012-05-21 16:07:20.000000000 +0000
2214 +++ linux-3.4.103-vs2.3.3.9/fs/ext2/ext2.h 2012-05-21 16:15:05.000000000 +0000
2215 @@ -244,8 +244,12 @@ struct ext2_group_desc
2216 #define EXT2_NOTAIL_FL FS_NOTAIL_FL /* file tail should not be merged */
2217 #define EXT2_DIRSYNC_FL FS_DIRSYNC_FL /* dirsync behaviour (directories only) */
2218 #define EXT2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
2219 +#define EXT2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
2220 #define EXT2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
2222 +#define EXT2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
2223 +#define EXT2_COW_FL FS_COW_FL /* Copy on Write marker */
2225 #define EXT2_FL_USER_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
2226 #define EXT2_FL_USER_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
2228 @@ -329,7 +333,8 @@ struct ext2_inode {
2230 __le16 l_i_uid_high; /* these 2 fields */
2231 __le16 l_i_gid_high; /* were reserved2[0] */
2232 - __u32 l_i_reserved2;
2233 + __le16 l_i_tag; /* Context Tag */
2234 + __u16 l_i_reserved2;
2237 __u8 h_i_frag; /* Fragment number */
2238 @@ -357,6 +362,7 @@ struct ext2_inode {
2239 #define i_gid_low i_gid
2240 #define i_uid_high osd2.linux2.l_i_uid_high
2241 #define i_gid_high osd2.linux2.l_i_gid_high
2242 +#define i_raw_tag osd2.linux2.l_i_tag
2243 #define i_reserved2 osd2.linux2.l_i_reserved2
2246 @@ -384,6 +390,7 @@ struct ext2_inode {
2247 #define EXT2_MOUNT_USRQUOTA 0x020000 /* user quota */
2248 #define EXT2_MOUNT_GRPQUOTA 0x040000 /* group quota */
2249 #define EXT2_MOUNT_RESERVATION 0x080000 /* Preallocation */
2250 +#define EXT2_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
2253 #define clear_opt(o, opt) o &= ~EXT2_MOUNT_##opt
2254 @@ -757,6 +764,7 @@ extern void ext2_set_inode_flags(struct
2255 extern void ext2_get_inode_flags(struct ext2_inode_info *);
2256 extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2257 u64 start, u64 len);
2258 +extern int ext2_sync_flags(struct inode *, int, int);
2261 extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
2262 diff -NurpP --minimal linux-3.4.103/fs/ext2/file.c linux-3.4.103-vs2.3.3.9/fs/ext2/file.c
2263 --- linux-3.4.103/fs/ext2/file.c 2011-10-24 16:45:27.000000000 +0000
2264 +++ linux-3.4.103-vs2.3.3.9/fs/ext2/file.c 2012-05-21 16:15:05.000000000 +0000
2265 @@ -104,4 +104,5 @@ const struct inode_operations ext2_file_
2266 .setattr = ext2_setattr,
2267 .get_acl = ext2_get_acl,
2268 .fiemap = ext2_fiemap,
2269 + .sync_flags = ext2_sync_flags,
2271 diff -NurpP --minimal linux-3.4.103/fs/ext2/ialloc.c linux-3.4.103-vs2.3.3.9/fs/ext2/ialloc.c
2272 --- linux-3.4.103/fs/ext2/ialloc.c 2012-03-19 18:47:25.000000000 +0000
2273 +++ linux-3.4.103-vs2.3.3.9/fs/ext2/ialloc.c 2012-05-21 16:15:05.000000000 +0000
2275 #include <linux/backing-dev.h>
2276 #include <linux/buffer_head.h>
2277 #include <linux/random.h>
2278 +#include <linux/vs_tag.h>
2282 @@ -549,6 +550,7 @@ got:
2283 inode->i_mode = mode;
2284 inode->i_uid = current_fsuid();
2285 inode->i_gid = dir->i_gid;
2286 + inode->i_tag = dx_current_fstag(sb);
2288 inode_init_owner(inode, dir, mode);
2290 diff -NurpP --minimal linux-3.4.103/fs/ext2/inode.c linux-3.4.103-vs2.3.3.9/fs/ext2/inode.c
2291 --- linux-3.4.103/fs/ext2/inode.c 2012-03-19 18:47:25.000000000 +0000
2292 +++ linux-3.4.103-vs2.3.3.9/fs/ext2/inode.c 2012-05-21 16:15:05.000000000 +0000
2294 #include <linux/mpage.h>
2295 #include <linux/fiemap.h>
2296 #include <linux/namei.h>
2297 +#include <linux/vs_tag.h>
2301 @@ -1162,7 +1163,7 @@ static void ext2_truncate_blocks(struct
2303 if (ext2_inode_is_fast_symlink(inode))
2305 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
2306 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
2308 __ext2_truncate_blocks(inode, offset);
2310 @@ -1253,36 +1254,61 @@ void ext2_set_inode_flags(struct inode *
2312 unsigned int flags = EXT2_I(inode)->i_flags;
2314 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2315 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2316 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2319 + if (flags & EXT2_IMMUTABLE_FL)
2320 + inode->i_flags |= S_IMMUTABLE;
2321 + if (flags & EXT2_IXUNLINK_FL)
2322 + inode->i_flags |= S_IXUNLINK;
2324 if (flags & EXT2_SYNC_FL)
2325 inode->i_flags |= S_SYNC;
2326 if (flags & EXT2_APPEND_FL)
2327 inode->i_flags |= S_APPEND;
2328 - if (flags & EXT2_IMMUTABLE_FL)
2329 - inode->i_flags |= S_IMMUTABLE;
2330 if (flags & EXT2_NOATIME_FL)
2331 inode->i_flags |= S_NOATIME;
2332 if (flags & EXT2_DIRSYNC_FL)
2333 inode->i_flags |= S_DIRSYNC;
2335 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2337 + if (flags & EXT2_BARRIER_FL)
2338 + inode->i_vflags |= V_BARRIER;
2339 + if (flags & EXT2_COW_FL)
2340 + inode->i_vflags |= V_COW;
2343 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */
2344 void ext2_get_inode_flags(struct ext2_inode_info *ei)
2346 unsigned int flags = ei->vfs_inode.i_flags;
2347 + unsigned int vflags = ei->vfs_inode.i_vflags;
2349 + ei->i_flags &= ~(EXT2_SYNC_FL | EXT2_APPEND_FL |
2350 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL |
2351 + EXT2_NOATIME_FL | EXT2_DIRSYNC_FL |
2352 + EXT2_BARRIER_FL | EXT2_COW_FL);
2354 + if (flags & S_IMMUTABLE)
2355 + ei->i_flags |= EXT2_IMMUTABLE_FL;
2356 + if (flags & S_IXUNLINK)
2357 + ei->i_flags |= EXT2_IXUNLINK_FL;
2359 - ei->i_flags &= ~(EXT2_SYNC_FL|EXT2_APPEND_FL|
2360 - EXT2_IMMUTABLE_FL|EXT2_NOATIME_FL|EXT2_DIRSYNC_FL);
2362 ei->i_flags |= EXT2_SYNC_FL;
2363 if (flags & S_APPEND)
2364 ei->i_flags |= EXT2_APPEND_FL;
2365 - if (flags & S_IMMUTABLE)
2366 - ei->i_flags |= EXT2_IMMUTABLE_FL;
2367 if (flags & S_NOATIME)
2368 ei->i_flags |= EXT2_NOATIME_FL;
2369 if (flags & S_DIRSYNC)
2370 ei->i_flags |= EXT2_DIRSYNC_FL;
2372 + if (vflags & V_BARRIER)
2373 + ei->i_flags |= EXT2_BARRIER_FL;
2374 + if (vflags & V_COW)
2375 + ei->i_flags |= EXT2_COW_FL;
2378 struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
2379 @@ -1292,6 +1318,8 @@ struct inode *ext2_iget (struct super_bl
2380 struct ext2_inode *raw_inode;
2381 struct inode *inode;
2387 inode = iget_locked(sb, ino);
2388 @@ -1310,12 +1338,16 @@ struct inode *ext2_iget (struct super_bl
2391 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2392 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2393 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2394 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2395 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2396 if (!(test_opt (inode->i_sb, NO_UID32))) {
2397 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2398 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2399 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2400 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2402 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2403 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2404 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2405 + le16_to_cpu(raw_inode->i_raw_tag));
2406 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
2407 inode->i_size = le32_to_cpu(raw_inode->i_size);
2408 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2409 @@ -1413,8 +1445,8 @@ static int __ext2_write_inode(struct ino
2410 struct ext2_inode_info *ei = EXT2_I(inode);
2411 struct super_block *sb = inode->i_sb;
2412 ino_t ino = inode->i_ino;
2413 - uid_t uid = inode->i_uid;
2414 - gid_t gid = inode->i_gid;
2415 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2416 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2417 struct buffer_head * bh;
2418 struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh);
2420 @@ -1450,6 +1482,9 @@ static int __ext2_write_inode(struct ino
2421 raw_inode->i_uid_high = 0;
2422 raw_inode->i_gid_high = 0;
2424 +#ifdef CONFIG_TAGGING_INTERN
2425 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2427 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2428 raw_inode->i_size = cpu_to_le32(inode->i_size);
2429 raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec);
2430 @@ -1530,7 +1565,8 @@ int ext2_setattr(struct dentry *dentry,
2431 if (is_quota_modification(inode, iattr))
2432 dquot_initialize(inode);
2433 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
2434 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
2435 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
2436 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
2437 error = dquot_transfer(inode, iattr);
2440 diff -NurpP --minimal linux-3.4.103/fs/ext2/ioctl.c linux-3.4.103-vs2.3.3.9/fs/ext2/ioctl.c
2441 --- linux-3.4.103/fs/ext2/ioctl.c 2012-03-19 18:47:25.000000000 +0000
2442 +++ linux-3.4.103-vs2.3.3.9/fs/ext2/ioctl.c 2012-05-21 16:15:05.000000000 +0000
2444 #include <asm/uaccess.h>
2447 +int ext2_sync_flags(struct inode *inode, int flags, int vflags)
2449 + inode->i_flags = flags;
2450 + inode->i_vflags = vflags;
2451 + ext2_get_inode_flags(EXT2_I(inode));
2452 + inode->i_ctime = CURRENT_TIME_SEC;
2453 + mark_inode_dirty(inode);
2457 long ext2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2459 struct inode *inode = filp->f_dentry->d_inode;
2460 @@ -51,6 +61,11 @@ long ext2_ioctl(struct file *filp, unsig
2462 flags = ext2_mask_flags(inode->i_mode, flags);
2464 + if (IS_BARRIER(inode)) {
2465 + vxwprintk_task(1, "messing with the barrier.");
2469 mutex_lock(&inode->i_mutex);
2470 /* Is it quota file? Do not allow user to mess with it */
2471 if (IS_NOQUOTA(inode)) {
2472 @@ -66,7 +81,9 @@ long ext2_ioctl(struct file *filp, unsig
2474 * This test looks nicer. Thanks to Pauline Middelink
2476 - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
2477 + if ((oldflags & EXT2_IMMUTABLE_FL) ||
2478 + ((flags ^ oldflags) & (EXT2_APPEND_FL |
2479 + EXT2_IMMUTABLE_FL | EXT2_IXUNLINK_FL))) {
2480 if (!capable(CAP_LINUX_IMMUTABLE)) {
2481 mutex_unlock(&inode->i_mutex);
2483 @@ -74,7 +91,7 @@ long ext2_ioctl(struct file *filp, unsig
2487 - flags = flags & EXT2_FL_USER_MODIFIABLE;
2488 + flags &= EXT2_FL_USER_MODIFIABLE;
2489 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
2490 ei->i_flags = flags;
2492 diff -NurpP --minimal linux-3.4.103/fs/ext2/namei.c linux-3.4.103-vs2.3.3.9/fs/ext2/namei.c
2493 --- linux-3.4.103/fs/ext2/namei.c 2012-05-21 16:07:20.000000000 +0000
2494 +++ linux-3.4.103-vs2.3.3.9/fs/ext2/namei.c 2012-05-21 16:15:05.000000000 +0000
2497 #include <linux/pagemap.h>
2498 #include <linux/quotaops.h>
2499 +#include <linux/vs_tag.h>
2503 @@ -73,6 +74,7 @@ static struct dentry *ext2_lookup(struct
2504 (unsigned long) ino);
2505 return ERR_PTR(-EIO);
2507 + dx_propagate_tag(nd, inode);
2509 return d_splice_alias(inode, dentry);
2511 @@ -397,6 +399,7 @@ const struct inode_operations ext2_dir_i
2512 .removexattr = generic_removexattr,
2514 .setattr = ext2_setattr,
2515 + .sync_flags = ext2_sync_flags,
2516 .get_acl = ext2_get_acl,
2519 diff -NurpP --minimal linux-3.4.103/fs/ext2/super.c linux-3.4.103-vs2.3.3.9/fs/ext2/super.c
2520 --- linux-3.4.103/fs/ext2/super.c 2012-05-21 16:07:20.000000000 +0000
2521 +++ linux-3.4.103-vs2.3.3.9/fs/ext2/super.c 2012-05-21 16:15:05.000000000 +0000
2522 @@ -393,7 +393,8 @@ enum {
2523 Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug,
2524 Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
2525 Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota,
2526 - Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
2527 + Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation,
2528 + Opt_tag, Opt_notag, Opt_tagid
2531 static const match_table_t tokens = {
2532 @@ -421,6 +422,9 @@ static const match_table_t tokens = {
2534 {Opt_noacl, "noacl"},
2537 + {Opt_notag, "notag"},
2538 + {Opt_tagid, "tagid=%u"},
2539 {Opt_grpquota, "grpquota"},
2540 {Opt_ignore, "noquota"},
2541 {Opt_quota, "quota"},
2542 @@ -491,6 +495,20 @@ static int parse_options(char *options,
2544 set_opt (sbi->s_mount_opt, NO_UID32);
2546 +#ifndef CONFIG_TAGGING_NONE
2548 + set_opt (sbi->s_mount_opt, TAGGED);
2551 + clear_opt (sbi->s_mount_opt, TAGGED);
2554 +#ifdef CONFIG_PROPAGATE
2557 + set_opt (sbi->s_mount_opt, TAGGED);
2561 clear_opt (sbi->s_mount_opt, CHECK);
2563 @@ -849,6 +867,8 @@ static int ext2_fill_super(struct super_
2564 if (!parse_options((char *) data, sb))
2567 + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGGED)
2568 + sb->s_flags |= MS_TAGGED;
2569 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2570 ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ?
2572 @@ -1222,6 +1242,14 @@ static int ext2_remount (struct super_bl
2577 + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGGED) &&
2578 + !(sb->s_flags & MS_TAGGED)) {
2579 + printk("EXT2-fs: %s: tagging not permitted on remount.\n",
2582 + goto restore_opts;
2585 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2586 ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0);
2587 diff -NurpP --minimal linux-3.4.103/fs/ext3/ext3.h linux-3.4.103-vs2.3.3.9/fs/ext3/ext3.h
2588 --- linux-3.4.103/fs/ext3/ext3.h 2014-08-30 13:37:13.000000000 +0000
2589 +++ linux-3.4.103-vs2.3.3.9/fs/ext3/ext3.h 2014-03-12 09:55:28.000000000 +0000
2590 @@ -151,10 +151,14 @@ struct ext3_group_desc
2591 #define EXT3_NOTAIL_FL 0x00008000 /* file tail should not be merged */
2592 #define EXT3_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
2593 #define EXT3_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
2594 +#define EXT3_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
2595 #define EXT3_RESERVED_FL 0x80000000 /* reserved for ext3 lib */
2597 -#define EXT3_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
2598 -#define EXT3_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
2599 +#define EXT3_BARRIER_FL 0x04000000 /* Barrier for chroot() */
2600 +#define EXT3_COW_FL 0x20000000 /* Copy on Write marker */
2602 +#define EXT3_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
2603 +#define EXT3_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
2605 /* Flags that should be inherited by new inodes from their parent. */
2606 #define EXT3_FL_INHERITED (EXT3_SECRM_FL | EXT3_UNRM_FL | EXT3_COMPR_FL |\
2607 @@ -290,7 +294,8 @@ struct ext3_inode {
2609 __le16 l_i_uid_high; /* these 2 fields */
2610 __le16 l_i_gid_high; /* were reserved2[0] */
2611 - __u32 l_i_reserved2;
2612 + __le16 l_i_tag; /* Context Tag */
2613 + __u16 l_i_reserved2;
2616 __u8 h_i_frag; /* Fragment number */
2617 @@ -320,6 +325,7 @@ struct ext3_inode {
2618 #define i_gid_low i_gid
2619 #define i_uid_high osd2.linux2.l_i_uid_high
2620 #define i_gid_high osd2.linux2.l_i_gid_high
2621 +#define i_raw_tag osd2.linux2.l_i_tag
2622 #define i_reserved2 osd2.linux2.l_i_reserved2
2625 @@ -364,6 +370,7 @@ struct ext3_inode {
2626 #define EXT3_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
2627 #define EXT3_MOUNT_DATA_ERR_ABORT 0x400000 /* Abort on file data write
2628 * error in ordered mode */
2629 +#define EXT3_MOUNT_TAGGED (1<<24) /* Enable Context Tags */
2631 /* Compatibility, for having both ext2_fs.h and ext3_fs.h included at once */
2632 #ifndef _LINUX_EXT2_FS_H
2633 @@ -1061,6 +1068,7 @@ extern void ext3_get_inode_flags(struct
2634 extern void ext3_set_aops(struct inode *inode);
2635 extern int ext3_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2636 u64 start, u64 len);
2637 +extern int ext3_sync_flags(struct inode *, int, int);
2640 extern long ext3_ioctl(struct file *, unsigned int, unsigned long);
2641 diff -NurpP --minimal linux-3.4.103/fs/ext3/file.c linux-3.4.103-vs2.3.3.9/fs/ext3/file.c
2642 --- linux-3.4.103/fs/ext3/file.c 2012-05-21 16:07:20.000000000 +0000
2643 +++ linux-3.4.103-vs2.3.3.9/fs/ext3/file.c 2012-05-21 16:15:05.000000000 +0000
2644 @@ -76,5 +76,6 @@ const struct inode_operations ext3_file_
2646 .get_acl = ext3_get_acl,
2647 .fiemap = ext3_fiemap,
2648 + .sync_flags = ext3_sync_flags,
2651 diff -NurpP --minimal linux-3.4.103/fs/ext3/ialloc.c linux-3.4.103-vs2.3.3.9/fs/ext3/ialloc.c
2652 --- linux-3.4.103/fs/ext3/ialloc.c 2012-05-21 16:07:20.000000000 +0000
2653 +++ linux-3.4.103-vs2.3.3.9/fs/ext3/ialloc.c 2012-05-21 16:15:05.000000000 +0000
2656 #include <linux/quotaops.h>
2657 #include <linux/random.h>
2658 +#include <linux/vs_tag.h>
2662 @@ -485,6 +486,7 @@ got:
2663 inode->i_mode = mode;
2664 inode->i_uid = current_fsuid();
2665 inode->i_gid = dir->i_gid;
2666 + inode->i_tag = dx_current_fstag(sb);
2668 inode_init_owner(inode, dir, mode);
2670 diff -NurpP --minimal linux-3.4.103/fs/ext3/inode.c linux-3.4.103-vs2.3.3.9/fs/ext3/inode.c
2671 --- linux-3.4.103/fs/ext3/inode.c 2014-08-30 13:37:14.000000000 +0000
2672 +++ linux-3.4.103-vs2.3.3.9/fs/ext3/inode.c 2013-08-13 17:07:36.000000000 +0000
2674 #include <linux/writeback.h>
2675 #include <linux/mpage.h>
2676 #include <linux/namei.h>
2677 +#include <linux/vs_tag.h>
2682 @@ -2849,36 +2851,60 @@ void ext3_set_inode_flags(struct inode *
2684 unsigned int flags = EXT3_I(inode)->i_flags;
2686 - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
2687 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
2688 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
2690 + if (flags & EXT3_IMMUTABLE_FL)
2691 + inode->i_flags |= S_IMMUTABLE;
2692 + if (flags & EXT3_IXUNLINK_FL)
2693 + inode->i_flags |= S_IXUNLINK;
2695 if (flags & EXT3_SYNC_FL)
2696 inode->i_flags |= S_SYNC;
2697 if (flags & EXT3_APPEND_FL)
2698 inode->i_flags |= S_APPEND;
2699 - if (flags & EXT3_IMMUTABLE_FL)
2700 - inode->i_flags |= S_IMMUTABLE;
2701 if (flags & EXT3_NOATIME_FL)
2702 inode->i_flags |= S_NOATIME;
2703 if (flags & EXT3_DIRSYNC_FL)
2704 inode->i_flags |= S_DIRSYNC;
2706 + inode->i_vflags &= ~(V_BARRIER | V_COW);
2708 + if (flags & EXT3_BARRIER_FL)
2709 + inode->i_vflags |= V_BARRIER;
2710 + if (flags & EXT3_COW_FL)
2711 + inode->i_vflags |= V_COW;
2714 /* Propagate flags from i_flags to EXT3_I(inode)->i_flags */
2715 void ext3_get_inode_flags(struct ext3_inode_info *ei)
2717 unsigned int flags = ei->vfs_inode.i_flags;
2718 + unsigned int vflags = ei->vfs_inode.i_vflags;
2720 + ei->i_flags &= ~(EXT3_SYNC_FL | EXT3_APPEND_FL |
2721 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL |
2722 + EXT3_NOATIME_FL | EXT3_DIRSYNC_FL |
2723 + EXT3_BARRIER_FL | EXT3_COW_FL);
2725 + if (flags & S_IMMUTABLE)
2726 + ei->i_flags |= EXT3_IMMUTABLE_FL;
2727 + if (flags & S_IXUNLINK)
2728 + ei->i_flags |= EXT3_IXUNLINK_FL;
2730 - ei->i_flags &= ~(EXT3_SYNC_FL|EXT3_APPEND_FL|
2731 - EXT3_IMMUTABLE_FL|EXT3_NOATIME_FL|EXT3_DIRSYNC_FL);
2733 ei->i_flags |= EXT3_SYNC_FL;
2734 if (flags & S_APPEND)
2735 ei->i_flags |= EXT3_APPEND_FL;
2736 - if (flags & S_IMMUTABLE)
2737 - ei->i_flags |= EXT3_IMMUTABLE_FL;
2738 if (flags & S_NOATIME)
2739 ei->i_flags |= EXT3_NOATIME_FL;
2740 if (flags & S_DIRSYNC)
2741 ei->i_flags |= EXT3_DIRSYNC_FL;
2743 + if (vflags & V_BARRIER)
2744 + ei->i_flags |= EXT3_BARRIER_FL;
2745 + if (vflags & V_COW)
2746 + ei->i_flags |= EXT3_COW_FL;
2749 struct inode *ext3_iget(struct super_block *sb, unsigned long ino)
2750 @@ -2892,6 +2918,8 @@ struct inode *ext3_iget(struct super_blo
2751 transaction_t *transaction;
2757 inode = iget_locked(sb, ino);
2759 @@ -2908,12 +2936,16 @@ struct inode *ext3_iget(struct super_blo
2761 raw_inode = ext3_raw_inode(&iloc);
2762 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
2763 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2764 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2765 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
2766 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
2767 if(!(test_opt (inode->i_sb, NO_UID32))) {
2768 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2769 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2770 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
2771 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
2773 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
2774 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
2775 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
2776 + le16_to_cpu(raw_inode->i_raw_tag));
2777 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
2778 inode->i_size = le32_to_cpu(raw_inode->i_size);
2779 inode->i_atime.tv_sec = (signed)le32_to_cpu(raw_inode->i_atime);
2780 @@ -3068,6 +3100,8 @@ static int ext3_do_update_inode(handle_t
2781 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
2782 struct ext3_inode_info *ei = EXT3_I(inode);
2783 struct buffer_head *bh = iloc->bh;
2784 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
2785 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
2786 int err = 0, rc, block;
2787 int need_datasync = 0;
2789 @@ -3084,29 +3118,32 @@ again:
2790 ext3_get_inode_flags(ei);
2791 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
2792 if(!(test_opt(inode->i_sb, NO_UID32))) {
2793 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
2794 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
2795 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
2796 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
2798 * Fix up interoperability with old kernels. Otherwise, old inodes get
2799 * re-used with the upper 16 bits of the uid/gid intact
2802 raw_inode->i_uid_high =
2803 - cpu_to_le16(high_16_bits(inode->i_uid));
2804 + cpu_to_le16(high_16_bits(uid));
2805 raw_inode->i_gid_high =
2806 - cpu_to_le16(high_16_bits(inode->i_gid));
2807 + cpu_to_le16(high_16_bits(gid));
2809 raw_inode->i_uid_high = 0;
2810 raw_inode->i_gid_high = 0;
2813 raw_inode->i_uid_low =
2814 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
2815 + cpu_to_le16(fs_high2lowuid(uid));
2816 raw_inode->i_gid_low =
2817 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
2818 + cpu_to_le16(fs_high2lowgid(gid));
2819 raw_inode->i_uid_high = 0;
2820 raw_inode->i_gid_high = 0;
2822 +#ifdef CONFIG_TAGGING_INTERN
2823 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
2825 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
2826 disksize = cpu_to_le32(ei->i_disksize);
2827 if (disksize != raw_inode->i_size) {
2828 @@ -3275,7 +3312,8 @@ int ext3_setattr(struct dentry *dentry,
2829 if (is_quota_modification(inode, attr))
2830 dquot_initialize(inode);
2831 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
2832 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
2833 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
2834 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
2837 /* (user+group)*(old+new) structure, inode write (sb,
2838 @@ -3297,6 +3335,8 @@ int ext3_setattr(struct dentry *dentry,
2839 inode->i_uid = attr->ia_uid;
2840 if (attr->ia_valid & ATTR_GID)
2841 inode->i_gid = attr->ia_gid;
2842 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
2843 + inode->i_tag = attr->ia_tag;
2844 error = ext3_mark_inode_dirty(handle, inode);
2845 ext3_journal_stop(handle);
2847 diff -NurpP --minimal linux-3.4.103/fs/ext3/ioctl.c linux-3.4.103-vs2.3.3.9/fs/ext3/ioctl.c
2848 --- linux-3.4.103/fs/ext3/ioctl.c 2012-05-21 16:07:20.000000000 +0000
2849 +++ linux-3.4.103-vs2.3.3.9/fs/ext3/ioctl.c 2012-05-21 16:15:05.000000000 +0000
2851 #include <asm/uaccess.h>
2855 +int ext3_sync_flags(struct inode *inode, int flags, int vflags)
2857 + handle_t *handle = NULL;
2858 + struct ext3_iloc iloc;
2861 + handle = ext3_journal_start(inode, 1);
2862 + if (IS_ERR(handle))
2863 + return PTR_ERR(handle);
2865 + if (IS_SYNC(inode))
2866 + handle->h_sync = 1;
2867 + err = ext3_reserve_inode_write(handle, inode, &iloc);
2871 + inode->i_flags = flags;
2872 + inode->i_vflags = vflags;
2873 + ext3_get_inode_flags(EXT3_I(inode));
2874 + inode->i_ctime = CURRENT_TIME_SEC;
2876 + err = ext3_mark_iloc_dirty(handle, inode, &iloc);
2878 + ext3_journal_stop(handle);
2882 long ext3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
2884 struct inode *inode = filp->f_dentry->d_inode;
2885 @@ -45,6 +73,11 @@ long ext3_ioctl(struct file *filp, unsig
2887 flags = ext3_mask_flags(inode->i_mode, flags);
2889 + if (IS_BARRIER(inode)) {
2890 + vxwprintk_task(1, "messing with the barrier.");
2894 mutex_lock(&inode->i_mutex);
2896 /* Is it quota file? Do not allow user to mess with it */
2897 @@ -63,7 +96,9 @@ long ext3_ioctl(struct file *filp, unsig
2899 * This test looks nicer. Thanks to Pauline Middelink
2901 - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) {
2902 + if ((oldflags & EXT3_IMMUTABLE_FL) ||
2903 + ((flags ^ oldflags) & (EXT3_APPEND_FL |
2904 + EXT3_IMMUTABLE_FL | EXT3_IXUNLINK_FL))) {
2905 if (!capable(CAP_LINUX_IMMUTABLE))
2908 @@ -88,7 +123,7 @@ long ext3_ioctl(struct file *filp, unsig
2912 - flags = flags & EXT3_FL_USER_MODIFIABLE;
2913 + flags &= EXT3_FL_USER_MODIFIABLE;
2914 flags |= oldflags & ~EXT3_FL_USER_MODIFIABLE;
2915 ei->i_flags = flags;
2917 diff -NurpP --minimal linux-3.4.103/fs/ext3/namei.c linux-3.4.103-vs2.3.3.9/fs/ext3/namei.c
2918 --- linux-3.4.103/fs/ext3/namei.c 2014-08-30 13:37:14.000000000 +0000
2919 +++ linux-3.4.103-vs2.3.3.9/fs/ext3/namei.c 2013-08-13 17:07:36.000000000 +0000
2923 #include <linux/quotaops.h>
2924 +#include <linux/vs_tag.h>
2929 @@ -912,6 +914,7 @@ restart:
2930 submit_bh(READ | REQ_META | REQ_PRIO,
2933 + dx_propagate_tag(nd, inode);
2936 if ((bh = bh_use[ra_ptr++]) == NULL)
2937 @@ -2523,6 +2526,7 @@ const struct inode_operations ext3_dir_i
2938 .listxattr = ext3_listxattr,
2939 .removexattr = generic_removexattr,
2941 + .sync_flags = ext3_sync_flags,
2942 .get_acl = ext3_get_acl,
2945 diff -NurpP --minimal linux-3.4.103/fs/ext3/super.c linux-3.4.103-vs2.3.3.9/fs/ext3/super.c
2946 --- linux-3.4.103/fs/ext3/super.c 2014-08-30 13:37:14.000000000 +0000
2947 +++ linux-3.4.103-vs2.3.3.9/fs/ext3/super.c 2013-03-30 21:29:17.000000000 +0000
2948 @@ -820,7 +820,8 @@ enum {
2949 Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
2950 Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
2951 Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
2952 - Opt_resize, Opt_usrquota, Opt_grpquota
2953 + Opt_resize, Opt_usrquota, Opt_grpquota,
2954 + Opt_tag, Opt_notag, Opt_tagid
2957 static const match_table_t tokens = {
2958 @@ -877,6 +878,9 @@ static const match_table_t tokens = {
2959 {Opt_barrier, "barrier"},
2960 {Opt_nobarrier, "nobarrier"},
2961 {Opt_resize, "resize"},
2963 + {Opt_notag, "notag"},
2964 + {Opt_tagid, "tagid=%u"},
2968 @@ -1029,6 +1033,20 @@ static int parse_options (char *options,
2970 set_opt (sbi->s_mount_opt, NO_UID32);
2972 +#ifndef CONFIG_TAGGING_NONE
2974 + set_opt (sbi->s_mount_opt, TAGGED);
2977 + clear_opt (sbi->s_mount_opt, TAGGED);
2980 +#ifdef CONFIG_PROPAGATE
2983 + set_opt (sbi->s_mount_opt, TAGGED);
2987 clear_opt (sbi->s_mount_opt, CHECK);
2989 @@ -1727,6 +1745,9 @@ static int ext3_fill_super (struct super
2993 + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGGED)
2994 + sb->s_flags |= MS_TAGGED;
2996 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
2997 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
2999 @@ -2608,6 +2629,14 @@ static int ext3_remount (struct super_bl
3000 if (test_opt(sb, ABORT))
3001 ext3_abort(sb, __func__, "Abort forced by user");
3003 + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGGED) &&
3004 + !(sb->s_flags & MS_TAGGED)) {
3005 + printk("EXT3-fs: %s: tagging not permitted on remount.\n",
3008 + goto restore_opts;
3011 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3012 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3014 diff -NurpP --minimal linux-3.4.103/fs/ext4/ext4.h linux-3.4.103-vs2.3.3.9/fs/ext4/ext4.h
3015 --- linux-3.4.103/fs/ext4/ext4.h 2014-08-30 13:37:14.000000000 +0000
3016 +++ linux-3.4.103-vs2.3.3.9/fs/ext4/ext4.h 2014-03-12 09:55:28.000000000 +0000
3017 @@ -380,8 +380,12 @@ struct flex_groups {
3018 #define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
3019 #define EXT4_EA_INODE_FL 0x00200000 /* Inode used for large EA */
3020 #define EXT4_EOFBLOCKS_FL 0x00400000 /* Blocks allocated beyond EOF */
3021 +#define EXT4_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3022 #define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
3024 +#define EXT4_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3025 +#define EXT4_COW_FL 0x20000000 /* Copy on Write marker */
3027 #define EXT4_FL_USER_VISIBLE 0x004BDFFF /* User visible flags */
3028 #define EXT4_FL_USER_MODIFIABLE 0x004B80FF /* User modifiable flags */
3030 @@ -650,7 +654,8 @@ struct ext4_inode {
3031 __le16 l_i_file_acl_high;
3032 __le16 l_i_uid_high; /* these 2 fields */
3033 __le16 l_i_gid_high; /* were reserved2[0] */
3034 - __u32 l_i_reserved2;
3035 + __le16 l_i_tag; /* Context Tag */
3036 + __u16 l_i_reserved2;
3039 __le16 h_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */
3040 @@ -770,6 +775,7 @@ do { \
3041 #define i_gid_low i_gid
3042 #define i_uid_high osd2.linux2.l_i_uid_high
3043 #define i_gid_high osd2.linux2.l_i_gid_high
3044 +#define i_raw_tag osd2.linux2.l_i_tag
3045 #define i_reserved2 osd2.linux2.l_i_reserved2
3047 #elif defined(__GNU__)
3048 @@ -947,6 +953,7 @@ struct ext4_inode_info {
3049 #define EXT4_MOUNT_POSIX_ACL 0x08000 /* POSIX Access Control Lists */
3050 #define EXT4_MOUNT_NO_AUTO_DA_ALLOC 0x10000 /* No auto delalloc mapping */
3051 #define EXT4_MOUNT_BARRIER 0x20000 /* Use block barriers */
3052 +#define EXT4_MOUNT_TAGGED 0x40000 /* Enable Context Tags */
3053 #define EXT4_MOUNT_QUOTA 0x80000 /* Some quota option set */
3054 #define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
3055 #define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
3056 @@ -2296,6 +2303,7 @@ extern int ext4_map_blocks(handle_t *han
3057 struct ext4_map_blocks *map, int flags);
3058 extern int ext4_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
3059 __u64 start, __u64 len);
3060 +extern int ext4_sync_flags(struct inode *, int, int);
3062 extern int ext4_move_extents(struct file *o_filp, struct file *d_filp,
3063 __u64 start_orig, __u64 start_donor,
3064 diff -NurpP --minimal linux-3.4.103/fs/ext4/file.c linux-3.4.103-vs2.3.3.9/fs/ext4/file.c
3065 --- linux-3.4.103/fs/ext4/file.c 2014-08-30 13:37:14.000000000 +0000
3066 +++ linux-3.4.103-vs2.3.3.9/fs/ext4/file.c 2014-05-20 04:30:31.000000000 +0000
3067 @@ -258,5 +258,6 @@ const struct inode_operations ext4_file_
3069 .get_acl = ext4_get_acl,
3070 .fiemap = ext4_fiemap,
3071 + .sync_flags = ext4_sync_flags,
3074 diff -NurpP --minimal linux-3.4.103/fs/ext4/ialloc.c linux-3.4.103-vs2.3.3.9/fs/ext4/ialloc.c
3075 --- linux-3.4.103/fs/ext4/ialloc.c 2014-08-30 13:37:14.000000000 +0000
3076 +++ linux-3.4.103-vs2.3.3.9/fs/ext4/ialloc.c 2014-03-12 09:55:28.000000000 +0000
3078 #include <linux/random.h>
3079 #include <linux/bitops.h>
3080 #include <linux/blkdev.h>
3081 +#include <linux/vs_tag.h>
3082 #include <asm/byteorder.h>
3085 @@ -817,6 +818,7 @@ got:
3086 inode->i_mode = mode;
3087 inode->i_uid = current_fsuid();
3088 inode->i_gid = dir->i_gid;
3089 + inode->i_tag = dx_current_fstag(sb);
3091 inode_init_owner(inode, dir, mode);
3093 diff -NurpP --minimal linux-3.4.103/fs/ext4/inode.c linux-3.4.103-vs2.3.3.9/fs/ext4/inode.c
3094 --- linux-3.4.103/fs/ext4/inode.c 2014-08-30 13:37:14.000000000 +0000
3095 +++ linux-3.4.103-vs2.3.3.9/fs/ext4/inode.c 2014-04-21 19:01:04.000000000 +0000
3097 #include <linux/slab.h>
3098 #include <linux/ratelimit.h>
3099 #include <linux/bitops.h>
3100 +#include <linux/vs_tag.h>
3102 #include "ext4_jbd2.h"
3104 @@ -3583,42 +3584,67 @@ void ext4_set_inode_flags(struct inode *
3105 unsigned int flags = EXT4_I(inode)->i_flags;
3106 unsigned int new_fl = 0;
3108 + if (flags & EXT4_IMMUTABLE_FL)
3109 + new_fl |= S_IMMUTABLE;
3110 + if (flags & EXT4_IXUNLINK_FL)
3111 + new_fl |= S_IXUNLINK;
3113 if (flags & EXT4_SYNC_FL)
3115 if (flags & EXT4_APPEND_FL)
3117 - if (flags & EXT4_IMMUTABLE_FL)
3118 - new_fl |= S_IMMUTABLE;
3119 if (flags & EXT4_NOATIME_FL)
3120 new_fl |= S_NOATIME;
3121 if (flags & EXT4_DIRSYNC_FL)
3122 new_fl |= S_DIRSYNC;
3124 set_mask_bits(&inode->i_flags,
3125 - S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC, new_fl);
3126 + S_IXUNLINK | S_IMMUTABLE |
3127 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC, new_fl);
3130 + if (flags & EXT4_BARRIER_FL)
3131 + new_fl |= V_BARRIER;
3132 + if (flags & EXT4_COW_FL)
3135 + set_mask_bits(&inode->i_vflags,
3136 + V_BARRIER | V_COW, new_fl);
3139 /* Propagate flags from i_flags to EXT4_I(inode)->i_flags */
3140 void ext4_get_inode_flags(struct ext4_inode_info *ei)
3142 - unsigned int vfs_fl;
3143 + unsigned int vfs_fl, vfs_vf;
3144 unsigned long old_fl, new_fl;
3147 vfs_fl = ei->vfs_inode.i_flags;
3148 + vfs_vf = ei->vfs_inode.i_vflags;
3149 old_fl = ei->i_flags;
3150 new_fl = old_fl & ~(EXT4_SYNC_FL|EXT4_APPEND_FL|
3151 EXT4_IMMUTABLE_FL|EXT4_NOATIME_FL|
3153 + EXT4_DIRSYNC_FL|EXT4_BARRIER_FL|
3156 + if (vfs_fl & S_IMMUTABLE)
3157 + new_fl |= EXT4_IMMUTABLE_FL;
3158 + if (vfs_fl & S_IXUNLINK)
3159 + new_fl |= EXT4_IXUNLINK_FL;
3161 if (vfs_fl & S_SYNC)
3162 new_fl |= EXT4_SYNC_FL;
3163 if (vfs_fl & S_APPEND)
3164 new_fl |= EXT4_APPEND_FL;
3165 - if (vfs_fl & S_IMMUTABLE)
3166 - new_fl |= EXT4_IMMUTABLE_FL;
3167 if (vfs_fl & S_NOATIME)
3168 new_fl |= EXT4_NOATIME_FL;
3169 if (vfs_fl & S_DIRSYNC)
3170 new_fl |= EXT4_DIRSYNC_FL;
3172 + if (vfs_vf & V_BARRIER)
3173 + new_fl |= EXT4_BARRIER_FL;
3174 + if (vfs_vf & V_COW)
3175 + new_fl |= EXT4_COW_FL;
3176 } while (cmpxchg(&ei->i_flags, old_fl, new_fl) != old_fl);
3179 @@ -3654,6 +3680,8 @@ struct inode *ext4_iget(struct super_blo
3180 journal_t *journal = EXT4_SB(sb)->s_journal;
3186 inode = iget_locked(sb, ino);
3188 @@ -3669,12 +3697,16 @@ struct inode *ext4_iget(struct super_blo
3190 raw_inode = ext4_raw_inode(&iloc);
3191 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3192 - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3193 - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3194 + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3195 + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3196 if (!(test_opt(inode->i_sb, NO_UID32))) {
3197 - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3198 - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3199 + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3200 + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3202 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
3203 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
3204 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
3205 + le16_to_cpu(raw_inode->i_raw_tag));
3206 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
3208 ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */
3209 @@ -3893,6 +3925,8 @@ static int ext4_do_update_inode(handle_t
3210 struct ext4_inode *raw_inode = ext4_raw_inode(iloc);
3211 struct ext4_inode_info *ei = EXT4_I(inode);
3212 struct buffer_head *bh = iloc->bh;
3213 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
3214 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
3215 int err = 0, rc, block;
3216 int need_datasync = 0;
3218 @@ -3904,29 +3938,32 @@ static int ext4_do_update_inode(handle_t
3219 ext4_get_inode_flags(ei);
3220 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3221 if (!(test_opt(inode->i_sb, NO_UID32))) {
3222 - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid));
3223 - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid));
3224 + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid));
3225 + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid));
3227 * Fix up interoperability with old kernels. Otherwise, old inodes get
3228 * re-used with the upper 16 bits of the uid/gid intact
3231 raw_inode->i_uid_high =
3232 - cpu_to_le16(high_16_bits(inode->i_uid));
3233 + cpu_to_le16(high_16_bits(uid));
3234 raw_inode->i_gid_high =
3235 - cpu_to_le16(high_16_bits(inode->i_gid));
3236 + cpu_to_le16(high_16_bits(gid));
3238 raw_inode->i_uid_high = 0;
3239 raw_inode->i_gid_high = 0;
3242 raw_inode->i_uid_low =
3243 - cpu_to_le16(fs_high2lowuid(inode->i_uid));
3244 + cpu_to_le16(fs_high2lowuid(uid));
3245 raw_inode->i_gid_low =
3246 - cpu_to_le16(fs_high2lowgid(inode->i_gid));
3247 + cpu_to_le16(fs_high2lowgid(gid));
3248 raw_inode->i_uid_high = 0;
3249 raw_inode->i_gid_high = 0;
3251 +#ifdef CONFIG_TAGGING_INTERN
3252 + raw_inode->i_raw_tag = cpu_to_le16(inode->i_tag);
3254 raw_inode->i_links_count = cpu_to_le16(inode->i_nlink);
3256 EXT4_INODE_SET_XTIME(i_ctime, inode, raw_inode);
3257 @@ -4113,7 +4150,8 @@ int ext4_setattr(struct dentry *dentry,
3258 if (is_quota_modification(inode, attr))
3259 dquot_initialize(inode);
3260 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
3261 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
3262 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
3263 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
3266 /* (user+group)*(old+new) structure, inode write (sb,
3267 @@ -4135,6 +4173,8 @@ int ext4_setattr(struct dentry *dentry,
3268 inode->i_uid = attr->ia_uid;
3269 if (attr->ia_valid & ATTR_GID)
3270 inode->i_gid = attr->ia_gid;
3271 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
3272 + inode->i_tag = attr->ia_tag;
3273 error = ext4_mark_inode_dirty(handle, inode);
3274 ext4_journal_stop(handle);
3276 diff -NurpP --minimal linux-3.4.103/fs/ext4/ioctl.c linux-3.4.103-vs2.3.3.9/fs/ext4/ioctl.c
3277 --- linux-3.4.103/fs/ext4/ioctl.c 2014-08-30 13:37:14.000000000 +0000
3278 +++ linux-3.4.103-vs2.3.3.9/fs/ext4/ioctl.c 2012-09-01 08:50:49.000000000 +0000
3280 #include <linux/compat.h>
3281 #include <linux/mount.h>
3282 #include <linux/file.h>
3283 +#include <linux/vs_tag.h>
3284 #include <asm/uaccess.h>
3285 #include "ext4_jbd2.h"
3288 #define MAX_32_NUM ((((unsigned long long) 1) << 32) - 1)
3290 +int ext4_sync_flags(struct inode *inode, int flags, int vflags)
3292 + handle_t *handle = NULL;
3293 + struct ext4_iloc iloc;
3296 + handle = ext4_journal_start(inode, 1);
3297 + if (IS_ERR(handle))
3298 + return PTR_ERR(handle);
3300 + if (IS_SYNC(inode))
3301 + ext4_handle_sync(handle);
3302 + err = ext4_reserve_inode_write(handle, inode, &iloc);
3306 + inode->i_flags = flags;
3307 + inode->i_vflags = vflags;
3308 + ext4_get_inode_flags(EXT4_I(inode));
3309 + inode->i_ctime = ext4_current_time(inode);
3311 + err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3313 + ext4_journal_stop(handle);
3317 long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3319 struct inode *inode = filp->f_dentry->d_inode;
3320 @@ -53,6 +81,11 @@ long ext4_ioctl(struct file *filp, unsig
3322 flags = ext4_mask_flags(inode->i_mode, flags);
3324 + if (IS_BARRIER(inode)) {
3325 + vxwprintk_task(1, "messing with the barrier.");
3330 mutex_lock(&inode->i_mutex);
3331 /* Is it quota file? Do not allow user to mess with it */
3332 @@ -70,7 +103,9 @@ long ext4_ioctl(struct file *filp, unsig
3334 * This test looks nicer. Thanks to Pauline Middelink
3336 - if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
3337 + if ((oldflags & EXT4_IMMUTABLE_FL) ||
3338 + ((flags ^ oldflags) & (EXT4_APPEND_FL |
3339 + EXT4_IMMUTABLE_FL | EXT4_IXUNLINK_FL))) {
3340 if (!capable(CAP_LINUX_IMMUTABLE))
3343 diff -NurpP --minimal linux-3.4.103/fs/ext4/namei.c linux-3.4.103-vs2.3.3.9/fs/ext4/namei.c
3344 --- linux-3.4.103/fs/ext4/namei.c 2014-08-30 13:37:14.000000000 +0000
3345 +++ linux-3.4.103-vs2.3.3.9/fs/ext4/namei.c 2013-10-26 18:10:21.000000000 +0000
3347 #include <linux/quotaops.h>
3348 #include <linux/buffer_head.h>
3349 #include <linux/bio.h>
3350 +#include <linux/vs_tag.h>
3352 #include "ext4_jbd2.h"
3354 @@ -922,6 +923,7 @@ restart:
3355 ll_rw_block(READ | REQ_META | REQ_PRIO,
3358 + dx_propagate_tag(nd, inode);
3360 if ((bh = bh_use[ra_ptr++]) == NULL)
3362 @@ -2589,6 +2591,7 @@ const struct inode_operations ext4_dir_i
3364 .get_acl = ext4_get_acl,
3365 .fiemap = ext4_fiemap,
3366 + .sync_flags = ext4_sync_flags,
3369 const struct inode_operations ext4_special_inode_operations = {
3370 diff -NurpP --minimal linux-3.4.103/fs/ext4/super.c linux-3.4.103-vs2.3.3.9/fs/ext4/super.c
3371 --- linux-3.4.103/fs/ext4/super.c 2014-08-30 13:37:14.000000000 +0000
3372 +++ linux-3.4.103-vs2.3.3.9/fs/ext4/super.c 2014-08-30 13:55:46.000000000 +0000
3373 @@ -1191,6 +1191,7 @@ enum {
3374 Opt_inode_readahead_blks, Opt_journal_ioprio,
3375 Opt_dioread_nolock, Opt_dioread_lock,
3376 Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable,
3377 + Opt_tag, Opt_notag, Opt_tagid
3380 static const match_table_t tokens = {
3381 @@ -1269,6 +1270,9 @@ static const match_table_t tokens = {
3382 {Opt_removed, "reservation"}, /* mount option from ext2/3 */
3383 {Opt_removed, "noreservation"}, /* mount option from ext2/3 */
3384 {Opt_removed, "journal=%u"}, /* mount option from ext2/3 */
3386 + {Opt_notag, "notag"},
3387 + {Opt_tagid, "tagid=%u"},
3391 @@ -1503,6 +1507,20 @@ static int handle_mount_opt(struct super
3393 *journal_ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, arg);
3395 +#ifndef CONFIG_TAGGING_NONE
3397 + set_opt(sb, TAGGED);
3400 + clear_opt(sb, TAGGED);
3403 +#ifdef CONFIG_PROPAGATE
3406 + set_opt(sb, TAGGED);
3411 for (m = ext4_mount_opts; m->token != Opt_err; m++) {
3412 @@ -3240,6 +3258,9 @@ static int ext4_fill_super(struct super_
3413 clear_opt(sb, DELALLOC);
3416 + if (EXT4_SB(sb)->s_mount_opt & EXT4_MOUNT_TAGGED)
3417 + sb->s_flags |= MS_TAGGED;
3419 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3420 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3422 @@ -4422,6 +4443,14 @@ static int ext4_remount(struct super_blo
3423 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
3424 ext4_abort(sb, "Abort forced by user");
3426 + if ((sbi->s_mount_opt & EXT4_MOUNT_TAGGED) &&
3427 + !(sb->s_flags & MS_TAGGED)) {
3428 + printk("EXT4-fs: %s: tagging not permitted on remount.\n",
3431 + goto restore_opts;
3434 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
3435 (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
3437 diff -NurpP --minimal linux-3.4.103/fs/fcntl.c linux-3.4.103-vs2.3.3.9/fs/fcntl.c
3438 --- linux-3.4.103/fs/fcntl.c 2012-05-21 16:07:20.000000000 +0000
3439 +++ linux-3.4.103-vs2.3.3.9/fs/fcntl.c 2012-05-21 16:15:05.000000000 +0000
3441 #include <linux/signal.h>
3442 #include <linux/rcupdate.h>
3443 #include <linux/pid_namespace.h>
3444 +#include <linux/vs_limit.h>
3446 #include <asm/poll.h>
3447 #include <asm/siginfo.h>
3448 @@ -103,6 +104,8 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldf
3451 filp_close(tofree, files);
3453 + vx_openfd_inc(newfd); /* fd was unused */
3457 @@ -447,6 +450,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
3458 filp = fget_raw(fd);
3461 + if (!vx_files_avail(1))
3464 if (unlikely(filp->f_mode & FMODE_PATH)) {
3465 if (!check_fcntl_cmd(cmd)) {
3466 diff -NurpP --minimal linux-3.4.103/fs/file.c linux-3.4.103-vs2.3.3.9/fs/file.c
3467 --- linux-3.4.103/fs/file.c 2014-08-30 13:37:14.000000000 +0000
3468 +++ linux-3.4.103-vs2.3.3.9/fs/file.c 2014-03-12 09:55:28.000000000 +0000
3470 #include <linux/spinlock.h>
3471 #include <linux/rcupdate.h>
3472 #include <linux/workqueue.h>
3473 +#include <linux/vs_limit.h>
3475 struct fdtable_defer {
3477 @@ -358,6 +359,8 @@ struct files_struct *dup_fd(struct files
3478 struct file *f = *old_fds++;
3481 + /* TODO: sum it first for check and performance */
3482 + vx_openfd_inc(open_files - i);
3485 * The fd may be claimed in the fd bitmap but not yet
3486 @@ -464,6 +467,7 @@ repeat:
3488 __clear_close_on_exec(fd, fdt);
3490 + vx_openfd_inc(fd);
3493 if (rcu_dereference_raw(fdt->fd[fd]) != NULL) {
3494 diff -NurpP --minimal linux-3.4.103/fs/file_table.c linux-3.4.103-vs2.3.3.9/fs/file_table.c
3495 --- linux-3.4.103/fs/file_table.c 2012-05-21 16:07:20.000000000 +0000
3496 +++ linux-3.4.103-vs2.3.3.9/fs/file_table.c 2012-05-21 16:15:05.000000000 +0000
3498 #include <linux/percpu_counter.h>
3499 #include <linux/percpu.h>
3500 #include <linux/ima.h>
3501 +#include <linux/vs_limit.h>
3502 +#include <linux/vs_context.h>
3504 #include <linux/atomic.h>
3506 @@ -135,6 +137,8 @@ struct file *get_empty_filp(void)
3507 spin_lock_init(&f->f_lock);
3508 eventpoll_init_file(f);
3509 /* f->f_version: 0 */
3510 + f->f_xid = vx_current_xid();
3515 @@ -252,6 +256,8 @@ static void __fput(struct file *file)
3517 fops_put(file->f_op);
3518 put_pid(file->f_owner.pid);
3519 + vx_files_dec(file);
3521 file_sb_list_del(file);
3522 if ((file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
3523 i_readcount_dec(inode);
3524 @@ -382,6 +388,8 @@ void put_filp(struct file *file)
3526 if (atomic_long_dec_and_test(&file->f_count)) {
3527 security_file_free(file);
3528 + vx_files_dec(file);
3530 file_sb_list_del(file);
3533 diff -NurpP --minimal linux-3.4.103/fs/fs_struct.c linux-3.4.103-vs2.3.3.9/fs/fs_struct.c
3534 --- linux-3.4.103/fs/fs_struct.c 2012-05-21 16:07:20.000000000 +0000
3535 +++ linux-3.4.103-vs2.3.3.9/fs/fs_struct.c 2012-05-21 16:15:05.000000000 +0000
3537 #include <linux/path.h>
3538 #include <linux/slab.h>
3539 #include <linux/fs_struct.h>
3540 +#include <linux/vserver/global.h>
3541 #include "internal.h"
3543 static inline void path_get_longterm(struct path *path)
3544 @@ -99,6 +100,7 @@ void free_fs_struct(struct fs_struct *fs
3546 path_put_longterm(&fs->root);
3547 path_put_longterm(&fs->pwd);
3548 + atomic_dec(&vs_global_fs);
3549 kmem_cache_free(fs_cachep, fs);
3552 @@ -136,6 +138,7 @@ struct fs_struct *copy_fs_struct(struct
3554 path_get_longterm(&fs->pwd);
3555 spin_unlock(&old->lock);
3556 + atomic_inc(&vs_global_fs);
3560 diff -NurpP --minimal linux-3.4.103/fs/gfs2/file.c linux-3.4.103-vs2.3.3.9/fs/gfs2/file.c
3561 --- linux-3.4.103/fs/gfs2/file.c 2012-05-21 16:07:20.000000000 +0000
3562 +++ linux-3.4.103-vs2.3.3.9/fs/gfs2/file.c 2012-05-21 16:15:05.000000000 +0000
3563 @@ -142,6 +142,9 @@ static const u32 fsflags_to_gfs2[32] = {
3564 [7] = GFS2_DIF_NOATIME,
3565 [12] = GFS2_DIF_EXHASH,
3566 [14] = GFS2_DIF_INHERIT_JDATA,
3567 + [27] = GFS2_DIF_IXUNLINK,
3568 + [26] = GFS2_DIF_BARRIER,
3569 + [29] = GFS2_DIF_COW,
3572 static const u32 gfs2_to_fsflags[32] = {
3573 @@ -151,6 +154,9 @@ static const u32 gfs2_to_fsflags[32] = {
3574 [gfs2fl_NoAtime] = FS_NOATIME_FL,
3575 [gfs2fl_ExHash] = FS_INDEX_FL,
3576 [gfs2fl_InheritJdata] = FS_JOURNAL_DATA_FL,
3577 + [gfs2fl_IXUnlink] = FS_IXUNLINK_FL,
3578 + [gfs2fl_Barrier] = FS_BARRIER_FL,
3579 + [gfs2fl_Cow] = FS_COW_FL,
3582 static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
3583 @@ -181,12 +187,18 @@ void gfs2_set_inode_flags(struct inode *
3585 struct gfs2_inode *ip = GFS2_I(inode);
3586 unsigned int flags = inode->i_flags;
3587 + unsigned int vflags = inode->i_vflags;
3589 + flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3590 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC | S_NOSEC);
3592 - flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC|S_NOSEC);
3593 if ((ip->i_eattr == 0) && !is_sxid(inode->i_mode))
3594 inode->i_flags |= S_NOSEC;
3595 if (ip->i_diskflags & GFS2_DIF_IMMUTABLE)
3596 flags |= S_IMMUTABLE;
3597 + if (ip->i_diskflags & GFS2_DIF_IXUNLINK)
3598 + flags |= S_IXUNLINK;
3600 if (ip->i_diskflags & GFS2_DIF_APPENDONLY)
3602 if (ip->i_diskflags & GFS2_DIF_NOATIME)
3603 @@ -194,6 +206,43 @@ void gfs2_set_inode_flags(struct inode *
3604 if (ip->i_diskflags & GFS2_DIF_SYNC)
3606 inode->i_flags = flags;
3608 + vflags &= ~(V_BARRIER | V_COW);
3610 + if (ip->i_diskflags & GFS2_DIF_BARRIER)
3611 + vflags |= V_BARRIER;
3612 + if (ip->i_diskflags & GFS2_DIF_COW)
3614 + inode->i_vflags = vflags;
3617 +void gfs2_get_inode_flags(struct inode *inode)
3619 + struct gfs2_inode *ip = GFS2_I(inode);
3620 + unsigned int flags = inode->i_flags;
3621 + unsigned int vflags = inode->i_vflags;
3623 + ip->i_diskflags &= ~(GFS2_DIF_APPENDONLY |
3624 + GFS2_DIF_NOATIME | GFS2_DIF_SYNC |
3625 + GFS2_DIF_IMMUTABLE | GFS2_DIF_IXUNLINK |
3626 + GFS2_DIF_BARRIER | GFS2_DIF_COW);
3628 + if (flags & S_IMMUTABLE)
3629 + ip->i_diskflags |= GFS2_DIF_IMMUTABLE;
3630 + if (flags & S_IXUNLINK)
3631 + ip->i_diskflags |= GFS2_DIF_IXUNLINK;
3633 + if (flags & S_APPEND)
3634 + ip->i_diskflags |= GFS2_DIF_APPENDONLY;
3635 + if (flags & S_NOATIME)
3636 + ip->i_diskflags |= GFS2_DIF_NOATIME;
3637 + if (flags & S_SYNC)
3638 + ip->i_diskflags |= GFS2_DIF_SYNC;
3640 + if (vflags & V_BARRIER)
3641 + ip->i_diskflags |= GFS2_DIF_BARRIER;
3642 + if (vflags & V_COW)
3643 + ip->i_diskflags |= GFS2_DIF_COW;
3646 /* Flags that can be set by user space */
3647 @@ -305,6 +354,37 @@ static int gfs2_set_flags(struct file *f
3648 return do_gfs2_set_flags(filp, gfsflags, ~GFS2_DIF_JDATA);
3651 +int gfs2_sync_flags(struct inode *inode, int flags, int vflags)
3653 + struct gfs2_inode *ip = GFS2_I(inode);
3654 + struct gfs2_sbd *sdp = GFS2_SB(inode);
3655 + struct buffer_head *bh;
3656 + struct gfs2_holder gh;
3659 + error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
3662 + error = gfs2_trans_begin(sdp, RES_DINODE, 0);
3665 + error = gfs2_meta_inode_buffer(ip, &bh);
3667 + goto out_trans_end;
3668 + gfs2_trans_add_bh(ip->i_gl, bh, 1);
3669 + inode->i_flags = flags;
3670 + inode->i_vflags = vflags;
3671 + gfs2_get_inode_flags(inode);
3672 + gfs2_dinode_out(ip, bh->b_data);
3674 + gfs2_set_aops(inode);
3676 + gfs2_trans_end(sdp);
3678 + gfs2_glock_dq_uninit(&gh);
3682 static long gfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3685 diff -NurpP --minimal linux-3.4.103/fs/gfs2/inode.h linux-3.4.103-vs2.3.3.9/fs/gfs2/inode.h
3686 --- linux-3.4.103/fs/gfs2/inode.h 2012-01-09 15:14:54.000000000 +0000
3687 +++ linux-3.4.103-vs2.3.3.9/fs/gfs2/inode.h 2012-05-21 16:15:05.000000000 +0000
3688 @@ -120,6 +120,7 @@ extern const struct file_operations gfs2
3689 extern const struct file_operations gfs2_dir_fops_nolock;
3691 extern void gfs2_set_inode_flags(struct inode *inode);
3692 +extern int gfs2_sync_flags(struct inode *inode, int flags, int vflags);
3694 #ifdef CONFIG_GFS2_FS_LOCKING_DLM
3695 extern const struct file_operations gfs2_file_fops;
3696 diff -NurpP --minimal linux-3.4.103/fs/inode.c linux-3.4.103-vs2.3.3.9/fs/inode.c
3697 --- linux-3.4.103/fs/inode.c 2014-08-30 13:37:14.000000000 +0000
3698 +++ linux-3.4.103-vs2.3.3.9/fs/inode.c 2013-07-14 13:38:34.000000000 +0000
3700 #include <linux/prefetch.h>
3701 #include <linux/buffer_head.h> /* for inode_has_buffers */
3702 #include <linux/ratelimit.h>
3703 +#include <linux/vs_tag.h>
3704 #include "internal.h"
3707 @@ -128,6 +129,9 @@ int inode_init_always(struct super_block
3708 struct address_space *const mapping = &inode->i_data;
3712 + /* essential because of inode slab reuse */
3714 inode->i_blkbits = sb->s_blocksize_bits;
3716 atomic_set(&inode->i_count, 1);
3717 @@ -149,6 +153,7 @@ int inode_init_always(struct super_block
3718 inode->i_bdev = NULL;
3719 inode->i_cdev = NULL;
3721 + inode->i_mdev = 0;
3722 inode->dirtied_when = 0;
3724 if (security_inode_alloc(inode))
3725 @@ -470,6 +475,8 @@ void __insert_inode_hash(struct inode *i
3727 EXPORT_SYMBOL(__insert_inode_hash);
3729 +EXPORT_SYMBOL_GPL(__iget);
3732 * __remove_inode_hash - remove an inode from the hash
3733 * @inode: inode to unhash
3734 @@ -1689,9 +1696,11 @@ void init_special_inode(struct inode *in
3735 if (S_ISCHR(mode)) {
3736 inode->i_fop = &def_chr_fops;
3737 inode->i_rdev = rdev;
3738 + inode->i_mdev = rdev;
3739 } else if (S_ISBLK(mode)) {
3740 inode->i_fop = &def_blk_fops;
3741 inode->i_rdev = rdev;
3742 + inode->i_mdev = rdev;
3743 } else if (S_ISFIFO(mode))
3744 inode->i_fop = &def_fifo_fops;
3745 else if (S_ISSOCK(mode))
3746 @@ -1720,6 +1729,7 @@ void inode_init_owner(struct inode *inod
3748 inode->i_gid = current_fsgid();
3749 inode->i_mode = mode;
3750 + inode->i_tag = dx_current_fstag(inode->i_sb);
3752 EXPORT_SYMBOL(inode_init_owner);
3754 diff -NurpP --minimal linux-3.4.103/fs/ioctl.c linux-3.4.103-vs2.3.3.9/fs/ioctl.c
3755 --- linux-3.4.103/fs/ioctl.c 2012-05-21 16:07:24.000000000 +0000
3756 +++ linux-3.4.103-vs2.3.3.9/fs/ioctl.c 2012-05-21 16:15:05.000000000 +0000
3758 #include <linux/writeback.h>
3759 #include <linux/buffer_head.h>
3760 #include <linux/falloc.h>
3761 +#include <linux/proc_fs.h>
3762 +#include <linux/vserver/inode.h>
3763 +#include <linux/vs_tag.h>
3765 #include <asm/ioctls.h>
3767 diff -NurpP --minimal linux-3.4.103/fs/ioprio.c linux-3.4.103-vs2.3.3.9/fs/ioprio.c
3768 --- linux-3.4.103/fs/ioprio.c 2012-03-19 18:47:25.000000000 +0000
3769 +++ linux-3.4.103-vs2.3.3.9/fs/ioprio.c 2012-05-21 16:15:05.000000000 +0000
3771 #include <linux/syscalls.h>
3772 #include <linux/security.h>
3773 #include <linux/pid_namespace.h>
3774 +#include <linux/vs_base.h>
3776 int set_task_ioprio(struct task_struct *task, int ioprio)
3778 @@ -104,6 +105,8 @@ SYSCALL_DEFINE3(ioprio_set, int, which,
3780 pgrp = find_vpid(who);
3781 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3782 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3784 ret = set_task_ioprio(p, ioprio);
3787 @@ -193,6 +196,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which,
3789 pgrp = find_vpid(who);
3790 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
3791 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
3793 tmpio = get_task_ioprio(p);
3796 diff -NurpP --minimal linux-3.4.103/fs/jfs/file.c linux-3.4.103-vs2.3.3.9/fs/jfs/file.c
3797 --- linux-3.4.103/fs/jfs/file.c 2011-10-24 16:45:27.000000000 +0000
3798 +++ linux-3.4.103-vs2.3.3.9/fs/jfs/file.c 2012-05-21 16:15:05.000000000 +0000
3799 @@ -109,7 +109,8 @@ int jfs_setattr(struct dentry *dentry, s
3800 if (is_quota_modification(inode, iattr))
3801 dquot_initialize(inode);
3802 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
3803 - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
3804 + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) ||
3805 + (iattr->ia_valid & ATTR_TAG && iattr->ia_tag != inode->i_tag)) {
3806 rc = dquot_transfer(inode, iattr);
3809 @@ -142,6 +143,7 @@ const struct inode_operations jfs_file_i
3810 #ifdef CONFIG_JFS_POSIX_ACL
3811 .get_acl = jfs_get_acl,
3813 + .sync_flags = jfs_sync_flags,
3816 const struct file_operations jfs_file_operations = {
3817 diff -NurpP --minimal linux-3.4.103/fs/jfs/ioctl.c linux-3.4.103-vs2.3.3.9/fs/jfs/ioctl.c
3818 --- linux-3.4.103/fs/jfs/ioctl.c 2012-03-19 18:47:25.000000000 +0000
3819 +++ linux-3.4.103-vs2.3.3.9/fs/jfs/ioctl.c 2012-05-21 16:15:05.000000000 +0000
3821 #include <linux/mount.h>
3822 #include <linux/time.h>
3823 #include <linux/sched.h>
3824 +#include <linux/mount.h>
3825 #include <asm/current.h>
3826 #include <asm/uaccess.h>
3828 @@ -52,6 +53,16 @@ static long jfs_map_ext2(unsigned long f
3832 +int jfs_sync_flags(struct inode *inode, int flags, int vflags)
3834 + inode->i_flags = flags;
3835 + inode->i_vflags = vflags;
3836 + jfs_get_inode_flags(JFS_IP(inode));
3837 + inode->i_ctime = CURRENT_TIME_SEC;
3838 + mark_inode_dirty(inode);
3842 long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3844 struct inode *inode = filp->f_dentry->d_inode;
3845 @@ -85,6 +96,11 @@ long jfs_ioctl(struct file *filp, unsign
3846 if (!S_ISDIR(inode->i_mode))
3847 flags &= ~JFS_DIRSYNC_FL;
3849 + if (IS_BARRIER(inode)) {
3850 + vxwprintk_task(1, "messing with the barrier.");
3854 /* Is it quota file? Do not allow user to mess with it */
3855 if (IS_NOQUOTA(inode)) {
3857 @@ -102,8 +118,8 @@ long jfs_ioctl(struct file *filp, unsign
3858 * the relevant capability.
3860 if ((oldflags & JFS_IMMUTABLE_FL) ||
3861 - ((flags ^ oldflags) &
3862 - (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
3863 + ((flags ^ oldflags) & (JFS_APPEND_FL |
3864 + JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL))) {
3865 if (!capable(CAP_LINUX_IMMUTABLE)) {
3866 mutex_unlock(&inode->i_mutex);
3868 @@ -111,7 +127,7 @@ long jfs_ioctl(struct file *filp, unsign
3872 - flags = flags & JFS_FL_USER_MODIFIABLE;
3873 + flags &= JFS_FL_USER_MODIFIABLE;
3874 flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
3875 jfs_inode->mode2 = flags;
3877 diff -NurpP --minimal linux-3.4.103/fs/jfs/jfs_dinode.h linux-3.4.103-vs2.3.3.9/fs/jfs/jfs_dinode.h
3878 --- linux-3.4.103/fs/jfs/jfs_dinode.h 2008-12-24 23:26:37.000000000 +0000
3879 +++ linux-3.4.103-vs2.3.3.9/fs/jfs/jfs_dinode.h 2012-05-21 16:15:05.000000000 +0000
3880 @@ -161,9 +161,13 @@ struct dinode {
3882 #define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
3883 #define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
3884 +#define JFS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
3886 -#define JFS_FL_USER_VISIBLE 0x03F80000
3887 -#define JFS_FL_USER_MODIFIABLE 0x03F80000
3888 +#define JFS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
3889 +#define JFS_COW_FL 0x20000000 /* Copy on Write marker */
3891 +#define JFS_FL_USER_VISIBLE 0x07F80000
3892 +#define JFS_FL_USER_MODIFIABLE 0x07F80000
3893 #define JFS_FL_INHERIT 0x03C80000
3895 /* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
3896 diff -NurpP --minimal linux-3.4.103/fs/jfs/jfs_filsys.h linux-3.4.103-vs2.3.3.9/fs/jfs/jfs_filsys.h
3897 --- linux-3.4.103/fs/jfs/jfs_filsys.h 2008-12-24 23:26:37.000000000 +0000
3898 +++ linux-3.4.103-vs2.3.3.9/fs/jfs/jfs_filsys.h 2012-05-21 16:15:05.000000000 +0000
3900 #define JFS_NAME_MAX 255
3901 #define JFS_PATH_MAX BPSIZE
3903 +#define JFS_TAGGED 0x00800000 /* Context Tagging */
3906 * file system state (superblock state)
3907 diff -NurpP --minimal linux-3.4.103/fs/jfs/jfs_imap.c linux-3.4.103-vs2.3.3.9/fs/jfs/jfs_imap.c
3908 --- linux-3.4.103/fs/jfs/jfs_imap.c 2012-01-09 15:14:54.000000000 +0000
3909 +++ linux-3.4.103-vs2.3.3.9/fs/jfs/jfs_imap.c 2012-05-21 16:15:05.000000000 +0000
3911 #include <linux/pagemap.h>
3912 #include <linux/quotaops.h>
3913 #include <linux/slab.h>
3914 +#include <linux/vs_tag.h>
3916 #include "jfs_incore.h"
3917 #include "jfs_inode.h"
3918 @@ -3058,6 +3059,8 @@ static int copy_from_dinode(struct dinod
3920 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
3921 struct jfs_sb_info *sbi = JFS_SBI(ip->i_sb);
3925 jfs_ip->fileset = le32_to_cpu(dip->di_fileset);
3926 jfs_ip->mode2 = le32_to_cpu(dip->di_mode);
3927 @@ -3078,14 +3081,18 @@ static int copy_from_dinode(struct dinod
3929 set_nlink(ip, le32_to_cpu(dip->di_nlink));
3931 - jfs_ip->saved_uid = le32_to_cpu(dip->di_uid);
3932 + uid = le32_to_cpu(dip->di_uid);
3933 + gid = le32_to_cpu(dip->di_gid);
3934 + ip->i_tag = INOTAG_TAG(DX_TAG(ip), uid, gid, 0);
3936 + jfs_ip->saved_uid = INOTAG_UID(DX_TAG(ip), uid, gid);
3938 ip->i_uid = jfs_ip->saved_uid;
3940 ip->i_uid = sbi->uid;
3943 - jfs_ip->saved_gid = le32_to_cpu(dip->di_gid);
3944 + jfs_ip->saved_gid = INOTAG_GID(DX_TAG(ip), uid, gid);
3946 ip->i_gid = jfs_ip->saved_gid;
3948 @@ -3150,14 +3157,12 @@ static void copy_to_dinode(struct dinode
3949 dip->di_size = cpu_to_le64(ip->i_size);
3950 dip->di_nblocks = cpu_to_le64(PBLK2LBLK(ip->i_sb, ip->i_blocks));
3951 dip->di_nlink = cpu_to_le32(ip->i_nlink);
3952 - if (sbi->uid == -1)
3953 - dip->di_uid = cpu_to_le32(ip->i_uid);
3955 - dip->di_uid = cpu_to_le32(jfs_ip->saved_uid);
3956 - if (sbi->gid == -1)
3957 - dip->di_gid = cpu_to_le32(ip->i_gid);
3959 - dip->di_gid = cpu_to_le32(jfs_ip->saved_gid);
3961 + dip->di_uid = cpu_to_le32(TAGINO_UID(DX_TAG(ip),
3962 + (sbi->uid == -1) ? ip->i_uid : jfs_ip->saved_uid, ip->i_tag));
3963 + dip->di_gid = cpu_to_le32(TAGINO_GID(DX_TAG(ip),
3964 + (sbi->gid == -1) ? ip->i_gid : jfs_ip->saved_gid, ip->i_tag));
3966 jfs_get_inode_flags(jfs_ip);
3968 * mode2 is only needed for storing the higher order bits.
3969 diff -NurpP --minimal linux-3.4.103/fs/jfs/jfs_inode.c linux-3.4.103-vs2.3.3.9/fs/jfs/jfs_inode.c
3970 --- linux-3.4.103/fs/jfs/jfs_inode.c 2014-08-30 13:37:14.000000000 +0000
3971 +++ linux-3.4.103-vs2.3.3.9/fs/jfs/jfs_inode.c 2014-03-12 09:55:28.000000000 +0000
3974 #include <linux/fs.h>
3975 #include <linux/quotaops.h>
3976 +#include <linux/vs_tag.h>
3977 #include "jfs_incore.h"
3978 #include "jfs_inode.h"
3979 #include "jfs_filsys.h"
3980 @@ -30,29 +31,46 @@ void jfs_set_inode_flags(struct inode *i
3982 unsigned int flags = JFS_IP(inode)->mode2;
3984 - inode->i_flags &= ~(S_IMMUTABLE | S_APPEND |
3985 - S_NOATIME | S_DIRSYNC | S_SYNC);
3986 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
3987 + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
3989 if (flags & JFS_IMMUTABLE_FL)
3990 inode->i_flags |= S_IMMUTABLE;
3991 + if (flags & JFS_IXUNLINK_FL)
3992 + inode->i_flags |= S_IXUNLINK;
3994 + if (flags & JFS_SYNC_FL)
3995 + inode->i_flags |= S_SYNC;
3996 if (flags & JFS_APPEND_FL)
3997 inode->i_flags |= S_APPEND;
3998 if (flags & JFS_NOATIME_FL)
3999 inode->i_flags |= S_NOATIME;
4000 if (flags & JFS_DIRSYNC_FL)
4001 inode->i_flags |= S_DIRSYNC;
4002 - if (flags & JFS_SYNC_FL)
4003 - inode->i_flags |= S_SYNC;
4005 + inode->i_vflags &= ~(V_BARRIER | V_COW);
4007 + if (flags & JFS_BARRIER_FL)
4008 + inode->i_vflags |= V_BARRIER;
4009 + if (flags & JFS_COW_FL)
4010 + inode->i_vflags |= V_COW;
4013 void jfs_get_inode_flags(struct jfs_inode_info *jfs_ip)
4015 unsigned int flags = jfs_ip->vfs_inode.i_flags;
4016 + unsigned int vflags = jfs_ip->vfs_inode.i_vflags;
4018 + jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_IXUNLINK_FL |
4019 + JFS_APPEND_FL | JFS_NOATIME_FL |
4020 + JFS_DIRSYNC_FL | JFS_SYNC_FL |
4021 + JFS_BARRIER_FL | JFS_COW_FL);
4023 - jfs_ip->mode2 &= ~(JFS_IMMUTABLE_FL | JFS_APPEND_FL | JFS_NOATIME_FL |
4024 - JFS_DIRSYNC_FL | JFS_SYNC_FL);
4025 if (flags & S_IMMUTABLE)
4026 jfs_ip->mode2 |= JFS_IMMUTABLE_FL;
4027 + if (flags & S_IXUNLINK)
4028 + jfs_ip->mode2 |= JFS_IXUNLINK_FL;
4030 if (flags & S_APPEND)
4031 jfs_ip->mode2 |= JFS_APPEND_FL;
4032 if (flags & S_NOATIME)
4033 @@ -61,6 +79,11 @@ void jfs_get_inode_flags(struct jfs_inod
4034 jfs_ip->mode2 |= JFS_DIRSYNC_FL;
4036 jfs_ip->mode2 |= JFS_SYNC_FL;
4038 + if (vflags & V_BARRIER)
4039 + jfs_ip->mode2 |= JFS_BARRIER_FL;
4040 + if (vflags & V_COW)
4041 + jfs_ip->mode2 |= JFS_COW_FL;
4045 diff -NurpP --minimal linux-3.4.103/fs/jfs/jfs_inode.h linux-3.4.103-vs2.3.3.9/fs/jfs/jfs_inode.h
4046 --- linux-3.4.103/fs/jfs/jfs_inode.h 2011-10-24 16:45:27.000000000 +0000
4047 +++ linux-3.4.103-vs2.3.3.9/fs/jfs/jfs_inode.h 2012-05-21 16:15:05.000000000 +0000
4048 @@ -39,6 +39,7 @@ extern struct dentry *jfs_fh_to_dentry(s
4049 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
4050 int fh_len, int fh_type);
4051 extern void jfs_set_inode_flags(struct inode *);
4052 +extern int jfs_sync_flags(struct inode *, int, int);
4053 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
4054 extern int jfs_setattr(struct dentry *, struct iattr *);
4056 diff -NurpP --minimal linux-3.4.103/fs/jfs/namei.c linux-3.4.103-vs2.3.3.9/fs/jfs/namei.c
4057 --- linux-3.4.103/fs/jfs/namei.c 2012-05-21 16:07:25.000000000 +0000
4058 +++ linux-3.4.103-vs2.3.3.9/fs/jfs/namei.c 2012-05-21 16:15:05.000000000 +0000
4060 #include <linux/ctype.h>
4061 #include <linux/quotaops.h>
4062 #include <linux/exportfs.h>
4063 +#include <linux/vs_tag.h>
4064 #include "jfs_incore.h"
4065 #include "jfs_superblock.h"
4066 #include "jfs_inode.h"
4067 @@ -1461,6 +1462,7 @@ static struct dentry *jfs_lookup(struct
4068 jfs_err("jfs_lookup: iget failed on inum %d", (uint)inum);
4071 + dx_propagate_tag(nd, ip);
4072 return d_splice_alias(ip, dentry);
4075 @@ -1525,6 +1527,7 @@ const struct inode_operations jfs_dir_in
4076 #ifdef CONFIG_JFS_POSIX_ACL
4077 .get_acl = jfs_get_acl,
4079 + .sync_flags = jfs_sync_flags,
4082 const struct file_operations jfs_dir_operations = {
4083 diff -NurpP --minimal linux-3.4.103/fs/jfs/super.c linux-3.4.103-vs2.3.3.9/fs/jfs/super.c
4084 --- linux-3.4.103/fs/jfs/super.c 2012-05-21 16:07:25.000000000 +0000
4085 +++ linux-3.4.103-vs2.3.3.9/fs/jfs/super.c 2012-05-21 16:15:05.000000000 +0000
4086 @@ -197,7 +197,8 @@ static void jfs_put_super(struct super_b
4088 Opt_integrity, Opt_nointegrity, Opt_iocharset, Opt_resize,
4089 Opt_resize_nosize, Opt_errors, Opt_ignore, Opt_err, Opt_quota,
4090 - Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask
4091 + Opt_usrquota, Opt_grpquota, Opt_uid, Opt_gid, Opt_umask,
4092 + Opt_tag, Opt_notag, Opt_tagid
4095 static const match_table_t tokens = {
4096 @@ -207,6 +208,10 @@ static const match_table_t tokens = {
4097 {Opt_resize, "resize=%u"},
4098 {Opt_resize_nosize, "resize"},
4099 {Opt_errors, "errors=%s"},
4101 + {Opt_notag, "notag"},
4102 + {Opt_tagid, "tagid=%u"},
4103 + {Opt_tag, "tagxid"},
4104 {Opt_ignore, "noquota"},
4105 {Opt_ignore, "quota"},
4106 {Opt_usrquota, "usrquota"},
4107 @@ -341,6 +346,20 @@ static int parse_options(char *options,
4111 +#ifndef CONFIG_TAGGING_NONE
4113 + *flag |= JFS_TAGGED;
4116 + *flag &= JFS_TAGGED;
4119 +#ifdef CONFIG_PROPAGATE
4122 + *flag |= JFS_TAGGED;
4126 printk("jfs: Unrecognized mount option \"%s\" "
4127 " or missing value\n", p);
4128 @@ -372,6 +391,12 @@ static int jfs_remount(struct super_bloc
4132 + if ((flag & JFS_TAGGED) && !(sb->s_flags & MS_TAGGED)) {
4133 + printk(KERN_ERR "JFS: %s: tagging not permitted on remount.\n",
4139 if (sb->s_flags & MS_RDONLY) {
4141 @@ -455,6 +480,9 @@ static int jfs_fill_super(struct super_b
4142 #ifdef CONFIG_JFS_POSIX_ACL
4143 sb->s_flags |= MS_POSIXACL;
4145 + /* map mount option tagxid */
4146 + if (sbi->flag & JFS_TAGGED)
4147 + sb->s_flags |= MS_TAGGED;
4150 printk(KERN_ERR "resize option for remount only\n");
4151 diff -NurpP --minimal linux-3.4.103/fs/libfs.c linux-3.4.103-vs2.3.3.9/fs/libfs.c
4152 --- linux-3.4.103/fs/libfs.c 2012-05-21 16:07:25.000000000 +0000
4153 +++ linux-3.4.103-vs2.3.3.9/fs/libfs.c 2012-05-21 16:15:05.000000000 +0000
4154 @@ -135,7 +135,8 @@ static inline unsigned char dt_type(stru
4155 * both impossible due to the lock on directory.
4158 -int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
4159 +static inline int do_dcache_readdir_filter(struct file *filp,
4160 + void *dirent, filldir_t filldir, int (*filter)(struct dentry *dentry))
4162 struct dentry *dentry = filp->f_path.dentry;
4163 struct dentry *cursor = filp->private_data;
4164 @@ -166,6 +167,8 @@ int dcache_readdir(struct file * filp, v
4165 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
4166 struct dentry *next;
4167 next = list_entry(p, struct dentry, d_u.d_child);
4168 + if (filter && !filter(next))
4170 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
4171 if (!simple_positive(next)) {
4172 spin_unlock(&next->d_lock);
4173 @@ -192,6 +195,17 @@ int dcache_readdir(struct file * filp, v
4177 +int dcache_readdir(struct file *filp, void *dirent, filldir_t filldir)
4179 + return do_dcache_readdir_filter(filp, dirent, filldir, NULL);
4182 +int dcache_readdir_filter(struct file *filp, void *dirent, filldir_t filldir,
4183 + int (*filter)(struct dentry *))
4185 + return do_dcache_readdir_filter(filp, dirent, filldir, filter);
4188 ssize_t generic_read_dir(struct file *filp, char __user *buf, size_t siz, loff_t *ppos)
4191 @@ -983,6 +997,7 @@ EXPORT_SYMBOL(dcache_dir_close);
4192 EXPORT_SYMBOL(dcache_dir_lseek);
4193 EXPORT_SYMBOL(dcache_dir_open);
4194 EXPORT_SYMBOL(dcache_readdir);
4195 +EXPORT_SYMBOL(dcache_readdir_filter);
4196 EXPORT_SYMBOL(generic_read_dir);
4197 EXPORT_SYMBOL(mount_pseudo);
4198 EXPORT_SYMBOL(simple_write_begin);
4199 diff -NurpP --minimal linux-3.4.103/fs/locks.c linux-3.4.103-vs2.3.3.9/fs/locks.c
4200 --- linux-3.4.103/fs/locks.c 2014-08-30 13:37:14.000000000 +0000
4201 +++ linux-3.4.103-vs2.3.3.9/fs/locks.c 2014-05-20 04:30:31.000000000 +0000
4203 #include <linux/time.h>
4204 #include <linux/rcupdate.h>
4205 #include <linux/pid_namespace.h>
4206 +#include <linux/vs_base.h>
4207 +#include <linux/vs_limit.h>
4209 #include <asm/uaccess.h>
4211 @@ -184,11 +186,17 @@ static void locks_init_lock_heads(struct
4212 /* Allocate an empty lock structure. */
4213 struct file_lock *locks_alloc_lock(void)
4215 - struct file_lock *fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL);
4216 + struct file_lock *fl;
4219 - locks_init_lock_heads(fl);
4220 + if (!vx_locks_avail(1))
4223 + fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL);
4226 + locks_init_lock_heads(fl);
4231 EXPORT_SYMBOL_GPL(locks_alloc_lock);
4232 @@ -216,6 +224,7 @@ void locks_free_lock(struct file_lock *f
4233 BUG_ON(!list_empty(&fl->fl_block));
4234 BUG_ON(!list_empty(&fl->fl_link));
4237 locks_release_private(fl);
4238 kmem_cache_free(filelock_cache, fl);
4240 @@ -225,6 +234,7 @@ void locks_init_lock(struct file_lock *f
4242 memset(fl, 0, sizeof(struct file_lock));
4243 locks_init_lock_heads(fl);
4247 EXPORT_SYMBOL(locks_init_lock);
4248 @@ -265,6 +275,7 @@ void locks_copy_lock(struct file_lock *n
4249 new->fl_file = fl->fl_file;
4250 new->fl_ops = fl->fl_ops;
4251 new->fl_lmops = fl->fl_lmops;
4252 + new->fl_xid = fl->fl_xid;
4254 locks_copy_private(new, fl);
4256 @@ -303,6 +314,11 @@ static int flock_make_lock(struct file *
4257 fl->fl_flags = FL_FLOCK;
4259 fl->fl_end = OFFSET_MAX;
4261 + vxd_assert(filp->f_xid == vx_current_xid(),
4262 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4263 + fl->fl_xid = filp->f_xid;
4268 @@ -452,6 +468,7 @@ static int lease_init(struct file *filp,
4270 fl->fl_owner = current->files;
4271 fl->fl_pid = current->tgid;
4272 + fl->fl_xid = vx_current_xid();
4275 fl->fl_flags = FL_LEASE;
4276 @@ -471,6 +488,11 @@ static struct file_lock *lease_alloc(str
4278 return ERR_PTR(error);
4280 + fl->fl_xid = vx_current_xid();
4282 + vxd_assert(filp->f_xid == fl->fl_xid,
4283 + "f_xid(%d) == fl_xid(%d)", filp->f_xid, fl->fl_xid);
4285 error = lease_init(filp, type, fl);
4287 locks_free_lock(fl);
4288 @@ -773,6 +795,7 @@ static int flock_lock_file(struct file *
4292 + new_fl->fl_xid = -1;
4294 for_each_lock(inode, before) {
4295 struct file_lock *fl = *before;
4296 @@ -793,6 +816,7 @@ find_conflict:
4298 locks_copy_lock(new_fl, request);
4299 locks_insert_lock(before, new_fl);
4300 + vx_locks_inc(new_fl);
4304 @@ -803,7 +827,8 @@ out:
4308 -static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
4309 +static int __posix_lock_file(struct inode *inode, struct file_lock *request,
4310 + struct file_lock *conflock, xid_t xid)
4312 struct file_lock *fl;
4313 struct file_lock *new_fl = NULL;
4314 @@ -813,6 +838,8 @@ static int __posix_lock_file(struct inod
4315 struct file_lock **before;
4316 int error, added = 0;
4318 + vxd_assert(xid == vx_current_xid(),
4319 + "xid(%d) == current(%d)", xid, vx_current_xid());
4321 * We may need two file_lock structures for this operation,
4322 * so we get them in advance to avoid races.
4323 @@ -823,7 +850,11 @@ static int __posix_lock_file(struct inod
4324 (request->fl_type != F_UNLCK ||
4325 request->fl_start != 0 || request->fl_end != OFFSET_MAX)) {
4326 new_fl = locks_alloc_lock();
4327 + new_fl->fl_xid = xid;
4328 + vx_locks_inc(new_fl);
4329 new_fl2 = locks_alloc_lock();
4330 + new_fl2->fl_xid = xid;
4331 + vx_locks_inc(new_fl2);
4335 @@ -1022,7 +1053,8 @@ static int __posix_lock_file(struct inod
4336 int posix_lock_file(struct file *filp, struct file_lock *fl,
4337 struct file_lock *conflock)
4339 - return __posix_lock_file(filp->f_path.dentry->d_inode, fl, conflock);
4340 + return __posix_lock_file(filp->f_path.dentry->d_inode,
4341 + fl, conflock, filp->f_xid);
4343 EXPORT_SYMBOL(posix_lock_file);
4345 @@ -1112,7 +1144,7 @@ int locks_mandatory_area(int read_write,
4346 fl.fl_end = offset + count - 1;
4349 - error = __posix_lock_file(inode, &fl, NULL);
4350 + error = __posix_lock_file(inode, &fl, NULL, filp->f_xid);
4351 if (error != FILE_LOCK_DEFERRED)
4353 error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);
4354 @@ -1406,6 +1438,7 @@ int generic_add_lease(struct file *filp,
4357 locks_insert_lock(before, lease);
4358 + vx_locks_inc(lease);
4362 @@ -1846,6 +1879,11 @@ int fcntl_setlk(unsigned int fd, struct
4363 if (file_lock == NULL)
4366 + vxd_assert(filp->f_xid == vx_current_xid(),
4367 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4368 + file_lock->fl_xid = filp->f_xid;
4369 + vx_locks_inc(file_lock);
4372 * This might block, so we do it before checking the inode.
4374 @@ -1964,6 +2002,11 @@ int fcntl_setlk64(unsigned int fd, struc
4375 if (file_lock == NULL)
4378 + vxd_assert(filp->f_xid == vx_current_xid(),
4379 + "f_xid(%d) == current(%d)", filp->f_xid, vx_current_xid());
4380 + file_lock->fl_xid = filp->f_xid;
4381 + vx_locks_inc(file_lock);
4384 * This might block, so we do it before checking the inode.
4386 @@ -2229,8 +2272,11 @@ static int locks_show(struct seq_file *f
4388 lock_get_status(f, fl, *((loff_t *)f->private), "");
4390 - list_for_each_entry(bfl, &fl->fl_block, fl_block)
4391 + list_for_each_entry(bfl, &fl->fl_block, fl_block) {
4392 + if (!vx_check(fl->fl_xid, VS_WATCH_P | VS_IDENT))
4394 lock_get_status(f, bfl, *((loff_t *)f->private), " ->");
4399 diff -NurpP --minimal linux-3.4.103/fs/mount.h linux-3.4.103-vs2.3.3.9/fs/mount.h
4400 --- linux-3.4.103/fs/mount.h 2012-03-19 18:47:26.000000000 +0000
4401 +++ linux-3.4.103-vs2.3.3.9/fs/mount.h 2012-05-21 16:15:05.000000000 +0000
4402 @@ -47,6 +47,7 @@ struct mount {
4403 int mnt_expiry_mark; /* true if marked for expiry */
4406 + tag_t mnt_tag; /* tagging used for vfsmount */
4409 static inline struct mount *real_mount(struct vfsmount *mnt)
4410 diff -NurpP --minimal linux-3.4.103/fs/namei.c linux-3.4.103-vs2.3.3.9/fs/namei.c
4411 --- linux-3.4.103/fs/namei.c 2012-05-21 16:07:25.000000000 +0000
4412 +++ linux-3.4.103-vs2.3.3.9/fs/namei.c 2012-05-21 16:15:05.000000000 +0000
4414 #include <linux/device_cgroup.h>
4415 #include <linux/fs_struct.h>
4416 #include <linux/posix_acl.h>
4417 +#include <linux/proc_fs.h>
4418 +#include <linux/vserver/inode.h>
4419 +#include <linux/vs_base.h>
4420 +#include <linux/vs_tag.h>
4421 +#include <linux/vs_cowbl.h>
4422 +#include <linux/vs_device.h>
4423 +#include <linux/vs_context.h>
4424 +#include <linux/pid_namespace.h>
4425 #include <asm/uaccess.h>
4427 #include "internal.h"
4428 @@ -221,6 +229,89 @@ static int check_acl(struct inode *inode
4432 +static inline int dx_barrier(const struct inode *inode)
4434 + if (IS_BARRIER(inode) && !vx_check(0, VS_ADMIN | VS_WATCH)) {
4435 + vxwprintk_task(1, "did hit the barrier.");
4441 +static int __dx_permission(const struct inode *inode, int mask)
4443 + if (dx_barrier(inode))
4446 + if (inode->i_sb->s_magic == DEVPTS_SUPER_MAGIC) {
4447 + /* devpts is xid tagged */
4448 + if (S_ISDIR(inode->i_mode) ||
4449 + vx_check((xid_t)inode->i_tag, VS_IDENT | VS_WATCH_P))
4452 + /* just pretend we didn't find anything */
4455 + else if (inode->i_sb->s_magic == PROC_SUPER_MAGIC) {
4456 + struct proc_dir_entry *de = PDE(inode);
4458 + if (de && !vx_hide_check(0, de->vx_flags))
4461 + if ((mask & (MAY_WRITE | MAY_APPEND))) {
4463 + struct task_struct *tsk;
4465 + if (vx_check(0, VS_ADMIN | VS_WATCH_P) ||
4466 + vx_flags(VXF_STATE_SETUP, 0))
4469 + pid = PROC_I(inode)->pid;
4474 + tsk = pid_task(pid, PIDTYPE_PID);
4475 + vxdprintk(VXD_CBIT(tag, 0), "accessing %p[#%u]",
4476 + tsk, (tsk ? vx_task_xid(tsk) : 0));
4478 + vx_check(vx_task_xid(tsk), VS_IDENT | VS_WATCH_P)) {
4479 + rcu_read_unlock();
4482 + rcu_read_unlock();
4485 + /* FIXME: Should we block some entries here? */
4490 + if (dx_notagcheck(inode->i_sb) ||
4491 + dx_check(inode->i_tag, DX_HOSTID | DX_ADMIN | DX_WATCH |
4500 +int dx_permission(const struct inode *inode, int mask)
4502 + int ret = __dx_permission(inode, mask);
4503 + if (unlikely(ret)) {
4504 +#ifndef CONFIG_VSERVER_WARN_DEVPTS
4505 + if (inode->i_sb->s_magic != DEVPTS_SUPER_MAGIC)
4508 + "denied [0x%x] access to inode %s:%p[#%d,%lu]",
4509 + mask, inode->i_sb->s_id, inode, inode->i_tag,
4516 * This does the basic permission checking
4518 @@ -356,10 +447,14 @@ int inode_permission(struct inode *inode
4520 * Nobody gets write access to an immutable file.
4522 - if (IS_IMMUTABLE(inode))
4523 + if (IS_IMMUTABLE(inode) && !IS_COW(inode))
4527 + retval = dx_permission(inode, mask);
4531 retval = do_inode_permission(inode, mask);
4534 @@ -1038,7 +1133,8 @@ static void follow_dotdot(struct nameida
4536 if (nd->path.dentry == nd->root.dentry &&
4537 nd->path.mnt == nd->root.mnt) {
4539 + /* for sane '/' avoid follow_mount() */
4542 if (nd->path.dentry != nd->path.mnt->mnt_root) {
4543 /* rare case of legitimate dget_parent()... */
4544 @@ -1174,6 +1270,9 @@ static int do_lookup(struct nameidata *n
4549 + /* FIXME: check dx permission */
4552 path->dentry = dentry;
4553 if (unlikely(!__follow_mount_rcu(nd, path, inode)))
4554 @@ -1208,6 +1307,9 @@ unlazy:
4559 + /* FIXME: check dx permission */
4563 path->dentry = dentry;
4564 @@ -1981,7 +2083,7 @@ static int may_delete(struct inode *dir,
4567 if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
4568 - IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4569 + IS_IXORUNLINK(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
4572 if (!S_ISDIR(victim->d_inode->i_mode))
4573 @@ -2061,19 +2163,25 @@ int vfs_create(struct inode *dir, struct
4575 int error = may_create(dir, dentry);
4579 + vxdprintk(VXD_CBIT(misc, 3), "may_create failed with %d", error);
4583 if (!dir->i_op->create)
4584 return -EACCES; /* shouldn't it be ENOSYS? */
4587 error = security_inode_create(dir, dentry, mode);
4590 + vxdprintk(VXD_CBIT(misc, 3), "security_inode_create failed with %d", error);
4593 error = dir->i_op->create(dir, dentry, mode, nd);
4595 fsnotify_create(dir, dentry);
4597 + vxdprintk(VXD_CBIT(misc, 3), "i_op->create failed with %d", error);
4601 @@ -2108,6 +2216,15 @@ static int may_open(struct path *path, i
4605 +#ifdef CONFIG_VSERVER_COWBL
4606 + if (IS_COW(inode) &&
4607 + ((flag & O_ACCMODE) != O_RDONLY)) {
4608 + if (IS_COW_LINK(inode))
4610 + inode->i_flags &= ~(S_IXUNLINK|S_IMMUTABLE);
4611 + mark_inode_dirty(inode);
4614 error = inode_permission(inode, acc_mode);
4617 @@ -2332,6 +2449,16 @@ ok:
4620 error = may_open(&nd->path, acc_mode, open_flag);
4621 +#ifdef CONFIG_VSERVER_COWBL
4622 + if (error == -EMLINK) {
4623 + struct dentry *dentry;
4624 + dentry = cow_break_link(pathname);
4625 + if (IS_ERR(dentry))
4626 + error = PTR_ERR(dentry);
4633 filp = nameidata_to_filp(nd);
4634 @@ -2374,6 +2501,7 @@ static struct file *path_openat(int dfd,
4639 filp = get_empty_filp();
4641 return ERR_PTR(-ENFILE);
4642 @@ -2411,6 +2539,17 @@ static struct file *path_openat(int dfd,
4643 filp = do_last(nd, &path, op, pathname);
4644 put_link(nd, &link, cookie);
4647 +#ifdef CONFIG_VSERVER_COWBL
4648 + if (filp == ERR_PTR(-EMLINK)) {
4649 + if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
4650 + path_put(&nd->root);
4653 + release_open_intent(nd);
4658 if (nd->root.mnt && !(nd->flags & LOOKUP_ROOT))
4659 path_put(&nd->root);
4660 @@ -2500,6 +2639,11 @@ struct dentry *kern_path_create(int dfd,
4664 + vxdprintk(VXD_CBIT(misc, 3), "kern_path_create path.dentry = %p (%.*s), dentry = %p (%.*s), d_inode = %p",
4665 + path->dentry, path->dentry->d_name.len,
4666 + path->dentry->d_name.name, dentry,
4667 + dentry->d_name.len, dentry->d_name.name,
4668 + path->dentry->d_inode);
4672 @@ -2986,7 +3130,7 @@ int vfs_link(struct dentry *old_dentry,
4674 * A link to an append-only or immutable file cannot be created.
4676 - if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
4677 + if (IS_APPEND(inode) || IS_IXORUNLINK(inode))
4679 if (!dir->i_op->link)
4681 @@ -3375,6 +3519,253 @@ int vfs_follow_link(struct nameidata *nd
4682 return __vfs_follow_link(nd, link);
4686 +#ifdef CONFIG_VSERVER_COWBL
4689 +long do_cow_splice(struct file *in, struct file *out, size_t len)
4693 + return do_splice_direct(in, &ppos, out, len, 0);
4696 +extern unsigned int mnt_get_count(struct mount *mnt);
4698 +struct dentry *cow_break_link(const char *pathname)
4700 + int ret, mode, pathlen, redo = 0;
4701 + struct nameidata old_nd, dir_nd;
4702 + struct path old_path, dir_path;
4703 + struct dentry *dir, *old_dentry, *new_dentry = NULL;
4704 + struct file *old_file;
4705 + struct file *new_file;
4706 + char *to, *path, pad='\251';
4709 + vxdprintk(VXD_CBIT(misc, 1),
4710 + "cow_break_link(" VS_Q("%s") ")", pathname);
4711 + path = kmalloc(PATH_MAX, GFP_KERNEL);
4716 + /* old_nd will have refs to dentry and mnt */
4717 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
4718 + vxdprintk(VXD_CBIT(misc, 2),
4719 + "do_path_lookup(old): %d [r=%d]",
4720 + ret, mnt_get_count(real_mount(old_nd.path.mnt)));
4722 + goto out_free_path;
4724 + old_path = old_nd.path;
4725 + old_dentry = old_path.dentry;
4726 + mode = old_dentry->d_inode->i_mode;
4728 + to = d_path(&old_path, path, PATH_MAX-2);
4729 + pathlen = strlen(to);
4730 + vxdprintk(VXD_CBIT(misc, 2),
4731 + "old path " VS_Q("%s") " [%p:" VS_Q("%.*s") ":%d]", to,
4733 + old_dentry->d_name.len, old_dentry->d_name.name,
4734 + old_dentry->d_name.len);
4736 + to[pathlen + 1] = 0;
4738 + new_dentry = NULL;
4739 + to[pathlen] = pad--;
4741 + if (pad <= '\240')
4744 + vxdprintk(VXD_CBIT(misc, 1), "temp copy " VS_Q("%s"), to);
4745 + /* dir_nd will have refs to dentry and mnt */
4746 + ret = do_path_lookup(AT_FDCWD, to,
4747 + LOOKUP_PARENT | LOOKUP_OPEN | LOOKUP_CREATE, &dir_nd);
4748 + vxdprintk(VXD_CBIT(misc, 2), "do_path_lookup(new): %d", ret);
4752 + /* this puppy downs the dir inode mutex if successful */
4753 + new_dentry = kern_path_create(AT_FDCWD, to, &dir_path, 0);
4754 + if (!new_dentry || IS_ERR(new_dentry)) {
4755 + path_put(&dir_nd.path);
4756 + vxdprintk(VXD_CBIT(misc, 2),
4757 + "kern_path_create(new) failed with %ld",
4758 + PTR_ERR(new_dentry));
4761 + path_put(&dir_path);
4762 + vxdprintk(VXD_CBIT(misc, 2),
4763 + "kern_path_create(new): %p [" VS_Q("%.*s") ":%d]",
4765 + new_dentry->d_name.len, new_dentry->d_name.name,
4766 + new_dentry->d_name.len);
4768 + dir = dir_nd.path.dentry;
4770 + ret = vfs_create(dir->d_inode, new_dentry, mode, &dir_nd);
4771 + vxdprintk(VXD_CBIT(misc, 2),
4772 + "vfs_create(new): %d", ret);
4773 + if (ret == -EEXIST) {
4774 + mutex_unlock(&dir->d_inode->i_mutex);
4775 + path_put(&dir_nd.path);
4780 + goto out_unlock_new;
4782 + /* drop out early, ret passes ENOENT */
4784 + if ((redo = d_unhashed(old_dentry)))
4785 + goto out_unlock_new;
4787 + path_get(&old_path);
4788 + /* this one cleans up the dentry/mnt in case of failure */
4789 + old_file = dentry_open(old_dentry, old_path.mnt,
4790 + O_RDONLY, current_cred());
4791 + vxdprintk(VXD_CBIT(misc, 2),
4792 + "dentry_open(old): %p", old_file);
4793 + if (IS_ERR(old_file)) {
4794 + ret = PTR_ERR(old_file);
4795 + goto out_unlock_new;
4799 + mntget(old_path.mnt);
4800 + /* this one cleans up the dentry/mnt in case of failure */
4801 + new_file = dentry_open(new_dentry, old_path.mnt,
4802 + O_WRONLY, current_cred());
4803 + vxdprintk(VXD_CBIT(misc, 2),
4804 + "dentry_open(new): %p", new_file);
4805 + if (IS_ERR(new_file)) {
4806 + ret = PTR_ERR(new_file);
4807 + goto out_fput_old;
4810 + size = i_size_read(old_file->f_dentry->d_inode);
4811 + ret = do_cow_splice(old_file, new_file, size);
4812 + vxdprintk(VXD_CBIT(misc, 2), "do_splice_direct: %d", ret);
4814 + goto out_fput_both;
4815 + } else if (ret < size) {
4817 + goto out_fput_both;
4819 + struct inode *old_inode = old_dentry->d_inode;
4820 + struct inode *new_inode = new_dentry->d_inode;
4821 + struct iattr attr = {
4822 + .ia_uid = old_inode->i_uid,
4823 + .ia_gid = old_inode->i_gid,
4824 + .ia_valid = ATTR_UID | ATTR_GID
4827 + setattr_copy(new_inode, &attr);
4828 + mark_inode_dirty(new_inode);
4831 + mutex_lock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
4833 + /* drop out late */
4835 + if ((redo = d_unhashed(old_dentry)))
4838 + vxdprintk(VXD_CBIT(misc, 2),
4839 + "vfs_rename: [" VS_Q("%*s") ":%d] -> [" VS_Q("%*s") ":%d]",
4840 + new_dentry->d_name.len, new_dentry->d_name.name,
4841 + new_dentry->d_name.len,
4842 + old_dentry->d_name.len, old_dentry->d_name.name,
4843 + old_dentry->d_name.len);
4844 + ret = vfs_rename(dir_nd.path.dentry->d_inode, new_dentry,
4845 + old_dentry->d_parent->d_inode, old_dentry);
4846 + vxdprintk(VXD_CBIT(misc, 2), "vfs_rename: %d", ret);
4849 + mutex_unlock(&old_dentry->d_inode->i_sb->s_vfs_rename_mutex);
4852 + vxdprintk(VXD_CBIT(misc, 3),
4853 + "fput(new_file=%p[#%ld])", new_file,
4854 + atomic_long_read(&new_file->f_count));
4858 + vxdprintk(VXD_CBIT(misc, 3),
4859 + "fput(old_file=%p[#%ld])", old_file,
4860 + atomic_long_read(&old_file->f_count));
4864 + mutex_unlock(&dir->d_inode->i_mutex);
4868 + /* error path cleanup */
4869 + vfs_unlink(dir->d_inode, new_dentry);
4873 + goto out_rel_both;
4874 + /* lookup dentry once again */
4875 + /* old_nd.path is freed as old_path in out_rel_old */
4876 + ret = do_path_lookup(AT_FDCWD, pathname, LOOKUP_FOLLOW, &old_nd);
4878 + goto out_rel_both;
4881 + new_dentry = old_nd.path.dentry;
4882 + vxdprintk(VXD_CBIT(misc, 2),
4883 + "do_path_lookup(redo): %p [" VS_Q("%.*s") ":%d]",
4885 + new_dentry->d_name.len, new_dentry->d_name.name,
4886 + new_dentry->d_name.len);
4890 + path_put(&dir_nd.path);
4892 + path_put(&old_path);
4898 + new_dentry = ERR_PTR(ret);
4900 + vxdprintk(VXD_CBIT(misc, 3),
4901 + "cow_break_link returning with %p [r=%d]",
4902 + new_dentry, mnt_get_count(real_mount(old_nd.path.mnt)));
4903 + return new_dentry;
4908 +int vx_info_mnt_namespace(struct mnt_namespace *ns, char *buffer)
4911 + struct vfsmount *vmnt;
4912 + char *pstr, *root;
4915 + pstr = kmalloc(PATH_MAX, GFP_KERNEL);
4919 + vmnt = &ns->root->mnt;
4921 + path.dentry = vmnt->mnt_root;
4922 + root = d_path(&path, pstr, PATH_MAX - 2);
4923 + length = sprintf(buffer + length,
4924 + "Namespace:\t%p [#%u]\n"
4925 + "RootPath:\t%s\n",
4926 + ns, atomic_read(&ns->count),
4932 /* get the link contents into pagecache */
4933 static char *page_getlink(struct dentry * dentry, struct page **ppage)
4935 @@ -3499,3 +3890,4 @@ EXPORT_SYMBOL(vfs_symlink);
4936 EXPORT_SYMBOL(vfs_unlink);
4937 EXPORT_SYMBOL(dentry_unhash);
4938 EXPORT_SYMBOL(generic_readlink);
4939 +EXPORT_SYMBOL(vx_info_mnt_namespace);
4940 diff -NurpP --minimal linux-3.4.103/fs/namespace.c linux-3.4.103-vs2.3.3.9/fs/namespace.c
4941 --- linux-3.4.103/fs/namespace.c 2014-08-30 13:37:14.000000000 +0000
4942 +++ linux-3.4.103-vs2.3.3.9/fs/namespace.c 2012-06-28 14:45:07.000000000 +0000
4944 #include <linux/fs_struct.h> /* get_fs_root et.al. */
4945 #include <linux/fsnotify.h> /* fsnotify_vfsmount_delete */
4946 #include <linux/uaccess.h>
4947 +#include <linux/vs_base.h>
4948 +#include <linux/vs_context.h>
4949 +#include <linux/vs_tag.h>
4950 +#include <linux/vserver/space.h>
4951 +#include <linux/vserver/global.h>
4953 #include "internal.h"
4955 @@ -697,6 +702,10 @@ vfs_kern_mount(struct file_system_type *
4957 return ERR_PTR(-ENODEV);
4959 + if ((type->fs_flags & FS_BINARY_MOUNTDATA) &&
4960 + !vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT))
4961 + return ERR_PTR(-EPERM);
4963 mnt = alloc_vfsmnt(name);
4965 return ERR_PTR(-ENOMEM);
4966 @@ -745,6 +754,7 @@ static struct mount *clone_mnt(struct mo
4967 mnt->mnt.mnt_root = dget(root);
4968 mnt->mnt_mountpoint = mnt->mnt.mnt_root;
4969 mnt->mnt_parent = mnt;
4970 + mnt->mnt_tag = old->mnt_tag;
4971 br_write_lock(vfsmount_lock);
4972 list_add_tail(&mnt->mnt_instance, &sb->s_mounts);
4973 br_write_unlock(vfsmount_lock);
4974 @@ -1210,7 +1220,7 @@ SYSCALL_DEFINE2(umount, char __user *, n
4978 - if (!capable(CAP_SYS_ADMIN))
4979 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
4982 retval = do_umount(mnt, flags);
4983 @@ -1236,7 +1246,7 @@ SYSCALL_DEFINE1(oldumount, char __user *
4985 static int mount_is_safe(struct path *path)
4987 - if (capable(CAP_SYS_ADMIN))
4988 + if (vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
4992 @@ -1549,7 +1559,7 @@ static int do_change_type(struct path *p
4996 - if (!capable(CAP_SYS_ADMIN))
4997 + if (!vx_capable(CAP_SYS_ADMIN, VXC_NAMESPACE))
5000 if (path->dentry != path->mnt->mnt_root)
5001 @@ -1565,6 +1575,7 @@ static int do_change_type(struct path *p
5005 + // mnt->mnt_flags = mnt_flags;
5007 br_write_lock(vfsmount_lock);
5008 for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL))
5009 @@ -1580,12 +1591,14 @@ static int do_change_type(struct path *p
5010 * do loopback mount.
5012 static int do_loopback(struct path *path, char *old_name,
5014 + tag_t tag, unsigned long flags, int mnt_flags)
5016 LIST_HEAD(umount_list);
5017 struct path old_path;
5018 struct mount *mnt = NULL, *old;
5019 int err = mount_is_safe(path);
5020 + int recurse = flags & MS_REC;
5024 if (!old_name || !*old_name)
5025 @@ -1653,13 +1666,13 @@ static int change_mount_flags(struct vfs
5026 * on it - tough luck.
5028 static int do_remount(struct path *path, int flags, int mnt_flags,
5030 + void *data, xid_t xid)
5033 struct super_block *sb = path->mnt->mnt_sb;
5034 struct mount *mnt = real_mount(path->mnt);
5036 - if (!capable(CAP_SYS_ADMIN))
5037 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_REMOUNT))
5040 if (!check_mnt(mnt))
5041 @@ -1708,7 +1721,7 @@ static int do_move_mount(struct path *pa
5045 - if (!capable(CAP_SYS_ADMIN))
5046 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5048 if (!old_name || !*old_name)
5050 @@ -1859,7 +1872,7 @@ static int do_new_mount(struct path *pat
5053 /* we need capabilities... */
5054 - if (!capable(CAP_SYS_ADMIN))
5055 + if (!vx_capable(CAP_SYS_ADMIN, VXC_SECURE_MOUNT))
5058 mnt = do_kern_mount(type, flags, name, data);
5059 @@ -2129,6 +2142,7 @@ long do_mount(char *dev_name, char *dir_
5066 if ((flags & MS_MGC_MSK) == MS_MGC_VAL)
5067 @@ -2156,6 +2170,12 @@ long do_mount(char *dev_name, char *dir_
5068 if (!(flags & MS_NOATIME))
5069 mnt_flags |= MNT_RELATIME;
5071 + if (dx_parse_tag(data_page, &tag, 1, &mnt_flags, &flags)) {
5072 + /* FIXME: bind and re-mounts get the tag flag? */
5073 + if (flags & (MS_BIND|MS_REMOUNT))
5074 + flags |= MS_TAGID;
5077 /* Separate the per-mountpoint flags */
5078 if (flags & MS_NOSUID)
5079 mnt_flags |= MNT_NOSUID;
5080 @@ -2172,15 +2192,17 @@ long do_mount(char *dev_name, char *dir_
5081 if (flags & MS_RDONLY)
5082 mnt_flags |= MNT_READONLY;
5084 + if (!capable(CAP_SYS_ADMIN))
5085 + mnt_flags |= MNT_NODEV;
5086 flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN |
5087 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
5090 if (flags & MS_REMOUNT)
5091 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
5094 else if (flags & MS_BIND)
5095 - retval = do_loopback(&path, dev_name, flags & MS_REC);
5096 + retval = do_loopback(&path, dev_name, tag, flags, mnt_flags);
5097 else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
5098 retval = do_change_type(&path, flags);
5099 else if (flags & MS_MOVE)
5100 @@ -2283,6 +2305,7 @@ static struct mnt_namespace *dup_mnt_ns(
5101 q = next_mnt(q, new);
5103 up_write(&namespace_sem);
5104 + atomic_inc(&vs_global_mnt_ns);
5108 @@ -2479,9 +2502,10 @@ SYSCALL_DEFINE2(pivot_root, const char _
5110 new_mnt = real_mount(new.mnt);
5111 root_mnt = real_mount(root.mnt);
5112 - if (IS_MNT_SHARED(real_mount(old.mnt)) ||
5113 + if ((IS_MNT_SHARED(real_mount(old.mnt)) ||
5114 IS_MNT_SHARED(new_mnt->mnt_parent) ||
5115 - IS_MNT_SHARED(root_mnt->mnt_parent))
5116 + IS_MNT_SHARED(root_mnt->mnt_parent)) &&
5117 + !vx_flags(VXF_STATE_SETUP, 0))
5119 if (!check_mnt(root_mnt) || !check_mnt(new_mnt))
5121 @@ -2602,6 +2626,7 @@ void put_mnt_ns(struct mnt_namespace *ns
5122 br_write_unlock(vfsmount_lock);
5123 up_write(&namespace_sem);
5124 release_mounts(&umount_list);
5125 + atomic_dec(&vs_global_mnt_ns);
5129 diff -NurpP --minimal linux-3.4.103/fs/nfs/client.c linux-3.4.103-vs2.3.3.9/fs/nfs/client.c
5130 --- linux-3.4.103/fs/nfs/client.c 2014-08-30 13:37:14.000000000 +0000
5131 +++ linux-3.4.103-vs2.3.3.9/fs/nfs/client.c 2013-01-16 00:15:57.000000000 +0000
5132 @@ -801,6 +801,9 @@ static int nfs_init_server_rpcclient(str
5133 if (server->flags & NFS_MOUNT_SOFT)
5134 server->client->cl_softrtry = 1;
5136 + server->client->cl_tag = 0;
5137 + if (server->flags & NFS_MOUNT_TAGGED)
5138 + server->client->cl_tag = 1;
5142 @@ -976,6 +979,10 @@ static void nfs_server_set_fsinfo(struct
5143 server->acdirmin = server->acdirmax = 0;
5146 + /* FIXME: needs fsinfo
5147 + if (server->flags & NFS_MOUNT_TAGGED)
5148 + sb->s_flags |= MS_TAGGED; */
5150 server->maxfilesize = fsinfo->maxfilesize;
5152 server->time_delta = fsinfo->time_delta;
5153 diff -NurpP --minimal linux-3.4.103/fs/nfs/dir.c linux-3.4.103-vs2.3.3.9/fs/nfs/dir.c
5154 --- linux-3.4.103/fs/nfs/dir.c 2014-08-30 13:37:14.000000000 +0000
5155 +++ linux-3.4.103-vs2.3.3.9/fs/nfs/dir.c 2013-01-16 00:15:57.000000000 +0000
5157 #include <linux/sched.h>
5158 #include <linux/kmemleak.h>
5159 #include <linux/xattr.h>
5160 +#include <linux/vs_tag.h>
5162 #include "delegation.h"
5164 @@ -1314,6 +1315,7 @@ static struct dentry *nfs_lookup(struct
5166 goto out_unblock_sillyrename;
5168 + dx_propagate_tag(nd, inode);
5170 res = d_materialise_unique(dentry, inode);
5172 diff -NurpP --minimal linux-3.4.103/fs/nfs/inode.c linux-3.4.103-vs2.3.3.9/fs/nfs/inode.c
5173 --- linux-3.4.103/fs/nfs/inode.c 2014-08-30 13:37:14.000000000 +0000
5174 +++ linux-3.4.103-vs2.3.3.9/fs/nfs/inode.c 2014-03-12 09:55:28.000000000 +0000
5176 #include <linux/compat.h>
5177 #include <linux/freezer.h>
5178 #include <linux/crc32.h>
5179 +#include <linux/vs_tag.h>
5181 #include <asm/uaccess.h>
5183 @@ -277,6 +278,8 @@ nfs_fhget(struct super_block *sb, struct
5184 if (inode->i_state & I_NEW) {
5185 struct nfs_inode *nfsi = NFS_I(inode);
5186 unsigned long now = jiffies;
5190 /* We set i_ino for the few things that still rely on it,
5191 * such as stat(2) */
5192 @@ -325,8 +328,8 @@ nfs_fhget(struct super_block *sb, struct
5193 inode->i_version = 0;
5196 - inode->i_uid = -2;
5197 - inode->i_gid = -2;
5200 inode->i_blocks = 0;
5201 memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf));
5203 @@ -363,13 +366,13 @@ nfs_fhget(struct super_block *sb, struct
5204 else if (nfs_server_capable(inode, NFS_CAP_NLINK))
5205 nfsi->cache_validity |= NFS_INO_INVALID_ATTR;
5206 if (fattr->valid & NFS_ATTR_FATTR_OWNER)
5207 - inode->i_uid = fattr->uid;
5209 else if (nfs_server_capable(inode, NFS_CAP_OWNER))
5210 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5211 | NFS_INO_INVALID_ACCESS
5212 | NFS_INO_INVALID_ACL;
5213 if (fattr->valid & NFS_ATTR_FATTR_GROUP)
5214 - inode->i_gid = fattr->gid;
5216 else if (nfs_server_capable(inode, NFS_CAP_OWNER_GROUP))
5217 nfsi->cache_validity |= NFS_INO_INVALID_ATTR
5218 | NFS_INO_INVALID_ACCESS
5219 @@ -382,6 +385,11 @@ nfs_fhget(struct super_block *sb, struct
5221 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
5223 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5224 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5225 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
5226 + /* maybe fattr->xid someday */
5228 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
5229 nfsi->attrtimeo_timestamp = now;
5230 nfsi->access_cache = RB_ROOT;
5231 @@ -499,6 +507,8 @@ void nfs_setattr_update_inode(struct ino
5232 inode->i_uid = attr->ia_uid;
5233 if ((attr->ia_valid & ATTR_GID) != 0)
5234 inode->i_gid = attr->ia_gid;
5235 + if ((attr->ia_valid & ATTR_TAG) && IS_TAGGED(inode))
5236 + inode->i_tag = attr->ia_tag;
5237 NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5238 spin_unlock(&inode->i_lock);
5240 @@ -948,6 +958,9 @@ static int nfs_check_inode_attributes(st
5241 struct nfs_inode *nfsi = NFS_I(inode);
5242 loff_t cur_size, new_isize;
5243 unsigned long invalid = 0;
5249 /* Has the inode gone and changed behind our back? */
5250 @@ -971,13 +984,18 @@ static int nfs_check_inode_attributes(st
5251 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE;
5254 + uid = INOTAG_UID(DX_TAG(inode), fattr->uid, fattr->gid);
5255 + gid = INOTAG_GID(DX_TAG(inode), fattr->uid, fattr->gid);
5256 + tag = INOTAG_TAG(DX_TAG(inode), fattr->uid, fattr->gid, 0);
5258 /* Have any file permissions changed? */
5259 if ((fattr->valid & NFS_ATTR_FATTR_MODE) && (inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO))
5260 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5261 - if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && inode->i_uid != fattr->uid)
5262 + if ((fattr->valid & NFS_ATTR_FATTR_OWNER) && uid != fattr->uid)
5263 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5264 - if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && inode->i_gid != fattr->gid)
5265 + if ((fattr->valid & NFS_ATTR_FATTR_GROUP) && gid != fattr->gid)
5266 invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL;
5267 + /* maybe check for tag too? */
5269 /* Has the link count changed? */
5270 if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
5271 @@ -1275,6 +1293,9 @@ static int nfs_update_inode(struct inode
5272 unsigned long invalid = 0;
5273 unsigned long now = jiffies;
5274 unsigned long save_cache_validity;
5279 dfprintk(VFS, "NFS: %s(%s/%ld fh_crc=0x%08x ct=%d info=0x%x)\n",
5280 __func__, inode->i_sb->s_id, inode->i_ino,
5281 @@ -1383,6 +1404,9 @@ static int nfs_update_inode(struct inode
5282 | NFS_INO_REVAL_PAGECACHE
5283 | NFS_INO_REVAL_FORCED);
5285 + uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
5286 + gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
5287 + tag = inode->i_tag;
5289 if (fattr->valid & NFS_ATTR_FATTR_ATIME)
5290 memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
5291 @@ -1404,9 +1428,9 @@ static int nfs_update_inode(struct inode
5292 | NFS_INO_REVAL_FORCED);
5294 if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
5295 - if (inode->i_uid != fattr->uid) {
5296 + if (uid != fattr->uid) {
5297 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5298 - inode->i_uid = fattr->uid;
5301 } else if (server->caps & NFS_CAP_OWNER)
5302 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5303 @@ -1415,9 +1439,9 @@ static int nfs_update_inode(struct inode
5304 | NFS_INO_REVAL_FORCED);
5306 if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
5307 - if (inode->i_gid != fattr->gid) {
5308 + if (gid != fattr->gid) {
5309 invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL;
5310 - inode->i_gid = fattr->gid;
5313 } else if (server->caps & NFS_CAP_OWNER_GROUP)
5314 invalid |= save_cache_validity & (NFS_INO_INVALID_ATTR
5315 @@ -1425,6 +1449,10 @@ static int nfs_update_inode(struct inode
5316 | NFS_INO_INVALID_ACL
5317 | NFS_INO_REVAL_FORCED);
5319 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5320 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5321 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, tag);
5323 if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
5324 if (inode->i_nlink != fattr->nlink) {
5325 invalid |= NFS_INO_INVALID_ATTR;
5326 diff -NurpP --minimal linux-3.4.103/fs/nfs/nfs3xdr.c linux-3.4.103-vs2.3.3.9/fs/nfs/nfs3xdr.c
5327 --- linux-3.4.103/fs/nfs/nfs3xdr.c 2012-05-21 16:07:25.000000000 +0000
5328 +++ linux-3.4.103-vs2.3.3.9/fs/nfs/nfs3xdr.c 2012-05-21 16:15:05.000000000 +0000
5330 #include <linux/nfs3.h>
5331 #include <linux/nfs_fs.h>
5332 #include <linux/nfsacl.h>
5333 +#include <linux/vs_tag.h>
5334 #include "internal.h"
5336 #define NFSDBG_FACILITY NFSDBG_XDR
5337 @@ -562,7 +563,8 @@ static __be32 *xdr_decode_nfstime3(__be3
5341 -static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr)
5342 +static void encode_sattr3(struct xdr_stream *xdr,
5343 + const struct iattr *attr, int tag)
5347 @@ -594,15 +596,19 @@ static void encode_sattr3(struct xdr_str
5351 - if (attr->ia_valid & ATTR_UID) {
5352 + if (attr->ia_valid & ATTR_UID ||
5353 + (tag && (attr->ia_valid & ATTR_TAG))) {
5355 - *p++ = cpu_to_be32(attr->ia_uid);
5356 + *p++ = cpu_to_be32(TAGINO_UID(tag,
5357 + attr->ia_uid, attr->ia_tag));
5361 - if (attr->ia_valid & ATTR_GID) {
5362 + if (attr->ia_valid & ATTR_GID ||
5363 + (tag && (attr->ia_valid & ATTR_TAG))) {
5365 - *p++ = cpu_to_be32(attr->ia_gid);
5366 + *p++ = cpu_to_be32(TAGINO_GID(tag,
5367 + attr->ia_gid, attr->ia_tag));
5371 @@ -878,7 +884,7 @@ static void nfs3_xdr_enc_setattr3args(st
5372 const struct nfs3_sattrargs *args)
5374 encode_nfs_fh3(xdr, args->fh);
5375 - encode_sattr3(xdr, args->sattr);
5376 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5377 encode_sattrguard3(xdr, args);
5380 @@ -1028,13 +1034,13 @@ static void nfs3_xdr_enc_write3args(stru
5383 static void encode_createhow3(struct xdr_stream *xdr,
5384 - const struct nfs3_createargs *args)
5385 + const struct nfs3_createargs *args, int tag)
5387 encode_uint32(xdr, args->createmode);
5388 switch (args->createmode) {
5389 case NFS3_CREATE_UNCHECKED:
5390 case NFS3_CREATE_GUARDED:
5391 - encode_sattr3(xdr, args->sattr);
5392 + encode_sattr3(xdr, args->sattr, tag);
5394 case NFS3_CREATE_EXCLUSIVE:
5395 encode_createverf3(xdr, args->verifier);
5396 @@ -1049,7 +1055,7 @@ static void nfs3_xdr_enc_create3args(str
5397 const struct nfs3_createargs *args)
5399 encode_diropargs3(xdr, args->fh, args->name, args->len);
5400 - encode_createhow3(xdr, args);
5401 + encode_createhow3(xdr, args, req->rq_task->tk_client->cl_tag);
5405 @@ -1065,7 +1071,7 @@ static void nfs3_xdr_enc_mkdir3args(stru
5406 const struct nfs3_mkdirargs *args)
5408 encode_diropargs3(xdr, args->fh, args->name, args->len);
5409 - encode_sattr3(xdr, args->sattr);
5410 + encode_sattr3(xdr, args->sattr, req->rq_task->tk_client->cl_tag);
5414 @@ -1082,9 +1088,9 @@ static void nfs3_xdr_enc_mkdir3args(stru
5417 static void encode_symlinkdata3(struct xdr_stream *xdr,
5418 - const struct nfs3_symlinkargs *args)
5419 + const struct nfs3_symlinkargs *args, int tag)
5421 - encode_sattr3(xdr, args->sattr);
5422 + encode_sattr3(xdr, args->sattr, tag);
5423 encode_nfspath3(xdr, args->pages, args->pathlen);
5426 @@ -1093,7 +1099,7 @@ static void nfs3_xdr_enc_symlink3args(st
5427 const struct nfs3_symlinkargs *args)
5429 encode_diropargs3(xdr, args->fromfh, args->fromname, args->fromlen);
5430 - encode_symlinkdata3(xdr, args);
5431 + encode_symlinkdata3(xdr, args, req->rq_task->tk_client->cl_tag);
5435 @@ -1121,24 +1127,24 @@ static void nfs3_xdr_enc_symlink3args(st
5438 static void encode_devicedata3(struct xdr_stream *xdr,
5439 - const struct nfs3_mknodargs *args)
5440 + const struct nfs3_mknodargs *args, int tag)
5442 - encode_sattr3(xdr, args->sattr);
5443 + encode_sattr3(xdr, args->sattr, tag);
5444 encode_specdata3(xdr, args->rdev);
5447 static void encode_mknoddata3(struct xdr_stream *xdr,
5448 - const struct nfs3_mknodargs *args)
5449 + const struct nfs3_mknodargs *args, int tag)
5451 encode_ftype3(xdr, args->type);
5452 switch (args->type) {
5455 - encode_devicedata3(xdr, args);
5456 + encode_devicedata3(xdr, args, tag);
5460 - encode_sattr3(xdr, args->sattr);
5461 + encode_sattr3(xdr, args->sattr, tag);
5465 @@ -1153,7 +1159,7 @@ static void nfs3_xdr_enc_mknod3args(stru
5466 const struct nfs3_mknodargs *args)
5468 encode_diropargs3(xdr, args->fh, args->name, args->len);
5469 - encode_mknoddata3(xdr, args);
5470 + encode_mknoddata3(xdr, args, req->rq_task->tk_client->cl_tag);
5474 diff -NurpP --minimal linux-3.4.103/fs/nfs/super.c linux-3.4.103-vs2.3.3.9/fs/nfs/super.c
5475 --- linux-3.4.103/fs/nfs/super.c 2014-08-30 13:37:14.000000000 +0000
5476 +++ linux-3.4.103-vs2.3.3.9/fs/nfs/super.c 2013-01-16 00:15:57.000000000 +0000
5478 #include <linux/parser.h>
5479 #include <linux/nsproxy.h>
5480 #include <linux/rcupdate.h>
5481 +#include <linux/vs_tag.h>
5483 #include <asm/uaccess.h>
5485 @@ -86,6 +87,7 @@ enum {
5486 Opt_sharecache, Opt_nosharecache,
5487 Opt_resvport, Opt_noresvport,
5488 Opt_fscache, Opt_nofscache,
5489 + Opt_tag, Opt_notag,
5491 /* Mount options that take integer arguments */
5493 @@ -98,6 +100,7 @@ enum {
5499 /* Mount options that take string arguments */
5501 @@ -180,6 +183,10 @@ static const match_table_t nfs_mount_opt
5502 /* The following needs to be listed after all other options */
5503 { Opt_nfsvers, "v%s" },
5505 + { Opt_tag, "tag" },
5506 + { Opt_notag, "notag" },
5507 + { Opt_tagid, "tagid=%u" },
5512 @@ -674,6 +681,7 @@ static void nfs_show_mount_options(struc
5513 { NFS_MOUNT_NORDIRPLUS, ",nordirplus", "" },
5514 { NFS_MOUNT_UNSHARED, ",nosharecache", "" },
5515 { NFS_MOUNT_NORESVPORT, ",noresvport", "" },
5516 + { NFS_MOUNT_TAGGED, ",tag", "" },
5519 const struct proc_nfs_info *nfs_infop;
5520 @@ -1286,6 +1294,14 @@ static int nfs_parse_mount_options(char
5521 kfree(mnt->fscache_uniq);
5522 mnt->fscache_uniq = NULL;
5524 +#ifndef CONFIG_TAGGING_NONE
5526 + mnt->flags |= NFS_MOUNT_TAGGED;
5529 + mnt->flags &= ~NFS_MOUNT_TAGGED;
5534 * options that take numeric values
5535 @@ -1372,6 +1388,12 @@ static int nfs_parse_mount_options(char
5536 goto out_invalid_value;
5537 mnt->minorversion = option;
5539 +#ifdef CONFIG_PROPAGATE
5542 + nfs_data.flags |= NFS_MOUNT_TAGGED;
5547 * options that take text values
5548 diff -NurpP --minimal linux-3.4.103/fs/nfsd/auth.c linux-3.4.103-vs2.3.3.9/fs/nfsd/auth.c
5549 --- linux-3.4.103/fs/nfsd/auth.c 2010-02-25 10:52:05.000000000 +0000
5550 +++ linux-3.4.103-vs2.3.3.9/fs/nfsd/auth.c 2012-05-21 16:15:05.000000000 +0000
5552 /* Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de> */
5554 #include <linux/sched.h>
5555 +#include <linux/vs_tag.h>
5559 @@ -36,6 +37,9 @@ int nfsd_setuser(struct svc_rqst *rqstp,
5561 new->fsuid = rqstp->rq_cred.cr_uid;
5562 new->fsgid = rqstp->rq_cred.cr_gid;
5563 + /* FIXME: this desperately needs a tag :)
5564 + new->xid = (xid_t)INOTAG_TAG(DX_TAG_NFSD, cred.cr_uid, cred.cr_gid, 0);
5567 rqgi = rqstp->rq_cred.cr_group_info;
5569 diff -NurpP --minimal linux-3.4.103/fs/nfsd/nfs3xdr.c linux-3.4.103-vs2.3.3.9/fs/nfsd/nfs3xdr.c
5570 --- linux-3.4.103/fs/nfsd/nfs3xdr.c 2012-05-21 16:07:26.000000000 +0000
5571 +++ linux-3.4.103-vs2.3.3.9/fs/nfsd/nfs3xdr.c 2012-05-21 16:15:05.000000000 +0000
5575 #include <linux/namei.h>
5576 +#include <linux/vs_tag.h>
5580 @@ -95,6 +96,8 @@ static __be32 *
5581 decode_sattr3(__be32 *p, struct iattr *iap)
5589 @@ -104,12 +107,15 @@ decode_sattr3(__be32 *p, struct iattr *i
5592 iap->ia_valid |= ATTR_UID;
5593 - iap->ia_uid = ntohl(*p++);
5594 + uid = ntohl(*p++);
5597 iap->ia_valid |= ATTR_GID;
5598 - iap->ia_gid = ntohl(*p++);
5599 + gid = ntohl(*p++);
5601 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
5602 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
5603 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
5607 @@ -165,8 +171,12 @@ encode_fattr3(struct svc_rqst *rqstp, __
5608 *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
5609 *p++ = htonl((u32) stat->mode);
5610 *p++ = htonl((u32) stat->nlink);
5611 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
5612 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
5613 + *p++ = htonl((u32) nfsd_ruid(rqstp,
5614 + TAGINO_UID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5615 + stat->uid, stat->tag)));
5616 + *p++ = htonl((u32) nfsd_rgid(rqstp,
5617 + TAGINO_GID(0 /* FIXME: DX_TAG(dentry->d_inode) */,
5618 + stat->gid, stat->tag)));
5619 if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
5620 p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
5622 diff -NurpP --minimal linux-3.4.103/fs/nfsd/nfs4xdr.c linux-3.4.103-vs2.3.3.9/fs/nfsd/nfs4xdr.c
5623 --- linux-3.4.103/fs/nfsd/nfs4xdr.c 2014-08-30 13:37:14.000000000 +0000
5624 +++ linux-3.4.103-vs2.3.3.9/fs/nfsd/nfs4xdr.c 2014-08-30 13:55:46.000000000 +0000
5626 #include <linux/utsname.h>
5627 #include <linux/pagemap.h>
5628 #include <linux/sunrpc/svcauth_gss.h>
5629 +#include <linux/vs_tag.h>
5633 @@ -2330,14 +2331,18 @@ out_acl:
5634 WRITE32(stat.nlink);
5636 if (bmval1 & FATTR4_WORD1_OWNER) {
5637 - status = nfsd4_encode_user(rqstp, stat.uid, &p, &buflen);
5638 + status = nfsd4_encode_user(rqstp,
5639 + TAGINO_UID(DX_TAG(dentry->d_inode),
5640 + stat.uid, stat.tag), &p, &buflen);
5641 if (status == nfserr_resource)
5646 if (bmval1 & FATTR4_WORD1_OWNER_GROUP) {
5647 - status = nfsd4_encode_group(rqstp, stat.gid, &p, &buflen);
5648 + status = nfsd4_encode_group(rqstp,
5649 + TAGINO_GID(DX_TAG(dentry->d_inode),
5650 + stat.gid, stat.tag), &p, &buflen);
5651 if (status == nfserr_resource)
5654 diff -NurpP --minimal linux-3.4.103/fs/nfsd/nfsxdr.c linux-3.4.103-vs2.3.3.9/fs/nfsd/nfsxdr.c
5655 --- linux-3.4.103/fs/nfsd/nfsxdr.c 2011-05-22 14:17:53.000000000 +0000
5656 +++ linux-3.4.103-vs2.3.3.9/fs/nfsd/nfsxdr.c 2012-05-21 16:15:05.000000000 +0000
5661 +#include <linux/vs_tag.h>
5663 #define NFSDDBG_FACILITY NFSDDBG_XDR
5665 @@ -88,6 +89,8 @@ static __be32 *
5666 decode_sattr(__be32 *p, struct iattr *iap)
5674 @@ -101,12 +104,15 @@ decode_sattr(__be32 *p, struct iattr *ia
5676 if ((tmp = ntohl(*p++)) != (u32)-1) {
5677 iap->ia_valid |= ATTR_UID;
5678 - iap->ia_uid = tmp;
5681 if ((tmp = ntohl(*p++)) != (u32)-1) {
5682 iap->ia_valid |= ATTR_GID;
5683 - iap->ia_gid = tmp;
5686 + iap->ia_uid = INOTAG_UID(DX_TAG_NFSD, uid, gid);
5687 + iap->ia_gid = INOTAG_GID(DX_TAG_NFSD, uid, gid);
5688 + iap->ia_tag = INOTAG_TAG(DX_TAG_NFSD, uid, gid, 0);
5689 if ((tmp = ntohl(*p++)) != (u32)-1) {
5690 iap->ia_valid |= ATTR_SIZE;
5692 @@ -151,8 +157,10 @@ encode_fattr(struct svc_rqst *rqstp, __b
5693 *p++ = htonl(nfs_ftypes[type >> 12]);
5694 *p++ = htonl((u32) stat->mode);
5695 *p++ = htonl((u32) stat->nlink);
5696 - *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid));
5697 - *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid));
5698 + *p++ = htonl((u32) nfsd_ruid(rqstp,
5699 + TAGINO_UID(DX_TAG(dentry->d_inode), stat->uid, stat->tag)));
5700 + *p++ = htonl((u32) nfsd_rgid(rqstp,
5701 + TAGINO_GID(DX_TAG(dentry->d_inode), stat->gid, stat->tag)));
5703 if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) {
5704 *p++ = htonl(NFS_MAXPATHLEN);
5705 diff -NurpP --minimal linux-3.4.103/fs/ocfs2/dlmglue.c linux-3.4.103-vs2.3.3.9/fs/ocfs2/dlmglue.c
5706 --- linux-3.4.103/fs/ocfs2/dlmglue.c 2014-08-30 13:37:15.000000000 +0000
5707 +++ linux-3.4.103-vs2.3.3.9/fs/ocfs2/dlmglue.c 2013-03-02 15:26:44.000000000 +0000
5708 @@ -2047,6 +2047,7 @@ static void __ocfs2_stuff_meta_lvb(struc
5709 lvb->lvb_iclusters = cpu_to_be32(oi->ip_clusters);
5710 lvb->lvb_iuid = cpu_to_be32(inode->i_uid);
5711 lvb->lvb_igid = cpu_to_be32(inode->i_gid);
5712 + lvb->lvb_itag = cpu_to_be16(inode->i_tag);
5713 lvb->lvb_imode = cpu_to_be16(inode->i_mode);
5714 lvb->lvb_inlink = cpu_to_be16(inode->i_nlink);
5715 lvb->lvb_iatime_packed =
5716 @@ -2097,6 +2098,7 @@ static void ocfs2_refresh_inode_from_lvb
5718 inode->i_uid = be32_to_cpu(lvb->lvb_iuid);
5719 inode->i_gid = be32_to_cpu(lvb->lvb_igid);
5720 + inode->i_tag = be16_to_cpu(lvb->lvb_itag);
5721 inode->i_mode = be16_to_cpu(lvb->lvb_imode);
5722 set_nlink(inode, be16_to_cpu(lvb->lvb_inlink));
5723 ocfs2_unpack_timespec(&inode->i_atime,
5724 diff -NurpP --minimal linux-3.4.103/fs/ocfs2/dlmglue.h linux-3.4.103-vs2.3.3.9/fs/ocfs2/dlmglue.h
5725 --- linux-3.4.103/fs/ocfs2/dlmglue.h 2010-10-21 11:07:50.000000000 +0000
5726 +++ linux-3.4.103-vs2.3.3.9/fs/ocfs2/dlmglue.h 2012-05-21 16:15:05.000000000 +0000
5727 @@ -46,7 +46,8 @@ struct ocfs2_meta_lvb {
5730 __be32 lvb_igeneration;
5731 - __be32 lvb_reserved2;
5733 + __be16 lvb_reserved2;
5736 #define OCFS2_QINFO_LVB_VERSION 1
5737 diff -NurpP --minimal linux-3.4.103/fs/ocfs2/file.c linux-3.4.103-vs2.3.3.9/fs/ocfs2/file.c
5738 --- linux-3.4.103/fs/ocfs2/file.c 2014-08-30 13:37:15.000000000 +0000
5739 +++ linux-3.4.103-vs2.3.3.9/fs/ocfs2/file.c 2014-04-21 18:56:34.000000000 +0000
5740 @@ -1123,7 +1123,7 @@ int ocfs2_setattr(struct dentry *dentry,
5741 attr->ia_valid &= ~ATTR_SIZE;
5743 #define OCFS2_VALID_ATTRS (ATTR_ATIME | ATTR_MTIME | ATTR_CTIME | ATTR_SIZE \
5744 - | ATTR_GID | ATTR_UID | ATTR_MODE)
5745 + | ATTR_GID | ATTR_UID | ATTR_TAG | ATTR_MODE)
5746 if (!(attr->ia_valid & OCFS2_VALID_ATTRS))
5749 diff -NurpP --minimal linux-3.4.103/fs/ocfs2/inode.c linux-3.4.103-vs2.3.3.9/fs/ocfs2/inode.c
5750 --- linux-3.4.103/fs/ocfs2/inode.c 2012-01-09 15:14:55.000000000 +0000
5751 +++ linux-3.4.103-vs2.3.3.9/fs/ocfs2/inode.c 2012-05-21 16:15:05.000000000 +0000
5753 #include <linux/highmem.h>
5754 #include <linux/pagemap.h>
5755 #include <linux/quotaops.h>
5756 +#include <linux/vs_tag.h>
5758 #include <asm/byteorder.h>
5760 @@ -78,11 +79,13 @@ void ocfs2_set_inode_flags(struct inode
5762 unsigned int flags = OCFS2_I(inode)->ip_attr;
5764 - inode->i_flags &= ~(S_IMMUTABLE |
5765 + inode->i_flags &= ~(S_IMMUTABLE | S_IXUNLINK |
5766 S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC);
5768 if (flags & OCFS2_IMMUTABLE_FL)
5769 inode->i_flags |= S_IMMUTABLE;
5770 + if (flags & OCFS2_IXUNLINK_FL)
5771 + inode->i_flags |= S_IXUNLINK;
5773 if (flags & OCFS2_SYNC_FL)
5774 inode->i_flags |= S_SYNC;
5775 @@ -92,25 +95,44 @@ void ocfs2_set_inode_flags(struct inode
5776 inode->i_flags |= S_NOATIME;
5777 if (flags & OCFS2_DIRSYNC_FL)
5778 inode->i_flags |= S_DIRSYNC;
5780 + inode->i_vflags &= ~(V_BARRIER | V_COW);
5782 + if (flags & OCFS2_BARRIER_FL)
5783 + inode->i_vflags |= V_BARRIER;
5784 + if (flags & OCFS2_COW_FL)
5785 + inode->i_vflags |= V_COW;
5788 /* Propagate flags from i_flags to OCFS2_I(inode)->ip_attr */
5789 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi)
5791 unsigned int flags = oi->vfs_inode.i_flags;
5792 + unsigned int vflags = oi->vfs_inode.i_vflags;
5794 + oi->ip_attr &= ~(OCFS2_SYNC_FL | OCFS2_APPEND_FL |
5795 + OCFS2_IMMUTABLE_FL | OCFS2_IXUNLINK_FL |
5796 + OCFS2_NOATIME_FL | OCFS2_DIRSYNC_FL |
5797 + OCFS2_BARRIER_FL | OCFS2_COW_FL);
5799 + if (flags & S_IMMUTABLE)
5800 + oi->ip_attr |= OCFS2_IMMUTABLE_FL;
5801 + if (flags & S_IXUNLINK)
5802 + oi->ip_attr |= OCFS2_IXUNLINK_FL;
5804 - oi->ip_attr &= ~(OCFS2_SYNC_FL|OCFS2_APPEND_FL|
5805 - OCFS2_IMMUTABLE_FL|OCFS2_NOATIME_FL|OCFS2_DIRSYNC_FL);
5807 oi->ip_attr |= OCFS2_SYNC_FL;
5808 if (flags & S_APPEND)
5809 oi->ip_attr |= OCFS2_APPEND_FL;
5810 - if (flags & S_IMMUTABLE)
5811 - oi->ip_attr |= OCFS2_IMMUTABLE_FL;
5812 if (flags & S_NOATIME)
5813 oi->ip_attr |= OCFS2_NOATIME_FL;
5814 if (flags & S_DIRSYNC)
5815 oi->ip_attr |= OCFS2_DIRSYNC_FL;
5817 + if (vflags & V_BARRIER)
5818 + oi->ip_attr |= OCFS2_BARRIER_FL;
5819 + if (vflags & V_COW)
5820 + oi->ip_attr |= OCFS2_COW_FL;
5823 struct inode *ocfs2_ilookup(struct super_block *sb, u64 blkno)
5824 @@ -241,6 +263,8 @@ void ocfs2_populate_inode(struct inode *
5825 struct super_block *sb;
5826 struct ocfs2_super *osb;
5833 @@ -269,8 +293,12 @@ void ocfs2_populate_inode(struct inode *
5834 inode->i_generation = le32_to_cpu(fe->i_generation);
5835 inode->i_rdev = huge_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
5836 inode->i_mode = le16_to_cpu(fe->i_mode);
5837 - inode->i_uid = le32_to_cpu(fe->i_uid);
5838 - inode->i_gid = le32_to_cpu(fe->i_gid);
5839 + uid = le32_to_cpu(fe->i_uid);
5840 + gid = le32_to_cpu(fe->i_gid);
5841 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
5842 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
5843 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid,
5844 + /* le16_to_cpu(raw_inode->i_raw_tag)i */ 0);
5846 /* Fast symlinks will have i_size but no allocated clusters. */
5847 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
5848 diff -NurpP --minimal linux-3.4.103/fs/ocfs2/inode.h linux-3.4.103-vs2.3.3.9/fs/ocfs2/inode.h
5849 --- linux-3.4.103/fs/ocfs2/inode.h 2012-01-09 15:14:55.000000000 +0000
5850 +++ linux-3.4.103-vs2.3.3.9/fs/ocfs2/inode.h 2012-05-21 16:15:05.000000000 +0000
5851 @@ -154,6 +154,7 @@ struct buffer_head *ocfs2_bread(struct i
5853 void ocfs2_set_inode_flags(struct inode *inode);
5854 void ocfs2_get_inode_flags(struct ocfs2_inode_info *oi);
5855 +int ocfs2_sync_flags(struct inode *inode, int, int);
5857 static inline blkcnt_t ocfs2_inode_sector_count(struct inode *inode)
5859 diff -NurpP --minimal linux-3.4.103/fs/ocfs2/ioctl.c linux-3.4.103-vs2.3.3.9/fs/ocfs2/ioctl.c
5860 --- linux-3.4.103/fs/ocfs2/ioctl.c 2012-05-21 16:07:26.000000000 +0000
5861 +++ linux-3.4.103-vs2.3.3.9/fs/ocfs2/ioctl.c 2012-05-21 16:15:05.000000000 +0000
5862 @@ -76,7 +76,41 @@ static int ocfs2_get_inode_attr(struct i
5866 -static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
5867 +int ocfs2_sync_flags(struct inode *inode, int flags, int vflags)
5869 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
5870 + struct buffer_head *bh = NULL;
5871 + handle_t *handle = NULL;
5874 + status = ocfs2_inode_lock(inode, &bh, 1);
5876 + mlog_errno(status);
5879 + handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
5880 + if (IS_ERR(handle)) {
5881 + status = PTR_ERR(handle);
5882 + mlog_errno(status);
5886 + inode->i_flags = flags;
5887 + inode->i_vflags = vflags;
5888 + ocfs2_get_inode_flags(OCFS2_I(inode));
5890 + status = ocfs2_mark_inode_dirty(handle, inode, bh);
5892 + mlog_errno(status);
5894 + ocfs2_commit_trans(osb, handle);
5896 + ocfs2_inode_unlock(inode, 1);
5901 +int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
5904 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
5905 @@ -101,6 +135,11 @@ static int ocfs2_set_inode_attr(struct i
5906 if (!S_ISDIR(inode->i_mode))
5907 flags &= ~OCFS2_DIRSYNC_FL;
5909 + if (IS_BARRIER(inode)) {
5910 + vxwprintk_task(1, "messing with the barrier.");
5914 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
5915 if (IS_ERR(handle)) {
5916 status = PTR_ERR(handle);
5917 @@ -879,6 +918,7 @@ bail:
5922 long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
5924 struct inode *inode = filp->f_path.dentry->d_inode;
5925 diff -NurpP --minimal linux-3.4.103/fs/ocfs2/namei.c linux-3.4.103-vs2.3.3.9/fs/ocfs2/namei.c
5926 --- linux-3.4.103/fs/ocfs2/namei.c 2012-03-19 18:47:26.000000000 +0000
5927 +++ linux-3.4.103-vs2.3.3.9/fs/ocfs2/namei.c 2012-05-21 16:15:05.000000000 +0000
5929 #include <linux/slab.h>
5930 #include <linux/highmem.h>
5931 #include <linux/quotaops.h>
5932 +#include <linux/vs_tag.h>
5934 #include <cluster/masklog.h>
5936 @@ -475,6 +476,7 @@ static int __ocfs2_mknod_locked(struct i
5937 struct ocfs2_dinode *fe = NULL;
5938 struct ocfs2_extent_list *fel;
5944 @@ -512,8 +514,11 @@ static int __ocfs2_mknod_locked(struct i
5945 fe->i_suballoc_loc = cpu_to_le64(suballoc_loc);
5946 fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
5947 fe->i_suballoc_slot = cpu_to_le16(inode_ac->ac_alloc_slot);
5948 - fe->i_uid = cpu_to_le32(inode->i_uid);
5949 - fe->i_gid = cpu_to_le32(inode->i_gid);
5951 + tag = dx_current_fstag(osb->sb);
5952 + fe->i_uid = cpu_to_le32(TAGINO_UID(DX_TAG(inode), inode->i_uid, tag));
5953 + fe->i_gid = cpu_to_le32(TAGINO_GID(DX_TAG(inode), inode->i_gid, tag));
5954 + inode->i_tag = tag;
5955 fe->i_mode = cpu_to_le16(inode->i_mode);
5956 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode))
5957 fe->id1.dev1.i_rdev = cpu_to_le64(huge_encode_dev(dev));
5958 diff -NurpP --minimal linux-3.4.103/fs/ocfs2/ocfs2.h linux-3.4.103-vs2.3.3.9/fs/ocfs2/ocfs2.h
5959 --- linux-3.4.103/fs/ocfs2/ocfs2.h 2012-01-09 15:14:55.000000000 +0000
5960 +++ linux-3.4.103-vs2.3.3.9/fs/ocfs2/ocfs2.h 2012-05-21 16:15:05.000000000 +0000
5961 @@ -272,6 +272,7 @@ enum ocfs2_mount_options
5963 OCFS2_MOUNT_HB_NONE = 1 << 13, /* No heartbeat */
5964 OCFS2_MOUNT_HB_GLOBAL = 1 << 14, /* Global heartbeat */
5965 + OCFS2_MOUNT_TAGGED = 1 << 15, /* use tagging */
5968 #define OCFS2_OSB_SOFT_RO 0x0001
5969 diff -NurpP --minimal linux-3.4.103/fs/ocfs2/ocfs2_fs.h linux-3.4.103-vs2.3.3.9/fs/ocfs2/ocfs2_fs.h
5970 --- linux-3.4.103/fs/ocfs2/ocfs2_fs.h 2011-05-22 14:17:53.000000000 +0000
5971 +++ linux-3.4.103-vs2.3.3.9/fs/ocfs2/ocfs2_fs.h 2012-05-21 16:15:05.000000000 +0000
5972 @@ -266,6 +266,11 @@
5973 #define OCFS2_TOPDIR_FL FS_TOPDIR_FL /* Top of directory hierarchies*/
5974 #define OCFS2_RESERVED_FL FS_RESERVED_FL /* reserved for ext2 lib */
5976 +#define OCFS2_IXUNLINK_FL FS_IXUNLINK_FL /* Immutable invert on unlink */
5978 +#define OCFS2_BARRIER_FL FS_BARRIER_FL /* Barrier for chroot() */
5979 +#define OCFS2_COW_FL FS_COW_FL /* Copy on Write marker */
5981 #define OCFS2_FL_VISIBLE FS_FL_USER_VISIBLE /* User visible flags */
5982 #define OCFS2_FL_MODIFIABLE FS_FL_USER_MODIFIABLE /* User modifiable flags */
5984 diff -NurpP --minimal linux-3.4.103/fs/ocfs2/super.c linux-3.4.103-vs2.3.3.9/fs/ocfs2/super.c
5985 --- linux-3.4.103/fs/ocfs2/super.c 2012-05-21 16:07:26.000000000 +0000
5986 +++ linux-3.4.103-vs2.3.3.9/fs/ocfs2/super.c 2012-05-21 16:15:05.000000000 +0000
5987 @@ -185,6 +185,7 @@ enum {
5991 + Opt_tag, Opt_notag, Opt_tagid,
5995 @@ -216,6 +217,9 @@ static const match_table_t tokens = {
5996 {Opt_coherency_full, "coherency=full"},
5997 {Opt_resv_level, "resv_level=%u"},
5998 {Opt_dir_resv_level, "dir_resv_level=%u"},
6000 + {Opt_notag, "notag"},
6001 + {Opt_tagid, "tagid=%u"},
6005 @@ -662,6 +666,13 @@ static int ocfs2_remount(struct super_bl
6009 + if ((osb->s_mount_opt & OCFS2_MOUNT_TAGGED) !=
6010 + (parsed_options.mount_opt & OCFS2_MOUNT_TAGGED)) {
6012 + mlog(ML_ERROR, "Cannot change tagging on remount\n");
6016 /* We're going to/from readonly mode. */
6017 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
6018 /* Disable quota accounting before remounting RO */
6019 @@ -1177,6 +1188,9 @@ static int ocfs2_fill_super(struct super
6021 ocfs2_complete_mount_recovery(osb);
6023 + if (osb->s_mount_opt & OCFS2_MOUNT_TAGGED)
6024 + sb->s_flags |= MS_TAGGED;
6026 if (ocfs2_mount_local(osb))
6027 snprintf(nodestr, sizeof(nodestr), "local");
6029 @@ -1503,6 +1517,20 @@ static int ocfs2_parse_options(struct su
6030 option < OCFS2_MAX_RESV_LEVEL)
6031 mopt->dir_resv_level = option;
6033 +#ifndef CONFIG_TAGGING_NONE
6035 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6038 + mopt->mount_opt &= ~OCFS2_MOUNT_TAGGED;
6041 +#ifdef CONFIG_PROPAGATE
6044 + mopt->mount_opt |= OCFS2_MOUNT_TAGGED;
6049 "Unrecognized mount option \"%s\" "
6050 diff -NurpP --minimal linux-3.4.103/fs/open.c linux-3.4.103-vs2.3.3.9/fs/open.c
6051 --- linux-3.4.103/fs/open.c 2014-08-30 13:37:15.000000000 +0000
6052 +++ linux-3.4.103-vs2.3.3.9/fs/open.c 2012-09-16 18:49:11.000000000 +0000
6054 #include <linux/fs_struct.h>
6055 #include <linux/ima.h>
6056 #include <linux/dnotify.h>
6057 +#include <linux/vs_base.h>
6058 +#include <linux/vs_limit.h>
6059 +#include <linux/vs_tag.h>
6060 +#include <linux/vs_cowbl.h>
6061 +#include <linux/vserver/dlimit.h>
6063 #include "internal.h"
6065 @@ -74,6 +79,12 @@ static long do_sys_truncate(const char _
6066 error = user_path(pathname, &path);
6070 +#ifdef CONFIG_VSERVER_COWBL
6071 + error = cow_check_and_break(&path);
6073 + goto dput_and_out;
6075 inode = path.dentry->d_inode;
6077 /* For directories it's -EISDIR, for other non-regulars - -EINVAL */
6078 @@ -489,6 +500,10 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, cons
6080 error = user_path_at(dfd, filename, LOOKUP_FOLLOW, &path);
6082 +#ifdef CONFIG_VSERVER_COWBL
6083 + error = cow_check_and_break(&path);
6086 error = chmod_common(&path, mode);
6089 @@ -509,11 +524,11 @@ static int chown_common(struct path *pat
6090 newattrs.ia_valid = ATTR_CTIME;
6091 if (user != (uid_t) -1) {
6092 newattrs.ia_valid |= ATTR_UID;
6093 - newattrs.ia_uid = user;
6094 + newattrs.ia_uid = dx_map_uid(user);
6096 if (group != (gid_t) -1) {
6097 newattrs.ia_valid |= ATTR_GID;
6098 - newattrs.ia_gid = group;
6099 + newattrs.ia_gid = dx_map_gid(group);
6101 if (!S_ISDIR(inode->i_mode))
6102 newattrs.ia_valid |=
6103 @@ -538,6 +553,10 @@ SYSCALL_DEFINE3(chown, const char __user
6104 error = mnt_want_write(path.mnt);
6107 +#ifdef CONFIG_VSERVER_COWBL
6108 + error = cow_check_and_break(&path);
6111 error = chown_common(&path, user, group);
6112 mnt_drop_write(path.mnt);
6114 @@ -565,6 +584,10 @@ SYSCALL_DEFINE5(fchownat, int, dfd, cons
6115 error = mnt_want_write(path.mnt);
6118 +#ifdef CONFIG_VSERVER_COWBL
6119 + error = cow_check_and_break(&path);
6122 error = chown_common(&path, user, group);
6123 mnt_drop_write(path.mnt);
6125 @@ -584,6 +607,10 @@ SYSCALL_DEFINE3(lchown, const char __use
6126 error = mnt_want_write(path.mnt);
6129 +#ifdef CONFIG_VSERVER_COWBL
6130 + error = cow_check_and_break(&path);
6133 error = chown_common(&path, user, group);
6134 mnt_drop_write(path.mnt);
6136 @@ -839,6 +866,7 @@ static void __put_unused_fd(struct files
6137 __clear_open_fd(fd, fdt);
6138 if (fd < files->next_fd)
6139 files->next_fd = fd;
6140 + vx_openfd_dec(fd);
6143 void put_unused_fd(unsigned int fd)
6144 diff -NurpP --minimal linux-3.4.103/fs/proc/array.c linux-3.4.103-vs2.3.3.9/fs/proc/array.c
6145 --- linux-3.4.103/fs/proc/array.c 2014-08-30 13:37:15.000000000 +0000
6146 +++ linux-3.4.103-vs2.3.3.9/fs/proc/array.c 2014-04-21 18:56:34.000000000 +0000
6148 #include <linux/pid_namespace.h>
6149 #include <linux/ptrace.h>
6150 #include <linux/tracehook.h>
6151 +#include <linux/vs_context.h>
6152 +#include <linux/vs_network.h>
6154 #include <asm/pgtable.h>
6155 #include <asm/processor.h>
6156 @@ -170,6 +172,9 @@ static inline void task_state(struct seq
6158 ppid = pid_alive(p) ?
6159 task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;
6160 + if (unlikely(vx_current_initpid(p->pid)))
6165 struct task_struct *tracer = ptrace_parent(p);
6166 @@ -287,7 +292,7 @@ static inline void task_sig(struct seq_f
6169 static void render_cap_t(struct seq_file *m, const char *header,
6171 + struct vx_info *vxi, kernel_cap_t *a)
6175 @@ -312,10 +317,11 @@ static inline void task_cap(struct seq_f
6176 cap_bset = cred->cap_bset;
6179 - render_cap_t(m, "CapInh:\t", &cap_inheritable);
6180 - render_cap_t(m, "CapPrm:\t", &cap_permitted);
6181 - render_cap_t(m, "CapEff:\t", &cap_effective);
6182 - render_cap_t(m, "CapBnd:\t", &cap_bset);
6183 + /* FIXME: maybe move the p->vx_info masking to __task_cred() ? */
6184 + render_cap_t(m, "CapInh:\t", p->vx_info, &cap_inheritable);
6185 + render_cap_t(m, "CapPrm:\t", p->vx_info, &cap_permitted);
6186 + render_cap_t(m, "CapEff:\t", p->vx_info, &cap_effective);
6187 + render_cap_t(m, "CapBnd:\t", p->vx_info, &cap_bset);
6190 static inline void task_context_switch_counts(struct seq_file *m,
6191 @@ -337,6 +343,42 @@ static void task_cpus_allowed(struct seq
6195 +int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6196 + struct pid *pid, struct task_struct *task)
6198 + seq_printf(m, "Proxy:\t%p(%c)\n"
6206 + (task->nsproxy == init_task.nsproxy ? 'I' : '-'),
6207 + atomic_read(&task->nsproxy->count),
6208 + task->nsproxy->uts_ns,
6209 + (task->nsproxy->uts_ns == init_task.nsproxy->uts_ns ? 'I' : '-'),
6210 + task->nsproxy->ipc_ns,
6211 + (task->nsproxy->ipc_ns == init_task.nsproxy->ipc_ns ? 'I' : '-'),
6212 + task->nsproxy->mnt_ns,
6213 + (task->nsproxy->mnt_ns == init_task.nsproxy->mnt_ns ? 'I' : '-'),
6214 + task->nsproxy->pid_ns,
6215 + (task->nsproxy->pid_ns == init_task.nsproxy->pid_ns ? 'I' : '-'),
6216 + task->nsproxy->net_ns,
6217 + (task->nsproxy->net_ns == init_task.nsproxy->net_ns ? 'I' : '-'));
6221 +void task_vs_id(struct seq_file *m, struct task_struct *task)
6223 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0))
6226 + seq_printf(m, "VxID: %d\n", vx_task_xid(task));
6227 + seq_printf(m, "NxID: %d\n", nx_task_nid(task));
6231 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
6232 struct pid *pid, struct task_struct *task)
6234 @@ -353,6 +395,7 @@ int proc_pid_status(struct seq_file *m,
6236 task_cpus_allowed(m, task);
6237 cpuset_task_status_allowed(m, task);
6238 + task_vs_id(m, task);
6239 task_context_switch_counts(m, task);
6242 @@ -462,6 +505,17 @@ static int do_task_stat(struct seq_file
6243 /* convert nsec -> ticks */
6244 start_time = nsec_to_clock_t(start_time);
6246 + /* fixup start time for virt uptime */
6247 + if (vx_flags(VXF_VIRT_UPTIME, 0)) {
6248 + unsigned long long bias =
6249 + current->vx_info->cvirt.bias_clock;
6251 + if (start_time > bias)
6252 + start_time -= bias;
6257 seq_printf(m, "%d (%s) %c", pid_nr_ns(pid, ns), tcomm, state);
6258 seq_put_decimal_ll(m, ' ', ppid);
6259 seq_put_decimal_ll(m, ' ', pgid);
6260 diff -NurpP --minimal linux-3.4.103/fs/proc/base.c linux-3.4.103-vs2.3.3.9/fs/proc/base.c
6261 --- linux-3.4.103/fs/proc/base.c 2014-08-30 13:37:15.000000000 +0000
6262 +++ linux-3.4.103-vs2.3.3.9/fs/proc/base.c 2014-04-21 18:56:34.000000000 +0000
6264 #include <linux/fs_struct.h>
6265 #include <linux/slab.h>
6266 #include <linux/flex_array.h>
6267 +#include <linux/vs_context.h>
6268 +#include <linux/vs_network.h>
6269 #ifdef CONFIG_HARDWALL
6270 #include <asm/hardwall.h>
6272 @@ -937,11 +939,16 @@ static ssize_t oom_adjust_write(struct f
6276 - if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
6277 + if (oom_adjust < task->signal->oom_adj &&
6278 + !vx_capable(CAP_SYS_RESOURCE, VXC_OOM_ADJUST)) {
6283 + /* prevent guest processes from circumventing the oom killer */
6284 + if (vx_current_xid() && (oom_adjust == OOM_DISABLE))
6285 + oom_adjust = OOM_ADJUST_MIN;
6288 * Warn that /proc/pid/oom_adj is deprecated, see
6289 * Documentation/feature-removal-schedule.txt.
6290 @@ -1541,6 +1548,8 @@ struct inode *proc_pid_make_inode(struct
6291 inode->i_gid = cred->egid;
6294 + /* procfs is xid tagged */
6295 + inode->i_tag = (tag_t)vx_task_xid(task);
6296 security_task_to_inode(task, inode);
6299 @@ -1586,6 +1595,8 @@ int pid_getattr(struct vfsmount *mnt, st
6303 +static unsigned name_to_int(struct dentry *dentry);
6306 * Exceptional case: normally we are not allowed to unhash a busy
6307 * directory. In this case, however, we can do it - no aliasing problems
6308 @@ -1614,6 +1625,12 @@ int pid_revalidate(struct dentry *dentry
6309 task = get_proc_task(inode);
6312 + unsigned pid = name_to_int(dentry);
6314 + if (pid != ~0U && pid != vx_map_pid(task->pid)) {
6315 + put_task_struct(task);
6318 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
6319 task_dumpable(task)) {
6321 @@ -1630,6 +1647,7 @@ int pid_revalidate(struct dentry *dentry
6322 put_task_struct(task);
6329 @@ -2453,6 +2471,13 @@ static struct dentry *proc_pident_lookup
6333 + /* TODO: maybe we can come up with a generic approach? */
6334 + if (task_vx_flags(task, VXF_HIDE_VINFO, 0) &&
6335 + (dentry->d_name.len == 5) &&
6336 + (!memcmp(dentry->d_name.name, "vinfo", 5) ||
6337 + !memcmp(dentry->d_name.name, "ninfo", 5)))
6341 * Yes, it does not scale. And it should not. Don't add
6342 * new entries into /proc/<tgid>/ without very good reasons.
6343 @@ -2838,7 +2863,7 @@ out_iput:
6344 static struct dentry *proc_base_lookup(struct inode *dir, struct dentry *dentry)
6346 struct dentry *error;
6347 - struct task_struct *task = get_proc_task(dir);
6348 + struct task_struct *task = get_proc_task_real(dir);
6349 const struct pid_entry *p, *last;
6351 error = ERR_PTR(-ENOENT);
6352 @@ -2945,6 +2970,9 @@ static int proc_pid_personality(struct s
6353 static const struct file_operations proc_task_operations;
6354 static const struct inode_operations proc_task_inode_operations;
6356 +extern int proc_pid_vx_info(struct task_struct *, char *);
6357 +extern int proc_pid_nx_info(struct task_struct *, char *);
6359 static const struct pid_entry tgid_base_stuff[] = {
6360 DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
6361 DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
6362 @@ -3011,6 +3039,8 @@ static const struct pid_entry tgid_base_
6363 #ifdef CONFIG_CGROUPS
6364 REG("cgroup", S_IRUGO, proc_cgroup_operations),
6366 + INF("vinfo", S_IRUGO, proc_pid_vx_info),
6367 + INF("ninfo", S_IRUGO, proc_pid_nx_info),
6368 INF("oom_score", S_IRUGO, proc_oom_score),
6369 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
6370 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
6371 @@ -3030,6 +3060,7 @@ static const struct pid_entry tgid_base_
6372 #ifdef CONFIG_HARDWALL
6373 INF("hardwall", S_IRUGO, proc_pid_hardwall),
6375 + ONE("nsproxy", S_IRUGO, proc_pid_nsproxy),
6378 static int proc_tgid_base_readdir(struct file * filp,
6379 @@ -3223,7 +3254,7 @@ retry:
6381 pid = find_ge_pid(iter.tgid, ns);
6383 - iter.tgid = pid_nr_ns(pid, ns);
6384 + iter.tgid = pid_unmapped_nr_ns(pid, ns);
6385 iter.task = pid_task(pid, PIDTYPE_PID);
6386 /* What we to know is if the pid we have find is the
6387 * pid of a thread_group_leader. Testing for task
6388 @@ -3253,7 +3284,7 @@ static int proc_pid_fill_cache(struct fi
6389 struct tgid_iter iter)
6391 char name[PROC_NUMBUF];
6392 - int len = snprintf(name, sizeof(name), "%d", iter.tgid);
6393 + int len = snprintf(name, sizeof(name), "%d", vx_map_tgid(iter.tgid));
6394 return proc_fill_cache(filp, dirent, filldir, name, len,
6395 proc_pid_instantiate, iter.task, NULL);
6397 @@ -3277,7 +3308,7 @@ int proc_pid_readdir(struct file * filp,
6399 nr = filp->f_pos - FIRST_PROCESS_ENTRY;
6401 - reaper = get_proc_task(filp->f_path.dentry->d_inode);
6402 + reaper = get_proc_task_real(filp->f_path.dentry->d_inode);
6406 @@ -3299,6 +3330,8 @@ int proc_pid_readdir(struct file * filp,
6407 __filldir = fake_filldir;
6409 filp->f_pos = iter.tgid + TGID_OFFSET;
6410 + if (!vx_proc_task_visible(iter.task))
6412 if (proc_pid_fill_cache(filp, dirent, __filldir, iter) < 0) {
6413 put_task_struct(iter.task);
6415 @@ -3452,6 +3485,8 @@ static struct dentry *proc_task_lookup(s
6416 tid = name_to_int(dentry);
6419 + if (vx_current_initpid(tid))
6422 ns = dentry->d_sb->s_fs_info;
6424 diff -NurpP --minimal linux-3.4.103/fs/proc/generic.c linux-3.4.103-vs2.3.3.9/fs/proc/generic.c
6425 --- linux-3.4.103/fs/proc/generic.c 2012-03-19 18:47:26.000000000 +0000
6426 +++ linux-3.4.103-vs2.3.3.9/fs/proc/generic.c 2012-05-21 16:15:05.000000000 +0000
6428 #include <linux/bitops.h>
6429 #include <linux/spinlock.h>
6430 #include <linux/completion.h>
6431 +#include <linux/vserver/inode.h>
6432 #include <asm/uaccess.h>
6434 #include "internal.h"
6435 @@ -424,11 +425,15 @@ struct dentry *proc_lookup_de(struct pro
6436 for (de = de->subdir; de ; de = de->next) {
6437 if (de->namelen != dentry->d_name.len)
6439 + if (!vx_hide_check(0, de->vx_flags))
6441 if (!memcmp(dentry->d_name.name, de->name, de->namelen)) {
6443 spin_unlock(&proc_subdir_lock);
6445 inode = proc_get_inode(dir->i_sb, de);
6446 + /* generic proc entries belong to the host */
6451 @@ -506,6 +511,8 @@ int proc_readdir_de(struct proc_dir_entr
6453 /* filldir passes info to user space */
6455 + if (!vx_hide_check(0, de->vx_flags))
6457 spin_unlock(&proc_subdir_lock);
6458 if (filldir(dirent, de->name, de->namelen, filp->f_pos,
6459 de->low_ino, de->mode >> 12) < 0) {
6460 @@ -513,6 +520,7 @@ int proc_readdir_de(struct proc_dir_entr
6463 spin_lock(&proc_subdir_lock);
6468 @@ -626,6 +634,7 @@ static struct proc_dir_entry *__proc_cre
6470 atomic_set(&ent->count, 1);
6472 + ent->vx_flags = IATTR_PROC_DEFAULT;
6473 spin_lock_init(&ent->pde_unload_lock);
6474 ent->pde_unload_completion = NULL;
6475 INIT_LIST_HEAD(&ent->pde_openers);
6476 @@ -649,7 +658,8 @@ struct proc_dir_entry *proc_symlink(cons
6482 + ent->vx_flags = IATTR_PROC_SYMLINK;
6486 diff -NurpP --minimal linux-3.4.103/fs/proc/inode.c linux-3.4.103-vs2.3.3.9/fs/proc/inode.c
6487 --- linux-3.4.103/fs/proc/inode.c 2014-08-30 13:37:15.000000000 +0000
6488 +++ linux-3.4.103-vs2.3.3.9/fs/proc/inode.c 2014-03-12 09:55:28.000000000 +0000
6489 @@ -456,6 +456,8 @@ struct inode *proc_get_inode(struct supe
6490 inode->i_uid = de->uid;
6491 inode->i_gid = de->gid;
6494 + PROC_I(inode)->vx_flags = de->vx_flags;
6496 inode->i_size = de->size;
6498 diff -NurpP --minimal linux-3.4.103/fs/proc/internal.h linux-3.4.103-vs2.3.3.9/fs/proc/internal.h
6499 --- linux-3.4.103/fs/proc/internal.h 2012-05-21 16:07:26.000000000 +0000
6500 +++ linux-3.4.103-vs2.3.3.9/fs/proc/internal.h 2012-05-21 16:15:05.000000000 +0000
6504 #include <linux/proc_fs.h>
6505 +#include <linux/vs_pid.h>
6507 struct ctl_table_header;
6509 extern struct proc_dir_entry proc_root;
6510 @@ -54,6 +56,9 @@ extern int proc_pid_status(struct seq_fi
6511 struct pid *pid, struct task_struct *task);
6512 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
6513 struct pid *pid, struct task_struct *task);
6514 +extern int proc_pid_nsproxy(struct seq_file *m, struct pid_namespace *ns,
6515 + struct pid *pid, struct task_struct *task);
6517 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
6519 extern const struct file_operations proc_pid_maps_operations;
6520 @@ -82,11 +87,16 @@ static inline struct pid *proc_pid(struc
6521 return PROC_I(inode)->pid;
6524 -static inline struct task_struct *get_proc_task(struct inode *inode)
6525 +static inline struct task_struct *get_proc_task_real(struct inode *inode)
6527 return get_pid_task(proc_pid(inode), PIDTYPE_PID);
6530 +static inline struct task_struct *get_proc_task(struct inode *inode)
6532 + return vx_get_proc_task(inode, proc_pid(inode));
6535 static inline int proc_fd(struct inode *inode)
6537 return PROC_I(inode)->fd;
6538 diff -NurpP --minimal linux-3.4.103/fs/proc/loadavg.c linux-3.4.103-vs2.3.3.9/fs/proc/loadavg.c
6539 --- linux-3.4.103/fs/proc/loadavg.c 2009-09-10 13:26:23.000000000 +0000
6540 +++ linux-3.4.103-vs2.3.3.9/fs/proc/loadavg.c 2012-05-21 16:15:05.000000000 +0000
6543 static int loadavg_proc_show(struct seq_file *m, void *v)
6545 + unsigned long running;
6546 + unsigned int threads;
6547 unsigned long avnrun[3];
6549 get_avenrun(avnrun, FIXED_1/200, 0);
6551 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
6552 + struct vx_info *vxi = current_vx_info();
6554 + running = atomic_read(&vxi->cvirt.nr_running);
6555 + threads = atomic_read(&vxi->cvirt.nr_threads);
6557 + running = nr_running();
6558 + threads = nr_threads;
6561 seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
6562 LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
6563 LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
6564 LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
6565 - nr_running(), nr_threads,
6567 task_active_pid_ns(current)->last_pid);
6570 diff -NurpP --minimal linux-3.4.103/fs/proc/meminfo.c linux-3.4.103-vs2.3.3.9/fs/proc/meminfo.c
6571 --- linux-3.4.103/fs/proc/meminfo.c 2012-01-09 15:14:55.000000000 +0000
6572 +++ linux-3.4.103-vs2.3.3.9/fs/proc/meminfo.c 2012-05-21 16:15:05.000000000 +0000
6573 @@ -39,7 +39,8 @@ static int meminfo_proc_show(struct seq_
6574 allowed = ((totalram_pages - hugetlb_total_pages())
6575 * sysctl_overcommit_ratio / 100) + total_swap_pages;
6577 - cached = global_page_state(NR_FILE_PAGES) -
6578 + cached = vx_flags(VXF_VIRT_MEM, 0) ?
6579 + vx_vsi_cached(&i) : global_page_state(NR_FILE_PAGES) -
6580 total_swapcache_pages - i.bufferram;
6583 diff -NurpP --minimal linux-3.4.103/fs/proc/root.c linux-3.4.103-vs2.3.3.9/fs/proc/root.c
6584 --- linux-3.4.103/fs/proc/root.c 2012-05-21 16:07:26.000000000 +0000
6585 +++ linux-3.4.103-vs2.3.3.9/fs/proc/root.c 2012-05-21 16:15:05.000000000 +0000
6587 #include <linux/mount.h>
6588 #include <linux/pid_namespace.h>
6589 #include <linux/parser.h>
6590 +#include <linux/vserver/inode.h>
6592 #include "internal.h"
6594 +struct proc_dir_entry *proc_virtual;
6596 +extern void proc_vx_init(void);
6598 static int proc_test_super(struct super_block *sb, void *data)
6600 return sb->s_fs_info == data;
6601 @@ -190,6 +195,7 @@ void __init proc_root_init(void)
6603 proc_mkdir("bus", NULL);
6608 static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat
6609 @@ -257,6 +263,7 @@ struct proc_dir_entry proc_root = {
6610 .proc_iops = &proc_root_inode_operations,
6611 .proc_fops = &proc_root_operations,
6612 .parent = &proc_root,
6613 + .vx_flags = IATTR_ADMIN | IATTR_WATCH,
6617 diff -NurpP --minimal linux-3.4.103/fs/proc/stat.c linux-3.4.103-vs2.3.3.9/fs/proc/stat.c
6618 --- linux-3.4.103/fs/proc/stat.c 2014-08-30 13:37:15.000000000 +0000
6619 +++ linux-3.4.103-vs2.3.3.9/fs/proc/stat.c 2012-11-06 17:02:35.000000000 +0000
6621 #include <linux/slab.h>
6622 #include <linux/time.h>
6623 #include <linux/irqnr.h>
6624 +#include <linux/vserver/cvirt.h>
6625 #include <asm/cputime.h>
6626 #include <linux/tick.h>
6628 @@ -92,6 +93,10 @@ static int show_stat(struct seq_file *p,
6629 irq = softirq = steal = 0;
6630 guest = guest_nice = 0;
6631 getboottime(&boottime);
6633 + if (vx_flags(VXF_VIRT_UPTIME, 0))
6634 + vx_vsi_boottime(&boottime);
6636 jif = boottime.tv_sec;
6638 for_each_possible_cpu(i) {
6639 diff -NurpP --minimal linux-3.4.103/fs/proc/uptime.c linux-3.4.103-vs2.3.3.9/fs/proc/uptime.c
6640 --- linux-3.4.103/fs/proc/uptime.c 2012-03-19 18:47:26.000000000 +0000
6641 +++ linux-3.4.103-vs2.3.3.9/fs/proc/uptime.c 2012-05-21 16:15:05.000000000 +0000
6643 #include <linux/seq_file.h>
6644 #include <linux/time.h>
6645 #include <linux/kernel_stat.h>
6646 +#include <linux/vserver/cvirt.h>
6647 #include <asm/cputime.h>
6649 static int uptime_proc_show(struct seq_file *m, void *v)
6650 @@ -25,6 +26,10 @@ static int uptime_proc_show(struct seq_f
6651 nsec = cputime64_to_jiffies64(idletime) * TICK_NSEC;
6652 idle.tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem);
6655 + if (vx_flags(VXF_VIRT_UPTIME, 0))
6656 + vx_vsi_uptime(&uptime, &idle);
6658 seq_printf(m, "%lu.%02lu %lu.%02lu\n",
6659 (unsigned long) uptime.tv_sec,
6660 (uptime.tv_nsec / (NSEC_PER_SEC / 100)),
6661 diff -NurpP --minimal linux-3.4.103/fs/proc_namespace.c linux-3.4.103-vs2.3.3.9/fs/proc_namespace.c
6662 --- linux-3.4.103/fs/proc_namespace.c 2012-03-19 18:47:26.000000000 +0000
6663 +++ linux-3.4.103-vs2.3.3.9/fs/proc_namespace.c 2012-05-21 16:15:05.000000000 +0000
6664 @@ -44,6 +44,8 @@ static int show_sb_opts(struct seq_file
6665 { MS_SYNCHRONOUS, ",sync" },
6666 { MS_DIRSYNC, ",dirsync" },
6667 { MS_MANDLOCK, ",mand" },
6668 + { MS_TAGGED, ",tag" },
6669 + { MS_NOTAGCHECK, ",notagcheck" },
6672 const struct proc_fs_info *fs_infop;
6673 @@ -80,6 +82,34 @@ static inline void mangle(struct seq_fil
6674 seq_escape(m, s, " \t\n\\");
6677 +static int mnt_is_reachable(struct vfsmount *vfsmnt)
6680 + struct dentry *point;
6681 + struct mount *mnt = real_mount(vfsmnt);
6682 + struct mount *root_mnt;
6685 + if (mnt == mnt->mnt_ns->root)
6688 + br_read_lock(vfsmount_lock);
6689 + root = current->fs->root;
6690 + root_mnt = real_mount(root.mnt);
6691 + point = root.dentry;
6693 + while ((mnt != mnt->mnt_parent) && (mnt != root_mnt)) {
6694 + point = mnt->mnt_mountpoint;
6695 + mnt = mnt->mnt_parent;
6698 + ret = (mnt == root_mnt) && is_subdir(point, root.dentry);
6700 + br_read_unlock(vfsmount_lock);
6705 static void show_type(struct seq_file *m, struct super_block *sb)
6707 mangle(m, sb->s_type->name);
6708 @@ -96,6 +126,17 @@ static int show_vfsmnt(struct seq_file *
6709 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
6710 struct super_block *sb = mnt_path.dentry->d_sb;
6712 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6714 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6717 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6718 + mnt == current->fs->root.mnt) {
6719 + seq_puts(m, "/dev/root / ");
6723 if (sb->s_op->show_devname) {
6724 err = sb->s_op->show_devname(m, mnt_path.dentry);
6726 @@ -106,6 +147,7 @@ static int show_vfsmnt(struct seq_file *
6728 seq_path(m, &mnt_path, " \t\n\\");
6732 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
6733 err = show_sb_opts(m, sb);
6734 @@ -128,6 +170,11 @@ static int show_mountinfo(struct seq_fil
6735 struct path root = p->root;
6738 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6740 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6743 seq_printf(m, "%i %i %u:%u ", r->mnt_id, r->mnt_parent->mnt_id,
6744 MAJOR(sb->s_dev), MINOR(sb->s_dev));
6745 if (sb->s_op->show_path)
6746 @@ -187,6 +234,17 @@ static int show_vfsstat(struct seq_file
6747 struct super_block *sb = mnt_path.dentry->d_sb;
6750 + if (vx_flags(VXF_HIDE_MOUNT, 0))
6752 + if (!mnt_is_reachable(mnt) && !vx_check(0, VS_WATCH_P))
6755 + if (!vx_check(0, VS_ADMIN|VS_WATCH) &&
6756 + mnt == current->fs->root.mnt) {
6757 + seq_puts(m, "device /dev/root mounted on / ");
6762 if (sb->s_op->show_devname) {
6763 seq_puts(m, "device ");
6764 @@ -203,7 +261,7 @@ static int show_vfsstat(struct seq_file
6765 seq_puts(m, " mounted on ");
6766 seq_path(m, &mnt_path, " \t\n\\");
6770 /* file system type */
6771 seq_puts(m, "with fstype ");
6773 diff -NurpP --minimal linux-3.4.103/fs/quota/dquot.c linux-3.4.103-vs2.3.3.9/fs/quota/dquot.c
6774 --- linux-3.4.103/fs/quota/dquot.c 2014-08-30 13:37:15.000000000 +0000
6775 +++ linux-3.4.103-vs2.3.3.9/fs/quota/dquot.c 2014-03-12 09:55:28.000000000 +0000
6776 @@ -1571,6 +1571,9 @@ int __dquot_alloc_space(struct inode *in
6777 struct dquot **dquots = inode->i_dquot;
6778 int reserve = flags & DQUOT_SPACE_RESERVE;
6780 + if ((ret = dl_alloc_space(inode, number)))
6784 * First test before acquiring mutex - solves deadlocks when we
6785 * re-enter the quota code and are already holding the mutex
6786 @@ -1626,6 +1629,9 @@ int dquot_alloc_inode(const struct inode
6787 struct dquot_warn warn[MAXQUOTAS];
6788 struct dquot * const *dquots = inode->i_dquot;
6790 + if ((ret = dl_alloc_inode(inode)))
6793 /* First test before acquiring mutex - solves deadlocks when we
6794 * re-enter the quota code and are already holding the mutex */
6795 if (!dquot_active(inode))
6796 @@ -1697,6 +1703,8 @@ void __dquot_free_space(struct inode *in
6797 struct dquot **dquots = inode->i_dquot;
6798 int reserve = flags & DQUOT_SPACE_RESERVE;
6800 + dl_free_space(inode, number);
6802 /* First test before acquiring mutex - solves deadlocks when we
6803 * re-enter the quota code and are already holding the mutex */
6804 if (!dquot_active(inode)) {
6805 @@ -1741,6 +1749,8 @@ void dquot_free_inode(const struct inode
6806 struct dquot_warn warn[MAXQUOTAS];
6807 struct dquot * const *dquots = inode->i_dquot;
6809 + dl_free_inode(inode);
6811 /* First test before acquiring mutex - solves deadlocks when we
6812 * re-enter the quota code and are already holding the mutex */
6813 if (!dquot_active(inode))
6814 diff -NurpP --minimal linux-3.4.103/fs/quota/quota.c linux-3.4.103-vs2.3.3.9/fs/quota/quota.c
6815 --- linux-3.4.103/fs/quota/quota.c 2012-05-21 16:07:26.000000000 +0000
6816 +++ linux-3.4.103-vs2.3.3.9/fs/quota/quota.c 2012-05-21 16:15:05.000000000 +0000
6818 #include <linux/fs.h>
6819 #include <linux/namei.h>
6820 #include <linux/slab.h>
6821 +#include <linux/vs_context.h>
6822 #include <asm/current.h>
6823 #include <asm/uaccess.h>
6824 #include <linux/kernel.h>
6825 @@ -37,7 +38,7 @@ static int check_quotactl_permission(str
6829 - if (!capable(CAP_SYS_ADMIN))
6830 + if (!vx_capable(CAP_SYS_ADMIN, VXC_QUOTA_CTL))
6834 @@ -291,6 +292,46 @@ static int do_quotactl(struct super_bloc
6838 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
6840 +#include <linux/vroot.h>
6841 +#include <linux/major.h>
6842 +#include <linux/module.h>
6843 +#include <linux/kallsyms.h>
6844 +#include <linux/vserver/debug.h>
6846 +static vroot_grb_func *vroot_get_real_bdev = NULL;
6848 +static DEFINE_SPINLOCK(vroot_grb_lock);
6850 +int register_vroot_grb(vroot_grb_func *func) {
6853 + spin_lock(&vroot_grb_lock);
6854 + if (!vroot_get_real_bdev) {
6855 + vroot_get_real_bdev = func;
6858 + spin_unlock(&vroot_grb_lock);
6861 +EXPORT_SYMBOL(register_vroot_grb);
6863 +int unregister_vroot_grb(vroot_grb_func *func) {
6864 + int ret = -EINVAL;
6866 + spin_lock(&vroot_grb_lock);
6867 + if (vroot_get_real_bdev) {
6868 + vroot_get_real_bdev = NULL;
6871 + spin_unlock(&vroot_grb_lock);
6874 +EXPORT_SYMBOL(unregister_vroot_grb);
6878 /* Return 1 if 'cmd' will block on frozen filesystem */
6879 static int quotactl_cmd_write(int cmd)
6881 @@ -323,6 +364,22 @@ static struct super_block *quotactl_bloc
6884 return ERR_CAST(bdev);
6885 +#if defined(CONFIG_BLK_DEV_VROOT) || defined(CONFIG_BLK_DEV_VROOT_MODULE)
6886 + if (bdev && bdev->bd_inode &&
6887 + imajor(bdev->bd_inode) == VROOT_MAJOR) {
6888 + struct block_device *bdnew = (void *)-EINVAL;
6890 + if (vroot_get_real_bdev)
6891 + bdnew = vroot_get_real_bdev(bdev);
6893 + vxdprintk(VXD_CBIT(misc, 0),
6894 + "vroot_get_real_bdev not set");
6896 + if (IS_ERR(bdnew))
6897 + return ERR_PTR(PTR_ERR(bdnew));
6901 if (quotactl_cmd_write(cmd))
6902 sb = get_super_thawed(bdev);
6904 diff -NurpP --minimal linux-3.4.103/fs/reiserfs/file.c linux-3.4.103-vs2.3.3.9/fs/reiserfs/file.c
6905 --- linux-3.4.103/fs/reiserfs/file.c 2012-05-21 16:07:26.000000000 +0000
6906 +++ linux-3.4.103-vs2.3.3.9/fs/reiserfs/file.c 2012-05-21 16:15:05.000000000 +0000
6907 @@ -319,5 +319,6 @@ const struct inode_operations reiserfs_f
6908 .listxattr = reiserfs_listxattr,
6909 .removexattr = reiserfs_removexattr,
6910 .permission = reiserfs_permission,
6911 + .sync_flags = reiserfs_sync_flags,
6912 .get_acl = reiserfs_get_acl,
6914 diff -NurpP --minimal linux-3.4.103/fs/reiserfs/inode.c linux-3.4.103-vs2.3.3.9/fs/reiserfs/inode.c
6915 --- linux-3.4.103/fs/reiserfs/inode.c 2014-08-30 13:37:15.000000000 +0000
6916 +++ linux-3.4.103-vs2.3.3.9/fs/reiserfs/inode.c 2012-12-08 00:53:53.000000000 +0000
6918 #include <linux/writeback.h>
6919 #include <linux/quotaops.h>
6920 #include <linux/swap.h>
6921 +#include <linux/vs_tag.h>
6923 int reiserfs_commit_write(struct file *f, struct page *page,
6924 unsigned from, unsigned to);
6925 @@ -1131,6 +1132,8 @@ static void init_inode(struct inode *ino
6926 struct buffer_head *bh;
6927 struct item_head *ih;
6931 //int version = ITEM_VERSION_1;
6933 bh = PATH_PLAST_BUFFER(path);
6934 @@ -1151,12 +1154,13 @@ static void init_inode(struct inode *ino
6935 (struct stat_data_v1 *)B_I_PITEM(bh, ih);
6936 unsigned long blocks;
6938 + uid = sd_v1_uid(sd);
6939 + gid = sd_v1_gid(sd);
6941 set_inode_item_key_version(inode, KEY_FORMAT_3_5);
6942 set_inode_sd_version(inode, STAT_DATA_V1);
6943 inode->i_mode = sd_v1_mode(sd);
6944 set_nlink(inode, sd_v1_nlink(sd));
6945 - inode->i_uid = sd_v1_uid(sd);
6946 - inode->i_gid = sd_v1_gid(sd);
6947 inode->i_size = sd_v1_size(sd);
6948 inode->i_atime.tv_sec = sd_v1_atime(sd);
6949 inode->i_mtime.tv_sec = sd_v1_mtime(sd);
6950 @@ -1198,11 +1202,12 @@ static void init_inode(struct inode *ino
6951 // (directories and symlinks)
6952 struct stat_data *sd = (struct stat_data *)B_I_PITEM(bh, ih);
6954 + uid = sd_v2_uid(sd);
6955 + gid = sd_v2_gid(sd);
6957 inode->i_mode = sd_v2_mode(sd);
6958 set_nlink(inode, sd_v2_nlink(sd));
6959 - inode->i_uid = sd_v2_uid(sd);
6960 inode->i_size = sd_v2_size(sd);
6961 - inode->i_gid = sd_v2_gid(sd);
6962 inode->i_mtime.tv_sec = sd_v2_mtime(sd);
6963 inode->i_atime.tv_sec = sd_v2_atime(sd);
6964 inode->i_ctime.tv_sec = sd_v2_ctime(sd);
6965 @@ -1232,6 +1237,10 @@ static void init_inode(struct inode *ino
6966 sd_attrs_to_i_attrs(sd_v2_attrs(sd), inode);
6969 + inode->i_uid = INOTAG_UID(DX_TAG(inode), uid, gid);
6970 + inode->i_gid = INOTAG_GID(DX_TAG(inode), uid, gid);
6971 + inode->i_tag = INOTAG_TAG(DX_TAG(inode), uid, gid, 0);
6974 if (S_ISREG(inode->i_mode)) {
6975 inode->i_op = &reiserfs_file_inode_operations;
6976 @@ -1254,13 +1263,15 @@ static void init_inode(struct inode *ino
6977 static void inode2sd(void *sd, struct inode *inode, loff_t size)
6979 struct stat_data *sd_v2 = (struct stat_data *)sd;
6980 + uid_t uid = TAGINO_UID(DX_TAG(inode), inode->i_uid, inode->i_tag);
6981 + gid_t gid = TAGINO_GID(DX_TAG(inode), inode->i_gid, inode->i_tag);
6984 + set_sd_v2_uid(sd_v2, uid);
6985 + set_sd_v2_gid(sd_v2, gid);
6986 set_sd_v2_mode(sd_v2, inode->i_mode);
6987 set_sd_v2_nlink(sd_v2, inode->i_nlink);
6988 - set_sd_v2_uid(sd_v2, inode->i_uid);
6989 set_sd_v2_size(sd_v2, size);
6990 - set_sd_v2_gid(sd_v2, inode->i_gid);
6991 set_sd_v2_mtime(sd_v2, inode->i_mtime.tv_sec);
6992 set_sd_v2_atime(sd_v2, inode->i_atime.tv_sec);
6993 set_sd_v2_ctime(sd_v2, inode->i_ctime.tv_sec);
6994 @@ -2875,14 +2886,19 @@ int reiserfs_commit_write(struct file *f
6995 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode)
6997 if (reiserfs_attrs(inode->i_sb)) {
6998 - if (sd_attrs & REISERFS_SYNC_FL)
6999 - inode->i_flags |= S_SYNC;
7001 - inode->i_flags &= ~S_SYNC;
7002 if (sd_attrs & REISERFS_IMMUTABLE_FL)
7003 inode->i_flags |= S_IMMUTABLE;
7005 inode->i_flags &= ~S_IMMUTABLE;
7006 + if (sd_attrs & REISERFS_IXUNLINK_FL)
7007 + inode->i_flags |= S_IXUNLINK;
7009 + inode->i_flags &= ~S_IXUNLINK;
7011 + if (sd_attrs & REISERFS_SYNC_FL)
7012 + inode->i_flags |= S_SYNC;
7014 + inode->i_flags &= ~S_SYNC;
7015 if (sd_attrs & REISERFS_APPEND_FL)
7016 inode->i_flags |= S_APPEND;
7018 @@ -2895,6 +2911,15 @@ void sd_attrs_to_i_attrs(__u16 sd_attrs,
7019 REISERFS_I(inode)->i_flags |= i_nopack_mask;
7021 REISERFS_I(inode)->i_flags &= ~i_nopack_mask;
7023 + if (sd_attrs & REISERFS_BARRIER_FL)
7024 + inode->i_vflags |= V_BARRIER;
7026 + inode->i_vflags &= ~V_BARRIER;
7027 + if (sd_attrs & REISERFS_COW_FL)
7028 + inode->i_vflags |= V_COW;
7030 + inode->i_vflags &= ~V_COW;
7034 @@ -2905,6 +2930,11 @@ void i_attrs_to_sd_attrs(struct inode *i
7035 *sd_attrs |= REISERFS_IMMUTABLE_FL;
7037 *sd_attrs &= ~REISERFS_IMMUTABLE_FL;
7038 + if (inode->i_flags & S_IXUNLINK)
7039 + *sd_attrs |= REISERFS_IXUNLINK_FL;
7041 + *sd_attrs &= ~REISERFS_IXUNLINK_FL;
7043 if (inode->i_flags & S_SYNC)
7044 *sd_attrs |= REISERFS_SYNC_FL;
7046 @@ -2917,6 +2947,15 @@ void i_attrs_to_sd_attrs(struct inode *i
7047 *sd_attrs |= REISERFS_NOTAIL_FL;
7049 *sd_attrs &= ~REISERFS_NOTAIL_FL;
7051 + if (inode->i_vflags & V_BARRIER)
7052 + *sd_attrs |= REISERFS_BARRIER_FL;
7054 + *sd_attrs &= ~REISERFS_BARRIER_FL;
7055 + if (inode->i_vflags & V_COW)
7056 + *sd_attrs |= REISERFS_COW_FL;
7058 + *sd_attrs &= ~REISERFS_COW_FL;
7062 @@ -3161,7 +3200,8 @@ int reiserfs_setattr(struct dentry *dent
7065 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) ||
7066 - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) {
7067 + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) ||
7068 + (ia_valid & ATTR_TAG && attr->ia_tag != inode->i_tag)) {
7069 struct reiserfs_transaction_handle th;
7072 @@ -3192,6 +3232,9 @@ int reiserfs_setattr(struct dentry *dent
7073 inode->i_uid = attr->ia_uid;
7074 if (attr->ia_valid & ATTR_GID)
7075 inode->i_gid = attr->ia_gid;
7076 + if ((attr->ia_valid & ATTR_TAG) &&
7078 + inode->i_tag = attr->ia_tag;
7079 mark_inode_dirty(inode);
7080 error = journal_end(&th, inode->i_sb, jbegin_count);
7082 diff -NurpP --minimal linux-3.4.103/fs/reiserfs/ioctl.c linux-3.4.103-vs2.3.3.9/fs/reiserfs/ioctl.c
7083 --- linux-3.4.103/fs/reiserfs/ioctl.c 2012-05-21 16:07:27.000000000 +0000
7084 +++ linux-3.4.103-vs2.3.3.9/fs/reiserfs/ioctl.c 2012-05-21 16:15:05.000000000 +0000
7086 #include <linux/pagemap.h>
7087 #include <linux/compat.h>
7090 +int reiserfs_sync_flags(struct inode *inode, int flags, int vflags)
7092 + __u16 sd_attrs = 0;
7094 + inode->i_flags = flags;
7095 + inode->i_vflags = vflags;
7097 + i_attrs_to_sd_attrs(inode, &sd_attrs);
7098 + REISERFS_I(inode)->i_attrs = sd_attrs;
7099 + inode->i_ctime = CURRENT_TIME_SEC;
7100 + mark_inode_dirty(inode);
7105 * reiserfs_ioctl - handler for ioctl for inode
7106 * supported commands:
7108 long reiserfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
7110 struct inode *inode = filp->f_path.dentry->d_inode;
7111 - unsigned int flags;
7112 + unsigned int flags, oldflags;
7115 reiserfs_write_lock(inode->i_sb);
7116 @@ -47,6 +62,7 @@ long reiserfs_ioctl(struct file *filp, u
7118 flags = REISERFS_I(inode)->i_attrs;
7119 i_attrs_to_sd_attrs(inode, (__u16 *) & flags);
7120 + flags &= REISERFS_FL_USER_VISIBLE;
7121 err = put_user(flags, (int __user *)arg);
7123 case REISERFS_IOC_SETFLAGS:{
7124 @@ -67,6 +83,10 @@ long reiserfs_ioctl(struct file *filp, u
7128 + if (IS_BARRIER(inode)) {
7129 + vxwprintk_task(1, "messing with the barrier.");
7133 * Is it quota file? Do not allow user to mess with it
7135 @@ -91,6 +111,10 @@ long reiserfs_ioctl(struct file *filp, u
7140 + oldflags = REISERFS_I(inode)->i_attrs;
7141 + flags &= REISERFS_FL_USER_MODIFIABLE;
7142 + flags |= oldflags & ~REISERFS_FL_USER_MODIFIABLE;
7143 sd_attrs_to_i_attrs(flags, inode);
7144 REISERFS_I(inode)->i_attrs = flags;
7145 inode->i_ctime = CURRENT_TIME_SEC;
7146 diff -NurpP --minimal linux-3.4.103/fs/reiserfs/namei.c linux-3.4.103-vs2.3.3.9/fs/reiserfs/namei.c
7147 --- linux-3.4.103/fs/reiserfs/namei.c 2012-05-21 16:07:27.000000000 +0000
7148 +++ linux-3.4.103-vs2.3.3.9/fs/reiserfs/namei.c 2012-05-21 16:15:05.000000000 +0000
7152 #include <linux/quotaops.h>
7153 +#include <linux/vs_tag.h>
7155 #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); }
7156 #define DEC_DIR_INODE_NLINK(i) if (i->i_nlink != 1) drop_nlink(i);
7157 @@ -362,6 +363,7 @@ static struct dentry *reiserfs_lookup(st
7158 if (retval == IO_ERROR) {
7159 return ERR_PTR(-EIO);
7161 + dx_propagate_tag(nd, inode);
7163 return d_splice_alias(inode, dentry);
7165 diff -NurpP --minimal linux-3.4.103/fs/reiserfs/reiserfs.h linux-3.4.103-vs2.3.3.9/fs/reiserfs/reiserfs.h
7166 --- linux-3.4.103/fs/reiserfs/reiserfs.h 2012-05-21 16:07:27.000000000 +0000
7167 +++ linux-3.4.103-vs2.3.3.9/fs/reiserfs/reiserfs.h 2012-05-21 17:19:33.000000000 +0000
7168 @@ -544,6 +544,7 @@ enum reiserfs_mount_options {
7169 REISERFS_EXPOSE_PRIVROOT,
7170 REISERFS_BARRIER_NONE,
7171 REISERFS_BARRIER_FLUSH,
7174 /* Actions on error */
7175 REISERFS_ERROR_PANIC,
7176 @@ -1543,6 +1544,11 @@ struct stat_data_v1 {
7177 #define REISERFS_COMPR_FL FS_COMPR_FL
7178 #define REISERFS_NOTAIL_FL FS_NOTAIL_FL
7180 +/* unfortunately reiserfs sdattr is only 16 bit */
7181 +#define REISERFS_IXUNLINK_FL (FS_IXUNLINK_FL >> 16)
7182 +#define REISERFS_BARRIER_FL (FS_BARRIER_FL >> 16)
7183 +#define REISERFS_COW_FL (FS_COW_FL >> 16)
7185 /* persistent flags that file inherits from the parent directory */
7186 #define REISERFS_INHERIT_MASK ( REISERFS_IMMUTABLE_FL | \
7187 REISERFS_SYNC_FL | \
7188 @@ -1552,6 +1558,9 @@ struct stat_data_v1 {
7189 REISERFS_COMPR_FL | \
7190 REISERFS_NOTAIL_FL )
7192 +#define REISERFS_FL_USER_VISIBLE 0x80FF
7193 +#define REISERFS_FL_USER_MODIFIABLE 0x80FF
7195 /* Stat Data on disk (reiserfs version of UFS disk inode minus the
7198 @@ -2641,6 +2650,7 @@ static inline void reiserfs_update_sd(st
7199 void sd_attrs_to_i_attrs(__u16 sd_attrs, struct inode *inode);
7200 void i_attrs_to_sd_attrs(struct inode *inode, __u16 * sd_attrs);
7201 int reiserfs_setattr(struct dentry *dentry, struct iattr *attr);
7202 +int reiserfs_sync_flags(struct inode *inode, int, int);
7204 int __reiserfs_write_begin(struct page *page, unsigned from, unsigned len);
7206 diff -NurpP --minimal linux-3.4.103/fs/reiserfs/super.c linux-3.4.103-vs2.3.3.9/fs/reiserfs/super.c
7207 --- linux-3.4.103/fs/reiserfs/super.c 2014-08-30 13:37:15.000000000 +0000
7208 +++ linux-3.4.103-vs2.3.3.9/fs/reiserfs/super.c 2012-12-08 00:53:53.000000000 +0000
7209 @@ -982,6 +982,14 @@ static int reiserfs_parse_options(struct
7210 {"user_xattr",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
7211 {"nouser_xattr",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
7213 +#ifndef CONFIG_TAGGING_NONE
7214 + {"tagxid",.setmask = 1 << REISERFS_TAGGED},
7215 + {"tag",.setmask = 1 << REISERFS_TAGGED},
7216 + {"notag",.clrmask = 1 << REISERFS_TAGGED},
7218 +#ifdef CONFIG_PROPAGATE
7219 + {"tag",.arg_required = 'T',.values = NULL},
7221 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
7222 {"acl",.setmask = 1 << REISERFS_POSIXACL},
7223 {"noacl",.clrmask = 1 << REISERFS_POSIXACL},
7224 @@ -1300,6 +1308,14 @@ static int reiserfs_remount(struct super
7225 handle_quota_files(s, qf_names, &qfmt);
7228 + if ((mount_options & (1 << REISERFS_TAGGED)) &&
7229 + !(s->s_flags & MS_TAGGED)) {
7230 + reiserfs_warning(s, "super-vs01",
7231 + "reiserfs: tagging not permitted on remount.");
7238 /* Add options that are safe here */
7239 @@ -1792,6 +1808,10 @@ static int reiserfs_fill_super(struct su
7240 goto error_unlocked;
7243 + /* map mount option tagxid */
7244 + if (REISERFS_SB(s)->s_mount_opt & (1 << REISERFS_TAGGED))
7245 + s->s_flags |= MS_TAGGED;
7247 rs = SB_DISK_SUPER_BLOCK(s);
7248 /* Let's do basic sanity check to verify that underlying device is not
7249 smaller than the filesystem. If the check fails then abort and scream,
7250 diff -NurpP --minimal linux-3.4.103/fs/reiserfs/xattr.c linux-3.4.103-vs2.3.3.9/fs/reiserfs/xattr.c
7251 --- linux-3.4.103/fs/reiserfs/xattr.c 2014-08-30 13:37:15.000000000 +0000
7252 +++ linux-3.4.103-vs2.3.3.9/fs/reiserfs/xattr.c 2013-07-14 13:38:35.000000000 +0000
7254 #include <linux/errno.h>
7255 #include <linux/gfp.h>
7256 #include <linux/fs.h>
7257 +#include <linux/mount.h>
7258 #include <linux/file.h>
7259 #include <linux/pagemap.h>
7260 #include <linux/xattr.h>
7261 diff -NurpP --minimal linux-3.4.103/fs/stat.c linux-3.4.103-vs2.3.3.9/fs/stat.c
7262 --- linux-3.4.103/fs/stat.c 2014-08-30 13:37:15.000000000 +0000
7263 +++ linux-3.4.103-vs2.3.3.9/fs/stat.c 2014-06-12 11:34:37.000000000 +0000
7264 @@ -26,6 +26,7 @@ void generic_fillattr(struct inode *inod
7265 stat->nlink = inode->i_nlink;
7266 stat->uid = inode->i_uid;
7267 stat->gid = inode->i_gid;
7268 + stat->tag = inode->i_tag;
7269 stat->rdev = inode->i_rdev;
7270 stat->size = i_size_read(inode);
7271 stat->atime = inode->i_atime;
7272 diff -NurpP --minimal linux-3.4.103/fs/statfs.c linux-3.4.103-vs2.3.3.9/fs/statfs.c
7273 --- linux-3.4.103/fs/statfs.c 2014-08-30 13:37:15.000000000 +0000
7274 +++ linux-3.4.103-vs2.3.3.9/fs/statfs.c 2013-10-26 18:10:23.000000000 +0000
7276 #include <linux/statfs.h>
7277 #include <linux/security.h>
7278 #include <linux/uaccess.h>
7279 +#include <linux/vs_base.h>
7280 +#include <linux/vs_dlimit.h>
7281 #include "internal.h"
7283 static int flags_by_mnt(int mnt_flags)
7284 @@ -60,6 +62,8 @@ static int statfs_by_dentry(struct dentr
7285 retval = dentry->d_sb->s_op->statfs(dentry, buf);
7286 if (retval == 0 && buf->f_frsize == 0)
7287 buf->f_frsize = buf->f_bsize;
7288 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
7289 + vx_vsi_statfs(dentry->d_sb, buf);
7293 diff -NurpP --minimal linux-3.4.103/fs/super.c linux-3.4.103-vs2.3.3.9/fs/super.c
7294 --- linux-3.4.103/fs/super.c 2014-08-30 13:37:15.000000000 +0000
7295 +++ linux-3.4.103-vs2.3.3.9/fs/super.c 2013-08-13 17:07:36.000000000 +0000
7297 #include <linux/rculist_bl.h>
7298 #include <linux/cleancache.h>
7299 #include <linux/fsnotify.h>
7300 +#include <linux/magic.h>
7301 +#include <linux/vs_context.h>
7302 #include "internal.h"
7305 @@ -1133,6 +1135,13 @@ mount_fs(struct file_system_type *type,
7306 WARN_ON(sb->s_bdi == &default_backing_dev_info);
7307 sb->s_flags |= MS_BORN;
7310 + if (!vx_capable(CAP_SYS_ADMIN, VXC_BINARY_MOUNT) &&
7312 + (sb->s_magic != PROC_SUPER_MAGIC) &&
7313 + (sb->s_magic != DEVPTS_SUPER_MAGIC))
7316 error = security_sb_kern_mount(sb, flags, secdata);
7319 diff -NurpP --minimal linux-3.4.103/fs/sysfs/mount.c linux-3.4.103-vs2.3.3.9/fs/sysfs/mount.c
7320 --- linux-3.4.103/fs/sysfs/mount.c 2012-05-21 16:07:27.000000000 +0000
7321 +++ linux-3.4.103-vs2.3.3.9/fs/sysfs/mount.c 2012-05-21 16:15:05.000000000 +0000
7322 @@ -47,7 +47,7 @@ static int sysfs_fill_super(struct super
7324 sb->s_blocksize = PAGE_CACHE_SIZE;
7325 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
7326 - sb->s_magic = SYSFS_MAGIC;
7327 + sb->s_magic = SYSFS_SUPER_MAGIC;
7328 sb->s_op = &sysfs_ops;
7329 sb->s_time_gran = 1;
7331 diff -NurpP --minimal linux-3.4.103/fs/utimes.c linux-3.4.103-vs2.3.3.9/fs/utimes.c
7332 --- linux-3.4.103/fs/utimes.c 2011-05-22 14:17:54.000000000 +0000
7333 +++ linux-3.4.103-vs2.3.3.9/fs/utimes.c 2012-05-21 16:15:05.000000000 +0000
7335 #include <linux/stat.h>
7336 #include <linux/utime.h>
7337 #include <linux/syscalls.h>
7338 +#include <linux/mount.h>
7339 +#include <linux/vs_cowbl.h>
7340 #include <asm/uaccess.h>
7341 #include <asm/unistd.h>
7343 @@ -52,12 +54,18 @@ static int utimes_common(struct path *pa
7346 struct iattr newattrs;
7347 - struct inode *inode = path->dentry->d_inode;
7348 + struct inode *inode;
7350 error = mnt_want_write(path->mnt);
7354 + error = cow_check_and_break(path);
7356 + goto mnt_drop_write_and_out;
7358 + inode = path->dentry->d_inode;
7360 if (times && times[0].tv_nsec == UTIME_NOW &&
7361 times[1].tv_nsec == UTIME_NOW)
7363 diff -NurpP --minimal linux-3.4.103/fs/xattr.c linux-3.4.103-vs2.3.3.9/fs/xattr.c
7364 --- linux-3.4.103/fs/xattr.c 2012-05-21 16:07:27.000000000 +0000
7365 +++ linux-3.4.103-vs2.3.3.9/fs/xattr.c 2012-05-21 16:15:05.000000000 +0000
7367 #include <linux/fsnotify.h>
7368 #include <linux/audit.h>
7369 #include <linux/vmalloc.h>
7370 +#include <linux/mount.h>
7372 #include <asm/uaccess.h>
7374 @@ -51,7 +52,7 @@ xattr_permission(struct inode *inode, co
7375 * The trusted.* namespace can only be accessed by privileged users.
7377 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) {
7378 - if (!capable(CAP_SYS_ADMIN))
7379 + if (!vx_capable(CAP_SYS_ADMIN, VXC_FS_TRUSTED))
7380 return (mask & MAY_WRITE) ? -EPERM : -ENODATA;
7383 diff -NurpP --minimal linux-3.4.103/fs/xfs/xfs_dinode.h linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_dinode.h
7384 --- linux-3.4.103/fs/xfs/xfs_dinode.h 2011-10-24 16:45:31.000000000 +0000
7385 +++ linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_dinode.h 2012-05-21 16:15:05.000000000 +0000
7386 @@ -51,7 +51,9 @@ typedef struct xfs_dinode {
7387 __be32 di_nlink; /* number of links to file */
7388 __be16 di_projid_lo; /* lower part of owner's project id */
7389 __be16 di_projid_hi; /* higher part owner's project id */
7390 - __u8 di_pad[6]; /* unused, zeroed space */
7391 + __u8 di_pad[2]; /* unused, zeroed space */
7392 + __be16 di_tag; /* context tagging */
7393 + __be16 di_vflags; /* vserver specific flags */
7394 __be16 di_flushiter; /* incremented on flush */
7395 xfs_timestamp_t di_atime; /* time last accessed */
7396 xfs_timestamp_t di_mtime; /* time last modified */
7397 @@ -184,6 +186,8 @@ static inline void xfs_dinode_put_rdev(s
7398 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
7399 #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */
7400 #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */
7401 +#define XFS_DIFLAG_IXUNLINK_BIT 15 /* Immutable inver on unlink */
7403 #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT)
7404 #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT)
7405 #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT)
7406 @@ -199,6 +203,7 @@ static inline void xfs_dinode_put_rdev(s
7407 #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
7408 #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT)
7409 #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT)
7410 +#define XFS_DIFLAG_IXUNLINK (1 << XFS_DIFLAG_IXUNLINK_BIT)
7412 #ifdef CONFIG_XFS_RT
7413 #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME)
7414 @@ -211,6 +216,10 @@ static inline void xfs_dinode_put_rdev(s
7415 XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
7416 XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
7417 XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
7418 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM)
7419 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM | \
7420 + XFS_DIFLAG_IXUNLINK)
7422 +#define XFS_DIVFLAG_BARRIER 0x01
7423 +#define XFS_DIVFLAG_COW 0x02
7425 #endif /* __XFS_DINODE_H__ */
7426 diff -NurpP --minimal linux-3.4.103/fs/xfs/xfs_fs.h linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_fs.h
7427 --- linux-3.4.103/fs/xfs/xfs_fs.h 2011-10-24 16:45:31.000000000 +0000
7428 +++ linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_fs.h 2012-05-21 16:15:05.000000000 +0000
7429 @@ -67,6 +67,9 @@ struct fsxattr {
7430 #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */
7431 #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */
7432 #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */
7433 +#define XFS_XFLAG_IXUNLINK 0x00008000 /* immutable invert on unlink */
7434 +#define XFS_XFLAG_BARRIER 0x10000000 /* chroot() barrier */
7435 +#define XFS_XFLAG_COW 0x20000000 /* copy on write mark */
7436 #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */
7439 @@ -302,7 +305,8 @@ typedef struct xfs_bstat {
7440 #define bs_projid bs_projid_lo /* (previously just bs_projid) */
7441 __u16 bs_forkoff; /* inode fork offset in bytes */
7442 __u16 bs_projid_hi; /* higher part of project id */
7443 - unsigned char bs_pad[10]; /* pad space, unused */
7444 + unsigned char bs_pad[8]; /* pad space, unused */
7445 + __u16 bs_tag; /* context tagging */
7446 __u32 bs_dmevmask; /* DMIG event mask */
7447 __u16 bs_dmstate; /* DMIG state info */
7448 __u16 bs_aextents; /* attribute number of extents */
7449 diff -NurpP --minimal linux-3.4.103/fs/xfs/xfs_ialloc.c linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_ialloc.c
7450 --- linux-3.4.103/fs/xfs/xfs_ialloc.c 2012-03-19 18:47:27.000000000 +0000
7451 +++ linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_ialloc.c 2012-05-21 16:15:05.000000000 +0000
7453 #include "xfs_error.h"
7454 #include "xfs_bmap.h"
7458 * Allocation group level functions.
7460 diff -NurpP --minimal linux-3.4.103/fs/xfs/xfs_inode.c linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_inode.c
7461 --- linux-3.4.103/fs/xfs/xfs_inode.c 2012-05-21 16:07:27.000000000 +0000
7462 +++ linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_inode.c 2012-05-21 16:15:05.000000000 +0000
7463 @@ -236,6 +236,7 @@ xfs_inotobp(
7467 +#include <linux/vs_tag.h>
7470 * This routine is called to map an inode to the buffer containing
7471 @@ -631,15 +632,25 @@ xfs_iformat_btree(
7473 xfs_dinode_from_disk(
7475 - xfs_dinode_t *from)
7476 + xfs_dinode_t *from,
7479 + uint32_t uid, gid, tag;
7481 to->di_magic = be16_to_cpu(from->di_magic);
7482 to->di_mode = be16_to_cpu(from->di_mode);
7483 to->di_version = from ->di_version;
7484 to->di_format = from->di_format;
7485 to->di_onlink = be16_to_cpu(from->di_onlink);
7486 - to->di_uid = be32_to_cpu(from->di_uid);
7487 - to->di_gid = be32_to_cpu(from->di_gid);
7489 + uid = be32_to_cpu(from->di_uid);
7490 + gid = be32_to_cpu(from->di_gid);
7491 + tag = be16_to_cpu(from->di_tag);
7493 + to->di_uid = INOTAG_UID(tagged, uid, gid);
7494 + to->di_gid = INOTAG_GID(tagged, uid, gid);
7495 + to->di_tag = INOTAG_TAG(tagged, uid, gid, tag);
7497 to->di_nlink = be32_to_cpu(from->di_nlink);
7498 to->di_projid_lo = be16_to_cpu(from->di_projid_lo);
7499 to->di_projid_hi = be16_to_cpu(from->di_projid_hi);
7500 @@ -661,21 +672,26 @@ xfs_dinode_from_disk(
7501 to->di_dmevmask = be32_to_cpu(from->di_dmevmask);
7502 to->di_dmstate = be16_to_cpu(from->di_dmstate);
7503 to->di_flags = be16_to_cpu(from->di_flags);
7504 + to->di_vflags = be16_to_cpu(from->di_vflags);
7505 to->di_gen = be32_to_cpu(from->di_gen);
7511 - xfs_icdinode_t *from)
7512 + xfs_icdinode_t *from,
7515 to->di_magic = cpu_to_be16(from->di_magic);
7516 to->di_mode = cpu_to_be16(from->di_mode);
7517 to->di_version = from ->di_version;
7518 to->di_format = from->di_format;
7519 to->di_onlink = cpu_to_be16(from->di_onlink);
7520 - to->di_uid = cpu_to_be32(from->di_uid);
7521 - to->di_gid = cpu_to_be32(from->di_gid);
7523 + to->di_uid = cpu_to_be32(TAGINO_UID(tagged, from->di_uid, from->di_tag));
7524 + to->di_gid = cpu_to_be32(TAGINO_GID(tagged, from->di_gid, from->di_tag));
7525 + to->di_tag = cpu_to_be16(TAGINO_TAG(tagged, from->di_tag));
7527 to->di_nlink = cpu_to_be32(from->di_nlink);
7528 to->di_projid_lo = cpu_to_be16(from->di_projid_lo);
7529 to->di_projid_hi = cpu_to_be16(from->di_projid_hi);
7530 @@ -697,12 +713,14 @@ xfs_dinode_to_disk(
7531 to->di_dmevmask = cpu_to_be32(from->di_dmevmask);
7532 to->di_dmstate = cpu_to_be16(from->di_dmstate);
7533 to->di_flags = cpu_to_be16(from->di_flags);
7534 + to->di_vflags = cpu_to_be16(from->di_vflags);
7535 to->di_gen = cpu_to_be32(from->di_gen);
7540 - __uint16_t di_flags)
7541 + __uint16_t di_flags,
7542 + __uint16_t di_vflags)
7546 @@ -713,6 +731,8 @@ _xfs_dic2xflags(
7547 flags |= XFS_XFLAG_PREALLOC;
7548 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7549 flags |= XFS_XFLAG_IMMUTABLE;
7550 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7551 + flags |= XFS_XFLAG_IXUNLINK;
7552 if (di_flags & XFS_DIFLAG_APPEND)
7553 flags |= XFS_XFLAG_APPEND;
7554 if (di_flags & XFS_DIFLAG_SYNC)
7555 @@ -737,6 +757,10 @@ _xfs_dic2xflags(
7556 flags |= XFS_XFLAG_FILESTREAM;
7559 + if (di_vflags & XFS_DIVFLAG_BARRIER)
7560 + flags |= FS_BARRIER_FL;
7561 + if (di_vflags & XFS_DIVFLAG_COW)
7562 + flags |= FS_COW_FL;
7566 @@ -746,7 +770,7 @@ xfs_ip2xflags(
7568 xfs_icdinode_t *dic = &ip->i_d;
7570 - return _xfs_dic2xflags(dic->di_flags) |
7571 + return _xfs_dic2xflags(dic->di_flags, dic->di_vflags) |
7572 (XFS_IFORK_Q(ip) ? XFS_XFLAG_HASATTR : 0);
7575 @@ -754,7 +778,8 @@ uint
7579 - return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
7580 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags),
7581 + be16_to_cpu(dip->di_vflags)) |
7582 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
7585 @@ -787,7 +812,6 @@ xfs_iread(
7588 dip = (xfs_dinode_t *)xfs_buf_offset(bp, ip->i_imap.im_boffset);
7591 * If we got something that isn't an inode it means someone
7592 * (nfs or dmi) has a stale handle.
7593 @@ -810,7 +834,8 @@ xfs_iread(
7594 * Otherwise, just get the truly permanent information.
7597 - xfs_dinode_from_disk(&ip->i_d, dip);
7598 + xfs_dinode_from_disk(&ip->i_d, dip,
7599 + mp->m_flags & XFS_MOUNT_TAGGED);
7600 error = xfs_iformat(ip, dip);
7603 @@ -998,6 +1023,7 @@ xfs_ialloc(
7604 ASSERT(ip->i_d.di_nlink == nlink);
7605 ip->i_d.di_uid = current_fsuid();
7606 ip->i_d.di_gid = current_fsgid();
7607 + ip->i_d.di_tag = current_fstag(&ip->i_vnode);
7608 xfs_set_projid(ip, prid);
7609 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
7611 @@ -1057,6 +1083,7 @@ xfs_ialloc(
7612 ip->i_d.di_dmevmask = 0;
7613 ip->i_d.di_dmstate = 0;
7614 ip->i_d.di_flags = 0;
7615 + ip->i_d.di_vflags = 0;
7616 flags = XFS_ILOG_CORE;
7617 switch (mode & S_IFMT) {
7619 @@ -1725,6 +1752,7 @@ xfs_ifree(
7621 ip->i_d.di_mode = 0; /* mark incore inode as free */
7622 ip->i_d.di_flags = 0;
7623 + ip->i_d.di_vflags = 0;
7624 ip->i_d.di_dmevmask = 0;
7625 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */
7626 ip->i_d.di_format = XFS_DINODE_FMT_EXTENTS;
7627 @@ -2598,7 +2626,8 @@ xfs_iflush_int(
7628 * because if the inode is dirty at all the core must
7631 - xfs_dinode_to_disk(dip, &ip->i_d);
7632 + xfs_dinode_to_disk(dip, &ip->i_d,
7633 + mp->m_flags & XFS_MOUNT_TAGGED);
7635 /* Wrap, we never let the log put out DI_MAX_FLUSH */
7636 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
7637 diff -NurpP --minimal linux-3.4.103/fs/xfs/xfs_inode.h linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_inode.h
7638 --- linux-3.4.103/fs/xfs/xfs_inode.h 2012-05-21 16:07:27.000000000 +0000
7639 +++ linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_inode.h 2012-05-21 16:15:05.000000000 +0000
7640 @@ -134,7 +134,9 @@ typedef struct xfs_icdinode {
7641 __uint32_t di_nlink; /* number of links to file */
7642 __uint16_t di_projid_lo; /* lower part of owner's project id */
7643 __uint16_t di_projid_hi; /* higher part of owner's project id */
7644 - __uint8_t di_pad[6]; /* unused, zeroed space */
7645 + __uint8_t di_pad[2]; /* unused, zeroed space */
7646 + __uint16_t di_tag; /* context tagging */
7647 + __uint16_t di_vflags; /* vserver specific flags */
7648 __uint16_t di_flushiter; /* incremented on flush */
7649 xfs_ictimestamp_t di_atime; /* time last accessed */
7650 xfs_ictimestamp_t di_mtime; /* time last modified */
7651 @@ -565,7 +567,7 @@ int xfs_itobp(struct xfs_mount *, struc
7652 int xfs_iread(struct xfs_mount *, struct xfs_trans *,
7653 struct xfs_inode *, uint);
7654 void xfs_dinode_to_disk(struct xfs_dinode *,
7655 - struct xfs_icdinode *);
7656 + struct xfs_icdinode *, int);
7657 void xfs_idestroy_fork(struct xfs_inode *, int);
7658 void xfs_idata_realloc(struct xfs_inode *, int, int);
7659 void xfs_iroot_realloc(struct xfs_inode *, int, int);
7660 diff -NurpP --minimal linux-3.4.103/fs/xfs/xfs_ioctl.c linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_ioctl.c
7661 --- linux-3.4.103/fs/xfs/xfs_ioctl.c 2014-08-30 13:37:15.000000000 +0000
7662 +++ linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_ioctl.c 2014-03-12 09:55:28.000000000 +0000
7664 #include "xfs_bmap_btree.h"
7665 #include "xfs_dinode.h"
7666 #include "xfs_inode.h"
7667 -#include "xfs_ioctl.h"
7668 +// #include "xfs_ioctl.h"
7669 #include "xfs_rtalloc.h"
7670 #include "xfs_itable.h"
7671 #include "xfs_error.h"
7672 @@ -751,6 +751,10 @@ xfs_merge_ioc_xflags(
7673 xflags |= XFS_XFLAG_IMMUTABLE;
7675 xflags &= ~XFS_XFLAG_IMMUTABLE;
7676 + if (flags & FS_IXUNLINK_FL)
7677 + xflags |= XFS_XFLAG_IXUNLINK;
7679 + xflags &= ~XFS_XFLAG_IXUNLINK;
7680 if (flags & FS_APPEND_FL)
7681 xflags |= XFS_XFLAG_APPEND;
7683 @@ -779,6 +783,8 @@ xfs_di2lxflags(
7685 if (di_flags & XFS_DIFLAG_IMMUTABLE)
7686 flags |= FS_IMMUTABLE_FL;
7687 + if (di_flags & XFS_DIFLAG_IXUNLINK)
7688 + flags |= FS_IXUNLINK_FL;
7689 if (di_flags & XFS_DIFLAG_APPEND)
7690 flags |= FS_APPEND_FL;
7691 if (di_flags & XFS_DIFLAG_SYNC)
7692 @@ -839,6 +845,8 @@ xfs_set_diflags(
7693 di_flags = (ip->i_d.di_flags & XFS_DIFLAG_PREALLOC);
7694 if (xflags & XFS_XFLAG_IMMUTABLE)
7695 di_flags |= XFS_DIFLAG_IMMUTABLE;
7696 + if (xflags & XFS_XFLAG_IXUNLINK)
7697 + di_flags |= XFS_DIFLAG_IXUNLINK;
7698 if (xflags & XFS_XFLAG_APPEND)
7699 di_flags |= XFS_DIFLAG_APPEND;
7700 if (xflags & XFS_XFLAG_SYNC)
7701 @@ -881,6 +889,10 @@ xfs_diflags_to_linux(
7702 inode->i_flags |= S_IMMUTABLE;
7704 inode->i_flags &= ~S_IMMUTABLE;
7705 + if (xflags & XFS_XFLAG_IXUNLINK)
7706 + inode->i_flags |= S_IXUNLINK;
7708 + inode->i_flags &= ~S_IXUNLINK;
7709 if (xflags & XFS_XFLAG_APPEND)
7710 inode->i_flags |= S_APPEND;
7712 @@ -1373,10 +1385,18 @@ xfs_file_ioctl(
7713 case XFS_IOC_FSGETXATTRA:
7714 return xfs_ioc_fsgetxattr(ip, 1, arg);
7715 case XFS_IOC_FSSETXATTR:
7716 + if (IS_BARRIER(inode)) {
7717 + vxwprintk_task(1, "messing with the barrier.");
7718 + return -XFS_ERROR(EACCES);
7720 return xfs_ioc_fssetxattr(ip, filp, arg);
7721 case XFS_IOC_GETXFLAGS:
7722 return xfs_ioc_getxflags(ip, arg);
7723 case XFS_IOC_SETXFLAGS:
7724 + if (IS_BARRIER(inode)) {
7725 + vxwprintk_task(1, "messing with the barrier.");
7726 + return -XFS_ERROR(EACCES);
7728 return xfs_ioc_setxflags(ip, filp, arg);
7730 case XFS_IOC_FSSETDM: {
7731 diff -NurpP --minimal linux-3.4.103/fs/xfs/xfs_ioctl.h linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_ioctl.h
7732 --- linux-3.4.103/fs/xfs/xfs_ioctl.h 2011-10-24 16:45:31.000000000 +0000
7733 +++ linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_ioctl.h 2012-05-21 16:15:05.000000000 +0000
7734 @@ -70,6 +70,12 @@ xfs_handle_to_dentry(
7735 void __user *uhandle,
7740 + struct inode *inode,
7747 diff -NurpP --minimal linux-3.4.103/fs/xfs/xfs_iops.c linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_iops.c
7748 --- linux-3.4.103/fs/xfs/xfs_iops.c 2014-08-30 13:37:15.000000000 +0000
7749 +++ linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_iops.c 2013-07-14 13:38:35.000000000 +0000
7751 #include "xfs_bmap_btree.h"
7752 #include "xfs_dinode.h"
7753 #include "xfs_inode.h"
7754 +#include "xfs_ioctl.h"
7755 #include "xfs_bmap.h"
7756 #include "xfs_rtalloc.h"
7757 #include "xfs_error.h"
7759 #include <linux/security.h>
7760 #include <linux/fiemap.h>
7761 #include <linux/slab.h>
7762 +#include <linux/vs_tag.h>
7766 @@ -424,6 +426,7 @@ xfs_vn_getattr(
7767 stat->nlink = ip->i_d.di_nlink;
7768 stat->uid = ip->i_d.di_uid;
7769 stat->gid = ip->i_d.di_gid;
7770 + stat->tag = ip->i_d.di_tag;
7771 stat->ino = ip->i_ino;
7772 stat->atime = inode->i_atime;
7773 stat->mtime = inode->i_mtime;
7774 @@ -1013,6 +1016,7 @@ static const struct inode_operations xfs
7775 .removexattr = generic_removexattr,
7776 .listxattr = xfs_vn_listxattr,
7777 .fiemap = xfs_vn_fiemap,
7778 + .sync_flags = xfs_sync_flags,
7781 static const struct inode_operations xfs_dir_inode_operations = {
7782 @@ -1038,6 +1042,7 @@ static const struct inode_operations xfs
7783 .getxattr = generic_getxattr,
7784 .removexattr = generic_removexattr,
7785 .listxattr = xfs_vn_listxattr,
7786 + .sync_flags = xfs_sync_flags,
7789 static const struct inode_operations xfs_dir_ci_inode_operations = {
7790 @@ -1087,6 +1092,10 @@ xfs_diflags_to_iflags(
7791 inode->i_flags |= S_IMMUTABLE;
7793 inode->i_flags &= ~S_IMMUTABLE;
7794 + if (ip->i_d.di_flags & XFS_DIFLAG_IXUNLINK)
7795 + inode->i_flags |= S_IXUNLINK;
7797 + inode->i_flags &= ~S_IXUNLINK;
7798 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
7799 inode->i_flags |= S_APPEND;
7801 @@ -1099,6 +1108,15 @@ xfs_diflags_to_iflags(
7802 inode->i_flags |= S_NOATIME;
7804 inode->i_flags &= ~S_NOATIME;
7806 + if (ip->i_d.di_vflags & XFS_DIVFLAG_BARRIER)
7807 + inode->i_vflags |= V_BARRIER;
7809 + inode->i_vflags &= ~V_BARRIER;
7810 + if (ip->i_d.di_vflags & XFS_DIVFLAG_COW)
7811 + inode->i_vflags |= V_COW;
7813 + inode->i_vflags &= ~V_COW;
7817 @@ -1130,6 +1148,7 @@ xfs_setup_inode(
7818 set_nlink(inode, ip->i_d.di_nlink);
7819 inode->i_uid = ip->i_d.di_uid;
7820 inode->i_gid = ip->i_d.di_gid;
7821 + inode->i_tag = ip->i_d.di_tag;
7823 switch (inode->i_mode & S_IFMT) {
7825 diff -NurpP --minimal linux-3.4.103/fs/xfs/xfs_itable.c linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_itable.c
7826 --- linux-3.4.103/fs/xfs/xfs_itable.c 2012-05-21 16:07:27.000000000 +0000
7827 +++ linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_itable.c 2012-05-21 16:15:05.000000000 +0000
7828 @@ -97,6 +97,7 @@ xfs_bulkstat_one_int(
7829 buf->bs_mode = dic->di_mode;
7830 buf->bs_uid = dic->di_uid;
7831 buf->bs_gid = dic->di_gid;
7832 + buf->bs_tag = dic->di_tag;
7833 buf->bs_size = dic->di_size;
7834 buf->bs_atime.tv_sec = dic->di_atime.t_sec;
7835 buf->bs_atime.tv_nsec = dic->di_atime.t_nsec;
7836 diff -NurpP --minimal linux-3.4.103/fs/xfs/xfs_linux.h linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_linux.h
7837 --- linux-3.4.103/fs/xfs/xfs_linux.h 2011-10-24 16:45:31.000000000 +0000
7838 +++ linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_linux.h 2012-05-21 16:15:05.000000000 +0000
7841 #define current_cpu() (raw_smp_processor_id())
7842 #define current_pid() (current->pid)
7843 +#define current_fstag(vp) (dx_current_fstag((vp)->i_sb))
7844 #define current_test_flags(f) (current->flags & (f))
7845 #define current_set_flags_nested(sp, f) \
7846 (*(sp) = current->flags, current->flags |= (f))
7847 diff -NurpP --minimal linux-3.4.103/fs/xfs/xfs_log_recover.c linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_log_recover.c
7848 --- linux-3.4.103/fs/xfs/xfs_log_recover.c 2014-08-30 13:37:15.000000000 +0000
7849 +++ linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_log_recover.c 2012-11-18 23:52:29.000000000 +0000
7850 @@ -2344,7 +2344,8 @@ xlog_recover_inode_pass2(
7853 /* The core is in in-core format */
7854 - xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr);
7855 + xfs_dinode_to_disk(dip, item->ri_buf[1].i_addr,
7856 + mp->m_flags & XFS_MOUNT_TAGGED);
7858 /* the rest is in on-disk format */
7859 if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
7860 diff -NurpP --minimal linux-3.4.103/fs/xfs/xfs_mount.h linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_mount.h
7861 --- linux-3.4.103/fs/xfs/xfs_mount.h 2012-05-21 16:07:28.000000000 +0000
7862 +++ linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_mount.h 2012-05-21 16:15:05.000000000 +0000
7863 @@ -251,6 +251,7 @@ typedef struct xfs_mount {
7865 #define XFS_MOUNT_NOATTR2 (1ULL << 25) /* disable use of attr2 format */
7867 +#define XFS_MOUNT_TAGGED (1ULL << 31) /* context tagging */
7870 * Default minimum read and write sizes.
7871 diff -NurpP --minimal linux-3.4.103/fs/xfs/xfs_super.c linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_super.c
7872 --- linux-3.4.103/fs/xfs/xfs_super.c 2012-05-21 16:07:28.000000000 +0000
7873 +++ linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_super.c 2012-05-21 16:15:05.000000000 +0000
7874 @@ -113,6 +113,9 @@ mempool_t *xfs_ioend_pool;
7875 #define MNTOPT_NODELAYLOG "nodelaylog" /* Delayed logging disabled */
7876 #define MNTOPT_DISCARD "discard" /* Discard unused blocks */
7877 #define MNTOPT_NODISCARD "nodiscard" /* Do not discard unused blocks */
7878 +#define MNTOPT_TAGXID "tagxid" /* context tagging for inodes */
7879 +#define MNTOPT_TAGGED "tag" /* context tagging for inodes */
7880 +#define MNTOPT_NOTAGTAG "notag" /* do not use context tagging */
7883 * Table driven mount option parser.
7884 @@ -121,10 +124,14 @@ mempool_t *xfs_ioend_pool;
7885 * in the future, too.
7888 + Opt_tag, Opt_notag,
7889 Opt_barrier, Opt_nobarrier, Opt_err
7892 static const match_table_t tokens = {
7893 + {Opt_tag, "tagxid"},
7895 + {Opt_notag, "notag"},
7896 {Opt_barrier, "barrier"},
7897 {Opt_nobarrier, "nobarrier"},
7899 @@ -372,6 +379,19 @@ xfs_parseargs(
7900 } else if (!strcmp(this_char, "irixsgid")) {
7902 "irixsgid is now a sysctl(2) variable, option is deprecated.");
7903 +#ifndef CONFIG_TAGGING_NONE
7904 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7905 + mp->m_flags |= XFS_MOUNT_TAGGED;
7906 + } else if (!strcmp(this_char, MNTOPT_NOTAGTAG)) {
7907 + mp->m_flags &= ~XFS_MOUNT_TAGGED;
7908 + } else if (!strcmp(this_char, MNTOPT_TAGXID)) {
7909 + mp->m_flags |= XFS_MOUNT_TAGGED;
7911 +#ifdef CONFIG_PROPAGATE
7912 + } else if (!strcmp(this_char, MNTOPT_TAGGED)) {
7914 + mp->m_flags |= XFS_MOUNT_TAGGED;
7917 xfs_warn(mp, "unknown mount option [%s].", this_char);
7919 @@ -1127,6 +1147,16 @@ xfs_fs_remount(
7921 mp->m_flags &= ~XFS_MOUNT_BARRIER;
7924 + if (!(sb->s_flags & MS_TAGGED)) {
7926 + "XFS: %s: tagging not permitted on remount.\n",
7935 * Logically we would return an error here to prevent
7936 @@ -1346,6 +1376,9 @@ xfs_fs_fill_super(
7940 + if (mp->m_flags & XFS_MOUNT_TAGGED)
7941 + sb->s_flags |= MS_TAGGED;
7944 * we must configure the block size in the superblock before we run the
7945 * full mount process as the mount process can lookup and cache inodes.
7946 diff -NurpP --minimal linux-3.4.103/fs/xfs/xfs_vnodeops.c linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_vnodeops.c
7947 --- linux-3.4.103/fs/xfs/xfs_vnodeops.c 2012-05-21 16:07:28.000000000 +0000
7948 +++ linux-3.4.103-vs2.3.3.9/fs/xfs/xfs_vnodeops.c 2012-05-21 16:15:05.000000000 +0000
7949 @@ -106,6 +106,77 @@ xfs_readlink_bmap(
7955 +xfs_get_inode_flags(
7958 + struct inode *inode = VFS_I(ip);
7959 + unsigned int flags = inode->i_flags;
7960 + unsigned int vflags = inode->i_vflags;
7962 + if (flags & S_IMMUTABLE)
7963 + ip->i_d.di_flags |= XFS_DIFLAG_IMMUTABLE;
7965 + ip->i_d.di_flags &= ~XFS_DIFLAG_IMMUTABLE;
7966 + if (flags & S_IXUNLINK)
7967 + ip->i_d.di_flags |= XFS_DIFLAG_IXUNLINK;
7969 + ip->i_d.di_flags &= ~XFS_DIFLAG_IXUNLINK;
7971 + if (vflags & V_BARRIER)
7972 + ip->i_d.di_vflags |= XFS_DIVFLAG_BARRIER;
7974 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_BARRIER;
7975 + if (vflags & V_COW)
7976 + ip->i_d.di_vflags |= XFS_DIVFLAG_COW;
7978 + ip->i_d.di_vflags &= ~XFS_DIVFLAG_COW;
7983 + struct inode *inode,
7987 + struct xfs_inode *ip = XFS_I(inode);
7988 + struct xfs_mount *mp = ip->i_mount;
7989 + struct xfs_trans *tp;
7990 + unsigned int lock_flags = 0;
7993 + tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
7994 + code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0);
7998 + xfs_ilock(ip, XFS_ILOCK_EXCL);
7999 + xfs_trans_ijoin(tp, ip, 0);
8001 + inode->i_flags = flags;
8002 + inode->i_vflags = vflags;
8003 + xfs_get_inode_flags(ip);
8005 + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
8006 + xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
8008 + XFS_STATS_INC(xs_ig_attrchg);
8010 + if (mp->m_flags & XFS_MOUNT_WSYNC)
8011 + xfs_trans_set_sync(tp);
8012 + code = xfs_trans_commit(tp, 0);
8013 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
8017 + xfs_trans_cancel(tp, 0);
8019 + xfs_iunlock(ip, XFS_ILOCK_EXCL);
8027 diff -NurpP --minimal linux-3.4.103/include/linux/Kbuild linux-3.4.103-vs2.3.3.9/include/linux/Kbuild
8028 --- linux-3.4.103/include/linux/Kbuild 2014-08-30 13:37:15.000000000 +0000
8029 +++ linux-3.4.103-vs2.3.3.9/include/linux/Kbuild 2012-07-24 09:52:30.000000000 +0000
8030 @@ -18,6 +18,7 @@ header-y += netfilter_bridge/
8031 header-y += netfilter_ipv4/
8032 header-y += netfilter_ipv6/
8034 +header-y += vserver/
8037 objhdr-y += version.h
8038 diff -NurpP --minimal linux-3.4.103/include/linux/capability.h linux-3.4.103-vs2.3.3.9/include/linux/capability.h
8039 --- linux-3.4.103/include/linux/capability.h 2012-03-19 18:47:27.000000000 +0000
8040 +++ linux-3.4.103-vs2.3.3.9/include/linux/capability.h 2012-05-21 16:15:05.000000000 +0000
8041 @@ -280,6 +280,7 @@ struct cpu_vfs_cap_data {
8042 arbitrary SCSI commands */
8043 /* Allow setting encryption key on loopback filesystem */
8044 /* Allow setting zone reclaim policy */
8045 +/* Allow the selection of a security context */
8047 #define CAP_SYS_ADMIN 21
8049 @@ -363,7 +364,12 @@ struct cpu_vfs_cap_data {
8051 #define CAP_LAST_CAP CAP_WAKE_ALARM
8053 -#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP)
8054 +/* Allow context manipulations */
8055 +/* Allow changing context info on files */
8057 +#define CAP_CONTEXT 63
8059 +#define cap_valid(x) ((x) >= 0 && ((x) <= CAP_LAST_CAP || (x) == CAP_CONTEXT))
8062 * Bit location of each capability (used by user-space library and kernel)
8063 diff -NurpP --minimal linux-3.4.103/include/linux/cred.h linux-3.4.103-vs2.3.3.9/include/linux/cred.h
8064 --- linux-3.4.103/include/linux/cred.h 2012-03-19 18:47:27.000000000 +0000
8065 +++ linux-3.4.103-vs2.3.3.9/include/linux/cred.h 2012-05-21 16:15:05.000000000 +0000
8066 @@ -156,6 +156,7 @@ extern void exit_creds(struct task_struc
8067 extern int copy_creds(struct task_struct *, unsigned long);
8068 extern const struct cred *get_task_cred(struct task_struct *);
8069 extern struct cred *cred_alloc_blank(void);
8070 +extern struct cred *__prepare_creds(const struct cred *);
8071 extern struct cred *prepare_creds(void);
8072 extern struct cred *prepare_exec_creds(void);
8073 extern int commit_creds(struct cred *);
8074 @@ -209,6 +210,31 @@ static inline void validate_process_cred
8078 +static inline void set_cred_subscribers(struct cred *cred, int n)
8080 +#ifdef CONFIG_DEBUG_CREDENTIALS
8081 + atomic_set(&cred->subscribers, n);
8085 +static inline int read_cred_subscribers(const struct cred *cred)
8087 +#ifdef CONFIG_DEBUG_CREDENTIALS
8088 + return atomic_read(&cred->subscribers);
8094 +static inline void alter_cred_subscribers(const struct cred *_cred, int n)
8096 +#ifdef CONFIG_DEBUG_CREDENTIALS
8097 + struct cred *cred = (struct cred *) _cred;
8099 + atomic_add(n, &cred->subscribers);
8104 * get_new_cred - Get a reference on a new set of credentials
8105 * @cred: The new credentials to reference
8106 diff -NurpP --minimal linux-3.4.103/include/linux/devpts_fs.h linux-3.4.103-vs2.3.3.9/include/linux/devpts_fs.h
8107 --- linux-3.4.103/include/linux/devpts_fs.h 2008-12-24 23:26:37.000000000 +0000
8108 +++ linux-3.4.103-vs2.3.3.9/include/linux/devpts_fs.h 2012-05-21 16:15:05.000000000 +0000
8109 @@ -45,5 +45,4 @@ static inline void devpts_pty_kill(struc
8114 #endif /* _LINUX_DEVPTS_FS_H */
8115 diff -NurpP --minimal linux-3.4.103/include/linux/fs.h linux-3.4.103-vs2.3.3.9/include/linux/fs.h
8116 --- linux-3.4.103/include/linux/fs.h 2014-08-30 13:37:17.000000000 +0000
8117 +++ linux-3.4.103-vs2.3.3.9/include/linux/fs.h 2014-03-12 09:55:28.000000000 +0000
8118 @@ -214,6 +214,9 @@ struct inodes_stat_t {
8119 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
8120 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
8121 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
8122 +#define MS_TAGGED (1<<25) /* use generic inode tagging */
8123 +#define MS_TAGID (1<<26) /* use specific tag for this mount */
8124 +#define MS_NOTAGCHECK (1<<27) /* don't check tags */
8125 #define MS_NOSEC (1<<28)
8126 #define MS_BORN (1<<29)
8127 #define MS_ACTIVE (1<<30)
8128 @@ -245,6 +248,14 @@ struct inodes_stat_t {
8129 #define S_IMA 1024 /* Inode has an associated IMA struct */
8130 #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */
8131 #define S_NOSEC 4096 /* no suid or xattr security attributes */
8132 +#define S_IXUNLINK 8192 /* Immutable Invert on unlink */
8134 +/* Linux-VServer related Inode flags */
8138 +#define V_BARRIER 4 /* Barrier for chroot() */
8139 +#define V_COW 8 /* Copy on Write */
8142 * Note that nosuid etc flags are inode-specific: setting some file-system
8143 @@ -267,12 +278,15 @@ struct inodes_stat_t {
8144 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
8145 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
8146 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
8147 -#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8148 -#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8149 +#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
8150 +#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
8151 +#define IS_TAGGED(inode) __IS_FLG(inode, MS_TAGGED)
8153 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
8154 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
8155 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
8156 +#define IS_IXUNLINK(inode) ((inode)->i_flags & S_IXUNLINK)
8157 +#define IS_IXORUNLINK(inode) ((IS_IXUNLINK(inode) ? S_IMMUTABLE : 0) ^ IS_IMMUTABLE(inode))
8158 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
8160 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
8161 @@ -283,6 +297,16 @@ struct inodes_stat_t {
8162 #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT)
8163 #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC)
8165 +#define IS_BARRIER(inode) (S_ISDIR((inode)->i_mode) && ((inode)->i_vflags & V_BARRIER))
8167 +#ifdef CONFIG_VSERVER_COWBL
8168 +# define IS_COW(inode) (IS_IXUNLINK(inode) && IS_IMMUTABLE(inode))
8169 +# define IS_COW_LINK(inode) (S_ISREG((inode)->i_mode) && ((inode)->i_nlink > 1))
8171 +# define IS_COW(inode) (0)
8172 +# define IS_COW_LINK(inode) (0)
8175 /* the read-only stuff doesn't really belong here, but any other place is
8176 probably as bad and I don't want to create yet another include file. */
8178 @@ -369,11 +393,14 @@ struct inodes_stat_t {
8179 #define FS_EXTENT_FL 0x00080000 /* Extents */
8180 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
8181 #define FS_NOCOW_FL 0x00800000 /* Do not cow file */
8182 +#define FS_IXUNLINK_FL 0x08000000 /* Immutable invert on unlink */
8183 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
8185 -#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
8186 -#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
8187 +#define FS_BARRIER_FL 0x04000000 /* Barrier for chroot() */
8188 +#define FS_COW_FL 0x20000000 /* Copy on Write marker */
8190 +#define FS_FL_USER_VISIBLE 0x0103DFFF /* User visible flags */
8191 +#define FS_FL_USER_MODIFIABLE 0x010380FF /* User modifiable flags */
8193 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
8194 #define SYNC_FILE_RANGE_WRITE 2
8195 @@ -456,6 +483,7 @@ typedef void (dio_iodone_t)(struct kiocb
8196 #define ATTR_KILL_PRIV (1 << 14)
8197 #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */
8198 #define ATTR_TIMES_SET (1 << 16)
8199 +#define ATTR_TAG (1 << 17)
8202 * This is the Inode Attributes structure, used for notify_change(). It
8203 @@ -471,6 +499,7 @@ struct iattr {
8209 struct timespec ia_atime;
8210 struct timespec ia_mtime;
8211 @@ -484,6 +513,9 @@ struct iattr {
8212 struct file *ia_file;
8215 +#define ATTR_FLAG_BARRIER 512 /* Barrier for chroot() */
8216 +#define ATTR_FLAG_IXUNLINK 1024 /* Immutable invert on unlink */
8219 * Includes for diskquotas.
8221 @@ -763,7 +795,9 @@ struct inode {
8222 unsigned short i_opflags;
8225 - unsigned int i_flags;
8227 + unsigned short i_flags;
8228 + unsigned short i_vflags;
8230 #ifdef CONFIG_FS_POSIX_ACL
8231 struct posix_acl *i_acl;
8232 @@ -792,6 +826,7 @@ struct inode {
8233 unsigned int __i_nlink;
8237 struct timespec i_atime;
8238 struct timespec i_mtime;
8239 struct timespec i_ctime;
8240 @@ -931,12 +966,12 @@ static inline void i_size_write(struct i
8242 static inline unsigned iminor(const struct inode *inode)
8244 - return MINOR(inode->i_rdev);
8245 + return MINOR(inode->i_mdev);
8248 static inline unsigned imajor(const struct inode *inode)
8250 - return MAJOR(inode->i_rdev);
8251 + return MAJOR(inode->i_mdev);
8254 extern struct block_device *I_BDEV(struct inode *inode);
8255 @@ -1003,6 +1038,7 @@ struct file {
8257 struct fown_struct f_owner;
8258 const struct cred *f_cred;
8260 struct file_ra_state f_ra;
8263 @@ -1150,6 +1186,7 @@ struct file_lock {
8264 struct file *fl_file;
8269 struct fasync_struct * fl_fasync; /* for lease break notifications */
8270 /* for lease breaks: */
8271 @@ -1663,6 +1700,7 @@ struct inode_operations {
8272 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
8273 ssize_t (*listxattr) (struct dentry *, char *, size_t);
8274 int (*removexattr) (struct dentry *, const char *);
8275 + int (*sync_flags) (struct inode *, int, int);
8276 void (*truncate_range)(struct inode *, loff_t, loff_t);
8277 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
8279 @@ -1682,6 +1720,7 @@ extern ssize_t vfs_readv(struct file *,
8280 unsigned long, loff_t *);
8281 extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
8282 unsigned long, loff_t *);
8283 +ssize_t vfs_sendfile(struct file *, struct file *, loff_t *, size_t, loff_t);
8285 struct super_operations {
8286 struct inode *(*alloc_inode)(struct super_block *sb);
8287 @@ -2511,6 +2550,7 @@ extern int dcache_dir_open(struct inode
8288 extern int dcache_dir_close(struct inode *, struct file *);
8289 extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
8290 extern int dcache_readdir(struct file *, void *, filldir_t);
8291 +extern int dcache_readdir_filter(struct file *, void *, filldir_t, int (*)(struct dentry *));
8292 extern int simple_setattr(struct dentry *, struct iattr *);
8293 extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);
8294 extern int simple_statfs(struct dentry *, struct kstatfs *);
8295 diff -NurpP --minimal linux-3.4.103/include/linux/gfs2_ondisk.h linux-3.4.103-vs2.3.3.9/include/linux/gfs2_ondisk.h
8296 --- linux-3.4.103/include/linux/gfs2_ondisk.h 2012-05-21 16:07:29.000000000 +0000
8297 +++ linux-3.4.103-vs2.3.3.9/include/linux/gfs2_ondisk.h 2012-05-21 16:15:05.000000000 +0000
8298 @@ -214,6 +214,9 @@ enum {
8302 + gfs2fl_IXUnlink = 16,
8303 + gfs2fl_Barrier = 17,
8305 gfs2fl_TruncInProg = 29,
8306 gfs2fl_InheritDirectio = 30,
8307 gfs2fl_InheritJdata = 31,
8308 @@ -230,6 +233,9 @@ enum {
8309 #define GFS2_DIF_NOATIME 0x00000080
8310 #define GFS2_DIF_SYNC 0x00000100
8311 #define GFS2_DIF_SYSTEM 0x00000200 /* New in gfs2 */
8312 +#define GFS2_DIF_IXUNLINK 0x00010000
8313 +#define GFS2_DIF_BARRIER 0x00020000
8314 +#define GFS2_DIF_COW 0x00040000
8315 #define GFS2_DIF_TRUNC_IN_PROG 0x20000000 /* New in gfs2 */
8316 #define GFS2_DIF_INHERIT_DIRECTIO 0x40000000
8317 #define GFS2_DIF_INHERIT_JDATA 0x80000000
8318 diff -NurpP --minimal linux-3.4.103/include/linux/if_tun.h linux-3.4.103-vs2.3.3.9/include/linux/if_tun.h
8319 --- linux-3.4.103/include/linux/if_tun.h 2010-08-02 14:52:54.000000000 +0000
8320 +++ linux-3.4.103-vs2.3.3.9/include/linux/if_tun.h 2012-05-21 16:15:05.000000000 +0000
8322 #define TUNDETACHFILTER _IOW('T', 214, struct sock_fprog)
8323 #define TUNGETVNETHDRSZ _IOR('T', 215, int)
8324 #define TUNSETVNETHDRSZ _IOW('T', 216, int)
8325 +#define TUNSETNID _IOW('T', 217, int)
8327 /* TUNSETIFF ifr flags */
8328 #define IFF_TUN 0x0001
8329 diff -NurpP --minimal linux-3.4.103/include/linux/init_task.h linux-3.4.103-vs2.3.3.9/include/linux/init_task.h
8330 --- linux-3.4.103/include/linux/init_task.h 2014-08-30 13:37:17.000000000 +0000
8331 +++ linux-3.4.103-vs2.3.3.9/include/linux/init_task.h 2012-10-22 13:09:53.000000000 +0000
8332 @@ -210,6 +210,10 @@ extern struct task_group root_task_group
8333 INIT_TRACE_RECURSION \
8334 INIT_TASK_RCU_PREEMPT(tsk) \
8337 + .vx_info = NULL, \
8339 + .nx_info = NULL, \
8343 diff -NurpP --minimal linux-3.4.103/include/linux/ipc.h linux-3.4.103-vs2.3.3.9/include/linux/ipc.h
8344 --- linux-3.4.103/include/linux/ipc.h 2012-03-19 18:47:28.000000000 +0000
8345 +++ linux-3.4.103-vs2.3.3.9/include/linux/ipc.h 2012-05-21 16:15:05.000000000 +0000
8346 @@ -91,6 +91,7 @@ struct kern_ipc_perm
8354 diff -NurpP --minimal linux-3.4.103/include/linux/ipc_namespace.h linux-3.4.103-vs2.3.3.9/include/linux/ipc_namespace.h
8355 --- linux-3.4.103/include/linux/ipc_namespace.h 2014-08-30 13:37:17.000000000 +0000
8356 +++ linux-3.4.103-vs2.3.3.9/include/linux/ipc_namespace.h 2013-07-14 13:38:35.000000000 +0000
8357 @@ -101,7 +101,8 @@ static inline int mq_init_ns(struct ipc_
8359 #if defined(CONFIG_IPC_NS)
8360 extern struct ipc_namespace *copy_ipcs(unsigned long flags,
8361 - struct task_struct *tsk);
8362 + struct ipc_namespace *old_ns,
8363 + struct user_namespace *user_ns);
8364 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
8367 @@ -112,12 +113,13 @@ static inline struct ipc_namespace *get_
8368 extern void put_ipc_ns(struct ipc_namespace *ns);
8370 static inline struct ipc_namespace *copy_ipcs(unsigned long flags,
8371 - struct task_struct *tsk)
8372 + struct ipc_namespace *old_ns,
8373 + struct user_namespace *user_ns)
8375 if (flags & CLONE_NEWIPC)
8376 return ERR_PTR(-EINVAL);
8378 - return tsk->nsproxy->ipc_ns;
8382 static inline struct ipc_namespace *get_ipc_ns(struct ipc_namespace *ns)
8383 diff -NurpP --minimal linux-3.4.103/include/linux/loop.h linux-3.4.103-vs2.3.3.9/include/linux/loop.h
8384 --- linux-3.4.103/include/linux/loop.h 2012-01-09 15:14:58.000000000 +0000
8385 +++ linux-3.4.103-vs2.3.3.9/include/linux/loop.h 2012-05-21 16:15:05.000000000 +0000
8386 @@ -45,6 +45,7 @@ struct loop_device {
8387 struct loop_func_table *lo_encryption;
8389 uid_t lo_key_owner; /* Who set the key */
8391 int (*ioctl)(struct loop_device *, int cmd,
8394 diff -NurpP --minimal linux-3.4.103/include/linux/magic.h linux-3.4.103-vs2.3.3.9/include/linux/magic.h
8395 --- linux-3.4.103/include/linux/magic.h 2012-05-21 16:07:31.000000000 +0000
8396 +++ linux-3.4.103-vs2.3.3.9/include/linux/magic.h 2012-05-21 16:15:05.000000000 +0000
8399 #define ADFS_SUPER_MAGIC 0xadf5
8400 #define AFFS_SUPER_MAGIC 0xadff
8401 -#define AFS_SUPER_MAGIC 0x5346414F
8402 +#define AFS_SUPER_MAGIC 0x5346414F
8403 #define AUTOFS_SUPER_MAGIC 0x0187
8404 #define CODA_SUPER_MAGIC 0x73757245
8405 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
8406 diff -NurpP --minimal linux-3.4.103/include/linux/major.h linux-3.4.103-vs2.3.3.9/include/linux/major.h
8407 --- linux-3.4.103/include/linux/major.h 2009-09-10 13:26:25.000000000 +0000
8408 +++ linux-3.4.103-vs2.3.3.9/include/linux/major.h 2012-05-21 16:15:05.000000000 +0000
8410 #define HD_MAJOR IDE0_MAJOR
8411 #define PTY_SLAVE_MAJOR 3
8413 +#define VROOT_MAJOR 4
8414 #define TTYAUX_MAJOR 5
8417 diff -NurpP --minimal linux-3.4.103/include/linux/memcontrol.h linux-3.4.103-vs2.3.3.9/include/linux/memcontrol.h
8418 --- linux-3.4.103/include/linux/memcontrol.h 2012-05-21 16:07:31.000000000 +0000
8419 +++ linux-3.4.103-vs2.3.3.9/include/linux/memcontrol.h 2012-05-21 16:15:05.000000000 +0000
8420 @@ -88,6 +88,13 @@ extern struct mem_cgroup *try_get_mem_cg
8421 extern struct mem_cgroup *parent_mem_cgroup(struct mem_cgroup *memcg);
8422 extern struct mem_cgroup *mem_cgroup_from_cont(struct cgroup *cont);
8424 +extern u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member);
8425 +extern u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member);
8427 +extern s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem);
8428 +extern s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem);
8429 +extern s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem);
8432 int mm_match_cgroup(const struct mm_struct *mm, const struct mem_cgroup *cgroup)
8434 diff -NurpP --minimal linux-3.4.103/include/linux/mm_types.h linux-3.4.103-vs2.3.3.9/include/linux/mm_types.h
8435 --- linux-3.4.103/include/linux/mm_types.h 2014-08-30 13:37:17.000000000 +0000
8436 +++ linux-3.4.103-vs2.3.3.9/include/linux/mm_types.h 2014-06-12 11:34:38.000000000 +0000
8437 @@ -354,6 +354,7 @@ struct mm_struct {
8439 /* Architecture-specific MM context */
8440 mm_context_t context;
8441 + struct vx_info *mm_vx_info;
8443 /* Swap token stuff */
8445 diff -NurpP --minimal linux-3.4.103/include/linux/mmzone.h linux-3.4.103-vs2.3.3.9/include/linux/mmzone.h
8446 --- linux-3.4.103/include/linux/mmzone.h 2014-08-30 13:37:17.000000000 +0000
8447 +++ linux-3.4.103-vs2.3.3.9/include/linux/mmzone.h 2012-07-17 22:29:43.000000000 +0000
8448 @@ -684,6 +684,13 @@ typedef struct pglist_data {
8449 __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
8452 +#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
8454 +#define node_end_pfn(nid) ({\
8455 + pg_data_t *__pgdat = NODE_DATA(nid);\
8456 + __pgdat->node_start_pfn + __pgdat->node_spanned_pages;\
8459 #include <linux/memory_hotplug.h>
8461 extern struct mutex zonelists_mutex;
8462 diff -NurpP --minimal linux-3.4.103/include/linux/mount.h linux-3.4.103-vs2.3.3.9/include/linux/mount.h
8463 --- linux-3.4.103/include/linux/mount.h 2012-03-19 18:47:28.000000000 +0000
8464 +++ linux-3.4.103-vs2.3.3.9/include/linux/mount.h 2012-05-21 16:15:05.000000000 +0000
8465 @@ -47,6 +47,9 @@ struct mnt_namespace;
8467 #define MNT_INTERNAL 0x4000
8469 +#define MNT_TAGID 0x10000
8470 +#define MNT_NOTAG 0x20000
8473 struct dentry *mnt_root; /* root of the mounted tree */
8474 struct super_block *mnt_sb; /* pointer to superblock */
8475 diff -NurpP --minimal linux-3.4.103/include/linux/net.h linux-3.4.103-vs2.3.3.9/include/linux/net.h
8476 --- linux-3.4.103/include/linux/net.h 2014-08-30 13:37:17.000000000 +0000
8477 +++ linux-3.4.103-vs2.3.3.9/include/linux/net.h 2014-06-12 11:34:38.000000000 +0000
8478 @@ -73,6 +73,7 @@ struct net;
8479 #define SOCK_PASSCRED 3
8480 #define SOCK_PASSSEC 4
8481 #define SOCK_EXTERNALLY_ALLOCATED 5
8482 +#define SOCK_USER_SOCKET 6
8484 #ifndef ARCH_HAS_SOCKET_TYPES
8486 diff -NurpP --minimal linux-3.4.103/include/linux/netdevice.h linux-3.4.103-vs2.3.3.9/include/linux/netdevice.h
8487 --- linux-3.4.103/include/linux/netdevice.h 2014-08-30 13:37:17.000000000 +0000
8488 +++ linux-3.4.103-vs2.3.3.9/include/linux/netdevice.h 2014-03-12 09:55:28.000000000 +0000
8489 @@ -1624,6 +1624,7 @@ extern void netdev_resync_ops(struct ne
8491 extern struct net_device *dev_get_by_index(struct net *net, int ifindex);
8492 extern struct net_device *__dev_get_by_index(struct net *net, int ifindex);
8493 +extern struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex);
8494 extern struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex);
8495 extern int dev_restart(struct net_device *dev);
8496 #ifdef CONFIG_NETPOLL_TRAP
8497 diff -NurpP --minimal linux-3.4.103/include/linux/nfs_mount.h linux-3.4.103-vs2.3.3.9/include/linux/nfs_mount.h
8498 --- linux-3.4.103/include/linux/nfs_mount.h 2011-01-05 20:50:31.000000000 +0000
8499 +++ linux-3.4.103-vs2.3.3.9/include/linux/nfs_mount.h 2012-05-21 16:15:05.000000000 +0000
8500 @@ -63,7 +63,8 @@ struct nfs_mount_data {
8501 #define NFS_MOUNT_SECFLAVOUR 0x2000 /* 5 */
8502 #define NFS_MOUNT_NORDIRPLUS 0x4000 /* 5 */
8503 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */
8504 -#define NFS_MOUNT_FLAGMASK 0xFFFF
8505 +#define NFS_MOUNT_TAGGED 0x10000 /* context tagging */
8506 +#define NFS_MOUNT_FLAGMASK 0x1FFFF
8508 /* The following are for internal use only */
8509 #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000
8510 diff -NurpP --minimal linux-3.4.103/include/linux/nsproxy.h linux-3.4.103-vs2.3.3.9/include/linux/nsproxy.h
8511 --- linux-3.4.103/include/linux/nsproxy.h 2011-10-24 16:45:32.000000000 +0000
8512 +++ linux-3.4.103-vs2.3.3.9/include/linux/nsproxy.h 2012-05-21 16:15:05.000000000 +0000
8515 #include <linux/spinlock.h>
8516 #include <linux/sched.h>
8517 +#include <linux/vserver/debug.h>
8519 struct mnt_namespace;
8520 struct uts_namespace;
8521 @@ -63,6 +64,7 @@ static inline struct nsproxy *task_nspro
8524 int copy_namespaces(unsigned long flags, struct task_struct *tsk);
8525 +struct nsproxy *copy_nsproxy(struct nsproxy *orig);
8526 void exit_task_namespaces(struct task_struct *tsk);
8527 void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new);
8528 void free_nsproxy(struct nsproxy *ns);
8529 @@ -70,16 +72,26 @@ int unshare_nsproxy_namespaces(unsigned
8530 struct fs_struct *);
8531 int __init nsproxy_cache_init(void);
8533 -static inline void put_nsproxy(struct nsproxy *ns)
8534 +#define get_nsproxy(n) __get_nsproxy(n, __FILE__, __LINE__)
8536 +static inline void __get_nsproxy(struct nsproxy *ns,
8537 + const char *_file, int _line)
8539 - if (atomic_dec_and_test(&ns->count)) {
8542 + vxlprintk(VXD_CBIT(space, 0), "get_nsproxy(%p[%u])",
8543 + ns, atomic_read(&ns->count), _file, _line);
8544 + atomic_inc(&ns->count);
8547 -static inline void get_nsproxy(struct nsproxy *ns)
8548 +#define put_nsproxy(n) __put_nsproxy(n, __FILE__, __LINE__)
8550 +static inline void __put_nsproxy(struct nsproxy *ns,
8551 + const char *_file, int _line)
8553 - atomic_inc(&ns->count);
8554 + vxlprintk(VXD_CBIT(space, 0), "put_nsproxy(%p[%u])",
8555 + ns, atomic_read(&ns->count), _file, _line);
8556 + if (atomic_dec_and_test(&ns->count)) {
8562 diff -NurpP --minimal linux-3.4.103/include/linux/pid.h linux-3.4.103-vs2.3.3.9/include/linux/pid.h
8563 --- linux-3.4.103/include/linux/pid.h 2011-07-22 09:18:11.000000000 +0000
8564 +++ linux-3.4.103-vs2.3.3.9/include/linux/pid.h 2012-05-21 16:15:05.000000000 +0000
8565 @@ -8,7 +8,8 @@ enum pid_type
8575 @@ -171,6 +172,7 @@ static inline pid_t pid_nr(struct pid *p
8578 pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns);
8579 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns);
8580 pid_t pid_vnr(struct pid *pid);
8582 #define do_each_pid_task(pid, type, task) \
8583 diff -NurpP --minimal linux-3.4.103/include/linux/proc_fs.h linux-3.4.103-vs2.3.3.9/include/linux/proc_fs.h
8584 --- linux-3.4.103/include/linux/proc_fs.h 2012-03-19 18:47:28.000000000 +0000
8585 +++ linux-3.4.103-vs2.3.3.9/include/linux/proc_fs.h 2012-05-21 16:15:05.000000000 +0000
8586 @@ -54,6 +54,7 @@ struct proc_dir_entry {
8592 const struct inode_operations *proc_iops;
8594 @@ -252,12 +253,18 @@ extern const struct proc_ns_operations n
8595 extern const struct proc_ns_operations utsns_operations;
8596 extern const struct proc_ns_operations ipcns_operations;
8602 int (*proc_get_link)(struct dentry *, struct path *);
8603 int (*proc_read)(struct task_struct *task, char *page);
8604 int (*proc_show)(struct seq_file *m,
8605 struct pid_namespace *ns, struct pid *pid,
8606 struct task_struct *task);
8607 + int (*proc_vs_read)(char *page);
8608 + int (*proc_vxi_read)(struct vx_info *vxi, char *page);
8609 + int (*proc_nxi_read)(struct nx_info *nxi, char *page);
8612 struct ctl_table_header;
8613 @@ -265,6 +272,7 @@ struct ctl_table;
8620 struct proc_dir_entry *pde;
8621 diff -NurpP --minimal linux-3.4.103/include/linux/quotaops.h linux-3.4.103-vs2.3.3.9/include/linux/quotaops.h
8622 --- linux-3.4.103/include/linux/quotaops.h 2012-01-09 15:14:58.000000000 +0000
8623 +++ linux-3.4.103-vs2.3.3.9/include/linux/quotaops.h 2012-05-21 16:15:05.000000000 +0000
8625 #define _LINUX_QUOTAOPS_
8627 #include <linux/fs.h>
8628 +#include <linux/vs_dlimit.h>
8630 #define DQUOT_SPACE_WARN 0x1
8631 #define DQUOT_SPACE_RESERVE 0x2
8632 @@ -204,11 +205,12 @@ static inline void dquot_drop(struct ino
8634 static inline int dquot_alloc_inode(const struct inode *inode)
8637 + return dl_alloc_inode(inode);
8640 static inline void dquot_free_inode(const struct inode *inode)
8642 + dl_free_inode(inode);
8645 static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
8646 @@ -219,6 +221,10 @@ static inline int dquot_transfer(struct
8647 static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
8652 + if ((ret = dl_alloc_space(inode, number)))
8654 if (!(flags & DQUOT_SPACE_RESERVE))
8655 inode_add_bytes(inode, number);
8657 @@ -229,6 +235,7 @@ static inline void __dquot_free_space(st
8659 if (!(flags & DQUOT_SPACE_RESERVE))
8660 inode_sub_bytes(inode, number);
8661 + dl_free_space(inode, number);
8664 static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
8665 diff -NurpP --minimal linux-3.4.103/include/linux/reboot.h linux-3.4.103-vs2.3.3.9/include/linux/reboot.h
8666 --- linux-3.4.103/include/linux/reboot.h 2011-10-24 16:45:32.000000000 +0000
8667 +++ linux-3.4.103-vs2.3.3.9/include/linux/reboot.h 2012-05-21 16:15:05.000000000 +0000
8669 #define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
8670 #define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
8671 #define LINUX_REBOOT_CMD_KEXEC 0x45584543
8672 +#define LINUX_REBOOT_CMD_OOM 0xDEADBEEF
8676 diff -NurpP --minimal linux-3.4.103/include/linux/sched.h linux-3.4.103-vs2.3.3.9/include/linux/sched.h
8677 --- linux-3.4.103/include/linux/sched.h 2014-08-30 13:37:17.000000000 +0000
8678 +++ linux-3.4.103-vs2.3.3.9/include/linux/sched.h 2014-03-12 09:55:28.000000000 +0000
8679 @@ -1461,6 +1461,14 @@ struct task_struct {
8683 +/* vserver context data */
8684 + struct vx_info *vx_info;
8685 + struct nx_info *nx_info;
8691 /* Thread group tracking */
8694 @@ -1705,6 +1713,11 @@ struct pid_namespace;
8695 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
8696 struct pid_namespace *ns);
8698 +#include <linux/vserver/base.h>
8699 +#include <linux/vserver/context.h>
8700 +#include <linux/vserver/debug.h>
8701 +#include <linux/vserver/pid.h>
8703 static inline pid_t task_pid_nr(struct task_struct *tsk)
8706 @@ -1718,7 +1731,8 @@ static inline pid_t task_pid_nr_ns(struc
8708 static inline pid_t task_pid_vnr(struct task_struct *tsk)
8710 - return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
8711 + // return __task_pid_nr_ns(tsk, PIDTYPE_PID, NULL);
8712 + return vx_map_pid(__task_pid_nr_ns(tsk, PIDTYPE_PID, NULL));
8716 @@ -1731,7 +1745,7 @@ pid_t task_tgid_nr_ns(struct task_struct
8718 static inline pid_t task_tgid_vnr(struct task_struct *tsk)
8720 - return pid_vnr(task_tgid(tsk));
8721 + return vx_map_tgid(pid_vnr(task_tgid(tsk)));
8725 diff -NurpP --minimal linux-3.4.103/include/linux/shmem_fs.h linux-3.4.103-vs2.3.3.9/include/linux/shmem_fs.h
8726 --- linux-3.4.103/include/linux/shmem_fs.h 2012-03-19 18:47:29.000000000 +0000
8727 +++ linux-3.4.103-vs2.3.3.9/include/linux/shmem_fs.h 2012-05-21 16:15:05.000000000 +0000
8730 /* inode in-kernel data */
8732 +#define TMPFS_SUPER_MAGIC 0x01021994
8735 struct shmem_inode_info {
8737 unsigned long flags;
8738 diff -NurpP --minimal linux-3.4.103/include/linux/stat.h linux-3.4.103-vs2.3.3.9/include/linux/stat.h
8739 --- linux-3.4.103/include/linux/stat.h 2008-12-24 23:26:37.000000000 +0000
8740 +++ linux-3.4.103-vs2.3.3.9/include/linux/stat.h 2012-05-21 16:15:05.000000000 +0000
8741 @@ -66,6 +66,7 @@ struct kstat {
8748 struct timespec atime;
8749 diff -NurpP --minimal linux-3.4.103/include/linux/sunrpc/auth.h linux-3.4.103-vs2.3.3.9/include/linux/sunrpc/auth.h
8750 --- linux-3.4.103/include/linux/sunrpc/auth.h 2012-05-21 16:07:32.000000000 +0000
8751 +++ linux-3.4.103-vs2.3.3.9/include/linux/sunrpc/auth.h 2012-05-21 16:15:05.000000000 +0000
8757 struct group_info *group_info;
8758 const char *principal;
8759 unsigned char machine_cred : 1;
8760 diff -NurpP --minimal linux-3.4.103/include/linux/sunrpc/clnt.h linux-3.4.103-vs2.3.3.9/include/linux/sunrpc/clnt.h
8761 --- linux-3.4.103/include/linux/sunrpc/clnt.h 2012-05-21 16:07:32.000000000 +0000
8762 +++ linux-3.4.103-vs2.3.3.9/include/linux/sunrpc/clnt.h 2012-05-21 16:15:05.000000000 +0000
8763 @@ -49,7 +49,8 @@ struct rpc_clnt {
8764 unsigned int cl_softrtry : 1,/* soft timeouts */
8765 cl_discrtry : 1,/* disconnect before retry */
8766 cl_autobind : 1,/* use getport() */
8767 - cl_chatty : 1;/* be verbose */
8768 + cl_chatty : 1,/* be verbose */
8769 + cl_tag : 1;/* context tagging */
8771 struct rpc_rtt * cl_rtt; /* RTO estimator data */
8772 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
8773 diff -NurpP --minimal linux-3.4.103/include/linux/sysctl.h linux-3.4.103-vs2.3.3.9/include/linux/sysctl.h
8774 --- linux-3.4.103/include/linux/sysctl.h 2012-05-21 16:07:32.000000000 +0000
8775 +++ linux-3.4.103-vs2.3.3.9/include/linux/sysctl.h 2012-05-21 16:15:05.000000000 +0000
8776 @@ -60,6 +60,7 @@ enum
8777 CTL_ABI=9, /* Binary emulation */
8778 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
8779 CTL_ARLAN=254, /* arlan wireless driver */
8780 + CTL_VSERVER=4242, /* Linux-VServer debug */
8781 CTL_S390DBF=5677, /* s390 debug */
8782 CTL_SUNRPC=7249, /* sunrpc debug */
8783 CTL_PM=9899, /* frv power management */
8784 @@ -94,6 +95,7 @@ enum
8786 KERN_PANIC=15, /* int: panic timeout */
8787 KERN_REALROOTDEV=16, /* real root device to mount after initrd */
8788 + KERN_VSHELPER=17, /* string: path to vshelper policy agent */
8790 KERN_SPARC_REBOOT=21, /* reboot command on Sparc */
8791 KERN_CTLALTDEL=22, /* int: allow ctl-alt-del to reboot */
8792 diff -NurpP --minimal linux-3.4.103/include/linux/sysfs.h linux-3.4.103-vs2.3.3.9/include/linux/sysfs.h
8793 --- linux-3.4.103/include/linux/sysfs.h 2012-03-19 18:47:29.000000000 +0000
8794 +++ linux-3.4.103-vs2.3.3.9/include/linux/sysfs.h 2012-05-21 16:15:05.000000000 +0000
8796 #include <linux/kobject_ns.h>
8797 #include <linux/atomic.h>
8799 +#define SYSFS_SUPER_MAGIC 0x62656572
8804 diff -NurpP --minimal linux-3.4.103/include/linux/time.h linux-3.4.103-vs2.3.3.9/include/linux/time.h
8805 --- linux-3.4.103/include/linux/time.h 2014-08-30 13:37:17.000000000 +0000
8806 +++ linux-3.4.103-vs2.3.3.9/include/linux/time.h 2012-10-22 13:09:53.000000000 +0000
8807 @@ -281,6 +281,8 @@ static __always_inline void timespec_add
8811 +#include <linux/vs_time.h>
8813 #endif /* __KERNEL__ */
8816 diff -NurpP --minimal linux-3.4.103/include/linux/types.h linux-3.4.103-vs2.3.3.9/include/linux/types.h
8817 --- linux-3.4.103/include/linux/types.h 2012-05-21 16:07:32.000000000 +0000
8818 +++ linux-3.4.103-vs2.3.3.9/include/linux/types.h 2012-05-21 16:15:05.000000000 +0000
8819 @@ -41,6 +41,9 @@ typedef __kernel_uid32_t uid_t;
8820 typedef __kernel_gid32_t gid_t;
8821 typedef __kernel_uid16_t uid16_t;
8822 typedef __kernel_gid16_t gid16_t;
8823 +typedef unsigned int xid_t;
8824 +typedef unsigned int nid_t;
8825 +typedef unsigned int tag_t;
8827 typedef unsigned long uintptr_t;
8829 diff -NurpP --minimal linux-3.4.103/include/linux/utsname.h linux-3.4.103-vs2.3.3.9/include/linux/utsname.h
8830 --- linux-3.4.103/include/linux/utsname.h 2012-01-09 15:14:59.000000000 +0000
8831 +++ linux-3.4.103-vs2.3.3.9/include/linux/utsname.h 2012-05-21 16:15:05.000000000 +0000
8832 @@ -62,7 +62,8 @@ static inline void get_uts_ns(struct uts
8835 extern struct uts_namespace *copy_utsname(unsigned long flags,
8836 - struct task_struct *tsk);
8837 + struct uts_namespace *old_ns,
8838 + struct user_namespace *user_ns);
8839 extern void free_uts_ns(struct kref *kref);
8841 static inline void put_uts_ns(struct uts_namespace *ns)
8842 @@ -79,12 +80,13 @@ static inline void put_uts_ns(struct uts
8845 static inline struct uts_namespace *copy_utsname(unsigned long flags,
8846 - struct task_struct *tsk)
8847 + struct uts_namespace *old_ns,
8848 + struct user_namespace *user_ns)
8850 if (flags & CLONE_NEWUTS)
8851 return ERR_PTR(-EINVAL);
8853 - return tsk->nsproxy->uts_ns;
8858 diff -NurpP --minimal linux-3.4.103/include/linux/vroot.h linux-3.4.103-vs2.3.3.9/include/linux/vroot.h
8859 --- linux-3.4.103/include/linux/vroot.h 1970-01-01 00:00:00.000000000 +0000
8860 +++ linux-3.4.103-vs2.3.3.9/include/linux/vroot.h 2012-05-21 16:15:05.000000000 +0000
8864 + * include/linux/vroot.h
8866 + * written by Herbert Pötzl, 9/11/2002
8867 + * ported to 2.6 by Herbert Pötzl, 30/12/2004
8869 + * Copyright (C) 2002-2007 by Herbert Pötzl.
8870 + * Redistribution of this file is permitted under the
8871 + * GNU General Public License.
8874 +#ifndef _LINUX_VROOT_H
8875 +#define _LINUX_VROOT_H
8880 +/* Possible states of device */
8886 +struct vroot_device {
8890 + struct semaphore vr_ctl_mutex;
8891 + struct block_device *vr_device;
8896 +typedef struct block_device *(vroot_grb_func)(struct block_device *);
8898 +extern int register_vroot_grb(vroot_grb_func *);
8899 +extern int unregister_vroot_grb(vroot_grb_func *);
8901 +#endif /* __KERNEL__ */
8903 +#define MAX_VROOT_DEFAULT 8
8906 + * IOCTL commands --- we will commandeer 0x56 ('V')
8909 +#define VROOT_SET_DEV 0x5600
8910 +#define VROOT_CLR_DEV 0x5601
8912 +#endif /* _LINUX_VROOT_H */
8913 diff -NurpP --minimal linux-3.4.103/include/linux/vs_base.h linux-3.4.103-vs2.3.3.9/include/linux/vs_base.h
8914 --- linux-3.4.103/include/linux/vs_base.h 1970-01-01 00:00:00.000000000 +0000
8915 +++ linux-3.4.103-vs2.3.3.9/include/linux/vs_base.h 2012-05-21 16:15:05.000000000 +0000
8920 +#include "vserver/base.h"
8921 +#include "vserver/check.h"
8922 +#include "vserver/debug.h"
8925 +#warning duplicate inclusion
8927 diff -NurpP --minimal linux-3.4.103/include/linux/vs_context.h linux-3.4.103-vs2.3.3.9/include/linux/vs_context.h
8928 --- linux-3.4.103/include/linux/vs_context.h 1970-01-01 00:00:00.000000000 +0000
8929 +++ linux-3.4.103-vs2.3.3.9/include/linux/vs_context.h 2012-05-21 16:15:05.000000000 +0000
8931 +#ifndef _VS_CONTEXT_H
8932 +#define _VS_CONTEXT_H
8934 +#include "vserver/base.h"
8935 +#include "vserver/check.h"
8936 +#include "vserver/context.h"
8937 +#include "vserver/history.h"
8938 +#include "vserver/debug.h"
8940 +#include <linux/sched.h>
8943 +#define get_vx_info(i) __get_vx_info(i, __FILE__, __LINE__, __HERE__)
8945 +static inline struct vx_info *__get_vx_info(struct vx_info *vxi,
8946 + const char *_file, int _line, void *_here)
8951 + vxlprintk(VXD_CBIT(xid, 2), "get_vx_info(%p[#%d.%d])",
8952 + vxi, vxi ? vxi->vx_id : 0,
8953 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8955 + __vxh_get_vx_info(vxi, _here);
8957 + atomic_inc(&vxi->vx_usecnt);
8962 +extern void free_vx_info(struct vx_info *);
8964 +#define put_vx_info(i) __put_vx_info(i, __FILE__, __LINE__, __HERE__)
8966 +static inline void __put_vx_info(struct vx_info *vxi,
8967 + const char *_file, int _line, void *_here)
8972 + vxlprintk(VXD_CBIT(xid, 2), "put_vx_info(%p[#%d.%d])",
8973 + vxi, vxi ? vxi->vx_id : 0,
8974 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8976 + __vxh_put_vx_info(vxi, _here);
8978 + if (atomic_dec_and_test(&vxi->vx_usecnt))
8979 + free_vx_info(vxi);
8983 +#define init_vx_info(p, i) \
8984 + __init_vx_info(p, i, __FILE__, __LINE__, __HERE__)
8986 +static inline void __init_vx_info(struct vx_info **vxp, struct vx_info *vxi,
8987 + const char *_file, int _line, void *_here)
8990 + vxlprintk(VXD_CBIT(xid, 3),
8991 + "init_vx_info(%p[#%d.%d])",
8992 + vxi, vxi ? vxi->vx_id : 0,
8993 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
8995 + __vxh_init_vx_info(vxi, vxp, _here);
8997 + atomic_inc(&vxi->vx_usecnt);
9003 +#define set_vx_info(p, i) \
9004 + __set_vx_info(p, i, __FILE__, __LINE__, __HERE__)
9006 +static inline void __set_vx_info(struct vx_info **vxp, struct vx_info *vxi,
9007 + const char *_file, int _line, void *_here)
9009 + struct vx_info *vxo;
9014 + vxlprintk(VXD_CBIT(xid, 3), "set_vx_info(%p[#%d.%d])",
9015 + vxi, vxi ? vxi->vx_id : 0,
9016 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9018 + __vxh_set_vx_info(vxi, vxp, _here);
9020 + atomic_inc(&vxi->vx_usecnt);
9021 + vxo = xchg(vxp, vxi);
9026 +#define clr_vx_info(p) __clr_vx_info(p, __FILE__, __LINE__, __HERE__)
9028 +static inline void __clr_vx_info(struct vx_info **vxp,
9029 + const char *_file, int _line, void *_here)
9031 + struct vx_info *vxo;
9033 + vxo = xchg(vxp, NULL);
9037 + vxlprintk(VXD_CBIT(xid, 3), "clr_vx_info(%p[#%d.%d])",
9038 + vxo, vxo ? vxo->vx_id : 0,
9039 + vxo ? atomic_read(&vxo->vx_usecnt) : 0,
9041 + __vxh_clr_vx_info(vxo, vxp, _here);
9043 + if (atomic_dec_and_test(&vxo->vx_usecnt))
9044 + free_vx_info(vxo);
9048 +#define claim_vx_info(v, p) \
9049 + __claim_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9051 +static inline void __claim_vx_info(struct vx_info *vxi,
9052 + struct task_struct *task,
9053 + const char *_file, int _line, void *_here)
9055 + vxlprintk(VXD_CBIT(xid, 3), "claim_vx_info(%p[#%d.%d.%d]) %p",
9056 + vxi, vxi ? vxi->vx_id : 0,
9057 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9058 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9059 + task, _file, _line);
9060 + __vxh_claim_vx_info(vxi, task, _here);
9062 + atomic_inc(&vxi->vx_tasks);
9066 +extern void unhash_vx_info(struct vx_info *);
9068 +#define release_vx_info(v, p) \
9069 + __release_vx_info(v, p, __FILE__, __LINE__, __HERE__)
9071 +static inline void __release_vx_info(struct vx_info *vxi,
9072 + struct task_struct *task,
9073 + const char *_file, int _line, void *_here)
9075 + vxlprintk(VXD_CBIT(xid, 3), "release_vx_info(%p[#%d.%d.%d]) %p",
9076 + vxi, vxi ? vxi->vx_id : 0,
9077 + vxi ? atomic_read(&vxi->vx_usecnt) : 0,
9078 + vxi ? atomic_read(&vxi->vx_tasks) : 0,
9079 + task, _file, _line);
9080 + __vxh_release_vx_info(vxi, task, _here);
9084 + if (atomic_dec_and_test(&vxi->vx_tasks))
9085 + unhash_vx_info(vxi);
9089 +#define task_get_vx_info(p) \
9090 + __task_get_vx_info(p, __FILE__, __LINE__, __HERE__)
9092 +static inline struct vx_info *__task_get_vx_info(struct task_struct *p,
9093 + const char *_file, int _line, void *_here)
9095 + struct vx_info *vxi;
9098 + vxlprintk(VXD_CBIT(xid, 5), "task_get_vx_info(%p)",
9100 + vxi = __get_vx_info(p->vx_info, _file, _line, _here);
9106 +static inline void __wakeup_vx_info(struct vx_info *vxi)
9108 + if (waitqueue_active(&vxi->vx_wait))
9109 + wake_up_interruptible(&vxi->vx_wait);
9113 +#define enter_vx_info(v, s) __enter_vx_info(v, s, __FILE__, __LINE__)
9115 +static inline void __enter_vx_info(struct vx_info *vxi,
9116 + struct vx_info_save *vxis, const char *_file, int _line)
9118 + vxlprintk(VXD_CBIT(xid, 5), "enter_vx_info(%p[#%d],%p) %p[#%d,%p]",
9119 + vxi, vxi ? vxi->vx_id : 0, vxis, current,
9120 + current->xid, current->vx_info, _file, _line);
9121 + vxis->vxi = xchg(¤t->vx_info, vxi);
9122 + vxis->xid = current->xid;
9123 + current->xid = vxi ? vxi->vx_id : 0;
9126 +#define leave_vx_info(s) __leave_vx_info(s, __FILE__, __LINE__)
9128 +static inline void __leave_vx_info(struct vx_info_save *vxis,
9129 + const char *_file, int _line)
9131 + vxlprintk(VXD_CBIT(xid, 5), "leave_vx_info(%p[#%d,%p]) %p[#%d,%p]",
9132 + vxis, vxis->xid, vxis->vxi, current,
9133 + current->xid, current->vx_info, _file, _line);
9134 + (void)xchg(¤t->vx_info, vxis->vxi);
9135 + current->xid = vxis->xid;
9139 +static inline void __enter_vx_admin(struct vx_info_save *vxis)
9141 + vxis->vxi = xchg(¤t->vx_info, NULL);
9142 + vxis->xid = xchg(¤t->xid, (xid_t)0);
9145 +static inline void __leave_vx_admin(struct vx_info_save *vxis)
9147 + (void)xchg(¤t->xid, vxis->xid);
9148 + (void)xchg(¤t->vx_info, vxis->vxi);
9151 +#define task_is_init(p) \
9152 + __task_is_init(p, __FILE__, __LINE__, __HERE__)
9154 +static inline int __task_is_init(struct task_struct *p,
9155 + const char *_file, int _line, void *_here)
9157 + int is_init = is_global_init(p);
9161 + is_init = p->vx_info->vx_initpid == p->pid;
9166 +extern void exit_vx_info(struct task_struct *, int);
9167 +extern void exit_vx_info_early(struct task_struct *, int);
9171 +#warning duplicate inclusion
9173 diff -NurpP --minimal linux-3.4.103/include/linux/vs_cowbl.h linux-3.4.103-vs2.3.3.9/include/linux/vs_cowbl.h
9174 --- linux-3.4.103/include/linux/vs_cowbl.h 1970-01-01 00:00:00.000000000 +0000
9175 +++ linux-3.4.103-vs2.3.3.9/include/linux/vs_cowbl.h 2012-05-21 16:15:05.000000000 +0000
9177 +#ifndef _VS_COWBL_H
9178 +#define _VS_COWBL_H
9180 +#include <linux/fs.h>
9181 +#include <linux/dcache.h>
9182 +#include <linux/namei.h>
9183 +#include <linux/slab.h>
9185 +extern struct dentry *cow_break_link(const char *pathname);
9187 +static inline int cow_check_and_break(struct path *path)
9189 + struct inode *inode = path->dentry->d_inode;
9192 + /* do we need this check? */
9193 + if (IS_RDONLY(inode))
9196 + if (IS_COW(inode)) {
9197 + if (IS_COW_LINK(inode)) {
9198 + struct dentry *new_dentry, *old_dentry = path->dentry;
9201 + buf = kmalloc(PATH_MAX, GFP_KERNEL);
9205 + pp = d_path(path, buf, PATH_MAX);
9206 + new_dentry = cow_break_link(pp);
9208 + if (!IS_ERR(new_dentry)) {
9209 + path->dentry = new_dentry;
9212 + error = PTR_ERR(new_dentry);
9214 + inode->i_flags &= ~(S_IXUNLINK | S_IMMUTABLE);
9215 + inode->i_ctime = CURRENT_TIME;
9216 + mark_inode_dirty(inode);
9223 +#warning duplicate inclusion
9225 diff -NurpP --minimal linux-3.4.103/include/linux/vs_cvirt.h linux-3.4.103-vs2.3.3.9/include/linux/vs_cvirt.h
9226 --- linux-3.4.103/include/linux/vs_cvirt.h 1970-01-01 00:00:00.000000000 +0000
9227 +++ linux-3.4.103-vs2.3.3.9/include/linux/vs_cvirt.h 2012-05-21 16:15:05.000000000 +0000
9229 +#ifndef _VS_CVIRT_H
9230 +#define _VS_CVIRT_H
9232 +#include "vserver/cvirt.h"
9233 +#include "vserver/context.h"
9234 +#include "vserver/base.h"
9235 +#include "vserver/check.h"
9236 +#include "vserver/debug.h"
9239 +static inline void vx_activate_task(struct task_struct *p)
9241 + struct vx_info *vxi;
9243 + if ((vxi = p->vx_info)) {
9244 + vx_update_load(vxi);
9245 + atomic_inc(&vxi->cvirt.nr_running);
9249 +static inline void vx_deactivate_task(struct task_struct *p)
9251 + struct vx_info *vxi;
9253 + if ((vxi = p->vx_info)) {
9254 + vx_update_load(vxi);
9255 + atomic_dec(&vxi->cvirt.nr_running);
9259 +static inline void vx_uninterruptible_inc(struct task_struct *p)
9261 + struct vx_info *vxi;
9263 + if ((vxi = p->vx_info))
9264 + atomic_inc(&vxi->cvirt.nr_uninterruptible);
9267 +static inline void vx_uninterruptible_dec(struct task_struct *p)
9269 + struct vx_info *vxi;
9271 + if ((vxi = p->vx_info))
9272 + atomic_dec(&vxi->cvirt.nr_uninterruptible);
9277 +#warning duplicate inclusion
9279 diff -NurpP --minimal linux-3.4.103/include/linux/vs_device.h linux-3.4.103-vs2.3.3.9/include/linux/vs_device.h
9280 --- linux-3.4.103/include/linux/vs_device.h 1970-01-01 00:00:00.000000000 +0000
9281 +++ linux-3.4.103-vs2.3.3.9/include/linux/vs_device.h 2012-05-21 16:15:05.000000000 +0000
9283 +#ifndef _VS_DEVICE_H
9284 +#define _VS_DEVICE_H
9286 +#include "vserver/base.h"
9287 +#include "vserver/device.h"
9288 +#include "vserver/debug.h"
9291 +#ifdef CONFIG_VSERVER_DEVICE
9293 +int vs_map_device(struct vx_info *, dev_t, dev_t *, umode_t);
9295 +#define vs_device_perm(v, d, m, p) \
9296 + ((vs_map_device(current_vx_info(), d, NULL, m) & (p)) == (p))
9301 +int vs_map_device(struct vx_info *vxi,
9302 + dev_t device, dev_t *target, umode_t mode)
9309 +#define vs_device_perm(v, d, m, p) ((p) == (p))
9314 +#define vs_map_chrdev(d, t, p) \
9315 + ((vs_map_device(current_vx_info(), d, t, S_IFCHR) & (p)) == (p))
9316 +#define vs_map_blkdev(d, t, p) \
9317 + ((vs_map_device(current_vx_info(), d, t, S_IFBLK) & (p)) == (p))
9319 +#define vs_chrdev_perm(d, p) \
9320 + vs_device_perm(current_vx_info(), d, S_IFCHR, p)
9321 +#define vs_blkdev_perm(d, p) \
9322 + vs_device_perm(current_vx_info(), d, S_IFBLK, p)
9326 +#warning duplicate inclusion
9328 diff -NurpP --minimal linux-3.4.103/include/linux/vs_dlimit.h linux-3.4.103-vs2.3.3.9/include/linux/vs_dlimit.h
9329 --- linux-3.4.103/include/linux/vs_dlimit.h 1970-01-01 00:00:00.000000000 +0000
9330 +++ linux-3.4.103-vs2.3.3.9/include/linux/vs_dlimit.h 2012-05-21 16:15:05.000000000 +0000
9332 +#ifndef _VS_DLIMIT_H
9333 +#define _VS_DLIMIT_H
9335 +#include <linux/fs.h>
9337 +#include "vserver/dlimit.h"
9338 +#include "vserver/base.h"
9339 +#include "vserver/debug.h"
9342 +#define get_dl_info(i) __get_dl_info(i, __FILE__, __LINE__)
9344 +static inline struct dl_info *__get_dl_info(struct dl_info *dli,
9345 + const char *_file, int _line)
9349 + vxlprintk(VXD_CBIT(dlim, 4), "get_dl_info(%p[#%d.%d])",
9350 + dli, dli ? dli->dl_tag : 0,
9351 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9353 + atomic_inc(&dli->dl_usecnt);
9358 +#define free_dl_info(i) \
9359 + call_rcu(&(i)->dl_rcu, rcu_free_dl_info)
9361 +#define put_dl_info(i) __put_dl_info(i, __FILE__, __LINE__)
9363 +static inline void __put_dl_info(struct dl_info *dli,
9364 + const char *_file, int _line)
9368 + vxlprintk(VXD_CBIT(dlim, 4), "put_dl_info(%p[#%d.%d])",
9369 + dli, dli ? dli->dl_tag : 0,
9370 + dli ? atomic_read(&dli->dl_usecnt) : 0,
9372 + if (atomic_dec_and_test(&dli->dl_usecnt))
9373 + free_dl_info(dli);
9377 +#define __dlimit_char(d) ((d) ? '*' : ' ')
9379 +static inline int __dl_alloc_space(struct super_block *sb,
9380 + tag_t tag, dlsize_t nr, const char *file, int line)
9382 + struct dl_info *dli = NULL;
9387 + dli = locate_dl_info(sb, tag);
9391 + spin_lock(&dli->dl_lock);
9392 + ret = (dli->dl_space_used + nr > dli->dl_space_total);
9394 + dli->dl_space_used += nr;
9395 + spin_unlock(&dli->dl_lock);
9398 + vxlprintk(VXD_CBIT(dlim, 1),
9399 + "ALLOC (%p,#%d)%c %lld bytes (%d)",
9400 + sb, tag, __dlimit_char(dli), (long long)nr,
9402 + return ret ? -ENOSPC : 0;
9405 +static inline void __dl_free_space(struct super_block *sb,
9406 + tag_t tag, dlsize_t nr, const char *_file, int _line)
9408 + struct dl_info *dli = NULL;
9412 + dli = locate_dl_info(sb, tag);
9416 + spin_lock(&dli->dl_lock);
9417 + if (dli->dl_space_used > nr)
9418 + dli->dl_space_used -= nr;
9420 + dli->dl_space_used = 0;
9421 + spin_unlock(&dli->dl_lock);
9424 + vxlprintk(VXD_CBIT(dlim, 1),
9425 + "FREE (%p,#%d)%c %lld bytes",
9426 + sb, tag, __dlimit_char(dli), (long long)nr,
9430 +static inline int __dl_alloc_inode(struct super_block *sb,
9431 + tag_t tag, const char *_file, int _line)
9433 + struct dl_info *dli;
9436 + dli = locate_dl_info(sb, tag);
9440 + spin_lock(&dli->dl_lock);
9441 + dli->dl_inodes_used++;
9442 + ret = (dli->dl_inodes_used > dli->dl_inodes_total);
9443 + spin_unlock(&dli->dl_lock);
9446 + vxlprintk(VXD_CBIT(dlim, 0),
9447 + "ALLOC (%p,#%d)%c inode (%d)",
9448 + sb, tag, __dlimit_char(dli), ret, _file, _line);
9449 + return ret ? -ENOSPC : 0;
9452 +static inline void __dl_free_inode(struct super_block *sb,
9453 + tag_t tag, const char *_file, int _line)
9455 + struct dl_info *dli;
9457 + dli = locate_dl_info(sb, tag);
9461 + spin_lock(&dli->dl_lock);
9462 + if (dli->dl_inodes_used > 1)
9463 + dli->dl_inodes_used--;
9465 + dli->dl_inodes_used = 0;
9466 + spin_unlock(&dli->dl_lock);
9469 + vxlprintk(VXD_CBIT(dlim, 0),
9470 + "FREE (%p,#%d)%c inode",
9471 + sb, tag, __dlimit_char(dli), _file, _line);
9474 +static inline void __dl_adjust_block(struct super_block *sb, tag_t tag,
9475 + unsigned long long *free_blocks, unsigned long long *root_blocks,
9476 + const char *_file, int _line)
9478 + struct dl_info *dli;
9479 + uint64_t broot, bfree;
9481 + dli = locate_dl_info(sb, tag);
9485 + spin_lock(&dli->dl_lock);
9486 + broot = (dli->dl_space_total -
9487 + (dli->dl_space_total >> 10) * dli->dl_nrlmult)
9488 + >> sb->s_blocksize_bits;
9489 + bfree = (dli->dl_space_total - dli->dl_space_used)
9490 + >> sb->s_blocksize_bits;
9491 + spin_unlock(&dli->dl_lock);
9493 + vxlprintk(VXD_CBIT(dlim, 2),
9494 + "ADJUST: %lld,%lld on %lld,%lld [mult=%d]",
9495 + (long long)bfree, (long long)broot,
9496 + *free_blocks, *root_blocks, dli->dl_nrlmult,
9498 + if (free_blocks) {
9499 + if (*free_blocks > bfree)
9500 + *free_blocks = bfree;
9502 + if (root_blocks) {
9503 + if (*root_blocks > broot)
9504 + *root_blocks = broot;
9509 +#define dl_prealloc_space(in, bytes) \
9510 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9511 + __FILE__, __LINE__ )
9513 +#define dl_alloc_space(in, bytes) \
9514 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9515 + __FILE__, __LINE__ )
9517 +#define dl_reserve_space(in, bytes) \
9518 + __dl_alloc_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9519 + __FILE__, __LINE__ )
9521 +#define dl_claim_space(in, bytes) (0)
9523 +#define dl_release_space(in, bytes) \
9524 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9525 + __FILE__, __LINE__ )
9527 +#define dl_free_space(in, bytes) \
9528 + __dl_free_space((in)->i_sb, (in)->i_tag, (dlsize_t)(bytes), \
9529 + __FILE__, __LINE__ )
9533 +#define dl_alloc_inode(in) \
9534 + __dl_alloc_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
9536 +#define dl_free_inode(in) \
9537 + __dl_free_inode((in)->i_sb, (in)->i_tag, __FILE__, __LINE__ )
9540 +#define dl_adjust_block(sb, tag, fb, rb) \
9541 + __dl_adjust_block(sb, tag, fb, rb, __FILE__, __LINE__ )
9545 +#warning duplicate inclusion
9547 diff -NurpP --minimal linux-3.4.103/include/linux/vs_inet.h linux-3.4.103-vs2.3.3.9/include/linux/vs_inet.h
9548 --- linux-3.4.103/include/linux/vs_inet.h 1970-01-01 00:00:00.000000000 +0000
9549 +++ linux-3.4.103-vs2.3.3.9/include/linux/vs_inet.h 2012-05-21 16:15:05.000000000 +0000
9554 +#include "vserver/base.h"
9555 +#include "vserver/network.h"
9556 +#include "vserver/debug.h"
9558 +#define IPI_LOOPBACK htonl(INADDR_LOOPBACK)
9560 +#define NXAV4(a) NIPQUAD((a)->ip[0]), NIPQUAD((a)->ip[1]), \
9561 + NIPQUAD((a)->mask), (a)->type
9562 +#define NXAV4_FMT "[" NIPQUAD_FMT "-" NIPQUAD_FMT "/" NIPQUAD_FMT ":%04x]"
9564 +#define NIPQUAD(addr) \
9565 + ((unsigned char *)&addr)[0], \
9566 + ((unsigned char *)&addr)[1], \
9567 + ((unsigned char *)&addr)[2], \
9568 + ((unsigned char *)&addr)[3]
9570 +#define NIPQUAD_FMT "%u.%u.%u.%u"
9574 +int v4_addr_match(struct nx_addr_v4 *nxa, __be32 addr, uint16_t tmask)
9576 + __be32 ip = nxa->ip[0].s_addr;
9577 + __be32 mask = nxa->mask.s_addr;
9578 + __be32 bcast = ip | ~mask;
9581 + switch (nxa->type & tmask) {
9582 + case NXA_TYPE_MASK:
9583 + ret = (ip == (addr & mask));
9585 + case NXA_TYPE_ADDR:
9589 + /* fall through to broadcast */
9590 + case NXA_MOD_BCAST:
9591 + ret = ((tmask & NXA_MOD_BCAST) && (addr == bcast));
9593 + case NXA_TYPE_RANGE:
9594 + ret = ((nxa->ip[0].s_addr <= addr) &&
9595 + (nxa->ip[1].s_addr > addr));
9597 + case NXA_TYPE_ANY:
9602 + vxdprintk(VXD_CBIT(net, 0),
9603 + "v4_addr_match(%p" NXAV4_FMT "," NIPQUAD_FMT ",%04x) = %d",
9604 + nxa, NXAV4(nxa), NIPQUAD(addr), tmask, ret);
9609 +int v4_addr_in_nx_info(struct nx_info *nxi, __be32 addr, uint16_t tmask)
9611 + struct nx_addr_v4 *nxa;
9618 + /* allow 127.0.0.1 when remapping lback */
9619 + if ((tmask & NXA_LOOPBACK) &&
9620 + (addr == IPI_LOOPBACK) &&
9621 + nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9624 + /* check for lback address */
9625 + if ((tmask & NXA_MOD_LBACK) &&
9626 + (nxi->v4_lback.s_addr == addr))
9629 + /* check for broadcast address */
9630 + if ((tmask & NXA_MOD_BCAST) &&
9631 + (nxi->v4_bcast.s_addr == addr))
9634 + /* check for v4 addresses */
9635 + for (nxa = &nxi->v4; nxa; nxa = nxa->next)
9636 + if (v4_addr_match(nxa, addr, tmask))
9640 + vxdprintk(VXD_CBIT(net, 0),
9641 + "v4_addr_in_nx_info(%p[#%u]," NIPQUAD_FMT ",%04x) = %d",
9642 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(addr), tmask, ret);
9647 +int v4_nx_addr_match(struct nx_addr_v4 *nxa, struct nx_addr_v4 *addr, uint16_t mask)
9649 + /* FIXME: needs full range checks */
9650 + return v4_addr_match(nxa, addr->ip[0].s_addr, mask);
9654 +int v4_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v4 *nxa, uint16_t mask)
9656 + struct nx_addr_v4 *ptr;
9658 + for (ptr = &nxi->v4; ptr; ptr = ptr->next)
9659 + if (v4_nx_addr_match(ptr, nxa, mask))
9664 +#include <net/inet_sock.h>
9667 + * Check if a given address matches for a socket
9669 + * nxi: the socket's nx_info if any
9670 + * addr: to be verified address
9673 +int v4_sock_addr_match (
9674 + struct nx_info *nxi,
9675 + struct inet_sock *inet,
9678 + __be32 saddr = inet->inet_rcv_saddr;
9679 + __be32 bcast = nxi ? nxi->v4_bcast.s_addr : INADDR_BROADCAST;
9681 + if (addr && (saddr == addr || bcast == addr))
9684 + return v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND);
9689 +/* inet related checks and helpers */
9698 +#include <linux/netdevice.h>
9699 +#include <linux/inetdevice.h>
9700 +#include <net/inet_sock.h>
9701 +#include <net/inet_timewait_sock.h>
9704 +int dev_in_nx_info(struct net_device *, struct nx_info *);
9705 +int v4_dev_in_nx_info(struct net_device *, struct nx_info *);
9706 +int nx_v4_addr_conflict(struct nx_info *, struct nx_info *);
9710 + * check if address is covered by socket
9712 + * sk: the socket to check against
9713 + * addr: the address in question (must be != 0)
9717 +int __v4_addr_match_socket(const struct sock *sk, struct nx_addr_v4 *nxa)
9719 + struct nx_info *nxi = sk->sk_nx_info;
9720 + __be32 saddr = sk_rcv_saddr(sk);
9722 + vxdprintk(VXD_CBIT(net, 5),
9723 + "__v4_addr_in_socket(%p," NXAV4_FMT ") %p:" NIPQUAD_FMT " %p;%lx",
9724 + sk, NXAV4(nxa), nxi, NIPQUAD(saddr), sk->sk_socket,
9725 + (sk->sk_socket?sk->sk_socket->flags:0));
9727 + if (saddr) { /* direct address match */
9728 + return v4_addr_match(nxa, saddr, -1);
9729 + } else if (nxi) { /* match against nx_info */
9730 + return v4_nx_addr_in_nx_info(nxi, nxa, -1);
9731 + } else { /* unrestricted any socket */
9739 +int nx_dev_visible(struct nx_info *nxi, struct net_device *dev)
9741 + vxdprintk(VXD_CBIT(net, 1),
9742 + "nx_dev_visible(%p[#%u],%p " VS_Q("%s") ") %d",
9743 + nxi, nxi ? nxi->nx_id : 0, dev, dev->name,
9744 + nxi ? dev_in_nx_info(dev, nxi) : 0);
9746 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9748 + if (dev_in_nx_info(dev, nxi))
9755 +int v4_ifa_in_nx_info(struct in_ifaddr *ifa, struct nx_info *nxi)
9761 + return v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW);
9765 +int nx_v4_ifa_visible(struct nx_info *nxi, struct in_ifaddr *ifa)
9767 + vxdprintk(VXD_CBIT(net, 1), "nx_v4_ifa_visible(%p[#%u],%p) %d",
9768 + nxi, nxi ? nxi->nx_id : 0, ifa,
9769 + nxi ? v4_ifa_in_nx_info(ifa, nxi) : 0);
9771 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
9773 + if (v4_ifa_in_nx_info(ifa, nxi))
9779 +struct nx_v4_sock_addr {
9780 + __be32 saddr; /* Address used for validation */
9781 + __be32 baddr; /* Address used for socket bind */
9785 +int v4_map_sock_addr(struct inet_sock *inet, struct sockaddr_in *addr,
9786 + struct nx_v4_sock_addr *nsa)
9788 + struct sock *sk = &inet->sk;
9789 + struct nx_info *nxi = sk->sk_nx_info;
9790 + __be32 saddr = addr->sin_addr.s_addr;
9791 + __be32 baddr = saddr;
9793 + vxdprintk(VXD_CBIT(net, 3),
9794 + "inet_bind(%p)* %p,%p;%lx " NIPQUAD_FMT,
9795 + sk, sk->sk_nx_info, sk->sk_socket,
9796 + (sk->sk_socket ? sk->sk_socket->flags : 0),
9800 + if (saddr == INADDR_ANY) {
9801 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0))
9802 + baddr = nxi->v4.ip[0].s_addr;
9803 + } else if (saddr == IPI_LOOPBACK) {
9804 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9805 + baddr = nxi->v4_lback.s_addr;
9806 + } else if (!ipv4_is_multicast(saddr) ||
9807 + !nx_info_ncaps(nxi, NXC_MULTICAST)) {
9808 + /* normal address bind */
9809 + if (!v4_addr_in_nx_info(nxi, saddr, NXA_MASK_BIND))
9810 + return -EADDRNOTAVAIL;
9814 + vxdprintk(VXD_CBIT(net, 3),
9815 + "inet_bind(%p) " NIPQUAD_FMT ", " NIPQUAD_FMT,
9816 + sk, NIPQUAD(saddr), NIPQUAD(baddr));
9818 + nsa->saddr = saddr;
9819 + nsa->baddr = baddr;
9824 +void v4_set_sock_addr(struct inet_sock *inet, struct nx_v4_sock_addr *nsa)
9826 + inet->inet_saddr = nsa->baddr;
9827 + inet->inet_rcv_saddr = nsa->baddr;
9832 + * helper to simplify inet_lookup_listener
9834 + * nxi: the socket's nx_info if any
9835 + * addr: to be verified address
9836 + * saddr: socket address
9838 +static inline int v4_inet_addr_match (
9839 + struct nx_info *nxi,
9843 + if (addr && (saddr == addr))
9846 + return nxi ? v4_addr_in_nx_info(nxi, addr, NXA_MASK_BIND) : 1;
9850 +static inline __be32 nx_map_sock_lback(struct nx_info *nxi, __be32 addr)
9852 + if (nx_info_flags(nxi, NXF_HIDE_LBACK, 0) &&
9853 + (addr == nxi->v4_lback.s_addr))
9854 + return IPI_LOOPBACK;
9859 +int nx_info_has_v4(struct nx_info *nxi)
9865 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0))
9870 +#else /* CONFIG_INET */
9873 +int nx_dev_visible(struct nx_info *n, struct net_device *d)
9879 +int nx_v4_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
9885 +int v4_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
9891 +int nx_info_has_v4(struct nx_info *nxi)
9896 +#endif /* CONFIG_INET */
9898 +#define current_nx_info_has_v4() \
9899 + nx_info_has_v4(current_nx_info())
9902 +// #warning duplicate inclusion
9904 diff -NurpP --minimal linux-3.4.103/include/linux/vs_inet6.h linux-3.4.103-vs2.3.3.9/include/linux/vs_inet6.h
9905 --- linux-3.4.103/include/linux/vs_inet6.h 1970-01-01 00:00:00.000000000 +0000
9906 +++ linux-3.4.103-vs2.3.3.9/include/linux/vs_inet6.h 2012-05-21 16:15:05.000000000 +0000
9908 +#ifndef _VS_INET6_H
9909 +#define _VS_INET6_H
9911 +#include "vserver/base.h"
9912 +#include "vserver/network.h"
9913 +#include "vserver/debug.h"
9915 +#include <net/ipv6.h>
9917 +#define NXAV6(a) &(a)->ip, &(a)->mask, (a)->prefix, (a)->type
9918 +#define NXAV6_FMT "[%pI6/%pI6/%d:%04x]"
9924 +int v6_addr_match(struct nx_addr_v6 *nxa,
9925 + const struct in6_addr *addr, uint16_t mask)
9929 + switch (nxa->type & mask) {
9930 + case NXA_TYPE_MASK:
9931 + ret = ipv6_masked_addr_cmp(&nxa->ip, &nxa->mask, addr);
9933 + case NXA_TYPE_ADDR:
9934 + ret = ipv6_addr_equal(&nxa->ip, addr);
9936 + case NXA_TYPE_ANY:
9940 + vxdprintk(VXD_CBIT(net, 0),
9941 + "v6_addr_match(%p" NXAV6_FMT ",%pI6,%04x) = %d",
9942 + nxa, NXAV6(nxa), addr, mask, ret);
9947 +int v6_addr_in_nx_info(struct nx_info *nxi,
9948 + const struct in6_addr *addr, uint16_t mask)
9950 + struct nx_addr_v6 *nxa;
9955 + for (nxa = &nxi->v6; nxa; nxa = nxa->next)
9956 + if (v6_addr_match(nxa, addr, mask))
9960 + vxdprintk(VXD_CBIT(net, 0),
9961 + "v6_addr_in_nx_info(%p[#%u],%pI6,%04x) = %d",
9962 + nxi, nxi ? nxi->nx_id : 0, addr, mask, ret);
9967 +int v6_nx_addr_match(struct nx_addr_v6 *nxa, struct nx_addr_v6 *addr, uint16_t mask)
9969 + /* FIXME: needs full range checks */
9970 + return v6_addr_match(nxa, &addr->ip, mask);
9974 +int v6_nx_addr_in_nx_info(struct nx_info *nxi, struct nx_addr_v6 *nxa, uint16_t mask)
9976 + struct nx_addr_v6 *ptr;
9978 + for (ptr = &nxi->v6; ptr; ptr = ptr->next)
9979 + if (v6_nx_addr_match(ptr, nxa, mask))
9986 + * Check if a given address matches for a socket
9988 + * nxi: the socket's nx_info if any
9989 + * addr: to be verified address
9992 +int v6_sock_addr_match (
9993 + struct nx_info *nxi,
9994 + struct inet_sock *inet,
9995 + struct in6_addr *addr)
9997 + struct sock *sk = &inet->sk;
9998 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
10000 + if (!ipv6_addr_any(addr) &&
10001 + ipv6_addr_equal(saddr, addr))
10003 + if (ipv6_addr_any(saddr))
10004 + return v6_addr_in_nx_info(nxi, addr, -1);
10009 + * check if address is covered by socket
10011 + * sk: the socket to check against
10012 + * addr: the address in question (must be != 0)
10016 +int __v6_addr_match_socket(const struct sock *sk, struct nx_addr_v6 *nxa)
10018 + struct nx_info *nxi = sk->sk_nx_info;
10019 + struct in6_addr *saddr = inet6_rcv_saddr(sk);
10021 + vxdprintk(VXD_CBIT(net, 5),
10022 + "__v6_addr_in_socket(%p," NXAV6_FMT ") %p:%pI6 %p;%lx",
10023 + sk, NXAV6(nxa), nxi, saddr, sk->sk_socket,
10024 + (sk->sk_socket?sk->sk_socket->flags:0));
10026 + if (!ipv6_addr_any(saddr)) { /* direct address match */
10027 + return v6_addr_match(nxa, saddr, -1);
10028 + } else if (nxi) { /* match against nx_info */
10029 + return v6_nx_addr_in_nx_info(nxi, nxa, -1);
10030 + } else { /* unrestricted any socket */
10036 +/* inet related checks and helpers */
10040 +struct net_device;
10044 +#include <linux/netdevice.h>
10045 +#include <linux/inetdevice.h>
10046 +#include <net/inet_timewait_sock.h>
10049 +int dev_in_nx_info(struct net_device *, struct nx_info *);
10050 +int v6_dev_in_nx_info(struct net_device *, struct nx_info *);
10051 +int nx_v6_addr_conflict(struct nx_info *, struct nx_info *);
10056 +int v6_ifa_in_nx_info(struct inet6_ifaddr *ifa, struct nx_info *nxi)
10062 + return v6_addr_in_nx_info(nxi, &ifa->addr, -1);
10066 +int nx_v6_ifa_visible(struct nx_info *nxi, struct inet6_ifaddr *ifa)
10068 + vxdprintk(VXD_CBIT(net, 1), "nx_v6_ifa_visible(%p[#%u],%p) %d",
10069 + nxi, nxi ? nxi->nx_id : 0, ifa,
10070 + nxi ? v6_ifa_in_nx_info(ifa, nxi) : 0);
10072 + if (!nx_info_flags(nxi, NXF_HIDE_NETIF, 0))
10074 + if (v6_ifa_in_nx_info(ifa, nxi))
10080 +struct nx_v6_sock_addr {
10081 + struct in6_addr saddr; /* Address used for validation */
10082 + struct in6_addr baddr; /* Address used for socket bind */
10086 +int v6_map_sock_addr(struct inet_sock *inet, struct sockaddr_in6 *addr,
10087 + struct nx_v6_sock_addr *nsa)
10089 + // struct sock *sk = &inet->sk;
10090 + // struct nx_info *nxi = sk->sk_nx_info;
10091 + struct in6_addr saddr = addr->sin6_addr;
10092 + struct in6_addr baddr = saddr;
10094 + nsa->saddr = saddr;
10095 + nsa->baddr = baddr;
10100 +void v6_set_sock_addr(struct inet_sock *inet, struct nx_v6_sock_addr *nsa)
10102 + // struct sock *sk = &inet->sk;
10103 + // struct in6_addr *saddr = inet6_rcv_saddr(sk);
10105 + // *saddr = nsa->baddr;
10106 + // inet->inet_saddr = nsa->baddr;
10110 +int nx_info_has_v6(struct nx_info *nxi)
10114 + if (NX_IPV6(nxi))
10119 +#else /* CONFIG_IPV6 */
10122 +int nx_v6_dev_visible(struct nx_info *n, struct net_device *d)
10129 +int nx_v6_addr_conflict(struct nx_info *n, uint32_t a, const struct sock *s)
10135 +int v6_ifa_in_nx_info(struct in_ifaddr *a, struct nx_info *n)
10141 +int nx_info_has_v6(struct nx_info *nxi)
10146 +#endif /* CONFIG_IPV6 */
10148 +#define current_nx_info_has_v6() \
10149 + nx_info_has_v6(current_nx_info())
10152 +#warning duplicate inclusion
10154 diff -NurpP --minimal linux-3.4.103/include/linux/vs_limit.h linux-3.4.103-vs2.3.3.9/include/linux/vs_limit.h
10155 --- linux-3.4.103/include/linux/vs_limit.h 1970-01-01 00:00:00.000000000 +0000
10156 +++ linux-3.4.103-vs2.3.3.9/include/linux/vs_limit.h 2012-05-21 16:15:05.000000000 +0000
10158 +#ifndef _VS_LIMIT_H
10159 +#define _VS_LIMIT_H
10161 +#include "vserver/limit.h"
10162 +#include "vserver/base.h"
10163 +#include "vserver/context.h"
10164 +#include "vserver/debug.h"
10165 +#include "vserver/context.h"
10166 +#include "vserver/limit_int.h"
10169 +#define vx_acc_cres(v, d, p, r) \
10170 + __vx_acc_cres(v, r, d, p, __FILE__, __LINE__)
10172 +#define vx_acc_cres_cond(x, d, p, r) \
10173 + __vx_acc_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
10174 + r, d, p, __FILE__, __LINE__)
10177 +#define vx_add_cres(v, a, p, r) \
10178 + __vx_add_cres(v, r, a, p, __FILE__, __LINE__)
10179 +#define vx_sub_cres(v, a, p, r) vx_add_cres(v, -(a), p, r)
10181 +#define vx_add_cres_cond(x, a, p, r) \
10182 + __vx_add_cres(((x) == vx_current_xid()) ? current_vx_info() : 0, \
10183 + r, a, p, __FILE__, __LINE__)
10184 +#define vx_sub_cres_cond(x, a, p, r) vx_add_cres_cond(x, -(a), p, r)
10187 +/* process and file limits */
10189 +#define vx_nproc_inc(p) \
10190 + vx_acc_cres((p)->vx_info, 1, p, RLIMIT_NPROC)
10192 +#define vx_nproc_dec(p) \
10193 + vx_acc_cres((p)->vx_info,-1, p, RLIMIT_NPROC)
10195 +#define vx_files_inc(f) \
10196 + vx_acc_cres_cond((f)->f_xid, 1, f, RLIMIT_NOFILE)
10198 +#define vx_files_dec(f) \
10199 + vx_acc_cres_cond((f)->f_xid,-1, f, RLIMIT_NOFILE)
10201 +#define vx_locks_inc(l) \
10202 + vx_acc_cres_cond((l)->fl_xid, 1, l, RLIMIT_LOCKS)
10204 +#define vx_locks_dec(l) \
10205 + vx_acc_cres_cond((l)->fl_xid,-1, l, RLIMIT_LOCKS)
10207 +#define vx_openfd_inc(f) \
10208 + vx_acc_cres(current_vx_info(), 1, (void *)(long)(f), VLIMIT_OPENFD)
10210 +#define vx_openfd_dec(f) \
10211 + vx_acc_cres(current_vx_info(),-1, (void *)(long)(f), VLIMIT_OPENFD)
10214 +#define vx_cres_avail(v, n, r) \
10215 + __vx_cres_avail(v, r, n, __FILE__, __LINE__)
10218 +#define vx_nproc_avail(n) \
10219 + vx_cres_avail(current_vx_info(), n, RLIMIT_NPROC)
10221 +#define vx_files_avail(n) \
10222 + vx_cres_avail(current_vx_info(), n, RLIMIT_NOFILE)
10224 +#define vx_locks_avail(n) \
10225 + vx_cres_avail(current_vx_info(), n, RLIMIT_LOCKS)
10227 +#define vx_openfd_avail(n) \
10228 + vx_cres_avail(current_vx_info(), n, VLIMIT_OPENFD)
10231 +/* dentry limits */
10233 +#define vx_dentry_inc(d) do { \
10234 + if ((d)->d_count == 1) \
10235 + vx_acc_cres(current_vx_info(), 1, d, VLIMIT_DENTRY); \
10238 +#define vx_dentry_dec(d) do { \
10239 + if ((d)->d_count == 0) \
10240 + vx_acc_cres(current_vx_info(),-1, d, VLIMIT_DENTRY); \
10243 +#define vx_dentry_avail(n) \
10244 + vx_cres_avail(current_vx_info(), n, VLIMIT_DENTRY)
10247 +/* socket limits */
10249 +#define vx_sock_inc(s) \
10250 + vx_acc_cres((s)->sk_vx_info, 1, s, VLIMIT_NSOCK)
10252 +#define vx_sock_dec(s) \
10253 + vx_acc_cres((s)->sk_vx_info,-1, s, VLIMIT_NSOCK)
10255 +#define vx_sock_avail(n) \
10256 + vx_cres_avail(current_vx_info(), n, VLIMIT_NSOCK)
10259 +/* ipc resource limits */
10261 +#define vx_ipcmsg_add(v, u, a) \
10262 + vx_add_cres(v, a, u, RLIMIT_MSGQUEUE)
10264 +#define vx_ipcmsg_sub(v, u, a) \
10265 + vx_sub_cres(v, a, u, RLIMIT_MSGQUEUE)
10267 +#define vx_ipcmsg_avail(v, a) \
10268 + vx_cres_avail(v, a, RLIMIT_MSGQUEUE)
10271 +#define vx_ipcshm_add(v, k, a) \
10272 + vx_add_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
10274 +#define vx_ipcshm_sub(v, k, a) \
10275 + vx_sub_cres(v, a, (void *)(long)(k), VLIMIT_SHMEM)
10277 +#define vx_ipcshm_avail(v, a) \
10278 + vx_cres_avail(v, a, VLIMIT_SHMEM)
10281 +#define vx_semary_inc(a) \
10282 + vx_acc_cres(current_vx_info(), 1, a, VLIMIT_SEMARY)
10284 +#define vx_semary_dec(a) \
10285 + vx_acc_cres(current_vx_info(), -1, a, VLIMIT_SEMARY)
10288 +#define vx_nsems_add(a,n) \
10289 + vx_add_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10291 +#define vx_nsems_sub(a,n) \
10292 + vx_sub_cres(current_vx_info(), n, a, VLIMIT_NSEMS)
10296 +#warning duplicate inclusion
10298 diff -NurpP --minimal linux-3.4.103/include/linux/vs_network.h linux-3.4.103-vs2.3.3.9/include/linux/vs_network.h
10299 --- linux-3.4.103/include/linux/vs_network.h 1970-01-01 00:00:00.000000000 +0000
10300 +++ linux-3.4.103-vs2.3.3.9/include/linux/vs_network.h 2012-05-21 16:15:05.000000000 +0000
10302 +#ifndef _NX_VS_NETWORK_H
10303 +#define _NX_VS_NETWORK_H
10305 +#include "vserver/context.h"
10306 +#include "vserver/network.h"
10307 +#include "vserver/base.h"
10308 +#include "vserver/check.h"
10309 +#include "vserver/debug.h"
10311 +#include <linux/sched.h>
10314 +#define get_nx_info(i) __get_nx_info(i, __FILE__, __LINE__)
10316 +static inline struct nx_info *__get_nx_info(struct nx_info *nxi,
10317 + const char *_file, int _line)
10322 + vxlprintk(VXD_CBIT(nid, 2), "get_nx_info(%p[#%d.%d])",
10323 + nxi, nxi ? nxi->nx_id : 0,
10324 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10327 + atomic_inc(&nxi->nx_usecnt);
10332 +extern void free_nx_info(struct nx_info *);
10334 +#define put_nx_info(i) __put_nx_info(i, __FILE__, __LINE__)
10336 +static inline void __put_nx_info(struct nx_info *nxi, const char *_file, int _line)
10341 + vxlprintk(VXD_CBIT(nid, 2), "put_nx_info(%p[#%d.%d])",
10342 + nxi, nxi ? nxi->nx_id : 0,
10343 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10346 + if (atomic_dec_and_test(&nxi->nx_usecnt))
10347 + free_nx_info(nxi);
10351 +#define init_nx_info(p, i) __init_nx_info(p, i, __FILE__, __LINE__)
10353 +static inline void __init_nx_info(struct nx_info **nxp, struct nx_info *nxi,
10354 + const char *_file, int _line)
10357 + vxlprintk(VXD_CBIT(nid, 3),
10358 + "init_nx_info(%p[#%d.%d])",
10359 + nxi, nxi ? nxi->nx_id : 0,
10360 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10363 + atomic_inc(&nxi->nx_usecnt);
10369 +#define set_nx_info(p, i) __set_nx_info(p, i, __FILE__, __LINE__)
10371 +static inline void __set_nx_info(struct nx_info **nxp, struct nx_info *nxi,
10372 + const char *_file, int _line)
10374 + struct nx_info *nxo;
10379 + vxlprintk(VXD_CBIT(nid, 3), "set_nx_info(%p[#%d.%d])",
10380 + nxi, nxi ? nxi->nx_id : 0,
10381 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10384 + atomic_inc(&nxi->nx_usecnt);
10385 + nxo = xchg(nxp, nxi);
10389 +#define clr_nx_info(p) __clr_nx_info(p, __FILE__, __LINE__)
10391 +static inline void __clr_nx_info(struct nx_info **nxp,
10392 + const char *_file, int _line)
10394 + struct nx_info *nxo;
10396 + nxo = xchg(nxp, NULL);
10400 + vxlprintk(VXD_CBIT(nid, 3), "clr_nx_info(%p[#%d.%d])",
10401 + nxo, nxo ? nxo->nx_id : 0,
10402 + nxo ? atomic_read(&nxo->nx_usecnt) : 0,
10405 + if (atomic_dec_and_test(&nxo->nx_usecnt))
10406 + free_nx_info(nxo);
10410 +#define claim_nx_info(v, p) __claim_nx_info(v, p, __FILE__, __LINE__)
10412 +static inline void __claim_nx_info(struct nx_info *nxi,
10413 + struct task_struct *task, const char *_file, int _line)
10415 + vxlprintk(VXD_CBIT(nid, 3), "claim_nx_info(%p[#%d.%d.%d]) %p",
10416 + nxi, nxi ? nxi->nx_id : 0,
10417 + nxi?atomic_read(&nxi->nx_usecnt):0,
10418 + nxi?atomic_read(&nxi->nx_tasks):0,
10419 + task, _file, _line);
10421 + atomic_inc(&nxi->nx_tasks);
10425 +extern void unhash_nx_info(struct nx_info *);
10427 +#define release_nx_info(v, p) __release_nx_info(v, p, __FILE__, __LINE__)
10429 +static inline void __release_nx_info(struct nx_info *nxi,
10430 + struct task_struct *task, const char *_file, int _line)
10432 + vxlprintk(VXD_CBIT(nid, 3), "release_nx_info(%p[#%d.%d.%d]) %p",
10433 + nxi, nxi ? nxi->nx_id : 0,
10434 + nxi ? atomic_read(&nxi->nx_usecnt) : 0,
10435 + nxi ? atomic_read(&nxi->nx_tasks) : 0,
10436 + task, _file, _line);
10440 + if (atomic_dec_and_test(&nxi->nx_tasks))
10441 + unhash_nx_info(nxi);
10445 +#define task_get_nx_info(i) __task_get_nx_info(i, __FILE__, __LINE__)
10447 +static __inline__ struct nx_info *__task_get_nx_info(struct task_struct *p,
10448 + const char *_file, int _line)
10450 + struct nx_info *nxi;
10453 + vxlprintk(VXD_CBIT(nid, 5), "task_get_nx_info(%p)",
10454 + p, _file, _line);
10455 + nxi = __get_nx_info(p->nx_info, _file, _line);
10461 +static inline void exit_nx_info(struct task_struct *p)
10464 + release_nx_info(p->nx_info, p);
10469 +#warning duplicate inclusion
10471 diff -NurpP --minimal linux-3.4.103/include/linux/vs_pid.h linux-3.4.103-vs2.3.3.9/include/linux/vs_pid.h
10472 --- linux-3.4.103/include/linux/vs_pid.h 1970-01-01 00:00:00.000000000 +0000
10473 +++ linux-3.4.103-vs2.3.3.9/include/linux/vs_pid.h 2012-05-21 16:15:05.000000000 +0000
10478 +#include "vserver/base.h"
10479 +#include "vserver/check.h"
10480 +#include "vserver/context.h"
10481 +#include "vserver/debug.h"
10482 +#include "vserver/pid.h"
10483 +#include <linux/pid_namespace.h>
10486 +#define VXF_FAKE_INIT (VXF_INFO_INIT | VXF_STATE_INIT)
10489 +int vx_proc_task_visible(struct task_struct *task)
10491 + if ((task->pid == 1) &&
10492 + !vx_flags(VXF_FAKE_INIT, VXF_FAKE_INIT))
10493 + /* show a blend through init */
10495 + if (vx_check(vx_task_xid(task), VS_WATCH | VS_IDENT))
10502 +#define find_task_by_real_pid(pid) find_task_by_pid_ns(pid, &init_pid_ns)
10506 +struct task_struct *vx_get_proc_task(struct inode *inode, struct pid *pid)
10508 + struct task_struct *task = get_pid_task(pid, PIDTYPE_PID);
10510 + if (task && !vx_proc_task_visible(task)) {
10511 + vxdprintk(VXD_CBIT(misc, 6),
10512 + "dropping task (get) %p[#%u,%u] for %p[#%u,%u]",
10513 + task, task->xid, task->pid,
10514 + current, current->xid, current->pid);
10515 + put_task_struct(task);
10523 +#warning duplicate inclusion
10525 diff -NurpP --minimal linux-3.4.103/include/linux/vs_sched.h linux-3.4.103-vs2.3.3.9/include/linux/vs_sched.h
10526 --- linux-3.4.103/include/linux/vs_sched.h 1970-01-01 00:00:00.000000000 +0000
10527 +++ linux-3.4.103-vs2.3.3.9/include/linux/vs_sched.h 2012-05-21 16:15:05.000000000 +0000
10529 +#ifndef _VS_SCHED_H
10530 +#define _VS_SCHED_H
10532 +#include "vserver/base.h"
10533 +#include "vserver/context.h"
10534 +#include "vserver/sched.h"
10537 +#define MAX_PRIO_BIAS 20
10538 +#define MIN_PRIO_BIAS -20
10541 +int vx_adjust_prio(struct task_struct *p, int prio, int max_user)
10543 + struct vx_info *vxi = p->vx_info;
10546 + prio += vx_cpu(vxi, sched_pc).prio_bias;
10550 +static inline void vx_account_user(struct vx_info *vxi,
10551 + cputime_t cputime, int nice)
10555 + vx_cpu(vxi, sched_pc).user_ticks += cputime;
10558 +static inline void vx_account_system(struct vx_info *vxi,
10559 + cputime_t cputime, int idle)
10563 + vx_cpu(vxi, sched_pc).sys_ticks += cputime;
10567 +#warning duplicate inclusion
10569 diff -NurpP --minimal linux-3.4.103/include/linux/vs_socket.h linux-3.4.103-vs2.3.3.9/include/linux/vs_socket.h
10570 --- linux-3.4.103/include/linux/vs_socket.h 1970-01-01 00:00:00.000000000 +0000
10571 +++ linux-3.4.103-vs2.3.3.9/include/linux/vs_socket.h 2012-05-21 16:15:05.000000000 +0000
10573 +#ifndef _VS_SOCKET_H
10574 +#define _VS_SOCKET_H
10576 +#include "vserver/debug.h"
10577 +#include "vserver/base.h"
10578 +#include "vserver/cacct.h"
10579 +#include "vserver/context.h"
10580 +#include "vserver/tag.h"
10583 +/* socket accounting */
10585 +#include <linux/socket.h>
10587 +static inline int vx_sock_type(int family)
10589 + switch (family) {
10591 + return VXA_SOCK_UNSPEC;
10593 + return VXA_SOCK_UNIX;
10595 + return VXA_SOCK_INET;
10597 + return VXA_SOCK_INET6;
10599 + return VXA_SOCK_PACKET;
10601 + return VXA_SOCK_OTHER;
10605 +#define vx_acc_sock(v, f, p, s) \
10606 + __vx_acc_sock(v, f, p, s, __FILE__, __LINE__)
10608 +static inline void __vx_acc_sock(struct vx_info *vxi,
10609 + int family, int pos, int size, char *file, int line)
10612 + int type = vx_sock_type(family);
10614 + atomic_long_inc(&vxi->cacct.sock[type][pos].count);
10615 + atomic_long_add(size, &vxi->cacct.sock[type][pos].total);
10619 +#define vx_sock_recv(sk, s) \
10620 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 0, s)
10621 +#define vx_sock_send(sk, s) \
10622 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 1, s)
10623 +#define vx_sock_fail(sk, s) \
10624 + vx_acc_sock((sk)->sk_vx_info, (sk)->sk_family, 2, s)
10627 +#define sock_vx_init(s) do { \
10628 + (s)->sk_xid = 0; \
10629 + (s)->sk_vx_info = NULL; \
10632 +#define sock_nx_init(s) do { \
10633 + (s)->sk_nid = 0; \
10634 + (s)->sk_nx_info = NULL; \
10638 +#warning duplicate inclusion
10640 diff -NurpP --minimal linux-3.4.103/include/linux/vs_tag.h linux-3.4.103-vs2.3.3.9/include/linux/vs_tag.h
10641 --- linux-3.4.103/include/linux/vs_tag.h 1970-01-01 00:00:00.000000000 +0000
10642 +++ linux-3.4.103-vs2.3.3.9/include/linux/vs_tag.h 2012-05-21 16:15:05.000000000 +0000
10647 +#include <linux/vserver/tag.h>
10649 +/* check conditions */
10651 +#define DX_ADMIN 0x0001
10652 +#define DX_WATCH 0x0002
10653 +#define DX_HOSTID 0x0008
10655 +#define DX_IDENT 0x0010
10657 +#define DX_ARG_MASK 0x0010
10660 +#define dx_task_tag(t) ((t)->tag)
10662 +#define dx_current_tag() dx_task_tag(current)
10664 +#define dx_check(c, m) __dx_check(dx_current_tag(), c, m)
10666 +#define dx_weak_check(c, m) ((m) ? dx_check(c, m) : 1)
10670 + * check current context for ADMIN/WATCH and
10671 + * optionally against supplied argument
10673 +static inline int __dx_check(tag_t cid, tag_t id, unsigned int mode)
10675 + if (mode & DX_ARG_MASK) {
10676 + if ((mode & DX_IDENT) && (id == cid))
10679 + return (((mode & DX_ADMIN) && (cid == 0)) ||
10680 + ((mode & DX_WATCH) && (cid == 1)) ||
10681 + ((mode & DX_HOSTID) && (id == 0)));
10685 +int dx_permission(const struct inode *inode, int mask);
10689 +#warning duplicate inclusion
10691 diff -NurpP --minimal linux-3.4.103/include/linux/vs_time.h linux-3.4.103-vs2.3.3.9/include/linux/vs_time.h
10692 --- linux-3.4.103/include/linux/vs_time.h 1970-01-01 00:00:00.000000000 +0000
10693 +++ linux-3.4.103-vs2.3.3.9/include/linux/vs_time.h 2012-05-21 16:15:05.000000000 +0000
10695 +#ifndef _VS_TIME_H
10696 +#define _VS_TIME_H
10699 +/* time faking stuff */
10701 +#ifdef CONFIG_VSERVER_VTIME
10703 +extern void vx_adjust_timespec(struct timespec *ts);
10704 +extern int vx_settimeofday(const struct timespec *ts);
10707 +#define vx_adjust_timespec(t) do { } while (0)
10708 +#define vx_settimeofday(t) do_settimeofday(t)
10712 +#warning duplicate inclusion
10714 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/Kbuild linux-3.4.103-vs2.3.3.9/include/linux/vserver/Kbuild
10715 --- linux-3.4.103/include/linux/vserver/Kbuild 1970-01-01 00:00:00.000000000 +0000
10716 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/Kbuild 2012-05-21 16:15:05.000000000 +0000
10719 +header-y += context_cmd.h network_cmd.h space_cmd.h \
10720 + cacct_cmd.h cvirt_cmd.h limit_cmd.h dlimit_cmd.h \
10721 + inode_cmd.h tag_cmd.h sched_cmd.h signal_cmd.h \
10722 + debug_cmd.h device_cmd.h
10724 +header-y += switch.h network.h monitor.h inode.h device.h
10726 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/base.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/base.h
10727 --- linux-3.4.103/include/linux/vserver/base.h 1970-01-01 00:00:00.000000000 +0000
10728 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/base.h 2012-05-21 16:15:05.000000000 +0000
10730 +#ifndef _VX_BASE_H
10731 +#define _VX_BASE_H
10734 +/* context state changes */
10746 +#define vx_task_xid(t) ((t)->xid)
10748 +#define vx_current_xid() vx_task_xid(current)
10750 +#define current_vx_info() (current->vx_info)
10753 +#define nx_task_nid(t) ((t)->nid)
10755 +#define nx_current_nid() nx_task_nid(current)
10757 +#define current_nx_info() (current->nx_info)
10760 +/* generic flag merging */
10762 +#define vs_check_flags(v, m, f) (((v) & (m)) ^ (f))
10764 +#define vs_mask_flags(v, f, m) (((v) & ~(m)) | ((f) & (m)))
10766 +#define vs_mask_mask(v, f, m) (((v) & ~(m)) | ((v) & (f) & (m)))
10768 +#define vs_check_bit(v, n) ((v) & (1LL << (n)))
10771 +/* context flags */
10773 +#define __vx_flags(v) ((v) ? (v)->vx_flags : 0)
10775 +#define vx_current_flags() __vx_flags(current_vx_info())
10777 +#define vx_info_flags(v, m, f) \
10778 + vs_check_flags(__vx_flags(v), m, f)
10780 +#define task_vx_flags(t, m, f) \
10781 + ((t) && vx_info_flags((t)->vx_info, m, f))
10783 +#define vx_flags(m, f) vx_info_flags(current_vx_info(), m, f)
10786 +/* context caps */
10788 +#define __vx_ccaps(v) ((v) ? (v)->vx_ccaps : 0)
10790 +#define vx_current_ccaps() __vx_ccaps(current_vx_info())
10792 +#define vx_info_ccaps(v, c) (__vx_ccaps(v) & (c))
10794 +#define vx_ccaps(c) vx_info_ccaps(current_vx_info(), (c))
10798 +/* network flags */
10800 +#define __nx_flags(n) ((n) ? (n)->nx_flags : 0)
10802 +#define nx_current_flags() __nx_flags(current_nx_info())
10804 +#define nx_info_flags(n, m, f) \
10805 + vs_check_flags(__nx_flags(n), m, f)
10807 +#define task_nx_flags(t, m, f) \
10808 + ((t) && nx_info_flags((t)->nx_info, m, f))
10810 +#define nx_flags(m, f) nx_info_flags(current_nx_info(), m, f)
10813 +/* network caps */
10815 +#define __nx_ncaps(n) ((n) ? (n)->nx_ncaps : 0)
10817 +#define nx_current_ncaps() __nx_ncaps(current_nx_info())
10819 +#define nx_info_ncaps(n, c) (__nx_ncaps(n) & (c))
10821 +#define nx_ncaps(c) nx_info_ncaps(current_nx_info(), c)
10824 +/* context mask capabilities */
10826 +#define __vx_mcaps(v) ((v) ? (v)->vx_ccaps >> 32UL : ~0 )
10828 +#define vx_info_mcaps(v, c) (__vx_mcaps(v) & (c))
10830 +#define vx_mcaps(c) vx_info_mcaps(current_vx_info(), c)
10833 +/* context bcap mask */
10835 +#define __vx_bcaps(v) ((v)->vx_bcaps)
10837 +#define vx_current_bcaps() __vx_bcaps(current_vx_info())
10840 +/* mask given bcaps */
10842 +#define vx_info_mbcaps(v, c) ((v) ? cap_intersect(__vx_bcaps(v), c) : c)
10844 +#define vx_mbcaps(c) vx_info_mbcaps(current_vx_info(), c)
10847 +/* masked cap_bset */
10849 +#define vx_info_cap_bset(v) vx_info_mbcaps(v, current->cap_bset)
10851 +#define vx_current_cap_bset() vx_info_cap_bset(current_vx_info())
10854 +#define vx_info_mbcap(v, b) \
10855 + (!vx_info_flags(v, VXF_STATE_SETUP, 0) ? \
10856 + vx_info_bcaps(v, b) : (b))
10858 +#define task_vx_mbcap(t, b) \
10859 + vx_info_mbcap((t)->vx_info, (t)->b)
10861 +#define vx_mbcap(b) task_vx_mbcap(current, b)
10864 +#define vx_cap_raised(v, c, f) cap_raised(vx_info_mbcaps(v, c), f)
10866 +#define vx_capable(b, c) (capable(b) || \
10867 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10869 +#define vx_ns_capable(n, b, c) (ns_capable(n, b) || \
10870 + (cap_raised(current_cap(), b) && vx_ccaps(c)))
10872 +#define nx_capable(b, c) (capable(b) || \
10873 + (cap_raised(current_cap(), b) && nx_ncaps(c)))
10875 +#define vx_task_initpid(t, n) \
10876 + ((t)->vx_info && \
10877 + ((t)->vx_info->vx_initpid == (n)))
10879 +#define vx_current_initpid(n) vx_task_initpid(current, n)
10882 +/* context unshare mask */
10884 +#define __vx_umask(v) ((v)->vx_umask)
10886 +#define vx_current_umask() __vx_umask(current_vx_info())
10888 +#define vx_can_unshare(b, f) (capable(b) || \
10889 + (cap_raised(current_cap(), b) && \
10890 + !((f) & ~vx_current_umask())))
10893 +#define __vx_wmask(v) ((v)->vx_wmask)
10895 +#define vx_current_wmask() __vx_wmask(current_vx_info())
10898 +#define __vx_state(v) ((v) ? ((v)->vx_state) : 0)
10900 +#define vx_info_state(v, m) (__vx_state(v) & (m))
10903 +#define __nx_state(n) ((n) ? ((n)->nx_state) : 0)
10905 +#define nx_info_state(n, m) (__nx_state(n) & (m))
10908 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/cacct.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/cacct.h
10909 --- linux-3.4.103/include/linux/vserver/cacct.h 1970-01-01 00:00:00.000000000 +0000
10910 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/cacct.h 2012-05-21 16:15:05.000000000 +0000
10912 +#ifndef _VX_CACCT_H
10913 +#define _VX_CACCT_H
10916 +enum sock_acc_field {
10917 + VXA_SOCK_UNSPEC = 0,
10923 + VXA_SOCK_SIZE /* array size */
10926 +#endif /* _VX_CACCT_H */
10927 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/cacct_cmd.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/cacct_cmd.h
10928 --- linux-3.4.103/include/linux/vserver/cacct_cmd.h 1970-01-01 00:00:00.000000000 +0000
10929 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/cacct_cmd.h 2012-05-21 16:15:05.000000000 +0000
10931 +#ifndef _VX_CACCT_CMD_H
10932 +#define _VX_CACCT_CMD_H
10935 +/* virtual host info name commands */
10937 +#define VCMD_sock_stat VC_CMD(VSTAT, 5, 0)
10939 +struct vcmd_sock_stat_v0 {
10941 + uint32_t count[3];
10942 + uint64_t total[3];
10948 +#include <linux/compiler.h>
10950 +extern int vc_sock_stat(struct vx_info *, void __user *);
10952 +#endif /* __KERNEL__ */
10953 +#endif /* _VX_CACCT_CMD_H */
10954 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/cacct_def.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/cacct_def.h
10955 --- linux-3.4.103/include/linux/vserver/cacct_def.h 1970-01-01 00:00:00.000000000 +0000
10956 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/cacct_def.h 2012-05-21 16:15:05.000000000 +0000
10958 +#ifndef _VX_CACCT_DEF_H
10959 +#define _VX_CACCT_DEF_H
10961 +#include <asm/atomic.h>
10962 +#include <linux/vserver/cacct.h>
10965 +struct _vx_sock_acc {
10966 + atomic_long_t count;
10967 + atomic_long_t total;
10970 +/* context sub struct */
10972 +struct _vx_cacct {
10973 + struct _vx_sock_acc sock[VXA_SOCK_SIZE][3];
10974 + atomic_t slab[8];
10975 + atomic_t page[6][8];
10978 +#ifdef CONFIG_VSERVER_DEBUG
10980 +static inline void __dump_vx_cacct(struct _vx_cacct *cacct)
10984 + printk("\t_vx_cacct:");
10985 + for (i = 0; i < 6; i++) {
10986 + struct _vx_sock_acc *ptr = cacct->sock[i];
10988 + printk("\t [%d] =", i);
10989 + for (j = 0; j < 3; j++) {
10990 + printk(" [%d] = %8lu, %8lu", j,
10991 + atomic_long_read(&ptr[j].count),
10992 + atomic_long_read(&ptr[j].total));
11000 +#endif /* _VX_CACCT_DEF_H */
11001 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/cacct_int.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/cacct_int.h
11002 --- linux-3.4.103/include/linux/vserver/cacct_int.h 1970-01-01 00:00:00.000000000 +0000
11003 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/cacct_int.h 2012-05-21 16:15:05.000000000 +0000
11005 +#ifndef _VX_CACCT_INT_H
11006 +#define _VX_CACCT_INT_H
11012 +unsigned long vx_sock_count(struct _vx_cacct *cacct, int type, int pos)
11014 + return atomic_long_read(&cacct->sock[type][pos].count);
11019 +unsigned long vx_sock_total(struct _vx_cacct *cacct, int type, int pos)
11021 + return atomic_long_read(&cacct->sock[type][pos].total);
11024 +#endif /* __KERNEL__ */
11025 +#endif /* _VX_CACCT_INT_H */
11026 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/check.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/check.h
11027 --- linux-3.4.103/include/linux/vserver/check.h 1970-01-01 00:00:00.000000000 +0000
11028 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/check.h 2012-05-21 16:15:05.000000000 +0000
11030 +#ifndef _VS_CHECK_H
11031 +#define _VS_CHECK_H
11034 +#define MAX_S_CONTEXT 65535 /* Arbitrary limit */
11036 +#ifdef CONFIG_VSERVER_DYNAMIC_IDS
11037 +#define MIN_D_CONTEXT 49152 /* dynamic contexts start here */
11039 +#define MIN_D_CONTEXT 65536
11042 +/* check conditions */
11044 +#define VS_ADMIN 0x0001
11045 +#define VS_WATCH 0x0002
11046 +#define VS_HIDE 0x0004
11047 +#define VS_HOSTID 0x0008
11049 +#define VS_IDENT 0x0010
11050 +#define VS_EQUIV 0x0020
11051 +#define VS_PARENT 0x0040
11052 +#define VS_CHILD 0x0080
11054 +#define VS_ARG_MASK 0x00F0
11056 +#define VS_DYNAMIC 0x0100
11057 +#define VS_STATIC 0x0200
11059 +#define VS_ATR_MASK 0x0F00
11061 +#ifdef CONFIG_VSERVER_PRIVACY
11062 +#define VS_ADMIN_P (0)
11063 +#define VS_WATCH_P (0)
11065 +#define VS_ADMIN_P VS_ADMIN
11066 +#define VS_WATCH_P VS_WATCH
11069 +#define VS_HARDIRQ 0x1000
11070 +#define VS_SOFTIRQ 0x2000
11071 +#define VS_IRQ 0x4000
11073 +#define VS_IRQ_MASK 0xF000
11075 +#include <linux/hardirq.h>
11078 + * check current context for ADMIN/WATCH and
11079 + * optionally against supplied argument
11081 +static inline int __vs_check(int cid, int id, unsigned int mode)
11083 + if (mode & VS_ARG_MASK) {
11084 + if ((mode & VS_IDENT) && (id == cid))
11087 + if (mode & VS_ATR_MASK) {
11088 + if ((mode & VS_DYNAMIC) &&
11089 + (id >= MIN_D_CONTEXT) &&
11090 + (id <= MAX_S_CONTEXT))
11092 + if ((mode & VS_STATIC) &&
11093 + (id > 1) && (id < MIN_D_CONTEXT))
11096 + if (mode & VS_IRQ_MASK) {
11097 + if ((mode & VS_IRQ) && unlikely(in_interrupt()))
11099 + if ((mode & VS_HARDIRQ) && unlikely(in_irq()))
11101 + if ((mode & VS_SOFTIRQ) && unlikely(in_softirq()))
11104 + return (((mode & VS_ADMIN) && (cid == 0)) ||
11105 + ((mode & VS_WATCH) && (cid == 1)) ||
11106 + ((mode & VS_HOSTID) && (id == 0)));
11109 +#define vx_check(c, m) __vs_check(vx_current_xid(), c, (m) | VS_IRQ)
11111 +#define vx_weak_check(c, m) ((m) ? vx_check(c, m) : 1)
11114 +#define nx_check(c, m) __vs_check(nx_current_nid(), c, m)
11116 +#define nx_weak_check(c, m) ((m) ? nx_check(c, m) : 1)
11119 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/context.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/context.h
11120 --- linux-3.4.103/include/linux/vserver/context.h 1970-01-01 00:00:00.000000000 +0000
11121 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/context.h 2012-05-21 16:15:05.000000000 +0000
11123 +#ifndef _VX_CONTEXT_H
11124 +#define _VX_CONTEXT_H
11126 +#include <linux/types.h>
11127 +#include <linux/capability.h>
11130 +/* context flags */
11132 +#define VXF_INFO_SCHED 0x00000002
11133 +#define VXF_INFO_NPROC 0x00000004
11134 +#define VXF_INFO_PRIVATE 0x00000008
11136 +#define VXF_INFO_INIT 0x00000010
11137 +#define VXF_INFO_HIDE 0x00000020
11138 +#define VXF_INFO_ULIMIT 0x00000040
11139 +#define VXF_INFO_NSPACE 0x00000080
11141 +#define VXF_SCHED_HARD 0x00000100
11142 +#define VXF_SCHED_PRIO 0x00000200
11143 +#define VXF_SCHED_PAUSE 0x00000400
11145 +#define VXF_VIRT_MEM 0x00010000
11146 +#define VXF_VIRT_UPTIME 0x00020000
11147 +#define VXF_VIRT_CPU 0x00040000
11148 +#define VXF_VIRT_LOAD 0x00080000
11149 +#define VXF_VIRT_TIME 0x00100000
11151 +#define VXF_HIDE_MOUNT 0x01000000
11152 +/* was VXF_HIDE_NETIF 0x02000000 */
11153 +#define VXF_HIDE_VINFO 0x04000000
11155 +#define VXF_STATE_SETUP (1ULL << 32)
11156 +#define VXF_STATE_INIT (1ULL << 33)
11157 +#define VXF_STATE_ADMIN (1ULL << 34)
11159 +#define VXF_SC_HELPER (1ULL << 36)
11160 +#define VXF_REBOOT_KILL (1ULL << 37)
11161 +#define VXF_PERSISTENT (1ULL << 38)
11163 +#define VXF_FORK_RSS (1ULL << 48)
11164 +#define VXF_PROLIFIC (1ULL << 49)
11166 +#define VXF_IGNEG_NICE (1ULL << 52)
11168 +#define VXF_ONE_TIME (0x0007ULL << 32)
11170 +#define VXF_INIT_SET (VXF_STATE_SETUP | VXF_STATE_INIT | VXF_STATE_ADMIN)
11173 +/* context migration */
11175 +#define VXM_SET_INIT 0x00000001
11176 +#define VXM_SET_REAPER 0x00000002
11178 +/* context caps */
11180 +#define VXC_SET_UTSNAME 0x00000001
11181 +#define VXC_SET_RLIMIT 0x00000002
11182 +#define VXC_FS_SECURITY 0x00000004
11183 +#define VXC_FS_TRUSTED 0x00000008
11184 +#define VXC_TIOCSTI 0x00000010
11186 +/* was VXC_RAW_ICMP 0x00000100 */
11187 +#define VXC_SYSLOG 0x00001000
11188 +#define VXC_OOM_ADJUST 0x00002000
11189 +#define VXC_AUDIT_CONTROL 0x00004000
11191 +#define VXC_SECURE_MOUNT 0x00010000
11192 +#define VXC_SECURE_REMOUNT 0x00020000
11193 +#define VXC_BINARY_MOUNT 0x00040000
11195 +#define VXC_QUOTA_CTL 0x00100000
11196 +#define VXC_ADMIN_MAPPER 0x00200000
11197 +#define VXC_ADMIN_CLOOP 0x00400000
11199 +#define VXC_KTHREAD 0x01000000
11200 +#define VXC_NAMESPACE 0x02000000
11205 +#include <linux/list.h>
11206 +#include <linux/spinlock.h>
11207 +#include <linux/rcupdate.h>
11209 +#include "limit_def.h"
11210 +#include "sched_def.h"
11211 +#include "cvirt_def.h"
11212 +#include "cacct_def.h"
11213 +#include "device_def.h"
11215 +#define VX_SPACES 2
11217 +struct _vx_info_pc {
11218 + struct _vx_sched_pc sched_pc;
11219 + struct _vx_cvirt_pc cvirt_pc;
11222 +struct _vx_space {
11223 + unsigned long vx_nsmask; /* assignment mask */
11224 + struct nsproxy *vx_nsproxy; /* private namespaces */
11225 + struct fs_struct *vx_fs; /* private namespace fs */
11226 + const struct cred *vx_cred; /* task credentials */
11230 + struct hlist_node vx_hlist; /* linked list of contexts */
11231 + xid_t vx_id; /* context id */
11232 + atomic_t vx_usecnt; /* usage count */
11233 + atomic_t vx_tasks; /* tasks count */
11234 + struct vx_info *vx_parent; /* parent context */
11235 + int vx_state; /* context state */
11237 + struct _vx_space space[VX_SPACES]; /* namespace store */
11239 + uint64_t vx_flags; /* context flags */
11240 + uint64_t vx_ccaps; /* context caps (vserver) */
11241 + uint64_t vx_umask; /* unshare mask (guest) */
11242 + uint64_t vx_wmask; /* warn mask (guest) */
11243 + kernel_cap_t vx_bcaps; /* bounding caps (system) */
11245 + struct task_struct *vx_reaper; /* guest reaper process */
11246 + pid_t vx_initpid; /* PID of guest init */
11247 + int64_t vx_badness_bias; /* OOM points bias */
11249 + struct _vx_limit limit; /* vserver limits */
11250 + struct _vx_sched sched; /* vserver scheduler */
11251 + struct _vx_cvirt cvirt; /* virtual/bias stuff */
11252 + struct _vx_cacct cacct; /* context accounting */
11254 + struct _vx_device dmap; /* default device map targets */
11256 +#ifndef CONFIG_SMP
11257 + struct _vx_info_pc info_pc; /* per cpu data */
11259 + struct _vx_info_pc *ptr_pc; /* per cpu array */
11262 + wait_queue_head_t vx_wait; /* context exit waitqueue */
11263 + int reboot_cmd; /* last sys_reboot() cmd */
11264 + int exit_code; /* last process exit code */
11266 + char vx_name[65]; /* vserver name */
11269 +#ifndef CONFIG_SMP
11270 +#define vx_ptr_pc(vxi) (&(vxi)->info_pc)
11271 +#define vx_per_cpu(vxi, v, id) vx_ptr_pc(vxi)->v
11273 +#define vx_ptr_pc(vxi) ((vxi)->ptr_pc)
11274 +#define vx_per_cpu(vxi, v, id) per_cpu_ptr(vx_ptr_pc(vxi), id)->v
11277 +#define vx_cpu(vxi, v) vx_per_cpu(vxi, v, smp_processor_id())
11280 +struct vx_info_save {
11281 + struct vx_info *vxi;
11286 +/* status flags */
11288 +#define VXS_HASHED 0x0001
11289 +#define VXS_PAUSED 0x0010
11290 +#define VXS_SHUTDOWN 0x0100
11291 +#define VXS_HELPER 0x1000
11292 +#define VXS_RELEASED 0x8000
11295 +extern void claim_vx_info(struct vx_info *, struct task_struct *);
11296 +extern void release_vx_info(struct vx_info *, struct task_struct *);
11298 +extern struct vx_info *lookup_vx_info(int);
11299 +extern struct vx_info *lookup_or_create_vx_info(int);
11301 +extern int get_xid_list(int, unsigned int *, int);
11302 +extern int xid_is_hashed(xid_t);
11304 +extern int vx_migrate_task(struct task_struct *, struct vx_info *, int);
11306 +extern long vs_state_change(struct vx_info *, unsigned int);
11309 +#endif /* __KERNEL__ */
11310 +#endif /* _VX_CONTEXT_H */
11311 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/context_cmd.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/context_cmd.h
11312 --- linux-3.4.103/include/linux/vserver/context_cmd.h 1970-01-01 00:00:00.000000000 +0000
11313 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/context_cmd.h 2012-05-21 16:15:05.000000000 +0000
11315 +#ifndef _VX_CONTEXT_CMD_H
11316 +#define _VX_CONTEXT_CMD_H
11319 +/* vinfo commands */
11321 +#define VCMD_task_xid VC_CMD(VINFO, 1, 0)
11324 +extern int vc_task_xid(uint32_t);
11326 +#endif /* __KERNEL__ */
11328 +#define VCMD_vx_info VC_CMD(VINFO, 5, 0)
11330 +struct vcmd_vx_info_v0 {
11332 + uint32_t initpid;
11333 + /* more to come */
11337 +extern int vc_vx_info(struct vx_info *, void __user *);
11339 +#endif /* __KERNEL__ */
11341 +#define VCMD_ctx_stat VC_CMD(VSTAT, 0, 0)
11343 +struct vcmd_ctx_stat_v0 {
11346 + /* more to come */
11350 +extern int vc_ctx_stat(struct vx_info *, void __user *);
11352 +#endif /* __KERNEL__ */
11354 +/* context commands */
11356 +#define VCMD_ctx_create_v0 VC_CMD(VPROC, 1, 0)
11357 +#define VCMD_ctx_create VC_CMD(VPROC, 1, 1)
11359 +struct vcmd_ctx_create {
11360 + uint64_t flagword;
11363 +#define VCMD_ctx_migrate_v0 VC_CMD(PROCMIG, 1, 0)
11364 +#define VCMD_ctx_migrate VC_CMD(PROCMIG, 1, 1)
11366 +struct vcmd_ctx_migrate {
11367 + uint64_t flagword;
11371 +extern int vc_ctx_create(uint32_t, void __user *);
11372 +extern int vc_ctx_migrate(struct vx_info *, void __user *);
11374 +#endif /* __KERNEL__ */
11377 +/* flag commands */
11379 +#define VCMD_get_cflags VC_CMD(FLAGS, 1, 0)
11380 +#define VCMD_set_cflags VC_CMD(FLAGS, 2, 0)
11382 +struct vcmd_ctx_flags_v0 {
11383 + uint64_t flagword;
11388 +extern int vc_get_cflags(struct vx_info *, void __user *);
11389 +extern int vc_set_cflags(struct vx_info *, void __user *);
11391 +#endif /* __KERNEL__ */
11394 +/* context caps commands */
11396 +#define VCMD_get_ccaps VC_CMD(FLAGS, 3, 1)
11397 +#define VCMD_set_ccaps VC_CMD(FLAGS, 4, 1)
11399 +struct vcmd_ctx_caps_v1 {
11405 +extern int vc_get_ccaps(struct vx_info *, void __user *);
11406 +extern int vc_set_ccaps(struct vx_info *, void __user *);
11408 +#endif /* __KERNEL__ */
11411 +/* bcaps commands */
11413 +#define VCMD_get_bcaps VC_CMD(FLAGS, 9, 0)
11414 +#define VCMD_set_bcaps VC_CMD(FLAGS, 10, 0)
11416 +struct vcmd_bcaps {
11422 +extern int vc_get_bcaps(struct vx_info *, void __user *);
11423 +extern int vc_set_bcaps(struct vx_info *, void __user *);
11425 +#endif /* __KERNEL__ */
11428 +/* umask commands */
11430 +#define VCMD_get_umask VC_CMD(FLAGS, 13, 0)
11431 +#define VCMD_set_umask VC_CMD(FLAGS, 14, 0)
11433 +struct vcmd_umask {
11439 +extern int vc_get_umask(struct vx_info *, void __user *);
11440 +extern int vc_set_umask(struct vx_info *, void __user *);
11442 +#endif /* __KERNEL__ */
11445 +/* wmask commands */
11447 +#define VCMD_get_wmask VC_CMD(FLAGS, 15, 0)
11448 +#define VCMD_set_wmask VC_CMD(FLAGS, 16, 0)
11450 +struct vcmd_wmask {
11456 +extern int vc_get_wmask(struct vx_info *, void __user *);
11457 +extern int vc_set_wmask(struct vx_info *, void __user *);
11459 +#endif /* __KERNEL__ */
11464 +#define VCMD_get_badness VC_CMD(MEMCTRL, 5, 0)
11465 +#define VCMD_set_badness VC_CMD(MEMCTRL, 6, 0)
11467 +struct vcmd_badness_v0 {
11472 +extern int vc_get_badness(struct vx_info *, void __user *);
11473 +extern int vc_set_badness(struct vx_info *, void __user *);
11475 +#endif /* __KERNEL__ */
11476 +#endif /* _VX_CONTEXT_CMD_H */
11477 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/cvirt.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/cvirt.h
11478 --- linux-3.4.103/include/linux/vserver/cvirt.h 1970-01-01 00:00:00.000000000 +0000
11479 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/cvirt.h 2012-05-21 16:15:05.000000000 +0000
11481 +#ifndef _VX_CVIRT_H
11482 +#define _VX_CVIRT_H
11489 +void vx_vsi_boottime(struct timespec *);
11491 +void vx_vsi_uptime(struct timespec *, struct timespec *);
11496 +void vx_update_load(struct vx_info *);
11499 +int vx_do_syslog(int, char __user *, int);
11501 +#endif /* __KERNEL__ */
11502 +#endif /* _VX_CVIRT_H */
11503 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/cvirt_cmd.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/cvirt_cmd.h
11504 --- linux-3.4.103/include/linux/vserver/cvirt_cmd.h 1970-01-01 00:00:00.000000000 +0000
11505 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/cvirt_cmd.h 2012-05-21 16:15:05.000000000 +0000
11507 +#ifndef _VX_CVIRT_CMD_H
11508 +#define _VX_CVIRT_CMD_H
11511 +/* virtual host info name commands */
11513 +#define VCMD_set_vhi_name VC_CMD(VHOST, 1, 0)
11514 +#define VCMD_get_vhi_name VC_CMD(VHOST, 2, 0)
11516 +struct vcmd_vhi_name_v0 {
11522 +enum vhi_name_field {
11523 + VHIN_CONTEXT = 0,
11535 +#include <linux/compiler.h>
11537 +extern int vc_set_vhi_name(struct vx_info *, void __user *);
11538 +extern int vc_get_vhi_name(struct vx_info *, void __user *);
11540 +#endif /* __KERNEL__ */
11542 +#define VCMD_virt_stat VC_CMD(VSTAT, 3, 0)
11544 +struct vcmd_virt_stat_v0 {
11547 + uint32_t nr_threads;
11548 + uint32_t nr_running;
11549 + uint32_t nr_uninterruptible;
11550 + uint32_t nr_onhold;
11551 + uint32_t nr_forks;
11552 + uint32_t load[3];
11556 +extern int vc_virt_stat(struct vx_info *, void __user *);
11558 +#endif /* __KERNEL__ */
11559 +#endif /* _VX_CVIRT_CMD_H */
11560 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/cvirt_def.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/cvirt_def.h
11561 --- linux-3.4.103/include/linux/vserver/cvirt_def.h 1970-01-01 00:00:00.000000000 +0000
11562 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/cvirt_def.h 2012-05-21 16:15:05.000000000 +0000
11564 +#ifndef _VX_CVIRT_DEF_H
11565 +#define _VX_CVIRT_DEF_H
11567 +#include <linux/jiffies.h>
11568 +#include <linux/spinlock.h>
11569 +#include <linux/wait.h>
11570 +#include <linux/time.h>
11571 +#include <asm/atomic.h>
11574 +struct _vx_usage_stat {
11578 + uint64_t softirq;
11584 +struct _vx_syslog {
11585 + wait_queue_head_t log_wait;
11586 + spinlock_t logbuf_lock; /* lock for the log buffer */
11588 + unsigned long log_start; /* next char to be read by syslog() */
11589 + unsigned long con_start; /* next char to be sent to consoles */
11590 + unsigned long log_end; /* most-recently-written-char + 1 */
11591 + unsigned long logged_chars; /* #chars since last read+clear operation */
11593 + char log_buf[1024];
11597 +/* context sub struct */
11599 +struct _vx_cvirt {
11600 + atomic_t nr_threads; /* number of current threads */
11601 + atomic_t nr_running; /* number of running threads */
11602 + atomic_t nr_uninterruptible; /* number of uninterruptible threads */
11604 + atomic_t nr_onhold; /* processes on hold */
11605 + uint32_t onhold_last; /* jiffies when put on hold */
11607 + struct timespec bias_ts; /* time offset to the host */
11608 + struct timespec bias_idle;
11609 + struct timespec bias_uptime; /* context creation point */
11610 + uint64_t bias_clock; /* offset in clock_t */
11612 + spinlock_t load_lock; /* lock for the load averages */
11613 + atomic_t load_updates; /* nr of load updates done so far */
11614 + uint32_t load_last; /* last time load was calculated */
11615 + uint32_t load[3]; /* load averages 1,5,15 */
11617 + atomic_t total_forks; /* number of forks so far */
11619 + struct _vx_syslog syslog;
11622 +struct _vx_cvirt_pc {
11623 + struct _vx_usage_stat cpustat;
11627 +#ifdef CONFIG_VSERVER_DEBUG
11629 +static inline void __dump_vx_cvirt(struct _vx_cvirt *cvirt)
11631 + printk("\t_vx_cvirt:\n");
11632 + printk("\t threads: %4d, %4d, %4d, %4d\n",
11633 + atomic_read(&cvirt->nr_threads),
11634 + atomic_read(&cvirt->nr_running),
11635 + atomic_read(&cvirt->nr_uninterruptible),
11636 + atomic_read(&cvirt->nr_onhold));
11637 + /* add rest here */
11638 + printk("\t total_forks = %d\n", atomic_read(&cvirt->total_forks));
11643 +#endif /* _VX_CVIRT_DEF_H */
11644 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/debug.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/debug.h
11645 --- linux-3.4.103/include/linux/vserver/debug.h 1970-01-01 00:00:00.000000000 +0000
11646 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/debug.h 2012-05-21 16:15:05.000000000 +0000
11648 +#ifndef _VX_DEBUG_H
11649 +#define _VX_DEBUG_H
11652 +#define VXD_CBIT(n, m) (vs_debug_ ## n & (1 << (m)))
11653 +#define VXD_CMIN(n, m) (vs_debug_ ## n > (m))
11654 +#define VXD_MASK(n, m) (vs_debug_ ## n & (m))
11656 +#define VXD_DEV(d) (d), (d)->bd_inode->i_ino, \
11657 + imajor((d)->bd_inode), iminor((d)->bd_inode)
11658 +#define VXF_DEV "%p[%lu,%d:%d]"
11660 +#if defined(CONFIG_QUOTES_UTF8)
11661 +#define VS_Q_LQM "\xc2\xbb"
11662 +#define VS_Q_RQM "\xc2\xab"
11663 +#elif defined(CONFIG_QUOTES_ASCII)
11664 +#define VS_Q_LQM "\x27"
11665 +#define VS_Q_RQM "\x27"
11667 +#define VS_Q_LQM "\xbb"
11668 +#define VS_Q_RQM "\xab"
11671 +#define VS_Q(f) VS_Q_LQM f VS_Q_RQM
11674 +#define vxd_path(p) \
11675 + ({ static char _buffer[PATH_MAX]; \
11676 + d_path(p, _buffer, sizeof(_buffer)); })
11678 +#define vxd_cond_path(n) \
11679 + ((n) ? vxd_path(&(n)->path) : "<null>" )
11682 +#ifdef CONFIG_VSERVER_DEBUG
11684 +extern unsigned int vs_debug_switch;
11685 +extern unsigned int vs_debug_xid;
11686 +extern unsigned int vs_debug_nid;
11687 +extern unsigned int vs_debug_tag;
11688 +extern unsigned int vs_debug_net;
11689 +extern unsigned int vs_debug_limit;
11690 +extern unsigned int vs_debug_cres;
11691 +extern unsigned int vs_debug_dlim;
11692 +extern unsigned int vs_debug_quota;
11693 +extern unsigned int vs_debug_cvirt;
11694 +extern unsigned int vs_debug_space;
11695 +extern unsigned int vs_debug_perm;
11696 +extern unsigned int vs_debug_misc;
11699 +#define VX_LOGLEVEL "vxD: "
11700 +#define VX_PROC_FMT "%p: "
11701 +#define VX_PROCESS current
11703 +#define vxdprintk(c, f, x...) \
11706 + printk(VX_LOGLEVEL VX_PROC_FMT f "\n", \
11707 + VX_PROCESS , ##x); \
11710 +#define vxlprintk(c, f, x...) \
11713 + printk(VX_LOGLEVEL f " @%s:%d\n", x); \
11716 +#define vxfprintk(c, f, x...) \
11719 + printk(VX_LOGLEVEL f " %s@%s:%d\n", x); \
11725 +void dump_vx_info(struct vx_info *, int);
11726 +void dump_vx_info_inactive(int);
11728 +#else /* CONFIG_VSERVER_DEBUG */
11730 +#define vs_debug_switch 0
11731 +#define vs_debug_xid 0
11732 +#define vs_debug_nid 0
11733 +#define vs_debug_tag 0
11734 +#define vs_debug_net 0
11735 +#define vs_debug_limit 0
11736 +#define vs_debug_cres 0
11737 +#define vs_debug_dlim 0
11738 +#define vs_debug_quota 0
11739 +#define vs_debug_cvirt 0
11740 +#define vs_debug_space 0
11741 +#define vs_debug_perm 0
11742 +#define vs_debug_misc 0
11744 +#define vxdprintk(x...) do { } while (0)
11745 +#define vxlprintk(x...) do { } while (0)
11746 +#define vxfprintk(x...) do { } while (0)
11748 +#endif /* CONFIG_VSERVER_DEBUG */
11751 +#ifdef CONFIG_VSERVER_WARN
11753 +#define VX_WARNLEVEL KERN_WARNING "vxW: "
11754 +#define VX_WARN_TASK "[" VS_Q("%s") ",%u:#%u|%u|%u] "
11755 +#define VX_WARN_XID "[xid #%u] "
11756 +#define VX_WARN_NID "[nid #%u] "
11757 +#define VX_WARN_TAG "[tag #%u] "
11759 +#define vxwprintk(c, f, x...) \
11762 + printk(VX_WARNLEVEL f "\n", ##x); \
11765 +#else /* CONFIG_VSERVER_WARN */
11767 +#define vxwprintk(x...) do { } while (0)
11769 +#endif /* CONFIG_VSERVER_WARN */
11771 +#define vxwprintk_task(c, f, x...) \
11772 + vxwprintk(c, VX_WARN_TASK f, \
11773 + current->comm, current->pid, \
11774 + current->xid, current->nid, current->tag, ##x)
11775 +#define vxwprintk_xid(c, f, x...) \
11776 + vxwprintk(c, VX_WARN_XID f, current->xid, x)
11777 +#define vxwprintk_nid(c, f, x...) \
11778 + vxwprintk(c, VX_WARN_NID f, current->nid, x)
11779 +#define vxwprintk_tag(c, f, x...) \
11780 + vxwprintk(c, VX_WARN_TAG f, current->tag, x)
11782 +#ifdef CONFIG_VSERVER_DEBUG
11783 +#define vxd_assert_lock(l) assert_spin_locked(l)
11784 +#define vxd_assert(c, f, x...) vxlprintk(!(c), \
11785 + "assertion [" f "] failed.", ##x, __FILE__, __LINE__)
11787 +#define vxd_assert_lock(l) do { } while (0)
11788 +#define vxd_assert(c, f, x...) do { } while (0)
11792 +#endif /* _VX_DEBUG_H */
11793 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/debug_cmd.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/debug_cmd.h
11794 --- linux-3.4.103/include/linux/vserver/debug_cmd.h 1970-01-01 00:00:00.000000000 +0000
11795 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/debug_cmd.h 2012-05-21 16:15:05.000000000 +0000
11797 +#ifndef _VX_DEBUG_CMD_H
11798 +#define _VX_DEBUG_CMD_H
11801 +/* debug commands */
11803 +#define VCMD_dump_history VC_CMD(DEBUG, 1, 0)
11805 +#define VCMD_read_history VC_CMD(DEBUG, 5, 0)
11806 +#define VCMD_read_monitor VC_CMD(DEBUG, 6, 0)
11808 +struct vcmd_read_history_v0 {
11811 + char __user *data;
11814 +struct vcmd_read_monitor_v0 {
11817 + char __user *data;
11823 +#ifdef CONFIG_COMPAT
11825 +#include <asm/compat.h>
11827 +struct vcmd_read_history_v0_x32 {
11830 + compat_uptr_t data_ptr;
11833 +struct vcmd_read_monitor_v0_x32 {
11836 + compat_uptr_t data_ptr;
11839 +#endif /* CONFIG_COMPAT */
11841 +extern int vc_dump_history(uint32_t);
11843 +extern int vc_read_history(uint32_t, void __user *);
11844 +extern int vc_read_monitor(uint32_t, void __user *);
11846 +#ifdef CONFIG_COMPAT
11848 +extern int vc_read_history_x32(uint32_t, void __user *);
11849 +extern int vc_read_monitor_x32(uint32_t, void __user *);
11851 +#endif /* CONFIG_COMPAT */
11853 +#endif /* __KERNEL__ */
11854 +#endif /* _VX_DEBUG_CMD_H */
11855 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/device.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/device.h
11856 --- linux-3.4.103/include/linux/vserver/device.h 1970-01-01 00:00:00.000000000 +0000
11857 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/device.h 2012-05-21 16:15:05.000000000 +0000
11859 +#ifndef _VX_DEVICE_H
11860 +#define _VX_DEVICE_H
11863 +#define DATTR_CREATE 0x00000001
11864 +#define DATTR_OPEN 0x00000002
11866 +#define DATTR_REMAP 0x00000010
11868 +#define DATTR_MASK 0x00000013
11871 +#else /* _VX_DEVICE_H */
11872 +#warning duplicate inclusion
11873 +#endif /* _VX_DEVICE_H */
11874 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/device_cmd.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/device_cmd.h
11875 --- linux-3.4.103/include/linux/vserver/device_cmd.h 1970-01-01 00:00:00.000000000 +0000
11876 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/device_cmd.h 2012-05-21 16:15:05.000000000 +0000
11878 +#ifndef _VX_DEVICE_CMD_H
11879 +#define _VX_DEVICE_CMD_H
11882 +/* device vserver commands */
11884 +#define VCMD_set_mapping VC_CMD(DEVICE, 1, 0)
11885 +#define VCMD_unset_mapping VC_CMD(DEVICE, 2, 0)
11887 +struct vcmd_set_mapping_v0 {
11888 + const char __user *device;
11889 + const char __user *target;
11896 +#ifdef CONFIG_COMPAT
11898 +#include <asm/compat.h>
11900 +struct vcmd_set_mapping_v0_x32 {
11901 + compat_uptr_t device_ptr;
11902 + compat_uptr_t target_ptr;
11906 +#endif /* CONFIG_COMPAT */
11908 +#include <linux/compiler.h>
11910 +extern int vc_set_mapping(struct vx_info *, void __user *);
11911 +extern int vc_unset_mapping(struct vx_info *, void __user *);
11913 +#ifdef CONFIG_COMPAT
11915 +extern int vc_set_mapping_x32(struct vx_info *, void __user *);
11916 +extern int vc_unset_mapping_x32(struct vx_info *, void __user *);
11918 +#endif /* CONFIG_COMPAT */
11920 +#endif /* __KERNEL__ */
11921 +#endif /* _VX_DEVICE_CMD_H */
11922 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/device_def.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/device_def.h
11923 --- linux-3.4.103/include/linux/vserver/device_def.h 1970-01-01 00:00:00.000000000 +0000
11924 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/device_def.h 2012-05-21 16:15:05.000000000 +0000
11926 +#ifndef _VX_DEVICE_DEF_H
11927 +#define _VX_DEVICE_DEF_H
11929 +#include <linux/types.h>
11931 +struct vx_dmap_target {
11936 +struct _vx_device {
11937 +#ifdef CONFIG_VSERVER_DEVICE
11938 + struct vx_dmap_target targets[2];
11942 +#endif /* _VX_DEVICE_DEF_H */
11943 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/dlimit.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/dlimit.h
11944 --- linux-3.4.103/include/linux/vserver/dlimit.h 1970-01-01 00:00:00.000000000 +0000
11945 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/dlimit.h 2012-05-21 16:15:05.000000000 +0000
11947 +#ifndef _VX_DLIMIT_H
11948 +#define _VX_DLIMIT_H
11950 +#include "switch.h"
11955 +/* keep in sync with CDLIM_INFINITY */
11957 +#define DLIM_INFINITY (~0ULL)
11959 +#include <linux/spinlock.h>
11960 +#include <linux/rcupdate.h>
11962 +struct super_block;
11965 + struct hlist_node dl_hlist; /* linked list of contexts */
11966 + struct rcu_head dl_rcu; /* the rcu head */
11967 + tag_t dl_tag; /* context tag */
11968 + atomic_t dl_usecnt; /* usage count */
11969 + atomic_t dl_refcnt; /* reference count */
11971 + struct super_block *dl_sb; /* associated superblock */
11973 + spinlock_t dl_lock; /* protect the values */
11975 + unsigned long long dl_space_used; /* used space in bytes */
11976 + unsigned long long dl_space_total; /* maximum space in bytes */
11977 + unsigned long dl_inodes_used; /* used inodes */
11978 + unsigned long dl_inodes_total; /* maximum inodes */
11980 + unsigned int dl_nrlmult; /* non root limit mult */
11985 +extern void rcu_free_dl_info(struct rcu_head *);
11986 +extern void unhash_dl_info(struct dl_info *);
11988 +extern struct dl_info *locate_dl_info(struct super_block *, tag_t);
11993 +extern void vx_vsi_statfs(struct super_block *, struct kstatfs *);
11995 +typedef uint64_t dlsize_t;
11997 +#endif /* __KERNEL__ */
11998 +#else /* _VX_DLIMIT_H */
11999 +#warning duplicate inclusion
12000 +#endif /* _VX_DLIMIT_H */
12001 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/dlimit_cmd.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/dlimit_cmd.h
12002 --- linux-3.4.103/include/linux/vserver/dlimit_cmd.h 1970-01-01 00:00:00.000000000 +0000
12003 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/dlimit_cmd.h 2012-05-21 16:15:05.000000000 +0000
12005 +#ifndef _VX_DLIMIT_CMD_H
12006 +#define _VX_DLIMIT_CMD_H
12009 +/* dlimit vserver commands */
12011 +#define VCMD_add_dlimit VC_CMD(DLIMIT, 1, 0)
12012 +#define VCMD_rem_dlimit VC_CMD(DLIMIT, 2, 0)
12014 +#define VCMD_set_dlimit VC_CMD(DLIMIT, 5, 0)
12015 +#define VCMD_get_dlimit VC_CMD(DLIMIT, 6, 0)
12017 +struct vcmd_ctx_dlimit_base_v0 {
12018 + const char __user *name;
12022 +struct vcmd_ctx_dlimit_v0 {
12023 + const char __user *name;
12024 + uint32_t space_used; /* used space in kbytes */
12025 + uint32_t space_total; /* maximum space in kbytes */
12026 + uint32_t inodes_used; /* used inodes */
12027 + uint32_t inodes_total; /* maximum inodes */
12028 + uint32_t reserved; /* reserved for root in % */
12032 +#define CDLIM_UNSET ((uint32_t)0UL)
12033 +#define CDLIM_INFINITY ((uint32_t)~0UL)
12034 +#define CDLIM_KEEP ((uint32_t)~1UL)
12036 +#define DLIME_UNIT 0
12037 +#define DLIME_KILO 1
12038 +#define DLIME_MEGA 2
12039 +#define DLIME_GIGA 3
12041 +#define DLIMF_SHIFT 0x10
12043 +#define DLIMS_USED 0
12044 +#define DLIMS_TOTAL 2
12047 +uint64_t dlimit_space_32to64(uint32_t val, uint32_t flags, int shift)
12049 + int exp = (flags & DLIMF_SHIFT) ?
12050 + (flags >> shift) & DLIME_GIGA : DLIME_KILO;
12051 + return ((uint64_t)val) << (10 * exp);
12055 +uint32_t dlimit_space_64to32(uint64_t val, uint32_t *flags, int shift)
12059 + if (*flags & DLIMF_SHIFT) {
12060 + while (val > (1LL << 32) && (exp < 3)) {
12064 + *flags &= ~(DLIME_GIGA << shift);
12065 + *flags |= exp << shift;
12073 +#ifdef CONFIG_COMPAT
12075 +#include <asm/compat.h>
12077 +struct vcmd_ctx_dlimit_base_v0_x32 {
12078 + compat_uptr_t name_ptr;
12082 +struct vcmd_ctx_dlimit_v0_x32 {
12083 + compat_uptr_t name_ptr;
12084 + uint32_t space_used; /* used space in kbytes */
12085 + uint32_t space_total; /* maximum space in kbytes */
12086 + uint32_t inodes_used; /* used inodes */
12087 + uint32_t inodes_total; /* maximum inodes */
12088 + uint32_t reserved; /* reserved for root in % */
12092 +#endif /* CONFIG_COMPAT */
12094 +#include <linux/compiler.h>
12096 +extern int vc_add_dlimit(uint32_t, void __user *);
12097 +extern int vc_rem_dlimit(uint32_t, void __user *);
12099 +extern int vc_set_dlimit(uint32_t, void __user *);
12100 +extern int vc_get_dlimit(uint32_t, void __user *);
12102 +#ifdef CONFIG_COMPAT
12104 +extern int vc_add_dlimit_x32(uint32_t, void __user *);
12105 +extern int vc_rem_dlimit_x32(uint32_t, void __user *);
12107 +extern int vc_set_dlimit_x32(uint32_t, void __user *);
12108 +extern int vc_get_dlimit_x32(uint32_t, void __user *);
12110 +#endif /* CONFIG_COMPAT */
12112 +#endif /* __KERNEL__ */
12113 +#endif /* _VX_DLIMIT_CMD_H */
12114 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/global.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/global.h
12115 --- linux-3.4.103/include/linux/vserver/global.h 1970-01-01 00:00:00.000000000 +0000
12116 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/global.h 2012-05-21 16:15:05.000000000 +0000
12118 +#ifndef _VX_GLOBAL_H
12119 +#define _VX_GLOBAL_H
12122 +extern atomic_t vx_global_ctotal;
12123 +extern atomic_t vx_global_cactive;
12125 +extern atomic_t nx_global_ctotal;
12126 +extern atomic_t nx_global_cactive;
12128 +extern atomic_t vs_global_nsproxy;
12129 +extern atomic_t vs_global_fs;
12130 +extern atomic_t vs_global_mnt_ns;
12131 +extern atomic_t vs_global_uts_ns;
12132 +extern atomic_t vs_global_user_ns;
12133 +extern atomic_t vs_global_pid_ns;
12136 +#endif /* _VX_GLOBAL_H */
12137 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/history.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/history.h
12138 --- linux-3.4.103/include/linux/vserver/history.h 1970-01-01 00:00:00.000000000 +0000
12139 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/history.h 2012-05-21 16:15:05.000000000 +0000
12141 +#ifndef _VX_HISTORY_H
12142 +#define _VX_HISTORY_H
12147 + VXH_THROW_OOPS = 1,
12151 + VXH_INIT_VX_INFO,
12154 + VXH_CLAIM_VX_INFO,
12155 + VXH_RELEASE_VX_INFO,
12156 + VXH_ALLOC_VX_INFO,
12157 + VXH_DEALLOC_VX_INFO,
12158 + VXH_HASH_VX_INFO,
12159 + VXH_UNHASH_VX_INFO,
12161 + VXH_LOOKUP_VX_INFO,
12162 + VXH_CREATE_VX_INFO,
12165 +struct _vxhe_vxi {
12166 + struct vx_info *ptr;
12172 +struct _vxhe_set_clr {
12176 +struct _vxhe_loc_lookup {
12180 +struct _vx_hist_entry {
12182 + unsigned short seq;
12183 + unsigned short type;
12184 + struct _vxhe_vxi vxi;
12186 + struct _vxhe_set_clr sc;
12187 + struct _vxhe_loc_lookup ll;
12191 +#ifdef CONFIG_VSERVER_HISTORY
12193 +extern unsigned volatile int vxh_active;
12195 +struct _vx_hist_entry *vxh_advance(void *loc);
12199 +void __vxh_copy_vxi(struct _vx_hist_entry *entry, struct vx_info *vxi)
12201 + entry->vxi.ptr = vxi;
12203 + entry->vxi.usecnt = atomic_read(&vxi->vx_usecnt);
12204 + entry->vxi.tasks = atomic_read(&vxi->vx_tasks);
12205 + entry->vxi.xid = vxi->vx_id;
12210 +#define __HERE__ current_text_addr()
12212 +#define __VXH_BODY(__type, __data, __here) \
12213 + struct _vx_hist_entry *entry; \
12215 + preempt_disable(); \
12216 + entry = vxh_advance(__here); \
12218 + entry->type = __type; \
12219 + preempt_enable();
12222 + /* pass vxi only */
12224 +#define __VXH_SMPL \
12225 + __vxh_copy_vxi(entry, vxi)
12228 +void __vxh_smpl(struct vx_info *vxi, int __type, void *__here)
12230 + __VXH_BODY(__type, __VXH_SMPL, __here)
12233 + /* pass vxi and data (void *) */
12235 +#define __VXH_DATA \
12236 + __vxh_copy_vxi(entry, vxi); \
12237 + entry->sc.data = data
12240 +void __vxh_data(struct vx_info *vxi, void *data,
12241 + int __type, void *__here)
12243 + __VXH_BODY(__type, __VXH_DATA, __here)
12246 + /* pass vxi and arg (long) */
12248 +#define __VXH_LONG \
12249 + __vxh_copy_vxi(entry, vxi); \
12250 + entry->ll.arg = arg
12253 +void __vxh_long(struct vx_info *vxi, long arg,
12254 + int __type, void *__here)
12256 + __VXH_BODY(__type, __VXH_LONG, __here)
12261 +void __vxh_throw_oops(void *__here)
12263 + __VXH_BODY(VXH_THROW_OOPS, {}, __here);
12264 + /* prevent further acquisition */
12269 +#define vxh_throw_oops() __vxh_throw_oops(__HERE__);
12271 +#define __vxh_get_vx_info(v, h) __vxh_smpl(v, VXH_GET_VX_INFO, h);
12272 +#define __vxh_put_vx_info(v, h) __vxh_smpl(v, VXH_PUT_VX_INFO, h);
12274 +#define __vxh_init_vx_info(v, d, h) \
12275 + __vxh_data(v, d, VXH_INIT_VX_INFO, h);
12276 +#define __vxh_set_vx_info(v, d, h) \
12277 + __vxh_data(v, d, VXH_SET_VX_INFO, h);
12278 +#define __vxh_clr_vx_info(v, d, h) \
12279 + __vxh_data(v, d, VXH_CLR_VX_INFO, h);
12281 +#define __vxh_claim_vx_info(v, d, h) \
12282 + __vxh_data(v, d, VXH_CLAIM_VX_INFO, h);
12283 +#define __vxh_release_vx_info(v, d, h) \
12284 + __vxh_data(v, d, VXH_RELEASE_VX_INFO, h);
12286 +#define vxh_alloc_vx_info(v) \
12287 + __vxh_smpl(v, VXH_ALLOC_VX_INFO, __HERE__);
12288 +#define vxh_dealloc_vx_info(v) \
12289 + __vxh_smpl(v, VXH_DEALLOC_VX_INFO, __HERE__);
12291 +#define vxh_hash_vx_info(v) \
12292 + __vxh_smpl(v, VXH_HASH_VX_INFO, __HERE__);
12293 +#define vxh_unhash_vx_info(v) \
12294 + __vxh_smpl(v, VXH_UNHASH_VX_INFO, __HERE__);
12296 +#define vxh_loc_vx_info(v, l) \
12297 + __vxh_long(v, l, VXH_LOC_VX_INFO, __HERE__);
12298 +#define vxh_lookup_vx_info(v, l) \
12299 + __vxh_long(v, l, VXH_LOOKUP_VX_INFO, __HERE__);
12300 +#define vxh_create_vx_info(v, l) \
12301 + __vxh_long(v, l, VXH_CREATE_VX_INFO, __HERE__);
12303 +extern void vxh_dump_history(void);
12306 +#else /* CONFIG_VSERVER_HISTORY */
12308 +#define __HERE__ 0
12310 +#define vxh_throw_oops() do { } while (0)
12312 +#define __vxh_get_vx_info(v, h) do { } while (0)
12313 +#define __vxh_put_vx_info(v, h) do { } while (0)
12315 +#define __vxh_init_vx_info(v, d, h) do { } while (0)
12316 +#define __vxh_set_vx_info(v, d, h) do { } while (0)
12317 +#define __vxh_clr_vx_info(v, d, h) do { } while (0)
12319 +#define __vxh_claim_vx_info(v, d, h) do { } while (0)
12320 +#define __vxh_release_vx_info(v, d, h) do { } while (0)
12322 +#define vxh_alloc_vx_info(v) do { } while (0)
12323 +#define vxh_dealloc_vx_info(v) do { } while (0)
12325 +#define vxh_hash_vx_info(v) do { } while (0)
12326 +#define vxh_unhash_vx_info(v) do { } while (0)
12328 +#define vxh_loc_vx_info(v, l) do { } while (0)
12329 +#define vxh_lookup_vx_info(v, l) do { } while (0)
12330 +#define vxh_create_vx_info(v, l) do { } while (0)
12332 +#define vxh_dump_history() do { } while (0)
12335 +#endif /* CONFIG_VSERVER_HISTORY */
12337 +#endif /* _VX_HISTORY_H */
12338 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/inode.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/inode.h
12339 --- linux-3.4.103/include/linux/vserver/inode.h 1970-01-01 00:00:00.000000000 +0000
12340 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/inode.h 2012-05-21 16:15:05.000000000 +0000
12342 +#ifndef _VX_INODE_H
12343 +#define _VX_INODE_H
12346 +#define IATTR_TAG 0x01000000
12348 +#define IATTR_ADMIN 0x00000001
12349 +#define IATTR_WATCH 0x00000002
12350 +#define IATTR_HIDE 0x00000004
12351 +#define IATTR_FLAGS 0x00000007
12353 +#define IATTR_BARRIER 0x00010000
12354 +#define IATTR_IXUNLINK 0x00020000
12355 +#define IATTR_IMMUTABLE 0x00040000
12356 +#define IATTR_COW 0x00080000
12361 +#ifdef CONFIG_VSERVER_PROC_SECURE
12362 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN | IATTR_HIDE )
12363 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
12365 +#define IATTR_PROC_DEFAULT ( IATTR_ADMIN )
12366 +#define IATTR_PROC_SYMLINK ( IATTR_ADMIN )
12369 +#define vx_hide_check(c, m) (((m) & IATTR_HIDE) ? vx_check(c, m) : 1)
12371 +#endif /* __KERNEL__ */
12373 +/* inode ioctls */
12375 +#define FIOC_GETXFLG _IOR('x', 5, long)
12376 +#define FIOC_SETXFLG _IOW('x', 6, long)
12378 +#else /* _VX_INODE_H */
12379 +#warning duplicate inclusion
12380 +#endif /* _VX_INODE_H */
12381 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/inode_cmd.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/inode_cmd.h
12382 --- linux-3.4.103/include/linux/vserver/inode_cmd.h 1970-01-01 00:00:00.000000000 +0000
12383 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/inode_cmd.h 2012-05-21 16:15:05.000000000 +0000
12385 +#ifndef _VX_INODE_CMD_H
12386 +#define _VX_INODE_CMD_H
12389 +/* inode vserver commands */
12391 +#define VCMD_get_iattr VC_CMD(INODE, 1, 1)
12392 +#define VCMD_set_iattr VC_CMD(INODE, 2, 1)
12394 +#define VCMD_fget_iattr VC_CMD(INODE, 3, 0)
12395 +#define VCMD_fset_iattr VC_CMD(INODE, 4, 0)
12397 +struct vcmd_ctx_iattr_v1 {
12398 + const char __user *name;
12404 +struct vcmd_ctx_fiattr_v0 {
12414 +#ifdef CONFIG_COMPAT
12416 +#include <asm/compat.h>
12418 +struct vcmd_ctx_iattr_v1_x32 {
12419 + compat_uptr_t name_ptr;
12425 +#endif /* CONFIG_COMPAT */
12427 +#include <linux/compiler.h>
12429 +extern int vc_get_iattr(void __user *);
12430 +extern int vc_set_iattr(void __user *);
12432 +extern int vc_fget_iattr(uint32_t, void __user *);
12433 +extern int vc_fset_iattr(uint32_t, void __user *);
12435 +#ifdef CONFIG_COMPAT
12437 +extern int vc_get_iattr_x32(void __user *);
12438 +extern int vc_set_iattr_x32(void __user *);
12440 +#endif /* CONFIG_COMPAT */
12442 +#endif /* __KERNEL__ */
12443 +#endif /* _VX_INODE_CMD_H */
12444 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/limit.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/limit.h
12445 --- linux-3.4.103/include/linux/vserver/limit.h 1970-01-01 00:00:00.000000000 +0000
12446 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/limit.h 2012-05-21 16:15:05.000000000 +0000
12448 +#ifndef _VX_LIMIT_H
12449 +#define _VX_LIMIT_H
12451 +#define VLIMIT_NSOCK 16
12452 +#define VLIMIT_OPENFD 17
12453 +#define VLIMIT_ANON 18
12454 +#define VLIMIT_SHMEM 19
12455 +#define VLIMIT_SEMARY 20
12456 +#define VLIMIT_NSEMS 21
12457 +#define VLIMIT_DENTRY 22
12458 +#define VLIMIT_MAPPED 23
12463 +#define VLIM_NOCHECK ((1L << VLIMIT_DENTRY) | (1L << RLIMIT_RSS))
12465 +/* keep in sync with CRLIM_INFINITY */
12467 +#define VLIM_INFINITY (~0ULL)
12469 +#include <asm/atomic.h>
12470 +#include <asm/resource.h>
12472 +#ifndef RLIM_INFINITY
12473 +#warning RLIM_INFINITY is undefined
12476 +#define __rlim_val(l, r, v) ((l)->res[r].v)
12478 +#define __rlim_soft(l, r) __rlim_val(l, r, soft)
12479 +#define __rlim_hard(l, r) __rlim_val(l, r, hard)
12481 +#define __rlim_rcur(l, r) __rlim_val(l, r, rcur)
12482 +#define __rlim_rmin(l, r) __rlim_val(l, r, rmin)
12483 +#define __rlim_rmax(l, r) __rlim_val(l, r, rmax)
12485 +#define __rlim_lhit(l, r) __rlim_val(l, r, lhit)
12486 +#define __rlim_hit(l, r) atomic_inc(&__rlim_lhit(l, r))
12488 +typedef atomic_long_t rlim_atomic_t;
12489 +typedef unsigned long rlim_t;
12491 +#define __rlim_get(l, r) atomic_long_read(&__rlim_rcur(l, r))
12492 +#define __rlim_set(l, r, v) atomic_long_set(&__rlim_rcur(l, r), v)
12493 +#define __rlim_inc(l, r) atomic_long_inc(&__rlim_rcur(l, r))
12494 +#define __rlim_dec(l, r) atomic_long_dec(&__rlim_rcur(l, r))
12495 +#define __rlim_add(l, r, v) atomic_long_add(v, &__rlim_rcur(l, r))
12496 +#define __rlim_sub(l, r, v) atomic_long_sub(v, &__rlim_rcur(l, r))
12499 +#if (RLIM_INFINITY == VLIM_INFINITY)
12500 +#define VX_VLIM(r) ((long long)(long)(r))
12501 +#define VX_RLIM(v) ((rlim_t)(v))
12503 +#define VX_VLIM(r) (((r) == RLIM_INFINITY) \
12504 + ? VLIM_INFINITY : (long long)(r))
12505 +#define VX_RLIM(v) (((v) == VLIM_INFINITY) \
12506 + ? RLIM_INFINITY : (rlim_t)(v))
12511 +void vx_vsi_meminfo(struct sysinfo *);
12512 +void vx_vsi_swapinfo(struct sysinfo *);
12513 +long vx_vsi_cached(struct sysinfo *);
12515 +#define NUM_LIMITS 24
12517 +#endif /* __KERNEL__ */
12518 +#endif /* _VX_LIMIT_H */
12519 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/limit_cmd.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/limit_cmd.h
12520 --- linux-3.4.103/include/linux/vserver/limit_cmd.h 1970-01-01 00:00:00.000000000 +0000
12521 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/limit_cmd.h 2012-05-21 16:15:05.000000000 +0000
12523 +#ifndef _VX_LIMIT_CMD_H
12524 +#define _VX_LIMIT_CMD_H
12527 +/* rlimit vserver commands */
12529 +#define VCMD_get_rlimit VC_CMD(RLIMIT, 1, 0)
12530 +#define VCMD_set_rlimit VC_CMD(RLIMIT, 2, 0)
12531 +#define VCMD_get_rlimit_mask VC_CMD(RLIMIT, 3, 0)
12532 +#define VCMD_reset_hits VC_CMD(RLIMIT, 7, 0)
12533 +#define VCMD_reset_minmax VC_CMD(RLIMIT, 9, 0)
12535 +struct vcmd_ctx_rlimit_v0 {
12537 + uint64_t minimum;
12538 + uint64_t softlimit;
12539 + uint64_t maximum;
12542 +struct vcmd_ctx_rlimit_mask_v0 {
12543 + uint32_t minimum;
12544 + uint32_t softlimit;
12545 + uint32_t maximum;
12548 +#define VCMD_rlimit_stat VC_CMD(VSTAT, 1, 0)
12550 +struct vcmd_rlimit_stat_v0 {
12554 + uint64_t minimum;
12555 + uint64_t maximum;
12558 +#define CRLIM_UNSET (0ULL)
12559 +#define CRLIM_INFINITY (~0ULL)
12560 +#define CRLIM_KEEP (~1ULL)
12564 +#ifdef CONFIG_IA32_EMULATION
12566 +struct vcmd_ctx_rlimit_v0_x32 {
12568 + uint64_t minimum;
12569 + uint64_t softlimit;
12570 + uint64_t maximum;
12571 +} __attribute__ ((packed));
12573 +#endif /* CONFIG_IA32_EMULATION */
12575 +#include <linux/compiler.h>
12577 +extern int vc_get_rlimit_mask(uint32_t, void __user *);
12578 +extern int vc_get_rlimit(struct vx_info *, void __user *);
12579 +extern int vc_set_rlimit(struct vx_info *, void __user *);
12580 +extern int vc_reset_hits(struct vx_info *, void __user *);
12581 +extern int vc_reset_minmax(struct vx_info *, void __user *);
12583 +extern int vc_rlimit_stat(struct vx_info *, void __user *);
12585 +#ifdef CONFIG_IA32_EMULATION
12587 +extern int vc_get_rlimit_x32(struct vx_info *, void __user *);
12588 +extern int vc_set_rlimit_x32(struct vx_info *, void __user *);
12590 +#endif /* CONFIG_IA32_EMULATION */
12592 +#endif /* __KERNEL__ */
12593 +#endif /* _VX_LIMIT_CMD_H */
12594 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/limit_def.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/limit_def.h
12595 --- linux-3.4.103/include/linux/vserver/limit_def.h 1970-01-01 00:00:00.000000000 +0000
12596 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/limit_def.h 2012-05-21 16:15:05.000000000 +0000
12598 +#ifndef _VX_LIMIT_DEF_H
12599 +#define _VX_LIMIT_DEF_H
12601 +#include <asm/atomic.h>
12602 +#include <asm/resource.h>
12604 +#include "limit.h"
12607 +struct _vx_res_limit {
12608 + rlim_t soft; /* Context soft limit */
12609 + rlim_t hard; /* Context hard limit */
12611 + rlim_atomic_t rcur; /* Current value */
12612 + rlim_t rmin; /* Context minimum */
12613 + rlim_t rmax; /* Context maximum */
12615 + atomic_t lhit; /* Limit hits */
12618 +/* context sub struct */
12620 +struct _vx_limit {
12621 + struct _vx_res_limit res[NUM_LIMITS];
12624 +#ifdef CONFIG_VSERVER_DEBUG
12626 +static inline void __dump_vx_limit(struct _vx_limit *limit)
12630 + printk("\t_vx_limit:");
12631 + for (i = 0; i < NUM_LIMITS; i++) {
12632 + printk("\t [%2d] = %8lu %8lu/%8lu, %8ld/%8ld, %8d\n",
12633 + i, (unsigned long)__rlim_get(limit, i),
12634 + (unsigned long)__rlim_rmin(limit, i),
12635 + (unsigned long)__rlim_rmax(limit, i),
12636 + (long)__rlim_soft(limit, i),
12637 + (long)__rlim_hard(limit, i),
12638 + atomic_read(&__rlim_lhit(limit, i)));
12644 +#endif /* _VX_LIMIT_DEF_H */
12645 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/limit_int.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/limit_int.h
12646 --- linux-3.4.103/include/linux/vserver/limit_int.h 1970-01-01 00:00:00.000000000 +0000
12647 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/limit_int.h 2012-05-21 16:15:05.000000000 +0000
12649 +#ifndef _VX_LIMIT_INT_H
12650 +#define _VX_LIMIT_INT_H
12652 +#include "context.h"
12656 +#define VXD_RCRES_COND(r) VXD_CBIT(cres, r)
12657 +#define VXD_RLIMIT_COND(r) VXD_CBIT(limit, r)
12659 +extern const char *vlimit_name[NUM_LIMITS];
12661 +static inline void __vx_acc_cres(struct vx_info *vxi,
12662 + int res, int dir, void *_data, char *_file, int _line)
12664 + if (VXD_RCRES_COND(res))
12665 + vxlprintk(1, "vx_acc_cres[%5d,%s,%2d]: %5ld%s (%p)",
12666 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12667 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12668 + (dir > 0) ? "++" : "--", _data, _file, _line);
12673 + __rlim_inc(&vxi->limit, res);
12675 + __rlim_dec(&vxi->limit, res);
12678 +static inline void __vx_add_cres(struct vx_info *vxi,
12679 + int res, int amount, void *_data, char *_file, int _line)
12681 + if (VXD_RCRES_COND(res))
12682 + vxlprintk(1, "vx_add_cres[%5d,%s,%2d]: %5ld += %5d (%p)",
12683 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12684 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12685 + amount, _data, _file, _line);
12690 + __rlim_add(&vxi->limit, res, amount);
12694 +int __vx_cres_adjust_max(struct _vx_limit *limit, int res, rlim_t value)
12696 + int cond = (value > __rlim_rmax(limit, res));
12699 + __rlim_rmax(limit, res) = value;
12704 +int __vx_cres_adjust_min(struct _vx_limit *limit, int res, rlim_t value)
12706 + int cond = (value < __rlim_rmin(limit, res));
12709 + __rlim_rmin(limit, res) = value;
12714 +void __vx_cres_fixup(struct _vx_limit *limit, int res, rlim_t value)
12716 + if (!__vx_cres_adjust_max(limit, res, value))
12717 + __vx_cres_adjust_min(limit, res, value);
12722 + +1 ... no limit hit
12723 + -1 ... over soft limit
12724 + 0 ... over hard limit */
12726 +static inline int __vx_cres_avail(struct vx_info *vxi,
12727 + int res, int num, char *_file, int _line)
12729 + struct _vx_limit *limit;
12732 + if (VXD_RLIMIT_COND(res))
12733 + vxlprintk(1, "vx_cres_avail[%5d,%s,%2d]: %5ld/%5ld > %5ld + %5d",
12734 + (vxi ? vxi->vx_id : -1), vlimit_name[res], res,
12735 + (vxi ? (long)__rlim_soft(&vxi->limit, res) : -1),
12736 + (vxi ? (long)__rlim_hard(&vxi->limit, res) : -1),
12737 + (vxi ? (long)__rlim_get(&vxi->limit, res) : 0),
12738 + num, _file, _line);
12742 + limit = &vxi->limit;
12743 + value = __rlim_get(limit, res);
12745 + if (!__vx_cres_adjust_max(limit, res, value))
12746 + __vx_cres_adjust_min(limit, res, value);
12751 + if (__rlim_soft(limit, res) == RLIM_INFINITY)
12753 + if (value + num <= __rlim_soft(limit, res))
12756 + if (__rlim_hard(limit, res) == RLIM_INFINITY)
12758 + if (value + num <= __rlim_hard(limit, res))
12761 + __rlim_hit(limit, res);
12766 +static const int VLA_RSS[] = { RLIMIT_RSS, VLIMIT_ANON, VLIMIT_MAPPED, 0 };
12769 +rlim_t __vx_cres_array_sum(struct _vx_limit *limit, const int *array)
12771 + rlim_t value, sum = 0;
12774 + while ((res = *array++)) {
12775 + value = __rlim_get(limit, res);
12776 + __vx_cres_fixup(limit, res, value);
12783 +rlim_t __vx_cres_array_fixup(struct _vx_limit *limit, const int *array)
12785 + rlim_t value = __vx_cres_array_sum(limit, array + 1);
12786 + int res = *array;
12788 + if (value == __rlim_get(limit, res))
12791 + __rlim_set(limit, res, value);
12792 + /* now adjust min/max */
12793 + if (!__vx_cres_adjust_max(limit, res, value))
12794 + __vx_cres_adjust_min(limit, res, value);
12799 +static inline int __vx_cres_array_avail(struct vx_info *vxi,
12800 + const int *array, int num, char *_file, int _line)
12802 + struct _vx_limit *limit;
12803 + rlim_t value = 0;
12811 + limit = &vxi->limit;
12813 + value = __vx_cres_array_sum(limit, array + 1);
12815 + __rlim_set(limit, res, value);
12816 + __vx_cres_fixup(limit, res, value);
12818 + return __vx_cres_avail(vxi, res, num, _file, _line);
12822 +static inline void vx_limit_fixup(struct _vx_limit *limit, int id)
12827 + /* complex resources first */
12828 + if ((id < 0) || (id == RLIMIT_RSS))
12829 + __vx_cres_array_fixup(limit, VLA_RSS);
12831 + for (res = 0; res < NUM_LIMITS; res++) {
12832 + if ((id > 0) && (res != id))
12835 + value = __rlim_get(limit, res);
12836 + __vx_cres_fixup(limit, res, value);
12838 + /* not supposed to happen, maybe warn? */
12839 + if (__rlim_rmax(limit, res) > __rlim_hard(limit, res))
12840 + __rlim_rmax(limit, res) = __rlim_hard(limit, res);
12845 +#endif /* __KERNEL__ */
12846 +#endif /* _VX_LIMIT_INT_H */
12847 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/monitor.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/monitor.h
12848 --- linux-3.4.103/include/linux/vserver/monitor.h 1970-01-01 00:00:00.000000000 +0000
12849 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/monitor.h 2012-05-21 16:15:05.000000000 +0000
12851 +#ifndef _VX_MONITOR_H
12852 +#define _VX_MONITOR_H
12854 +#include <linux/types.h>
12861 + VXM_UPDATE = 0x20,
12865 + VXM_RQINFO_1 = 0x24,
12868 + VXM_ACTIVATE = 0x40,
12875 + VXM_MIGRATE = 0x48,
12878 + /* all other bits are flags */
12879 + VXM_SCHED = 0x80,
12882 +struct _vxm_update_1 {
12883 + uint32_t tokens_max;
12884 + uint32_t fill_rate;
12885 + uint32_t interval;
12888 +struct _vxm_update_2 {
12889 + uint32_t tokens_min;
12890 + uint32_t fill_rate;
12891 + uint32_t interval;
12894 +struct _vxm_rqinfo_1 {
12895 + uint16_t running;
12899 + uint32_t idle_tokens;
12902 +struct _vxm_rqinfo_2 {
12903 + uint32_t norm_time;
12904 + uint32_t idle_time;
12905 + uint32_t idle_skip;
12908 +struct _vxm_sched {
12910 + uint32_t norm_time;
12911 + uint32_t idle_time;
12914 +struct _vxm_task {
12919 +struct _vxm_event {
12928 + struct _vxm_task tsk;
12932 +struct _vx_mon_entry {
12936 + struct _vxm_event ev;
12937 + struct _vxm_sched sd;
12938 + struct _vxm_update_1 u1;
12939 + struct _vxm_update_2 u2;
12940 + struct _vxm_rqinfo_1 q1;
12941 + struct _vxm_rqinfo_2 q2;
12946 +#endif /* _VX_MONITOR_H */
12947 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/network.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/network.h
12948 --- linux-3.4.103/include/linux/vserver/network.h 1970-01-01 00:00:00.000000000 +0000
12949 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/network.h 2012-05-21 16:15:05.000000000 +0000
12951 +#ifndef _VX_NETWORK_H
12952 +#define _VX_NETWORK_H
12954 +#include <linux/types.h>
12957 +#define MAX_N_CONTEXT 65535 /* Arbitrary limit */
12960 +/* network flags */
12962 +#define NXF_INFO_PRIVATE 0x00000008
12964 +#define NXF_SINGLE_IP 0x00000100
12965 +#define NXF_LBACK_REMAP 0x00000200
12966 +#define NXF_LBACK_ALLOW 0x00000400
12968 +#define NXF_HIDE_NETIF 0x02000000
12969 +#define NXF_HIDE_LBACK 0x04000000
12971 +#define NXF_STATE_SETUP (1ULL << 32)
12972 +#define NXF_STATE_ADMIN (1ULL << 34)
12974 +#define NXF_SC_HELPER (1ULL << 36)
12975 +#define NXF_PERSISTENT (1ULL << 38)
12977 +#define NXF_ONE_TIME (0x0005ULL << 32)
12980 +#define NXF_INIT_SET (__nxf_init_set())
12982 +static inline uint64_t __nxf_init_set(void) {
12983 + return NXF_STATE_ADMIN
12984 +#ifdef CONFIG_VSERVER_AUTO_LBACK
12985 + | NXF_LBACK_REMAP
12988 +#ifdef CONFIG_VSERVER_AUTO_SINGLE
12991 + | NXF_HIDE_NETIF;
12995 +/* network caps */
12997 +#define NXC_TUN_CREATE 0x00000001
12999 +#define NXC_RAW_ICMP 0x00000100
13001 +#define NXC_MULTICAST 0x00001000
13004 +/* address types */
13006 +#define NXA_TYPE_IPV4 0x0001
13007 +#define NXA_TYPE_IPV6 0x0002
13009 +#define NXA_TYPE_NONE 0x0000
13010 +#define NXA_TYPE_ANY 0x00FF
13012 +#define NXA_TYPE_ADDR 0x0010
13013 +#define NXA_TYPE_MASK 0x0020
13014 +#define NXA_TYPE_RANGE 0x0040
13016 +#define NXA_MASK_ALL (NXA_TYPE_ADDR | NXA_TYPE_MASK | NXA_TYPE_RANGE)
13018 +#define NXA_MOD_BCAST 0x0100
13019 +#define NXA_MOD_LBACK 0x0200
13021 +#define NXA_LOOPBACK 0x1000
13023 +#define NXA_MASK_BIND (NXA_MASK_ALL | NXA_MOD_BCAST | NXA_MOD_LBACK)
13024 +#define NXA_MASK_SHOW (NXA_MASK_ALL | NXA_LOOPBACK)
13028 +#include <linux/list.h>
13029 +#include <linux/spinlock.h>
13030 +#include <linux/rcupdate.h>
13031 +#include <linux/in.h>
13032 +#include <linux/in6.h>
13033 +#include <asm/atomic.h>
13035 +struct nx_addr_v4 {
13036 + struct nx_addr_v4 *next;
13037 + struct in_addr ip[2];
13038 + struct in_addr mask;
13043 +struct nx_addr_v6 {
13044 + struct nx_addr_v6 *next;
13045 + struct in6_addr ip;
13046 + struct in6_addr mask;
13053 + struct hlist_node nx_hlist; /* linked list of nxinfos */
13054 + nid_t nx_id; /* vnet id */
13055 + atomic_t nx_usecnt; /* usage count */
13056 + atomic_t nx_tasks; /* tasks count */
13057 + int nx_state; /* context state */
13059 + uint64_t nx_flags; /* network flag word */
13060 + uint64_t nx_ncaps; /* network capabilities */
13062 + struct in_addr v4_lback; /* Loopback address */
13063 + struct in_addr v4_bcast; /* Broadcast address */
13064 + struct nx_addr_v4 v4; /* First/Single ipv4 address */
13065 +#ifdef CONFIG_IPV6
13066 + struct nx_addr_v6 v6; /* First/Single ipv6 address */
13068 + char nx_name[65]; /* network context name */
13072 +/* status flags */
13074 +#define NXS_HASHED 0x0001
13075 +#define NXS_SHUTDOWN 0x0100
13076 +#define NXS_RELEASED 0x8000
13078 +extern struct nx_info *lookup_nx_info(int);
13080 +extern int get_nid_list(int, unsigned int *, int);
13081 +extern int nid_is_hashed(nid_t);
13083 +extern int nx_migrate_task(struct task_struct *, struct nx_info *);
13085 +extern long vs_net_change(struct nx_info *, unsigned int);
13090 +#define NX_IPV4(n) ((n)->v4.type != NXA_TYPE_NONE)
13091 +#ifdef CONFIG_IPV6
13092 +#define NX_IPV6(n) ((n)->v6.type != NXA_TYPE_NONE)
13094 +#define NX_IPV6(n) (0)
13097 +#endif /* __KERNEL__ */
13098 +#endif /* _VX_NETWORK_H */
13099 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/network_cmd.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/network_cmd.h
13100 --- linux-3.4.103/include/linux/vserver/network_cmd.h 1970-01-01 00:00:00.000000000 +0000
13101 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/network_cmd.h 2012-05-21 16:15:05.000000000 +0000
13103 +#ifndef _VX_NETWORK_CMD_H
13104 +#define _VX_NETWORK_CMD_H
13107 +/* vinfo commands */
13109 +#define VCMD_task_nid VC_CMD(VINFO, 2, 0)
13112 +extern int vc_task_nid(uint32_t);
13114 +#endif /* __KERNEL__ */
13116 +#define VCMD_nx_info VC_CMD(VINFO, 6, 0)
13118 +struct vcmd_nx_info_v0 {
13120 + /* more to come */
13124 +extern int vc_nx_info(struct nx_info *, void __user *);
13126 +#endif /* __KERNEL__ */
13128 +#include <linux/in.h>
13129 +#include <linux/in6.h>
13131 +#define VCMD_net_create_v0 VC_CMD(VNET, 1, 0)
13132 +#define VCMD_net_create VC_CMD(VNET, 1, 1)
13134 +struct vcmd_net_create {
13135 + uint64_t flagword;
13138 +#define VCMD_net_migrate VC_CMD(NETMIG, 1, 0)
13140 +#define VCMD_net_add VC_CMD(NETALT, 1, 0)
13141 +#define VCMD_net_remove VC_CMD(NETALT, 2, 0)
13143 +struct vcmd_net_addr_v0 {
13146 + struct in_addr ip[4];
13147 + struct in_addr mask[4];
13150 +#define VCMD_net_add_ipv4_v1 VC_CMD(NETALT, 1, 1)
13151 +#define VCMD_net_rem_ipv4_v1 VC_CMD(NETALT, 2, 1)
13153 +struct vcmd_net_addr_ipv4_v1 {
13156 + struct in_addr ip;
13157 + struct in_addr mask;
13160 +#define VCMD_net_add_ipv4 VC_CMD(NETALT, 1, 2)
13161 +#define VCMD_net_rem_ipv4 VC_CMD(NETALT, 2, 2)
13163 +struct vcmd_net_addr_ipv4_v2 {
13166 + struct in_addr ip;
13167 + struct in_addr ip2;
13168 + struct in_addr mask;
13171 +#define VCMD_net_add_ipv6 VC_CMD(NETALT, 3, 1)
13172 +#define VCMD_net_remove_ipv6 VC_CMD(NETALT, 4, 1)
13174 +struct vcmd_net_addr_ipv6_v1 {
13178 + struct in6_addr ip;
13179 + struct in6_addr mask;
13182 +#define VCMD_add_match_ipv4 VC_CMD(NETALT, 5, 0)
13183 +#define VCMD_get_match_ipv4 VC_CMD(NETALT, 6, 0)
13185 +struct vcmd_match_ipv4_v0 {
13190 + struct in_addr ip;
13191 + struct in_addr ip2;
13192 + struct in_addr mask;
13195 +#define VCMD_add_match_ipv6 VC_CMD(NETALT, 7, 0)
13196 +#define VCMD_get_match_ipv6 VC_CMD(NETALT, 8, 0)
13198 +struct vcmd_match_ipv6_v0 {
13203 + struct in6_addr ip;
13204 + struct in6_addr ip2;
13205 + struct in6_addr mask;
13210 +extern int vc_net_create(uint32_t, void __user *);
13211 +extern int vc_net_migrate(struct nx_info *, void __user *);
13213 +extern int vc_net_add(struct nx_info *, void __user *);
13214 +extern int vc_net_remove(struct nx_info *, void __user *);
13216 +extern int vc_net_add_ipv4_v1(struct nx_info *, void __user *);
13217 +extern int vc_net_add_ipv4(struct nx_info *, void __user *);
13219 +extern int vc_net_rem_ipv4_v1(struct nx_info *, void __user *);
13220 +extern int vc_net_rem_ipv4(struct nx_info *, void __user *);
13222 +extern int vc_net_add_ipv6(struct nx_info *, void __user *);
13223 +extern int vc_net_remove_ipv6(struct nx_info *, void __user *);
13225 +extern int vc_add_match_ipv4(struct nx_info *, void __user *);
13226 +extern int vc_get_match_ipv4(struct nx_info *, void __user *);
13228 +extern int vc_add_match_ipv6(struct nx_info *, void __user *);
13229 +extern int vc_get_match_ipv6(struct nx_info *, void __user *);
13231 +#endif /* __KERNEL__ */
13234 +/* flag commands */
13236 +#define VCMD_get_nflags VC_CMD(FLAGS, 5, 0)
13237 +#define VCMD_set_nflags VC_CMD(FLAGS, 6, 0)
13239 +struct vcmd_net_flags_v0 {
13240 + uint64_t flagword;
13245 +extern int vc_get_nflags(struct nx_info *, void __user *);
13246 +extern int vc_set_nflags(struct nx_info *, void __user *);
13248 +#endif /* __KERNEL__ */
13251 +/* network caps commands */
13253 +#define VCMD_get_ncaps VC_CMD(FLAGS, 7, 0)
13254 +#define VCMD_set_ncaps VC_CMD(FLAGS, 8, 0)
13256 +struct vcmd_net_caps_v0 {
13262 +extern int vc_get_ncaps(struct nx_info *, void __user *);
13263 +extern int vc_set_ncaps(struct nx_info *, void __user *);
13265 +#endif /* __KERNEL__ */
13266 +#endif /* _VX_CONTEXT_CMD_H */
13267 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/percpu.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/percpu.h
13268 --- linux-3.4.103/include/linux/vserver/percpu.h 1970-01-01 00:00:00.000000000 +0000
13269 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/percpu.h 2012-05-21 16:15:05.000000000 +0000
13271 +#ifndef _VX_PERCPU_H
13272 +#define _VX_PERCPU_H
13274 +#include "cvirt_def.h"
13275 +#include "sched_def.h"
13277 +struct _vx_percpu {
13278 + struct _vx_cvirt_pc cvirt;
13279 + struct _vx_sched_pc sched;
13282 +#define PERCPU_PERCTX (sizeof(struct _vx_percpu))
13284 +#endif /* _VX_PERCPU_H */
13285 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/pid.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/pid.h
13286 --- linux-3.4.103/include/linux/vserver/pid.h 1970-01-01 00:00:00.000000000 +0000
13287 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/pid.h 2012-05-21 16:15:05.000000000 +0000
13289 +#ifndef _VSERVER_PID_H
13290 +#define _VSERVER_PID_H
13292 +/* pid faking stuff */
13294 +#define vx_info_map_pid(v, p) \
13295 + __vx_info_map_pid((v), (p), __func__, __FILE__, __LINE__)
13296 +#define vx_info_map_tgid(v,p) vx_info_map_pid(v,p)
13297 +#define vx_map_pid(p) vx_info_map_pid(current_vx_info(), p)
13298 +#define vx_map_tgid(p) vx_map_pid(p)
13300 +static inline int __vx_info_map_pid(struct vx_info *vxi, int pid,
13301 + const char *func, const char *file, int line)
13303 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13304 + vxfprintk(VXD_CBIT(cvirt, 2),
13305 + "vx_map_tgid: %p/%llx: %d -> %d",
13306 + vxi, (long long)vxi->vx_flags, pid,
13307 + (pid && pid == vxi->vx_initpid) ? 1 : pid,
13308 + func, file, line);
13311 + if (pid == vxi->vx_initpid)
13317 +#define vx_info_rmap_pid(v, p) \
13318 + __vx_info_rmap_pid((v), (p), __func__, __FILE__, __LINE__)
13319 +#define vx_rmap_pid(p) vx_info_rmap_pid(current_vx_info(), p)
13320 +#define vx_rmap_tgid(p) vx_rmap_pid(p)
13322 +static inline int __vx_info_rmap_pid(struct vx_info *vxi, int pid,
13323 + const char *func, const char *file, int line)
13325 + if (vx_info_flags(vxi, VXF_INFO_INIT, 0)) {
13326 + vxfprintk(VXD_CBIT(cvirt, 2),
13327 + "vx_rmap_tgid: %p/%llx: %d -> %d",
13328 + vxi, (long long)vxi->vx_flags, pid,
13329 + (pid == 1) ? vxi->vx_initpid : pid,
13330 + func, file, line);
13331 + if ((pid == 1) && vxi->vx_initpid)
13332 + return vxi->vx_initpid;
13333 + if (pid == vxi->vx_initpid)
13340 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/sched.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/sched.h
13341 --- linux-3.4.103/include/linux/vserver/sched.h 1970-01-01 00:00:00.000000000 +0000
13342 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/sched.h 2012-05-21 16:15:05.000000000 +0000
13344 +#ifndef _VX_SCHED_H
13345 +#define _VX_SCHED_H
13352 +void vx_vsi_uptime(struct timespec *, struct timespec *);
13357 +void vx_update_load(struct vx_info *);
13360 +void vx_update_sched_param(struct _vx_sched *sched,
13361 + struct _vx_sched_pc *sched_pc);
13363 +#endif /* __KERNEL__ */
13364 +#else /* _VX_SCHED_H */
13365 +#warning duplicate inclusion
13366 +#endif /* _VX_SCHED_H */
13367 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/sched_cmd.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/sched_cmd.h
13368 --- linux-3.4.103/include/linux/vserver/sched_cmd.h 1970-01-01 00:00:00.000000000 +0000
13369 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/sched_cmd.h 2012-05-21 16:15:05.000000000 +0000
13371 +#ifndef _VX_SCHED_CMD_H
13372 +#define _VX_SCHED_CMD_H
13375 +struct vcmd_prio_bias {
13377 + int32_t prio_bias;
13380 +#define VCMD_set_prio_bias VC_CMD(SCHED, 4, 0)
13381 +#define VCMD_get_prio_bias VC_CMD(SCHED, 5, 0)
13385 +#include <linux/compiler.h>
13387 +extern int vc_set_prio_bias(struct vx_info *, void __user *);
13388 +extern int vc_get_prio_bias(struct vx_info *, void __user *);
13390 +#endif /* __KERNEL__ */
13391 +#endif /* _VX_SCHED_CMD_H */
13392 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/sched_def.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/sched_def.h
13393 --- linux-3.4.103/include/linux/vserver/sched_def.h 1970-01-01 00:00:00.000000000 +0000
13394 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/sched_def.h 2012-05-21 16:15:05.000000000 +0000
13396 +#ifndef _VX_SCHED_DEF_H
13397 +#define _VX_SCHED_DEF_H
13399 +#include <linux/spinlock.h>
13400 +#include <linux/jiffies.h>
13401 +#include <linux/cpumask.h>
13402 +#include <asm/atomic.h>
13403 +#include <asm/param.h>
13406 +/* context sub struct */
13408 +struct _vx_sched {
13409 + int prio_bias; /* bias offset for priority */
13411 + cpumask_t update; /* CPUs which should update */
13414 +struct _vx_sched_pc {
13415 + int prio_bias; /* bias offset for priority */
13417 + uint64_t user_ticks; /* token tick events */
13418 + uint64_t sys_ticks; /* token tick events */
13419 + uint64_t hold_ticks; /* token ticks paused */
13423 +#ifdef CONFIG_VSERVER_DEBUG
13425 +static inline void __dump_vx_sched(struct _vx_sched *sched)
13427 + printk("\t_vx_sched:\n");
13428 + printk("\t priority = %4d\n", sched->prio_bias);
13433 +#endif /* _VX_SCHED_DEF_H */
13434 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/signal.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/signal.h
13435 --- linux-3.4.103/include/linux/vserver/signal.h 1970-01-01 00:00:00.000000000 +0000
13436 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/signal.h 2012-05-21 16:15:05.000000000 +0000
13438 +#ifndef _VX_SIGNAL_H
13439 +#define _VX_SIGNAL_H
13446 +int vx_info_kill(struct vx_info *, int, int);
13448 +#endif /* __KERNEL__ */
13449 +#else /* _VX_SIGNAL_H */
13450 +#warning duplicate inclusion
13451 +#endif /* _VX_SIGNAL_H */
13452 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/signal_cmd.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/signal_cmd.h
13453 --- linux-3.4.103/include/linux/vserver/signal_cmd.h 1970-01-01 00:00:00.000000000 +0000
13454 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/signal_cmd.h 2012-05-21 16:15:05.000000000 +0000
13456 +#ifndef _VX_SIGNAL_CMD_H
13457 +#define _VX_SIGNAL_CMD_H
13460 +/* signalling vserver commands */
13462 +#define VCMD_ctx_kill VC_CMD(PROCTRL, 1, 0)
13463 +#define VCMD_wait_exit VC_CMD(EVENT, 99, 0)
13465 +struct vcmd_ctx_kill_v0 {
13470 +struct vcmd_wait_exit_v0 {
13471 + int32_t reboot_cmd;
13472 + int32_t exit_code;
13477 +extern int vc_ctx_kill(struct vx_info *, void __user *);
13478 +extern int vc_wait_exit(struct vx_info *, void __user *);
13480 +#endif /* __KERNEL__ */
13482 +/* process alteration commands */
13484 +#define VCMD_get_pflags VC_CMD(PROCALT, 5, 0)
13485 +#define VCMD_set_pflags VC_CMD(PROCALT, 6, 0)
13487 +struct vcmd_pflags_v0 {
13488 + uint32_t flagword;
13494 +extern int vc_get_pflags(uint32_t pid, void __user *);
13495 +extern int vc_set_pflags(uint32_t pid, void __user *);
13497 +#endif /* __KERNEL__ */
13498 +#endif /* _VX_SIGNAL_CMD_H */
13499 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/space.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/space.h
13500 --- linux-3.4.103/include/linux/vserver/space.h 1970-01-01 00:00:00.000000000 +0000
13501 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/space.h 2012-05-21 16:15:05.000000000 +0000
13503 +#ifndef _VX_SPACE_H
13504 +#define _VX_SPACE_H
13506 +#include <linux/types.h>
13510 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index);
13512 +#else /* _VX_SPACE_H */
13513 +#warning duplicate inclusion
13514 +#endif /* _VX_SPACE_H */
13515 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/space_cmd.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/space_cmd.h
13516 --- linux-3.4.103/include/linux/vserver/space_cmd.h 1970-01-01 00:00:00.000000000 +0000
13517 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/space_cmd.h 2012-05-21 16:15:05.000000000 +0000
13519 +#ifndef _VX_SPACE_CMD_H
13520 +#define _VX_SPACE_CMD_H
13523 +#define VCMD_enter_space_v0 VC_CMD(PROCALT, 1, 0)
13524 +#define VCMD_enter_space_v1 VC_CMD(PROCALT, 1, 1)
13525 +#define VCMD_enter_space VC_CMD(PROCALT, 1, 2)
13527 +#define VCMD_set_space_v0 VC_CMD(PROCALT, 3, 0)
13528 +#define VCMD_set_space_v1 VC_CMD(PROCALT, 3, 1)
13529 +#define VCMD_set_space VC_CMD(PROCALT, 3, 2)
13531 +#define VCMD_get_space_mask_v0 VC_CMD(PROCALT, 4, 0)
13533 +#define VCMD_get_space_mask VC_CMD(VSPACE, 0, 1)
13534 +#define VCMD_get_space_default VC_CMD(VSPACE, 1, 0)
13537 +struct vcmd_space_mask_v1 {
13541 +struct vcmd_space_mask_v2 {
13549 +extern int vc_enter_space_v1(struct vx_info *, void __user *);
13550 +extern int vc_set_space_v1(struct vx_info *, void __user *);
13551 +extern int vc_enter_space(struct vx_info *, void __user *);
13552 +extern int vc_set_space(struct vx_info *, void __user *);
13553 +extern int vc_get_space_mask(void __user *, int);
13555 +#endif /* __KERNEL__ */
13556 +#endif /* _VX_SPACE_CMD_H */
13557 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/switch.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/switch.h
13558 --- linux-3.4.103/include/linux/vserver/switch.h 1970-01-01 00:00:00.000000000 +0000
13559 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/switch.h 2012-05-21 16:15:05.000000000 +0000
13561 +#ifndef _VX_SWITCH_H
13562 +#define _VX_SWITCH_H
13564 +#include <linux/types.h>
13567 +#define VC_CATEGORY(c) (((c) >> 24) & 0x3F)
13568 +#define VC_COMMAND(c) (((c) >> 16) & 0xFF)
13569 +#define VC_VERSION(c) ((c) & 0xFFF)
13571 +#define VC_CMD(c, i, v) ((((VC_CAT_ ## c) & 0x3F) << 24) \
13572 + | (((i) & 0xFF) << 16) | ((v) & 0xFFF))
13576 + Syscall Matrix V2.8
13578 + |VERSION|CREATE |MODIFY |MIGRATE|CONTROL|EXPERIM| |SPECIAL|SPECIAL|
13579 + |STATS |DESTROY|ALTER |CHANGE |LIMIT |TEST | | | |
13580 + |INFO |SETUP | |MOVE | | | | | |
13581 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13582 + SYSTEM |VERSION|VSETUP |VHOST | | | | |DEVICE | |
13583 + HOST | 00| 01| 02| 03| 04| 05| | 06| 07|
13584 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13585 + CPU | |VPROC |PROCALT|PROCMIG|PROCTRL| | |SCHED. | |
13586 + PROCESS| 08| 09| 10| 11| 12| 13| | 14| 15|
13587 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13588 + MEMORY | | | | |MEMCTRL| | |SWAP | |
13589 + | 16| 17| 18| 19| 20| 21| | 22| 23|
13590 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13591 + NETWORK| |VNET |NETALT |NETMIG |NETCTL | | |SERIAL | |
13592 + | 24| 25| 26| 27| 28| 29| | 30| 31|
13593 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13594 + DISK | | | |TAGMIG |DLIMIT | | |INODE | |
13595 + VFS | 32| 33| 34| 35| 36| 37| | 38| 39|
13596 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13597 + OTHER |VSTAT | | | | | | |VINFO | |
13598 + | 40| 41| 42| 43| 44| 45| | 46| 47|
13599 + =======+=======+=======+=======+=======+=======+=======+ +=======+=======+
13600 + SPECIAL|EVENT | | | |FLAGS | | |VSPACE | |
13601 + | 48| 49| 50| 51| 52| 53| | 54| 55|
13602 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13603 + SPECIAL|DEBUG | | | |RLIMIT |SYSCALL| | |COMPAT |
13604 + | 56| 57| 58| 59| 60|TEST 61| | 62| 63|
13605 + -------+-------+-------+-------+-------+-------+-------+ +-------+-------+
13609 +#define VC_CAT_VERSION 0
13611 +#define VC_CAT_VSETUP 1
13612 +#define VC_CAT_VHOST 2
13614 +#define VC_CAT_DEVICE 6
13616 +#define VC_CAT_VPROC 9
13617 +#define VC_CAT_PROCALT 10
13618 +#define VC_CAT_PROCMIG 11
13619 +#define VC_CAT_PROCTRL 12
13621 +#define VC_CAT_SCHED 14
13622 +#define VC_CAT_MEMCTRL 20
13624 +#define VC_CAT_VNET 25
13625 +#define VC_CAT_NETALT 26
13626 +#define VC_CAT_NETMIG 27
13627 +#define VC_CAT_NETCTRL 28
13629 +#define VC_CAT_TAGMIG 35
13630 +#define VC_CAT_DLIMIT 36
13631 +#define VC_CAT_INODE 38
13633 +#define VC_CAT_VSTAT 40
13634 +#define VC_CAT_VINFO 46
13635 +#define VC_CAT_EVENT 48
13637 +#define VC_CAT_FLAGS 52
13638 +#define VC_CAT_VSPACE 54
13639 +#define VC_CAT_DEBUG 56
13640 +#define VC_CAT_RLIMIT 60
13642 +#define VC_CAT_SYSTEST 61
13643 +#define VC_CAT_COMPAT 63
13645 +/* query version */
13647 +#define VCMD_get_version VC_CMD(VERSION, 0, 0)
13648 +#define VCMD_get_vci VC_CMD(VERSION, 1, 0)
13653 +#include <linux/errno.h>
13655 +#endif /* __KERNEL__ */
13657 +#endif /* _VX_SWITCH_H */
13659 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/tag.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/tag.h
13660 --- linux-3.4.103/include/linux/vserver/tag.h 1970-01-01 00:00:00.000000000 +0000
13661 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/tag.h 2012-05-21 16:15:05.000000000 +0000
13666 +#include <linux/types.h>
13669 +#define DX_TAG(in) (IS_TAGGED(in))
13672 +#ifdef CONFIG_TAG_NFSD
13673 +#define DX_TAG_NFSD 1
13675 +#define DX_TAG_NFSD 0
13679 +#ifdef CONFIG_TAGGING_NONE
13681 +#define MAX_UID 0xFFFFFFFF
13682 +#define MAX_GID 0xFFFFFFFF
13684 +#define INOTAG_TAG(cond, uid, gid, tag) (0)
13686 +#define TAGINO_UID(cond, uid, tag) (uid)
13687 +#define TAGINO_GID(cond, gid, tag) (gid)
13692 +#ifdef CONFIG_TAGGING_GID16
13694 +#define MAX_UID 0xFFFFFFFF
13695 +#define MAX_GID 0x0000FFFF
13697 +#define INOTAG_TAG(cond, uid, gid, tag) \
13698 + ((cond) ? (((gid) >> 16) & 0xFFFF) : 0)
13700 +#define TAGINO_UID(cond, uid, tag) (uid)
13701 +#define TAGINO_GID(cond, gid, tag) \
13702 + ((cond) ? (((gid) & 0xFFFF) | ((tag) << 16)) : (gid))
13707 +#ifdef CONFIG_TAGGING_ID24
13709 +#define MAX_UID 0x00FFFFFF
13710 +#define MAX_GID 0x00FFFFFF
13712 +#define INOTAG_TAG(cond, uid, gid, tag) \
13713 + ((cond) ? ((((uid) >> 16) & 0xFF00) | (((gid) >> 24) & 0xFF)) : 0)
13715 +#define TAGINO_UID(cond, uid, tag) \
13716 + ((cond) ? (((uid) & 0xFFFFFF) | (((tag) & 0xFF00) << 16)) : (uid))
13717 +#define TAGINO_GID(cond, gid, tag) \
13718 + ((cond) ? (((gid) & 0xFFFFFF) | (((tag) & 0x00FF) << 24)) : (gid))
13723 +#ifdef CONFIG_TAGGING_UID16
13725 +#define MAX_UID 0x0000FFFF
13726 +#define MAX_GID 0xFFFFFFFF
13728 +#define INOTAG_TAG(cond, uid, gid, tag) \
13729 + ((cond) ? (((uid) >> 16) & 0xFFFF) : 0)
13731 +#define TAGINO_UID(cond, uid, tag) \
13732 + ((cond) ? (((uid) & 0xFFFF) | ((tag) << 16)) : (uid))
13733 +#define TAGINO_GID(cond, gid, tag) (gid)
13738 +#ifdef CONFIG_TAGGING_INTERN
13740 +#define MAX_UID 0xFFFFFFFF
13741 +#define MAX_GID 0xFFFFFFFF
13743 +#define INOTAG_TAG(cond, uid, gid, tag) \
13744 + ((cond) ? (tag) : 0)
13746 +#define TAGINO_UID(cond, uid, tag) (uid)
13747 +#define TAGINO_GID(cond, gid, tag) (gid)
13752 +#ifndef CONFIG_TAGGING_NONE
13753 +#define dx_current_fstag(sb) \
13754 + ((sb)->s_flags & MS_TAGGED ? dx_current_tag() : 0)
13756 +#define dx_current_fstag(sb) (0)
13759 +#ifndef CONFIG_TAGGING_INTERN
13760 +#define TAGINO_TAG(cond, tag) (0)
13762 +#define TAGINO_TAG(cond, tag) ((cond) ? (tag) : 0)
13765 +#define INOTAG_UID(cond, uid, gid) \
13766 + ((cond) ? ((uid) & MAX_UID) : (uid))
13767 +#define INOTAG_GID(cond, uid, gid) \
13768 + ((cond) ? ((gid) & MAX_GID) : (gid))
13771 +static inline uid_t dx_map_uid(uid_t uid)
13773 + if ((uid > MAX_UID) && (uid != -1))
13775 + return (uid & MAX_UID);
13778 +static inline gid_t dx_map_gid(gid_t gid)
13780 + if ((gid > MAX_GID) && (gid != -1))
13782 + return (gid & MAX_GID);
13790 +#define dx_notagcheck(sb) ((sb) && ((sb)->s_flags & MS_NOTAGCHECK))
13792 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
13793 + unsigned long *flags);
13795 +#ifdef CONFIG_PROPAGATE
13797 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode);
13799 +#define dx_propagate_tag(n, i) __dx_propagate_tag(n, i)
13802 +#define dx_propagate_tag(n, i) do { } while (0)
13805 +#endif /* _DX_TAG_H */
13806 diff -NurpP --minimal linux-3.4.103/include/linux/vserver/tag_cmd.h linux-3.4.103-vs2.3.3.9/include/linux/vserver/tag_cmd.h
13807 --- linux-3.4.103/include/linux/vserver/tag_cmd.h 1970-01-01 00:00:00.000000000 +0000
13808 +++ linux-3.4.103-vs2.3.3.9/include/linux/vserver/tag_cmd.h 2012-05-21 16:15:05.000000000 +0000
13810 +#ifndef _VX_TAG_CMD_H
13811 +#define _VX_TAG_CMD_H
13814 +/* vinfo commands */
13816 +#define VCMD_task_tag VC_CMD(VINFO, 3, 0)
13819 +extern int vc_task_tag(uint32_t);
13821 +#endif /* __KERNEL__ */
13823 +/* context commands */
13825 +#define VCMD_tag_migrate VC_CMD(TAGMIG, 1, 0)
13828 +extern int vc_tag_migrate(uint32_t);
13830 +#endif /* __KERNEL__ */
13831 +#endif /* _VX_TAG_CMD_H */
13832 diff -NurpP --minimal linux-3.4.103/include/net/addrconf.h linux-3.4.103-vs2.3.3.9/include/net/addrconf.h
13833 --- linux-3.4.103/include/net/addrconf.h 2014-08-30 13:37:17.000000000 +0000
13834 +++ linux-3.4.103-vs2.3.3.9/include/net/addrconf.h 2013-08-13 17:08:10.000000000 +0000
13835 @@ -80,7 +80,8 @@ extern int ipv6_dev_get_saddr(struct n
13836 struct net_device *dev,
13837 const struct in6_addr *daddr,
13838 unsigned int srcprefs,
13839 - struct in6_addr *saddr);
13840 + struct in6_addr *saddr,
13841 + struct nx_info *nxi);
13842 extern int __ipv6_get_lladdr(struct inet6_dev *idev,
13843 struct in6_addr *addr,
13844 unsigned char banned_flags);
13845 diff -NurpP --minimal linux-3.4.103/include/net/af_unix.h linux-3.4.103-vs2.3.3.9/include/net/af_unix.h
13846 --- linux-3.4.103/include/net/af_unix.h 2012-05-21 16:07:33.000000000 +0000
13847 +++ linux-3.4.103-vs2.3.3.9/include/net/af_unix.h 2012-05-21 16:15:05.000000000 +0000
13849 #include <linux/socket.h>
13850 #include <linux/un.h>
13851 #include <linux/mutex.h>
13852 +#include <linux/vs_base.h>
13853 #include <net/sock.h>
13855 extern void unix_inflight(struct file *fp);
13856 diff -NurpP --minimal linux-3.4.103/include/net/inet_timewait_sock.h linux-3.4.103-vs2.3.3.9/include/net/inet_timewait_sock.h
13857 --- linux-3.4.103/include/net/inet_timewait_sock.h 2012-03-19 18:47:29.000000000 +0000
13858 +++ linux-3.4.103-vs2.3.3.9/include/net/inet_timewait_sock.h 2012-05-21 16:15:05.000000000 +0000
13859 @@ -112,6 +112,10 @@ struct inet_timewait_sock {
13860 #define tw_net __tw_common.skc_net
13861 #define tw_daddr __tw_common.skc_daddr
13862 #define tw_rcv_saddr __tw_common.skc_rcv_saddr
13863 +#define tw_xid __tw_common.skc_xid
13864 +#define tw_vx_info __tw_common.skc_vx_info
13865 +#define tw_nid __tw_common.skc_nid
13866 +#define tw_nx_info __tw_common.skc_nx_info
13868 volatile unsigned char tw_substate;
13869 unsigned char tw_rcv_wscale;
13870 diff -NurpP --minimal linux-3.4.103/include/net/ip6_route.h linux-3.4.103-vs2.3.3.9/include/net/ip6_route.h
13871 --- linux-3.4.103/include/net/ip6_route.h 2014-08-30 13:37:18.000000000 +0000
13872 +++ linux-3.4.103-vs2.3.3.9/include/net/ip6_route.h 2014-06-12 11:34:38.000000000 +0000
13873 @@ -93,7 +93,8 @@ extern int ip6_route_get_saddr(struct
13874 struct rt6_info *rt,
13875 const struct in6_addr *daddr,
13876 unsigned int prefs,
13877 - struct in6_addr *saddr);
13878 + struct in6_addr *saddr,
13879 + struct nx_info *nxi);
13881 extern struct rt6_info *rt6_lookup(struct net *net,
13882 const struct in6_addr *daddr,
13883 diff -NurpP --minimal linux-3.4.103/include/net/route.h linux-3.4.103-vs2.3.3.9/include/net/route.h
13884 --- linux-3.4.103/include/net/route.h 2012-03-19 18:47:29.000000000 +0000
13885 +++ linux-3.4.103-vs2.3.3.9/include/net/route.h 2012-05-21 16:15:05.000000000 +0000
13886 @@ -202,6 +202,9 @@ static inline void ip_rt_put(struct rtab
13887 dst_release(&rt->dst);
13890 +#include <linux/vs_base.h>
13891 +#include <linux/vs_inet.h>
13893 #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3)
13895 extern const __u8 ip_tos2prio[16];
13896 @@ -253,6 +256,9 @@ static inline void ip_route_connect_init
13897 protocol, flow_flags, dst, src, dport, sport);
13900 +extern struct rtable *ip_v4_find_src(struct net *net, struct nx_info *,
13901 + struct flowi4 *);
13903 static inline struct rtable *ip_route_connect(struct flowi4 *fl4,
13904 __be32 dst, __be32 src, u32 tos,
13905 int oif, u8 protocol,
13906 @@ -261,11 +267,25 @@ static inline struct rtable *ip_route_co
13908 struct net *net = sock_net(sk);
13910 + struct nx_info *nx_info = current_nx_info();
13912 ip_route_connect_init(fl4, dst, src, tos, oif, protocol,
13913 sport, dport, sk, can_sleep);
13915 - if (!dst || !src) {
13917 + nx_info = sk->sk_nx_info;
13919 + vxdprintk(VXD_CBIT(net, 4),
13920 + "ip_route_connect(%p) %p,%p;%lx",
13921 + sk, nx_info, sk->sk_socket,
13922 + (sk->sk_socket?sk->sk_socket->flags:0));
13924 + rt = ip_v4_find_src(net, nx_info, fl4);
13929 + if (!fl4->daddr || !fl4->saddr) {
13930 rt = __ip_route_output_key(net, fl4);
13933 diff -NurpP --minimal linux-3.4.103/include/net/sock.h linux-3.4.103-vs2.3.3.9/include/net/sock.h
13934 --- linux-3.4.103/include/net/sock.h 2014-08-30 13:37:18.000000000 +0000
13935 +++ linux-3.4.103-vs2.3.3.9/include/net/sock.h 2013-07-14 13:38:35.000000000 +0000
13936 @@ -170,6 +170,10 @@ struct sock_common {
13937 #ifdef CONFIG_NET_NS
13938 struct net *skc_net;
13941 + struct vx_info *skc_vx_info;
13943 + struct nx_info *skc_nx_info;
13945 * fields between dontcopy_begin/dontcopy_end
13946 * are not copied in sock_copy()
13947 @@ -282,6 +286,10 @@ struct sock {
13948 #define sk_bind_node __sk_common.skc_bind_node
13949 #define sk_prot __sk_common.skc_prot
13950 #define sk_net __sk_common.skc_net
13951 +#define sk_xid __sk_common.skc_xid
13952 +#define sk_vx_info __sk_common.skc_vx_info
13953 +#define sk_nid __sk_common.skc_nid
13954 +#define sk_nx_info __sk_common.skc_nx_info
13955 socket_lock_t sk_lock;
13956 struct sk_buff_head sk_receive_queue;
13958 diff -NurpP --minimal linux-3.4.103/init/Kconfig linux-3.4.103-vs2.3.3.9/init/Kconfig
13959 --- linux-3.4.103/init/Kconfig 2012-05-21 16:07:33.000000000 +0000
13960 +++ linux-3.4.103-vs2.3.3.9/init/Kconfig 2012-05-21 16:15:05.000000000 +0000
13961 @@ -579,6 +579,7 @@ config HAVE_UNSTABLE_SCHED_CLOCK
13963 boolean "Control Group support"
13967 This option adds support for grouping sets of processes together, for
13968 use with process control subsystems such as Cpusets, CFS, memory
13969 @@ -828,6 +829,7 @@ config IPC_NS
13971 bool "User namespace (EXPERIMENTAL)"
13972 depends on EXPERIMENTAL
13973 + depends on VSERVER_DISABLED
13976 This allows containers, i.e. vservers, to use user namespaces
13977 diff -NurpP --minimal linux-3.4.103/init/main.c linux-3.4.103-vs2.3.3.9/init/main.c
13978 --- linux-3.4.103/init/main.c 2014-08-30 13:37:18.000000000 +0000
13979 +++ linux-3.4.103-vs2.3.3.9/init/main.c 2014-08-30 13:55:46.000000000 +0000
13981 #include <linux/slab.h>
13982 #include <linux/perf_event.h>
13983 #include <linux/random.h>
13984 +#include <linux/vserver/percpu.h>
13986 #include <asm/io.h>
13987 #include <asm/bugs.h>
13988 diff -NurpP --minimal linux-3.4.103/ipc/mqueue.c linux-3.4.103-vs2.3.3.9/ipc/mqueue.c
13989 --- linux-3.4.103/ipc/mqueue.c 2012-05-21 16:07:34.000000000 +0000
13990 +++ linux-3.4.103-vs2.3.3.9/ipc/mqueue.c 2012-05-21 16:15:05.000000000 +0000
13992 #include <linux/ipc_namespace.h>
13993 #include <linux/user_namespace.h>
13994 #include <linux/slab.h>
13995 +#include <linux/vs_context.h>
13996 +#include <linux/vs_limit.h>
13998 #include <net/sock.h>
14000 @@ -67,6 +69,7 @@ struct mqueue_inode_info {
14001 struct sigevent notify;
14002 struct pid* notify_owner;
14003 struct user_struct *user; /* user who created, for accounting */
14004 + struct vx_info *vxi;
14005 struct sock *notify_sock;
14006 struct sk_buff *notify_cookie;
14008 @@ -129,6 +132,7 @@ static struct inode *mqueue_get_inode(st
14009 if (S_ISREG(mode)) {
14010 struct mqueue_inode_info *info;
14011 unsigned long mq_bytes, mq_msg_tblsz;
14012 + struct vx_info *vxi = current_vx_info();
14014 inode->i_fop = &mqueue_file_operations;
14015 inode->i_size = FILENT_SIZE;
14016 @@ -141,6 +145,7 @@ static struct inode *mqueue_get_inode(st
14017 info->notify_owner = NULL;
14019 info->user = NULL; /* set when all is ok */
14020 + info->vxi = NULL;
14021 memset(&info->attr, 0, sizeof(info->attr));
14022 info->attr.mq_maxmsg = ipc_ns->mq_msg_max;
14023 info->attr.mq_msgsize = ipc_ns->mq_msgsize_max;
14024 @@ -158,17 +163,20 @@ static struct inode *mqueue_get_inode(st
14026 spin_lock(&mq_lock);
14027 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
14028 - u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
14029 + u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE) ||
14030 + !vx_ipcmsg_avail(vxi, mq_bytes)) {
14031 spin_unlock(&mq_lock);
14032 /* mqueue_evict_inode() releases info->messages */
14036 u->mq_bytes += mq_bytes;
14037 + vx_ipcmsg_add(vxi, u, mq_bytes);
14038 spin_unlock(&mq_lock);
14041 info->user = get_uid(u);
14042 + info->vxi = get_vx_info(vxi);
14043 } else if (S_ISDIR(mode)) {
14045 /* Some things misbehave if size == 0 on a directory */
14046 @@ -267,8 +275,11 @@ static void mqueue_evict_inode(struct in
14047 + info->attr.mq_msgsize);
14050 + struct vx_info *vxi = info->vxi;
14052 spin_lock(&mq_lock);
14053 user->mq_bytes -= mq_bytes;
14054 + vx_ipcmsg_sub(vxi, user, mq_bytes);
14056 * get_ns_from_inode() ensures that the
14057 * (ipc_ns = sb->s_fs_info) is either a valid ipc_ns
14058 @@ -278,6 +289,7 @@ static void mqueue_evict_inode(struct in
14060 ipc_ns->mq_queues_count--;
14061 spin_unlock(&mq_lock);
14062 + put_vx_info(vxi);
14066 diff -NurpP --minimal linux-3.4.103/ipc/msg.c linux-3.4.103-vs2.3.3.9/ipc/msg.c
14067 --- linux-3.4.103/ipc/msg.c 2014-08-30 13:37:18.000000000 +0000
14068 +++ linux-3.4.103-vs2.3.3.9/ipc/msg.c 2014-04-21 18:56:35.000000000 +0000
14070 #include <linux/rwsem.h>
14071 #include <linux/nsproxy.h>
14072 #include <linux/ipc_namespace.h>
14073 +#include <linux/vs_base.h>
14075 #include <asm/current.h>
14076 #include <asm/uaccess.h>
14077 @@ -190,6 +191,7 @@ static int newque(struct ipc_namespace *
14079 msq->q_perm.mode = msgflg & S_IRWXUGO;
14080 msq->q_perm.key = key;
14081 + msq->q_perm.xid = vx_current_xid();
14083 msq->q_perm.security = NULL;
14084 retval = security_msg_queue_alloc(msq);
14085 diff -NurpP --minimal linux-3.4.103/ipc/namespace.c linux-3.4.103-vs2.3.3.9/ipc/namespace.c
14086 --- linux-3.4.103/ipc/namespace.c 2011-07-22 09:18:12.000000000 +0000
14087 +++ linux-3.4.103-vs2.3.3.9/ipc/namespace.c 2012-05-21 16:15:05.000000000 +0000
14088 @@ -13,11 +13,12 @@
14089 #include <linux/mount.h>
14090 #include <linux/user_namespace.h>
14091 #include <linux/proc_fs.h>
14092 +#include <linux/vs_base.h>
14093 +#include <linux/vserver/global.h>
14097 -static struct ipc_namespace *create_ipc_ns(struct task_struct *tsk,
14098 - struct ipc_namespace *old_ns)
14099 +static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns)
14101 struct ipc_namespace *ns;
14103 @@ -46,19 +47,18 @@ static struct ipc_namespace *create_ipc_
14104 ipcns_notify(IPCNS_CREATED);
14105 register_ipcns_notifier(ns);
14107 - ns->user_ns = get_user_ns(task_cred_xxx(tsk, user)->user_ns);
14108 + ns->user_ns = get_user_ns(user_ns);
14113 struct ipc_namespace *copy_ipcs(unsigned long flags,
14114 - struct task_struct *tsk)
14115 + struct ipc_namespace *old_ns,
14116 + struct user_namespace *user_ns)
14118 - struct ipc_namespace *ns = tsk->nsproxy->ipc_ns;
14120 if (!(flags & CLONE_NEWIPC))
14121 - return get_ipc_ns(ns);
14122 - return create_ipc_ns(tsk, ns);
14123 + return get_ipc_ns(old_ns);
14124 + return create_ipc_ns(user_ns);
14128 diff -NurpP --minimal linux-3.4.103/ipc/sem.c linux-3.4.103-vs2.3.3.9/ipc/sem.c
14129 --- linux-3.4.103/ipc/sem.c 2012-01-09 15:14:59.000000000 +0000
14130 +++ linux-3.4.103-vs2.3.3.9/ipc/sem.c 2012-05-21 16:15:05.000000000 +0000
14132 #include <linux/rwsem.h>
14133 #include <linux/nsproxy.h>
14134 #include <linux/ipc_namespace.h>
14135 +#include <linux/vs_base.h>
14136 +#include <linux/vs_limit.h>
14138 #include <asm/uaccess.h>
14140 @@ -306,6 +308,7 @@ static int newary(struct ipc_namespace *
14142 sma->sem_perm.mode = (semflg & S_IRWXUGO);
14143 sma->sem_perm.key = key;
14144 + sma->sem_perm.xid = vx_current_xid();
14146 sma->sem_perm.security = NULL;
14147 retval = security_sem_alloc(sma);
14148 @@ -321,6 +324,9 @@ static int newary(struct ipc_namespace *
14151 ns->used_sems += nsems;
14152 + /* FIXME: obsoleted? */
14153 + vx_semary_inc(sma);
14154 + vx_nsems_add(sma, nsems);
14156 sma->sem_base = (struct sem *) &sma[1];
14158 @@ -770,6 +776,9 @@ static void freeary(struct ipc_namespace
14160 wake_up_sem_queue_do(&tasks);
14161 ns->used_sems -= sma->sem_nsems;
14162 + /* FIXME: obsoleted? */
14163 + vx_nsems_sub(sma, sma->sem_nsems);
14164 + vx_semary_dec(sma);
14165 security_sem_free(sma);
14166 ipc_rcu_putref(sma);
14168 diff -NurpP --minimal linux-3.4.103/ipc/shm.c linux-3.4.103-vs2.3.3.9/ipc/shm.c
14169 --- linux-3.4.103/ipc/shm.c 2014-08-30 13:37:18.000000000 +0000
14170 +++ linux-3.4.103-vs2.3.3.9/ipc/shm.c 2013-07-14 13:38:36.000000000 +0000
14172 #include <linux/nsproxy.h>
14173 #include <linux/mount.h>
14174 #include <linux/ipc_namespace.h>
14175 +#include <linux/vs_context.h>
14176 +#include <linux/vs_limit.h>
14178 #include <asm/uaccess.h>
14180 @@ -187,7 +189,12 @@ static void shm_open(struct vm_area_stru
14182 static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
14184 - ns->shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14185 + struct vx_info *vxi = lookup_vx_info(shp->shm_perm.xid);
14186 + int numpages = (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
14188 + vx_ipcshm_sub(vxi, shp, numpages);
14189 + ns->shm_tot -= numpages;
14193 if (!is_file_hugepages(shp->shm_file))
14194 @@ -197,6 +204,7 @@ static void shm_destroy(struct ipc_names
14196 fput (shp->shm_file);
14197 security_shm_free(shp);
14198 + put_vx_info(vxi);
14199 ipc_rcu_putref(shp);
14202 @@ -462,11 +470,15 @@ static int newseg(struct ipc_namespace *
14203 if (ns->shm_tot + numpages > ns->shm_ctlall)
14206 + if (!vx_ipcshm_avail(current_vx_info(), numpages))
14209 shp = ipc_rcu_alloc(sizeof(*shp));
14213 shp->shm_perm.key = key;
14214 + shp->shm_perm.xid = vx_current_xid();
14215 shp->shm_perm.mode = (shmflg & S_IRWXUGO);
14216 shp->mlock_user = NULL;
14218 @@ -523,6 +535,7 @@ static int newseg(struct ipc_namespace *
14219 ns->shm_tot += numpages;
14220 error = shp->shm_perm.id;
14222 + vx_ipcshm_add(current_vx_info(), key, numpages);
14226 diff -NurpP --minimal linux-3.4.103/kernel/Makefile linux-3.4.103-vs2.3.3.9/kernel/Makefile
14227 --- linux-3.4.103/kernel/Makefile 2012-05-21 16:07:34.000000000 +0000
14228 +++ linux-3.4.103-vs2.3.3.9/kernel/Makefile 2012-05-21 16:15:05.000000000 +0000
14229 @@ -25,6 +25,7 @@ endif
14234 obj-$(CONFIG_FREEZER) += freezer.o
14235 obj-$(CONFIG_PROFILING) += profile.o
14236 obj-$(CONFIG_STACKTRACE) += stacktrace.o
14237 diff -NurpP --minimal linux-3.4.103/kernel/auditsc.c linux-3.4.103-vs2.3.3.9/kernel/auditsc.c
14238 --- linux-3.4.103/kernel/auditsc.c 2014-08-30 13:37:18.000000000 +0000
14239 +++ linux-3.4.103-vs2.3.3.9/kernel/auditsc.c 2014-08-30 13:55:46.000000000 +0000
14240 @@ -2317,7 +2317,7 @@ int audit_set_loginuid(uid_t loginuid)
14241 if (task->loginuid != -1)
14243 #else /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
14244 - if (!capable(CAP_AUDIT_CONTROL))
14245 + if (!vx_capable(CAP_AUDIT_CONTROL, VXC_AUDIT_CONTROL))
14247 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
14249 diff -NurpP --minimal linux-3.4.103/kernel/capability.c linux-3.4.103-vs2.3.3.9/kernel/capability.c
14250 --- linux-3.4.103/kernel/capability.c 2012-03-19 18:47:29.000000000 +0000
14251 +++ linux-3.4.103-vs2.3.3.9/kernel/capability.c 2012-05-21 16:15:05.000000000 +0000
14253 #include <linux/syscalls.h>
14254 #include <linux/pid_namespace.h>
14255 #include <linux/user_namespace.h>
14256 +#include <linux/vs_context.h>
14257 #include <asm/uaccess.h>
14260 @@ -116,6 +117,7 @@ static int cap_validate_magic(cap_user_h
14266 * The only thing that can change the capabilities of the current
14267 * process is the current process. As such, we can't be in this code
14268 @@ -349,6 +351,8 @@ bool has_ns_capability_noaudit(struct ta
14272 +#include <linux/vserver/base.h>
14275 * has_capability_noaudit - Does a task have a capability (unaudited) in the
14277 diff -NurpP --minimal linux-3.4.103/kernel/compat.c linux-3.4.103-vs2.3.3.9/kernel/compat.c
14278 --- linux-3.4.103/kernel/compat.c 2012-05-21 16:07:34.000000000 +0000
14279 +++ linux-3.4.103-vs2.3.3.9/kernel/compat.c 2012-05-21 16:15:05.000000000 +0000
14280 @@ -1054,7 +1054,7 @@ asmlinkage long compat_sys_stime(compat_
14284 - do_settimeofday(&tv);
14285 + vx_settimeofday(&tv);
14289 diff -NurpP --minimal linux-3.4.103/kernel/cred.c linux-3.4.103-vs2.3.3.9/kernel/cred.c
14290 --- linux-3.4.103/kernel/cred.c 2012-05-21 16:07:34.000000000 +0000
14291 +++ linux-3.4.103-vs2.3.3.9/kernel/cred.c 2012-05-21 16:15:05.000000000 +0000
14292 @@ -62,31 +62,6 @@ struct cred init_cred = {
14296 -static inline void set_cred_subscribers(struct cred *cred, int n)
14298 -#ifdef CONFIG_DEBUG_CREDENTIALS
14299 - atomic_set(&cred->subscribers, n);
14303 -static inline int read_cred_subscribers(const struct cred *cred)
14305 -#ifdef CONFIG_DEBUG_CREDENTIALS
14306 - return atomic_read(&cred->subscribers);
14312 -static inline void alter_cred_subscribers(const struct cred *_cred, int n)
14314 -#ifdef CONFIG_DEBUG_CREDENTIALS
14315 - struct cred *cred = (struct cred *) _cred;
14317 - atomic_add(n, &cred->subscribers);
14322 * Dispose of the shared task group credentials
14324 @@ -282,21 +257,16 @@ error:
14326 * Call commit_creds() or abort_creds() to clean up.
14328 -struct cred *prepare_creds(void)
14329 +struct cred *__prepare_creds(const struct cred *old)
14331 - struct task_struct *task = current;
14332 - const struct cred *old;
14335 - validate_process_creds();
14337 new = kmem_cache_alloc(cred_jar, GFP_KERNEL);
14341 kdebug("prepare_creds() alloc %p", new);
14343 - old = task->cred;
14344 memcpy(new, old, sizeof(struct cred));
14346 atomic_set(&new->usage, 1);
14347 @@ -323,6 +293,13 @@ error:
14352 +struct cred *prepare_creds(void)
14354 + validate_process_creds();
14356 + return __prepare_creds(current->cred);
14358 EXPORT_SYMBOL(prepare_creds);
14361 diff -NurpP --minimal linux-3.4.103/kernel/exit.c linux-3.4.103-vs2.3.3.9/kernel/exit.c
14362 --- linux-3.4.103/kernel/exit.c 2014-08-30 13:37:18.000000000 +0000
14363 +++ linux-3.4.103-vs2.3.3.9/kernel/exit.c 2014-05-20 04:30:31.000000000 +0000
14365 #include <linux/fs_struct.h>
14366 #include <linux/init_task.h>
14367 #include <linux/perf_event.h>
14368 +#include <linux/vs_limit.h>
14369 +#include <linux/vs_context.h>
14370 +#include <linux/vs_network.h>
14371 +#include <linux/vs_pid.h>
14372 #include <trace/events/sched.h>
14373 #include <linux/hw_breakpoint.h>
14374 #include <linux/oom.h>
14375 @@ -482,9 +486,11 @@ static void close_files(struct files_str
14376 filp_close(file, files);
14379 + vx_openfd_dec(i);
14387 @@ -699,15 +705,25 @@ static struct task_struct *find_new_reap
14388 __acquires(&tasklist_lock)
14390 struct pid_namespace *pid_ns = task_active_pid_ns(father);
14391 - struct task_struct *thread;
14392 + struct vx_info *vxi = task_get_vx_info(father);
14393 + struct task_struct *thread = father;
14394 + struct task_struct *reaper;
14397 while_each_thread(father, thread) {
14398 if (thread->flags & PF_EXITING)
14400 if (unlikely(pid_ns->child_reaper == father))
14401 pid_ns->child_reaper = thread;
14407 + reaper = pid_ns->child_reaper;
14409 + BUG_ON(!vxi->vx_reaper);
14410 + if (vxi->vx_reaper != init_pid_ns.child_reaper &&
14411 + vxi->vx_reaper != father)
14412 + reaper = vxi->vx_reaper;
14415 if (unlikely(pid_ns->child_reaper == father)) {
14416 @@ -751,7 +767,9 @@ static struct task_struct *find_new_reap
14420 - return pid_ns->child_reaper;
14422 + put_vx_info(vxi);
14427 @@ -809,10 +827,15 @@ static void forget_original_parent(struc
14428 list_for_each_entry_safe(p, n, &father->children, sibling) {
14429 struct task_struct *t = p;
14431 - t->real_parent = reaper;
14432 + struct task_struct *new_parent = reaper;
14434 + if (unlikely(p == reaper))
14435 + new_parent = task_active_pid_ns(p)->child_reaper;
14437 + t->real_parent = new_parent;
14438 if (t->parent == father) {
14440 - t->parent = t->real_parent;
14441 + t->parent = new_parent;
14443 if (t->pdeath_signal)
14444 group_send_sig_info(t->pdeath_signal,
14445 @@ -1020,6 +1043,9 @@ void do_exit(long code)
14447 ptrace_put_breakpoints(tsk);
14449 + /* needs to stay before exit_notify() */
14450 + exit_vx_info_early(tsk, code);
14452 exit_notify(tsk, group_dead);
14455 @@ -1070,10 +1096,15 @@ void do_exit(long code)
14457 raw_spin_unlock_wait(&tsk->pi_lock);
14459 + /* needs to stay after exit_notify() */
14460 + exit_vx_info(tsk, code);
14461 + exit_nx_info(tsk);
14463 /* causes final put_task_struct in finish_task_switch(). */
14464 tsk->state = TASK_DEAD;
14465 tsk->flags |= PF_NOFREEZE; /* tell freezer to ignore us */
14467 + printk("bad task: %p [%lx]\n", current, current->state);
14469 /* Avoid "noreturn function does return". */
14471 diff -NurpP --minimal linux-3.4.103/kernel/fork.c linux-3.4.103-vs2.3.3.9/kernel/fork.c
14472 --- linux-3.4.103/kernel/fork.c 2014-08-30 13:37:18.000000000 +0000
14473 +++ linux-3.4.103-vs2.3.3.9/kernel/fork.c 2014-08-30 13:56:13.000000000 +0000
14475 #include <linux/oom.h>
14476 #include <linux/khugepaged.h>
14477 #include <linux/signalfd.h>
14478 +#include <linux/vs_context.h>
14479 +#include <linux/vs_network.h>
14480 +#include <linux/vs_limit.h>
14482 #include <asm/pgtable.h>
14483 #include <asm/pgalloc.h>
14484 @@ -170,6 +173,8 @@ void free_task(struct task_struct *tsk)
14485 account_kernel_stack(tsk->stack, -1);
14486 free_thread_info(tsk->stack);
14487 rt_mutex_debug_task_free(tsk);
14488 + clr_vx_info(&tsk->vx_info);
14489 + clr_nx_info(&tsk->nx_info);
14490 ftrace_graph_exit_task(tsk);
14491 free_task_struct(tsk);
14493 @@ -507,6 +512,7 @@ static struct mm_struct *mm_init(struct
14494 if (likely(!mm_alloc_pgd(mm))) {
14496 mmu_notifier_mm_init(mm);
14497 + set_vx_info(&mm->mm_vx_info, p->vx_info);
14501 @@ -559,6 +565,7 @@ void __mmdrop(struct mm_struct *mm)
14502 destroy_context(mm);
14503 mmu_notifier_mm_destroy(mm);
14505 + clr_vx_info(&mm->mm_vx_info);
14508 EXPORT_SYMBOL_GPL(__mmdrop);
14509 @@ -794,6 +801,7 @@ struct mm_struct *dup_mm(struct task_str
14512 memcpy(mm, oldmm, sizeof(*mm));
14513 + mm->mm_vx_info = NULL;
14514 mm_init_cpumask(mm);
14516 /* Initializing for Swap token stuff */
14517 @@ -837,6 +845,7 @@ fail_nocontext:
14518 * If init_new_context() failed, we cannot use mmput() to free the mm
14519 * because it calls destroy_context()
14521 + clr_vx_info(&mm->mm_vx_info);
14525 @@ -1124,6 +1133,8 @@ static struct task_struct *copy_process(
14528 struct task_struct *p;
14529 + struct vx_info *vxi;
14530 + struct nx_info *nxi;
14532 if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
14533 return ERR_PTR(-EINVAL);
14534 @@ -1170,7 +1181,12 @@ static struct task_struct *copy_process(
14535 DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
14536 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
14538 + init_vx_info(&p->vx_info, current_vx_info());
14539 + init_nx_info(&p->nx_info, current_nx_info());
14542 + if (!vx_nproc_avail(1))
14543 + goto bad_fork_free;
14544 if (atomic_read(&p->real_cred->user->processes) >=
14545 task_rlimit(p, RLIMIT_NPROC)) {
14546 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
14547 @@ -1442,6 +1458,18 @@ static struct task_struct *copy_process(
14549 spin_unlock(¤t->sighand->siglock);
14550 syscall_tracepoint_update(p);
14552 + /* p is copy of current */
14553 + vxi = p->vx_info;
14555 + claim_vx_info(vxi, p);
14556 + atomic_inc(&vxi->cvirt.nr_threads);
14557 + atomic_inc(&vxi->cvirt.total_forks);
14560 + nxi = p->nx_info;
14562 + claim_nx_info(nxi, p);
14563 write_unlock_irq(&tasklist_lock);
14565 proc_fork_connector(p);
14566 diff -NurpP --minimal linux-3.4.103/kernel/kthread.c linux-3.4.103-vs2.3.3.9/kernel/kthread.c
14567 --- linux-3.4.103/kernel/kthread.c 2014-08-30 13:37:18.000000000 +0000
14568 +++ linux-3.4.103-vs2.3.3.9/kernel/kthread.c 2012-10-22 13:09:53.000000000 +0000
14570 #include <linux/mutex.h>
14571 #include <linux/slab.h>
14572 #include <linux/freezer.h>
14573 +#include <linux/vs_pid.h>
14574 #include <trace/events/sched.h>
14576 static DEFINE_SPINLOCK(kthread_create_lock);
14577 diff -NurpP --minimal linux-3.4.103/kernel/nsproxy.c linux-3.4.103-vs2.3.3.9/kernel/nsproxy.c
14578 --- linux-3.4.103/kernel/nsproxy.c 2012-01-09 15:15:00.000000000 +0000
14579 +++ linux-3.4.103-vs2.3.3.9/kernel/nsproxy.c 2012-05-21 16:15:05.000000000 +0000
14580 @@ -20,11 +20,14 @@
14581 #include <linux/mnt_namespace.h>
14582 #include <linux/utsname.h>
14583 #include <linux/pid_namespace.h>
14584 +#include <linux/vserver/global.h>
14585 +#include <linux/vserver/debug.h>
14586 #include <net/net_namespace.h>
14587 #include <linux/ipc_namespace.h>
14588 #include <linux/proc_fs.h>
14589 #include <linux/file.h>
14590 #include <linux/syscalls.h>
14591 +#include "../fs/mount.h"
14593 static struct kmem_cache *nsproxy_cachep;
14595 @@ -46,8 +49,11 @@ static inline struct nsproxy *create_nsp
14596 struct nsproxy *nsproxy;
14598 nsproxy = kmem_cache_alloc(nsproxy_cachep, GFP_KERNEL);
14601 atomic_set(&nsproxy->count, 1);
14602 + atomic_inc(&vs_global_nsproxy);
14604 + vxdprintk(VXD_CBIT(space, 2), "create_nsproxy = %p[1]", nsproxy);
14608 @@ -56,8 +62,11 @@ static inline struct nsproxy *create_nsp
14609 * Return the newly created nsproxy. Do not attach this to the task,
14610 * leave it to the caller to do proper locking and attach it to task.
14612 -static struct nsproxy *create_new_namespaces(unsigned long flags,
14613 - struct task_struct *tsk, struct fs_struct *new_fs)
14614 +static struct nsproxy *unshare_namespaces(unsigned long flags,
14615 + struct nsproxy *orig,
14616 + struct fs_struct *new_fs,
14617 + struct user_namespace *new_user,
14618 + struct pid_namespace *new_pid)
14620 struct nsproxy *new_nsp;
14622 @@ -66,31 +75,31 @@ static struct nsproxy *create_new_namesp
14624 return ERR_PTR(-ENOMEM);
14626 - new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
14627 + new_nsp->mnt_ns = copy_mnt_ns(flags, orig->mnt_ns, new_fs);
14628 if (IS_ERR(new_nsp->mnt_ns)) {
14629 err = PTR_ERR(new_nsp->mnt_ns);
14633 - new_nsp->uts_ns = copy_utsname(flags, tsk);
14634 + new_nsp->uts_ns = copy_utsname(flags, orig->uts_ns, new_user);
14635 if (IS_ERR(new_nsp->uts_ns)) {
14636 err = PTR_ERR(new_nsp->uts_ns);
14640 - new_nsp->ipc_ns = copy_ipcs(flags, tsk);
14641 + new_nsp->ipc_ns = copy_ipcs(flags, orig->ipc_ns, new_user);
14642 if (IS_ERR(new_nsp->ipc_ns)) {
14643 err = PTR_ERR(new_nsp->ipc_ns);
14647 - new_nsp->pid_ns = copy_pid_ns(flags, task_active_pid_ns(tsk));
14648 + new_nsp->pid_ns = copy_pid_ns(flags, new_pid);
14649 if (IS_ERR(new_nsp->pid_ns)) {
14650 err = PTR_ERR(new_nsp->pid_ns);
14654 - new_nsp->net_ns = copy_net_ns(flags, tsk->nsproxy->net_ns);
14655 + new_nsp->net_ns = copy_net_ns(flags, orig->net_ns);
14656 if (IS_ERR(new_nsp->net_ns)) {
14657 err = PTR_ERR(new_nsp->net_ns);
14659 @@ -115,6 +124,40 @@ out_ns:
14660 return ERR_PTR(err);
14663 +static struct nsproxy *create_new_namespaces(unsigned long flags,
14664 + struct task_struct *tsk, struct fs_struct *new_fs)
14666 + return unshare_namespaces(flags, tsk->nsproxy,
14667 + new_fs, task_cred_xxx(tsk, user)->user_ns,
14668 + task_active_pid_ns(tsk));
14672 + * copies the nsproxy, setting refcount to 1, and grabbing a
14673 + * reference to all contained namespaces.
14675 +struct nsproxy *copy_nsproxy(struct nsproxy *orig)
14677 + struct nsproxy *ns = create_nsproxy();
14680 + memcpy(ns, orig, sizeof(struct nsproxy));
14681 + atomic_set(&ns->count, 1);
14684 + get_mnt_ns(ns->mnt_ns);
14686 + get_uts_ns(ns->uts_ns);
14688 + get_ipc_ns(ns->ipc_ns);
14690 + get_pid_ns(ns->pid_ns);
14692 + get_net(ns->net_ns);
14698 * called from clone. This now handles copy for nsproxy and all
14699 * namespaces therein.
14700 @@ -122,9 +165,12 @@ out_ns:
14701 int copy_namespaces(unsigned long flags, struct task_struct *tsk)
14703 struct nsproxy *old_ns = tsk->nsproxy;
14704 - struct nsproxy *new_ns;
14705 + struct nsproxy *new_ns = NULL;
14708 + vxdprintk(VXD_CBIT(space, 7), "copy_namespaces(0x%08lx,%p[%p])",
14709 + flags, tsk, old_ns);
14714 @@ -134,7 +180,7 @@ int copy_namespaces(unsigned long flags,
14715 CLONE_NEWPID | CLONE_NEWNET)))
14718 - if (!capable(CAP_SYS_ADMIN)) {
14719 + if (!vx_can_unshare(CAP_SYS_ADMIN, flags)) {
14723 @@ -161,6 +207,9 @@ int copy_namespaces(unsigned long flags,
14726 put_nsproxy(old_ns);
14727 + vxdprintk(VXD_CBIT(space, 3),
14728 + "copy_namespaces(0x%08lx,%p[%p]) = %d [%p]",
14729 + flags, tsk, old_ns, err, new_ns);
14733 @@ -174,7 +223,9 @@ void free_nsproxy(struct nsproxy *ns)
14734 put_ipc_ns(ns->ipc_ns);
14736 put_pid_ns(ns->pid_ns);
14737 - put_net(ns->net_ns);
14739 + put_net(ns->net_ns);
14740 + atomic_dec(&vs_global_nsproxy);
14741 kmem_cache_free(nsproxy_cachep, ns);
14744 @@ -187,11 +238,15 @@ int unshare_nsproxy_namespaces(unsigned
14748 + vxdprintk(VXD_CBIT(space, 4),
14749 + "unshare_nsproxy_namespaces(0x%08lx,[%p])",
14750 + unshare_flags, current->nsproxy);
14752 if (!(unshare_flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC |
14756 - if (!capable(CAP_SYS_ADMIN))
14757 + if (!vx_can_unshare(CAP_SYS_ADMIN, unshare_flags))
14760 *new_nsp = create_new_namespaces(unshare_flags, current,
14761 diff -NurpP --minimal linux-3.4.103/kernel/pid.c linux-3.4.103-vs2.3.3.9/kernel/pid.c
14762 --- linux-3.4.103/kernel/pid.c 2012-03-19 18:47:30.000000000 +0000
14763 +++ linux-3.4.103-vs2.3.3.9/kernel/pid.c 2012-05-21 16:15:05.000000000 +0000
14765 #include <linux/pid_namespace.h>
14766 #include <linux/init_task.h>
14767 #include <linux/syscalls.h>
14768 +#include <linux/vs_pid.h>
14770 #define pid_hashfn(nr, ns) \
14771 hash_long((unsigned long)nr + (unsigned long)ns, pidhash_shift)
14772 @@ -344,7 +345,7 @@ EXPORT_SYMBOL_GPL(find_pid_ns);
14774 struct pid *find_vpid(int nr)
14776 - return find_pid_ns(nr, current->nsproxy->pid_ns);
14777 + return find_pid_ns(vx_rmap_pid(nr), current->nsproxy->pid_ns);
14779 EXPORT_SYMBOL_GPL(find_vpid);
14781 @@ -404,6 +405,9 @@ void transfer_pid(struct task_struct *ol
14782 struct task_struct *pid_task(struct pid *pid, enum pid_type type)
14784 struct task_struct *result = NULL;
14786 + if (type == PIDTYPE_REALPID)
14787 + type = PIDTYPE_PID;
14789 struct hlist_node *first;
14790 first = rcu_dereference_check(hlist_first_rcu(&pid->tasks[type]),
14791 @@ -423,7 +427,7 @@ struct task_struct *find_task_by_pid_ns(
14792 rcu_lockdep_assert(rcu_read_lock_held(),
14793 "find_task_by_pid_ns() needs rcu_read_lock()"
14795 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
14796 + return pid_task(find_pid_ns(vx_rmap_pid(nr), ns), PIDTYPE_PID);
14799 struct task_struct *find_task_by_vpid(pid_t vnr)
14800 @@ -467,7 +471,7 @@ struct pid *find_get_pid(pid_t nr)
14802 EXPORT_SYMBOL_GPL(find_get_pid);
14804 -pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
14805 +pid_t pid_unmapped_nr_ns(struct pid *pid, struct pid_namespace *ns)
14809 @@ -480,6 +484,11 @@ pid_t pid_nr_ns(struct pid *pid, struct
14813 +pid_t pid_nr_ns(struct pid *pid, struct pid_namespace *ns)
14815 + return vx_map_pid(pid_unmapped_nr_ns(pid, ns));
14818 pid_t pid_vnr(struct pid *pid)
14820 return pid_nr_ns(pid, current->nsproxy->pid_ns);
14821 diff -NurpP --minimal linux-3.4.103/kernel/pid_namespace.c linux-3.4.103-vs2.3.3.9/kernel/pid_namespace.c
14822 --- linux-3.4.103/kernel/pid_namespace.c 2012-05-21 16:07:34.000000000 +0000
14823 +++ linux-3.4.103-vs2.3.3.9/kernel/pid_namespace.c 2012-05-21 16:15:05.000000000 +0000
14825 #include <linux/slab.h>
14826 #include <linux/proc_fs.h>
14827 #include <linux/reboot.h>
14828 +#include <linux/vserver/global.h>
14830 #define BITS_PER_PAGE (PAGE_SIZE*8)
14832 @@ -89,6 +90,7 @@ static struct pid_namespace *create_pid_
14835 kref_init(&ns->kref);
14836 + atomic_inc(&vs_global_pid_ns);
14838 ns->parent = get_pid_ns(parent_pid_ns);
14840 @@ -120,6 +122,7 @@ static void destroy_pid_namespace(struct
14842 for (i = 0; i < PIDMAP_ENTRIES; i++)
14843 kfree(ns->pidmap[i].page);
14844 + atomic_dec(&vs_global_pid_ns);
14845 kmem_cache_free(pid_ns_cachep, ns);
14848 diff -NurpP --minimal linux-3.4.103/kernel/posix-timers.c linux-3.4.103-vs2.3.3.9/kernel/posix-timers.c
14849 --- linux-3.4.103/kernel/posix-timers.c 2014-08-30 13:37:18.000000000 +0000
14850 +++ linux-3.4.103-vs2.3.3.9/kernel/posix-timers.c 2013-03-30 21:29:17.000000000 +0000
14852 #include <linux/wait.h>
14853 #include <linux/workqueue.h>
14854 #include <linux/export.h>
14855 +#include <linux/vs_context.h>
14858 * Management arrays for POSIX timers. Timers are kept in slab memory
14859 @@ -340,6 +341,7 @@ int posix_timer_event(struct k_itimer *t
14861 struct task_struct *task;
14862 int shared, ret = -1;
14865 * FIXME: if ->sigq is queued we can race with
14866 * dequeue_signal()->do_schedule_next_timer().
14867 @@ -356,10 +358,18 @@ int posix_timer_event(struct k_itimer *t
14869 task = pid_task(timr->it_pid, PIDTYPE_PID);
14871 + struct vx_info_save vxis;
14872 + struct vx_info *vxi;
14874 + vxi = get_vx_info(task->vx_info);
14875 + enter_vx_info(vxi, &vxis);
14876 shared = !(timr->it_sigev_notify & SIGEV_THREAD_ID);
14877 ret = send_sigqueue(timr->sigq, task, shared);
14878 + leave_vx_info(&vxis);
14879 + put_vx_info(vxi);
14883 /* If we failed to send the signal the timer stops. */
14886 diff -NurpP --minimal linux-3.4.103/kernel/printk.c linux-3.4.103-vs2.3.3.9/kernel/printk.c
14887 --- linux-3.4.103/kernel/printk.c 2014-08-30 13:37:18.000000000 +0000
14888 +++ linux-3.4.103-vs2.3.3.9/kernel/printk.c 2014-08-30 13:55:46.000000000 +0000
14890 #include <linux/cpu.h>
14891 #include <linux/notifier.h>
14892 #include <linux/rculist.h>
14893 +#include <linux/vs_cvirt.h>
14895 #include <asm/uaccess.h>
14897 @@ -317,7 +318,7 @@ static int check_syslog_permissions(int
14900 if (syslog_action_restricted(type)) {
14901 - if (capable(CAP_SYSLOG))
14902 + if (vx_capable(CAP_SYSLOG, VXC_SYSLOG))
14904 /* For historical reasons, accept CAP_SYS_ADMIN too, with a warning */
14905 if (capable(CAP_SYS_ADMIN)) {
14906 @@ -347,12 +348,9 @@ int do_syslog(int type, char __user *buf
14911 - case SYSLOG_ACTION_CLOSE: /* Close log */
14913 - case SYSLOG_ACTION_OPEN: /* Open log */
14915 - case SYSLOG_ACTION_READ: /* Read from log */
14916 + if ((type == SYSLOG_ACTION_READ) ||
14917 + (type == SYSLOG_ACTION_READ_ALL) ||
14918 + (type == SYSLOG_ACTION_READ_CLEAR)) {
14920 if (!buf || len < 0)
14922 @@ -363,6 +361,16 @@ int do_syslog(int type, char __user *buf
14927 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
14928 + return vx_do_syslog(type, buf, len);
14931 + case SYSLOG_ACTION_CLOSE: /* Close log */
14933 + case SYSLOG_ACTION_OPEN: /* Open log */
14935 + case SYSLOG_ACTION_READ: /* Read from log */
14936 error = wait_event_interruptible(log_wait,
14937 (log_start - log_end));
14939 @@ -389,16 +397,6 @@ int do_syslog(int type, char __user *buf
14941 /* Read last kernel messages */
14942 case SYSLOG_ACTION_READ_ALL:
14944 - if (!buf || len < 0)
14949 - if (!access_ok(VERIFY_WRITE, buf, len)) {
14954 if (count > log_buf_len)
14955 count = log_buf_len;
14956 diff -NurpP --minimal linux-3.4.103/kernel/ptrace.c linux-3.4.103-vs2.3.3.9/kernel/ptrace.c
14957 --- linux-3.4.103/kernel/ptrace.c 2014-08-30 13:37:18.000000000 +0000
14958 +++ linux-3.4.103-vs2.3.3.9/kernel/ptrace.c 2014-03-12 09:55:28.000000000 +0000
14960 #include <linux/syscalls.h>
14961 #include <linux/uaccess.h>
14962 #include <linux/regset.h>
14963 +#include <linux/vs_context.h>
14964 #include <linux/hw_breakpoint.h>
14965 #include <linux/cn_proc.h>
14967 @@ -257,6 +258,11 @@ ok:
14968 if (dumpable != SUID_DUMP_USER &&
14969 !ptrace_has_cap(task_user_ns(task), mode))
14971 + if (!vx_check(task->xid, VS_ADMIN_P|VS_WATCH_P|VS_IDENT))
14973 + if (!vx_check(task->xid, VS_IDENT) &&
14974 + !task_vx_flags(task, VXF_STATE_ADMIN, 0))
14977 return security_ptrace_access_check(task, mode);
14979 diff -NurpP --minimal linux-3.4.103/kernel/sched/core.c linux-3.4.103-vs2.3.3.9/kernel/sched/core.c
14980 --- linux-3.4.103/kernel/sched/core.c 2014-08-30 13:37:18.000000000 +0000
14981 +++ linux-3.4.103-vs2.3.3.9/kernel/sched/core.c 2014-08-30 13:55:46.000000000 +0000
14983 #include <linux/slab.h>
14984 #include <linux/init_task.h>
14985 #include <linux/binfmts.h>
14986 +#include <linux/vs_sched.h>
14987 +#include <linux/vs_cvirt.h>
14989 #include <asm/switch_to.h>
14990 #include <asm/tlb.h>
14991 @@ -2226,9 +2228,17 @@ EXPORT_SYMBOL(avenrun); /* should be rem
14993 void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
14995 - loads[0] = (avenrun[0] + offset) << shift;
14996 - loads[1] = (avenrun[1] + offset) << shift;
14997 - loads[2] = (avenrun[2] + offset) << shift;
14998 + if (vx_flags(VXF_VIRT_LOAD, 0)) {
14999 + struct vx_info *vxi = current_vx_info();
15001 + loads[0] = (vxi->cvirt.load[0] + offset) << shift;
15002 + loads[1] = (vxi->cvirt.load[1] + offset) << shift;
15003 + loads[2] = (vxi->cvirt.load[2] + offset) << shift;
15005 + loads[0] = (avenrun[0] + offset) << shift;
15006 + loads[1] = (avenrun[1] + offset) << shift;
15007 + loads[2] = (avenrun[2] + offset) << shift;
15011 static long calc_load_fold_active(struct rq *this_rq)
15012 @@ -2857,14 +2867,17 @@ static inline void task_group_account_fi
15013 void account_user_time(struct task_struct *p, cputime_t cputime,
15014 cputime_t cputime_scaled)
15016 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15017 + int nice = (TASK_NICE(p) > 0);
15020 /* Add user time to process. */
15021 p->utime += cputime;
15022 p->utimescaled += cputime_scaled;
15023 + vx_account_user(vxi, cputime, nice);
15024 account_group_user_time(p, cputime);
15026 - index = (TASK_NICE(p) > 0) ? CPUTIME_NICE : CPUTIME_USER;
15027 + index = (nice) ? CPUTIME_NICE : CPUTIME_USER;
15029 /* Add user time to cpustat. */
15030 task_group_account_field(p, index, (__force u64) cputime);
15031 @@ -2911,9 +2924,12 @@ static inline
15032 void __account_system_time(struct task_struct *p, cputime_t cputime,
15033 cputime_t cputime_scaled, int index)
15035 + struct vx_info *vxi = p->vx_info; /* p is _always_ current */
15037 /* Add system time to process. */
15038 p->stime += cputime;
15039 p->stimescaled += cputime_scaled;
15040 + vx_account_system(vxi, cputime, 0 /* do we have idle time? */);
15041 account_group_system_time(p, cputime);
15043 /* Add system time to cpustat. */
15044 @@ -4139,7 +4155,7 @@ SYSCALL_DEFINE1(nice, int, increment)
15047 if (increment < 0 && !can_nice(current, nice))
15049 + return vx_flags(VXF_IGNEG_NICE, 0) ? 0 : -EPERM;
15051 retval = security_task_setnice(current, nice);
15053 diff -NurpP --minimal linux-3.4.103/kernel/sched/fair.c linux-3.4.103-vs2.3.3.9/kernel/sched/fair.c
15054 --- linux-3.4.103/kernel/sched/fair.c 2014-08-30 13:37:18.000000000 +0000
15055 +++ linux-3.4.103-vs2.3.3.9/kernel/sched/fair.c 2014-04-21 18:56:35.000000000 +0000
15057 #include <linux/slab.h>
15058 #include <linux/profile.h>
15059 #include <linux/interrupt.h>
15060 +#include <linux/vs_cvirt.h>
15062 #include <trace/events/sched.h>
15064 @@ -1111,6 +1112,8 @@ enqueue_entity(struct cfs_rq *cfs_rq, st
15065 __enqueue_entity(cfs_rq, se);
15068 + if (entity_is_task(se))
15069 + vx_activate_task(task_of(se));
15070 if (cfs_rq->nr_running == 1) {
15071 list_add_leaf_cfs_rq(cfs_rq);
15072 check_enqueue_throttle(cfs_rq);
15073 @@ -1191,6 +1194,8 @@ dequeue_entity(struct cfs_rq *cfs_rq, st
15074 if (se != cfs_rq->curr)
15075 __dequeue_entity(cfs_rq, se);
15077 + if (entity_is_task(se))
15078 + vx_deactivate_task(task_of(se));
15079 update_cfs_load(cfs_rq, 0);
15080 account_entity_dequeue(cfs_rq, se);
15082 diff -NurpP --minimal linux-3.4.103/kernel/signal.c linux-3.4.103-vs2.3.3.9/kernel/signal.c
15083 --- linux-3.4.103/kernel/signal.c 2014-08-30 13:37:18.000000000 +0000
15084 +++ linux-3.4.103-vs2.3.3.9/kernel/signal.c 2013-07-14 13:38:36.000000000 +0000
15086 #include <linux/pid_namespace.h>
15087 #include <linux/nsproxy.h>
15088 #include <linux/user_namespace.h>
15089 +#include <linux/vs_context.h>
15090 +#include <linux/vs_pid.h>
15091 #define CREATE_TRACE_POINTS
15092 #include <trace/events/signal.h>
15094 @@ -787,9 +789,18 @@ static int check_kill_permission(int sig
15098 + vxdprintk(VXD_CBIT(misc, 7),
15099 + "check_kill_permission(%d,%p,%p[#%u,%u])",
15100 + sig, info, t, vx_task_xid(t), t->pid);
15102 if (!valid_signal(sig))
15105 +/* FIXME: needed? if so, why?
15106 + if ((info != SEND_SIG_NOINFO) &&
15107 + (is_si_special(info) || !si_fromuser(info)))
15110 if (!si_fromuser(info))
15113 @@ -813,6 +824,20 @@ static int check_kill_permission(int sig
15118 + if (t->pid == 1 && current->xid)
15122 + /* FIXME: we shouldn't return ESRCH ever, to avoid
15123 + loops, maybe ENOENT or EACCES? */
15124 + if (!vx_check(vx_task_xid(t), VS_WATCH_P | VS_IDENT)) {
15125 + vxdprintk(current->xid || VXD_CBIT(misc, 7),
15126 + "signal %d[%p] xid mismatch %p[#%u,%u] xid=#%u",
15127 + sig, info, t, vx_task_xid(t), t->pid, current->xid);
15131 return security_task_kill(t, info, sig, 0);
15134 @@ -1355,7 +1380,7 @@ int kill_pid_info(int sig, struct siginf
15137 p = pid_task(pid, PIDTYPE_PID);
15139 + if (p && vx_check(vx_task_xid(p), VS_IDENT)) {
15140 error = group_send_sig_info(sig, info, p);
15141 if (unlikely(error == -ESRCH))
15143 @@ -1405,7 +1430,7 @@ int kill_pid_info_as_cred(int sig, struc
15146 p = pid_task(pid, PIDTYPE_PID);
15148 + if (!p || !vx_check(vx_task_xid(p), VS_IDENT)) {
15152 @@ -1457,8 +1482,10 @@ static int kill_something_info(int sig,
15153 struct task_struct * p;
15155 for_each_process(p) {
15156 - if (task_pid_vnr(p) > 1 &&
15157 - !same_thread_group(p, current)) {
15158 + if (vx_check(vx_task_xid(p), VS_ADMIN|VS_IDENT) &&
15159 + task_pid_vnr(p) > 1 &&
15160 + !same_thread_group(p, current) &&
15161 + !vx_current_initpid(p->pid)) {
15162 int err = group_send_sig_info(sig, info, p);
15165 @@ -2312,6 +2339,11 @@ relock:
15166 !sig_kernel_only(signr))
15169 + /* virtual init is protected against user signals */
15170 + if ((info->si_code == SI_USER) &&
15171 + vx_current_initpid(current->pid))
15174 if (sig_kernel_stop(signr)) {
15176 * The default action is to stop all threads in
15177 diff -NurpP --minimal linux-3.4.103/kernel/softirq.c linux-3.4.103-vs2.3.3.9/kernel/softirq.c
15178 --- linux-3.4.103/kernel/softirq.c 2012-05-21 16:07:34.000000000 +0000
15179 +++ linux-3.4.103-vs2.3.3.9/kernel/softirq.c 2012-05-21 16:15:05.000000000 +0000
15181 #include <linux/ftrace.h>
15182 #include <linux/smp.h>
15183 #include <linux/tick.h>
15184 +#include <linux/vs_context.h>
15186 #define CREATE_TRACE_POINTS
15187 #include <trace/events/irq.h>
15188 diff -NurpP --minimal linux-3.4.103/kernel/sys.c linux-3.4.103-vs2.3.3.9/kernel/sys.c
15189 --- linux-3.4.103/kernel/sys.c 2014-08-30 13:37:18.000000000 +0000
15190 +++ linux-3.4.103-vs2.3.3.9/kernel/sys.c 2013-07-14 13:38:36.000000000 +0000
15192 #include <linux/syscalls.h>
15193 #include <linux/kprobes.h>
15194 #include <linux/user_namespace.h>
15195 +#include <linux/vs_pid.h>
15197 #include <linux/kmsg_dump.h>
15198 /* Move somewhere else to avoid recompiling? */
15199 @@ -155,7 +156,10 @@ static int set_one_prio(struct task_stru
15202 if (niceval < task_nice(p) && !can_nice(p, niceval)) {
15204 + if (vx_flags(VXF_IGNEG_NICE, 0))
15210 no_nice = security_task_setnice(p, niceval);
15211 @@ -205,6 +209,8 @@ SYSCALL_DEFINE3(setpriority, int, which,
15213 pgrp = task_pgrp(current);
15214 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15215 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15217 error = set_one_prio(p, niceval, error);
15218 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
15220 @@ -268,6 +274,8 @@ SYSCALL_DEFINE2(getpriority, int, which,
15222 pgrp = task_pgrp(current);
15223 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
15224 + if (!vx_check(p->xid, VS_ADMIN_P | VS_IDENT))
15226 niceval = 20 - task_nice(p);
15227 if (niceval > retval)
15229 @@ -443,6 +451,8 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
15231 static DEFINE_MUTEX(reboot_mutex);
15233 +long vs_reboot(unsigned int, void __user *);
15236 * Reboot system call: for obvious reasons only root may call it,
15237 * and even root needs to set up some magic numbers in the registers
15238 @@ -484,6 +494,9 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
15239 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
15240 cmd = LINUX_REBOOT_CMD_HALT;
15242 + if (!vx_check(0, VS_ADMIN|VS_WATCH))
15243 + return vs_reboot(cmd, arg);
15245 mutex_lock(&reboot_mutex);
15247 case LINUX_REBOOT_CMD_RESTART:
15248 @@ -1309,7 +1322,8 @@ SYSCALL_DEFINE2(sethostname, char __user
15250 char tmp[__NEW_UTS_LEN];
15252 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
15253 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
15254 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15257 if (len < 0 || len > __NEW_UTS_LEN)
15258 @@ -1360,7 +1374,8 @@ SYSCALL_DEFINE2(setdomainname, char __us
15260 char tmp[__NEW_UTS_LEN];
15262 - if (!ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN))
15263 + if (!vx_ns_capable(current->nsproxy->uts_ns->user_ns,
15264 + CAP_SYS_ADMIN, VXC_SET_UTSNAME))
15266 if (len < 0 || len > __NEW_UTS_LEN)
15268 @@ -1479,7 +1494,7 @@ int do_prlimit(struct task_struct *tsk,
15269 /* Keep the capable check against init_user_ns until
15270 cgroups can contain all limits */
15271 if (new_rlim->rlim_max > rlim->rlim_max &&
15272 - !capable(CAP_SYS_RESOURCE))
15273 + !vx_capable(CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
15276 retval = security_task_setrlimit(tsk->group_leader,
15277 @@ -1533,7 +1548,8 @@ static int check_prlimit_permission(stru
15278 cred->gid == tcred->sgid &&
15279 cred->gid == tcred->gid))
15281 - if (ns_capable(tcred->user->user_ns, CAP_SYS_RESOURCE))
15282 + if (vx_ns_capable(tcred->user->user_ns,
15283 + CAP_SYS_RESOURCE, VXC_SET_RLIMIT))
15287 diff -NurpP --minimal linux-3.4.103/kernel/sysctl.c linux-3.4.103-vs2.3.3.9/kernel/sysctl.c
15288 --- linux-3.4.103/kernel/sysctl.c 2014-08-30 13:37:18.000000000 +0000
15289 +++ linux-3.4.103-vs2.3.3.9/kernel/sysctl.c 2014-05-20 04:30:31.000000000 +0000
15291 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
15292 #include <linux/lockdep.h>
15294 +extern char vshelper_path[];
15295 #ifdef CONFIG_CHR_DEV_SG
15296 #include <scsi/sg.h>
15298 @@ -567,6 +568,13 @@ static struct ctl_table kern_table[] = {
15299 .proc_handler = proc_dostring,
15303 + .procname = "vshelper",
15304 + .data = &vshelper_path,
15307 + .proc_handler = &proc_dostring,
15309 #ifdef CONFIG_CHR_DEV_SG
15311 .procname = "sg-big-buff",
15312 diff -NurpP --minimal linux-3.4.103/kernel/sysctl_binary.c linux-3.4.103-vs2.3.3.9/kernel/sysctl_binary.c
15313 --- linux-3.4.103/kernel/sysctl_binary.c 2014-08-30 13:37:18.000000000 +0000
15314 +++ linux-3.4.103-vs2.3.3.9/kernel/sysctl_binary.c 2013-03-30 21:29:17.000000000 +0000
15315 @@ -73,6 +73,7 @@ static const struct bin_table bin_kern_t
15317 { CTL_INT, KERN_PANIC, "panic" },
15318 { CTL_INT, KERN_REALROOTDEV, "real-root-dev" },
15319 + { CTL_STR, KERN_VSHELPER, "vshelper" },
15321 { CTL_STR, KERN_SPARC_REBOOT, "reboot-cmd" },
15322 { CTL_INT, KERN_CTLALTDEL, "ctrl-alt-del" },
15323 diff -NurpP --minimal linux-3.4.103/kernel/time/timekeeping.c linux-3.4.103-vs2.3.3.9/kernel/time/timekeeping.c
15324 --- linux-3.4.103/kernel/time/timekeeping.c 2014-08-30 13:37:19.000000000 +0000
15325 +++ linux-3.4.103-vs2.3.3.9/kernel/time/timekeeping.c 2014-03-12 09:55:28.000000000 +0000
15326 @@ -254,6 +254,7 @@ void getnstimeofday(struct timespec *ts)
15327 } while (read_seqretry(&timekeeper.lock, seq));
15329 timespec_add_ns(ts, nsecs);
15330 + vx_adjust_timespec(ts);
15333 EXPORT_SYMBOL(getnstimeofday);
15334 diff -NurpP --minimal linux-3.4.103/kernel/time.c linux-3.4.103-vs2.3.3.9/kernel/time.c
15335 --- linux-3.4.103/kernel/time.c 2012-05-21 16:07:34.000000000 +0000
15336 +++ linux-3.4.103-vs2.3.3.9/kernel/time.c 2012-05-21 16:15:05.000000000 +0000
15337 @@ -92,7 +92,7 @@ SYSCALL_DEFINE1(stime, time_t __user *,
15341 - do_settimeofday(&tv);
15342 + vx_settimeofday(&tv);
15346 @@ -172,7 +172,7 @@ int do_sys_settimeofday(const struct tim
15350 - return do_settimeofday(tv);
15351 + return vx_settimeofday(tv);
15355 diff -NurpP --minimal linux-3.4.103/kernel/timer.c linux-3.4.103-vs2.3.3.9/kernel/timer.c
15356 --- linux-3.4.103/kernel/timer.c 2014-08-30 13:37:19.000000000 +0000
15357 +++ linux-3.4.103-vs2.3.3.9/kernel/timer.c 2014-06-12 11:34:38.000000000 +0000
15359 #include <linux/irq_work.h>
15360 #include <linux/sched.h>
15361 #include <linux/slab.h>
15362 +#include <linux/vs_base.h>
15363 +#include <linux/vs_cvirt.h>
15364 +#include <linux/vs_pid.h>
15365 +#include <linux/vserver/sched.h>
15367 #include <asm/uaccess.h>
15368 #include <asm/unistd.h>
15369 @@ -1390,12 +1394,6 @@ SYSCALL_DEFINE1(alarm, unsigned int, sec
15376 - * The Alpha uses getxpid, getxuid, and getxgid instead. Maybe this
15377 - * should be moved into arch/i386 instead?
15381 * sys_getpid - return the thread group id of the current process
15382 @@ -1424,10 +1422,23 @@ SYSCALL_DEFINE0(getppid)
15384 pid = task_tgid_vnr(rcu_dereference(current->real_parent));
15386 + return vx_map_pid(pid);
15393 + * The Alpha uses getxpid, getxuid, and getxgid instead.
15396 +asmlinkage long do_getxpid(long *ppid)
15398 + *ppid = sys_getppid();
15399 + return sys_getpid();
15402 +#else /* _alpha_ */
15404 SYSCALL_DEFINE0(getuid)
15406 /* Only we change this so SMP safe */
15407 diff -NurpP --minimal linux-3.4.103/kernel/user_namespace.c linux-3.4.103-vs2.3.3.9/kernel/user_namespace.c
15408 --- linux-3.4.103/kernel/user_namespace.c 2012-01-09 15:15:00.000000000 +0000
15409 +++ linux-3.4.103-vs2.3.3.9/kernel/user_namespace.c 2012-05-21 16:15:05.000000000 +0000
15411 #include <linux/user_namespace.h>
15412 #include <linux/highuid.h>
15413 #include <linux/cred.h>
15414 +#include <linux/vserver/global.h>
15416 static struct kmem_cache *user_ns_cachep __read_mostly;
15418 @@ -33,6 +34,7 @@ int create_user_ns(struct cred *new)
15421 kref_init(&ns->kref);
15422 + atomic_inc(&vs_global_user_ns);
15424 for (n = 0; n < UIDHASH_SZ; ++n)
15425 INIT_HLIST_HEAD(ns->uidhash_table + n);
15426 @@ -81,6 +83,8 @@ void free_user_ns(struct kref *kref)
15427 struct user_namespace *ns =
15428 container_of(kref, struct user_namespace, kref);
15430 + /* FIXME: maybe move into destroyer? */
15431 + atomic_dec(&vs_global_user_ns);
15432 INIT_WORK(&ns->destroyer, free_user_ns_work);
15433 schedule_work(&ns->destroyer);
15435 diff -NurpP --minimal linux-3.4.103/kernel/utsname.c linux-3.4.103-vs2.3.3.9/kernel/utsname.c
15436 --- linux-3.4.103/kernel/utsname.c 2012-01-09 15:15:00.000000000 +0000
15437 +++ linux-3.4.103-vs2.3.3.9/kernel/utsname.c 2012-05-21 16:15:05.000000000 +0000
15438 @@ -16,14 +16,17 @@
15439 #include <linux/slab.h>
15440 #include <linux/user_namespace.h>
15441 #include <linux/proc_fs.h>
15442 +#include <linux/vserver/global.h>
15444 static struct uts_namespace *create_uts_ns(void)
15446 struct uts_namespace *uts_ns;
15448 uts_ns = kmalloc(sizeof(struct uts_namespace), GFP_KERNEL);
15451 kref_init(&uts_ns->kref);
15452 + atomic_inc(&vs_global_uts_ns);
15457 @@ -32,8 +35,8 @@ static struct uts_namespace *create_uts_
15458 * @old_ns: namespace to clone
15459 * Return NULL on error (failure to kmalloc), new ns otherwise
15461 -static struct uts_namespace *clone_uts_ns(struct task_struct *tsk,
15462 - struct uts_namespace *old_ns)
15463 +static struct uts_namespace *clone_uts_ns(struct uts_namespace *old_ns,
15464 + struct user_namespace *old_user)
15466 struct uts_namespace *ns;
15468 @@ -43,7 +46,7 @@ static struct uts_namespace *clone_uts_n
15470 down_read(&uts_sem);
15471 memcpy(&ns->name, &old_ns->name, sizeof(ns->name));
15472 - ns->user_ns = get_user_ns(task_cred_xxx(tsk, user)->user_ns);
15473 + ns->user_ns = get_user_ns(old_user);
15477 @@ -55,9 +58,9 @@ static struct uts_namespace *clone_uts_n
15480 struct uts_namespace *copy_utsname(unsigned long flags,
15481 - struct task_struct *tsk)
15482 + struct uts_namespace *old_ns,
15483 + struct user_namespace *user_ns)
15485 - struct uts_namespace *old_ns = tsk->nsproxy->uts_ns;
15486 struct uts_namespace *new_ns;
15489 @@ -66,7 +69,7 @@ struct uts_namespace *copy_utsname(unsig
15490 if (!(flags & CLONE_NEWUTS))
15493 - new_ns = clone_uts_ns(tsk, old_ns);
15494 + new_ns = clone_uts_ns(old_ns, user_ns);
15496 put_uts_ns(old_ns);
15498 @@ -78,6 +81,7 @@ void free_uts_ns(struct kref *kref)
15500 ns = container_of(kref, struct uts_namespace, kref);
15501 put_user_ns(ns->user_ns);
15502 + atomic_dec(&vs_global_uts_ns);
15506 diff -NurpP --minimal linux-3.4.103/kernel/vserver/Kconfig linux-3.4.103-vs2.3.3.9/kernel/vserver/Kconfig
15507 --- linux-3.4.103/kernel/vserver/Kconfig 1970-01-01 00:00:00.000000000 +0000
15508 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/Kconfig 2012-05-21 16:15:05.000000000 +0000
15511 +# Linux VServer configuration
15514 +menu "Linux VServer"
15516 +config VSERVER_AUTO_LBACK
15517 + bool "Automatically Assign Loopback IP"
15520 + Automatically assign a guest specific loopback
15521 + IP and add it to the kernel network stack on
15524 +config VSERVER_AUTO_SINGLE
15525 + bool "Automatic Single IP Special Casing"
15526 + depends on EXPERIMENTAL
15529 + This allows network contexts with a single IP to
15530 + automatically remap 0.0.0.0 bindings to that IP,
15531 + avoiding further network checks and improving
15534 + (note: such guests do not allow to change the ip
15535 + on the fly and do not show loopback addresses)
15537 +config VSERVER_COWBL
15538 + bool "Enable COW Immutable Link Breaking"
15541 + This enables the COW (Copy-On-Write) link break code.
15542 + It allows you to treat unified files like normal files
15543 + when writing to them (which will implicitely break the
15544 + link and create a copy of the unified file)
15546 +config VSERVER_VTIME
15547 + bool "Enable Virtualized Guest Time"
15548 + depends on EXPERIMENTAL
15551 + This enables per guest time offsets to allow for
15552 + adjusting the system clock individually per guest.
15553 + this adds some overhead to the time functions and
15554 + therefore should not be enabled without good reason.
15556 +config VSERVER_DEVICE
15557 + bool "Enable Guest Device Mapping"
15558 + depends on EXPERIMENTAL
15561 + This enables generic device remapping.
15563 +config VSERVER_PROC_SECURE
15564 + bool "Enable Proc Security"
15565 + depends on PROC_FS
15568 + This configures ProcFS security to initially hide
15569 + non-process entries for all contexts except the main and
15570 + spectator context (i.e. for all guests), which is a secure
15573 + (note: on 1.2x the entries were visible by default)
15576 + prompt "Persistent Inode Tagging"
15577 + default TAGGING_ID24
15579 + This adds persistent context information to filesystems
15580 + mounted with the tagxid option. Tagging is a requirement
15581 + for per-context disk limits and per-context quota.
15584 +config TAGGING_NONE
15587 + do not store per-context information in inodes.
15589 +config TAGGING_UID16
15590 + bool "UID16/GID32"
15592 + reduces UID to 16 bit, but leaves GID at 32 bit.
15594 +config TAGGING_GID16
15595 + bool "UID32/GID16"
15597 + reduces GID to 16 bit, but leaves UID at 32 bit.
15599 +config TAGGING_ID24
15600 + bool "UID24/GID24"
15602 + uses the upper 8bit from UID and GID for XID tagging
15603 + which leaves 24bit for UID/GID each, which should be
15604 + more than sufficient for normal use.
15606 +config TAGGING_INTERN
15607 + bool "UID32/GID32"
15609 + this uses otherwise reserved inode fields in the on
15610 + disk representation, which limits the use to a few
15611 + filesystems (currently ext2 and ext3)
15616 + bool "Tag NFSD User Auth and Files"
15619 + Enable this if you do want the in-kernel NFS
15620 + Server to use the tagging specified above.
15621 + (will require patched clients too)
15623 +config VSERVER_PRIVACY
15624 + bool "Honor Privacy Aspects of Guests"
15627 + When enabled, most context checks will disallow
15628 + access to structures assigned to a specific context,
15629 + like ptys or loop devices.
15631 +config VSERVER_CONTEXTS
15632 + int "Maximum number of Contexts (1-65533)" if EMBEDDED
15634 + default "768" if 64BIT
15637 + This setting will optimize certain data structures
15638 + and memory allocations according to the expected
15641 + note: this is not a strict upper limit.
15643 +config VSERVER_WARN
15644 + bool "VServer Warnings"
15647 + This enables various runtime warnings, which will
15648 + notify about potential manipulation attempts or
15649 + resource shortage. It is generally considered to
15650 + be a good idea to have that enabled.
15652 +config VSERVER_WARN_DEVPTS
15653 + bool "VServer DevPTS Warnings"
15654 + depends on VSERVER_WARN
15657 + This enables DevPTS related warnings, issued when a
15658 + process inside a context tries to lookup or access
15659 + a dynamic pts from the host or a different context.
15661 +config VSERVER_DEBUG
15662 + bool "VServer Debugging Code"
15665 + Set this to yes if you want to be able to activate
15666 + debugging output at runtime. It adds a very small
15667 + overhead to all vserver related functions and
15668 + increases the kernel size by about 20k.
15670 +config VSERVER_HISTORY
15671 + bool "VServer History Tracing"
15672 + depends on VSERVER_DEBUG
15675 + Set this to yes if you want to record the history of
15676 + linux-vserver activities, so they can be replayed in
15677 + the event of a kernel panic or oops.
15679 +config VSERVER_HISTORY_SIZE
15680 + int "Per-CPU History Size (32-65536)"
15681 + depends on VSERVER_HISTORY
15685 + This allows you to specify the number of entries in
15686 + the per-CPU history buffer.
15689 + prompt "Quotes used in debug and warn messages"
15690 + default QUOTES_ISO8859
15692 +config QUOTES_ISO8859
15693 + bool "Extended ASCII (ISO 8859) angle quotes"
15695 + This uses the extended ASCII characters \xbb
15696 + and \xab for quoting file and process names.
15698 +config QUOTES_UTF8
15699 + bool "UTF-8 angle quotes"
15701 + This uses the the UTF-8 sequences for angle
15702 + quotes to quote file and process names.
15704 +config QUOTES_ASCII
15705 + bool "ASCII single quotes"
15707 + This uses the ASCII single quote character
15708 + (\x27) to quote file and process names.
15718 + select NAMESPACES
15724 +config VSERVER_SECURITY
15726 + depends on SECURITY
15728 + select SECURITY_CAPABILITIES
15730 +config VSERVER_DISABLED
15734 diff -NurpP --minimal linux-3.4.103/kernel/vserver/Makefile linux-3.4.103-vs2.3.3.9/kernel/vserver/Makefile
15735 --- linux-3.4.103/kernel/vserver/Makefile 1970-01-01 00:00:00.000000000 +0000
15736 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/Makefile 2012-05-21 16:15:05.000000000 +0000
15739 +# Makefile for the Linux vserver routines.
15743 +obj-y += vserver.o
15745 +vserver-y := switch.o context.o space.o sched.o network.o inode.o \
15746 + limit.o cvirt.o cacct.o signal.o helper.o init.o \
15749 +vserver-$(CONFIG_INET) += inet.o
15750 +vserver-$(CONFIG_PROC_FS) += proc.o
15751 +vserver-$(CONFIG_VSERVER_DEBUG) += sysctl.o debug.o
15752 +vserver-$(CONFIG_VSERVER_HISTORY) += history.o
15753 +vserver-$(CONFIG_VSERVER_MONITOR) += monitor.o
15754 +vserver-$(CONFIG_VSERVER_DEVICE) += device.o
15756 diff -NurpP --minimal linux-3.4.103/kernel/vserver/cacct.c linux-3.4.103-vs2.3.3.9/kernel/vserver/cacct.c
15757 --- linux-3.4.103/kernel/vserver/cacct.c 1970-01-01 00:00:00.000000000 +0000
15758 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/cacct.c 2012-05-21 16:15:05.000000000 +0000
15761 + * linux/kernel/vserver/cacct.c
15763 + * Virtual Server: Context Accounting
15765 + * Copyright (C) 2006-2007 Herbert Pötzl
15767 + * V0.01 added accounting stats
15771 +#include <linux/types.h>
15772 +#include <linux/vs_context.h>
15773 +#include <linux/vserver/cacct_cmd.h>
15774 +#include <linux/vserver/cacct_int.h>
15776 +#include <asm/errno.h>
15777 +#include <asm/uaccess.h>
15780 +int vc_sock_stat(struct vx_info *vxi, void __user *data)
15782 + struct vcmd_sock_stat_v0 vc_data;
15785 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
15788 + field = vc_data.field;
15789 + if ((field < 0) || (field >= VXA_SOCK_SIZE))
15792 + for (j = 0; j < 3; j++) {
15793 + vc_data.count[j] = vx_sock_count(&vxi->cacct, field, j);
15794 + vc_data.total[j] = vx_sock_total(&vxi->cacct, field, j);
15797 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
15802 diff -NurpP --minimal linux-3.4.103/kernel/vserver/cacct_init.h linux-3.4.103-vs2.3.3.9/kernel/vserver/cacct_init.h
15803 --- linux-3.4.103/kernel/vserver/cacct_init.h 1970-01-01 00:00:00.000000000 +0000
15804 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/cacct_init.h 2012-05-21 16:15:05.000000000 +0000
15808 +static inline void vx_info_init_cacct(struct _vx_cacct *cacct)
15813 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
15814 + for (j = 0; j < 3; j++) {
15815 + atomic_long_set(&cacct->sock[i][j].count, 0);
15816 + atomic_long_set(&cacct->sock[i][j].total, 0);
15819 + for (i = 0; i < 8; i++)
15820 + atomic_set(&cacct->slab[i], 0);
15821 + for (i = 0; i < 5; i++)
15822 + for (j = 0; j < 4; j++)
15823 + atomic_set(&cacct->page[i][j], 0);
15826 +static inline void vx_info_exit_cacct(struct _vx_cacct *cacct)
15831 diff -NurpP --minimal linux-3.4.103/kernel/vserver/cacct_proc.h linux-3.4.103-vs2.3.3.9/kernel/vserver/cacct_proc.h
15832 --- linux-3.4.103/kernel/vserver/cacct_proc.h 1970-01-01 00:00:00.000000000 +0000
15833 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/cacct_proc.h 2012-05-21 16:15:05.000000000 +0000
15835 +#ifndef _VX_CACCT_PROC_H
15836 +#define _VX_CACCT_PROC_H
15838 +#include <linux/vserver/cacct_int.h>
15841 +#define VX_SOCKA_TOP \
15842 + "Type\t recv #/bytes\t\t send #/bytes\t\t fail #/bytes\n"
15844 +static inline int vx_info_proc_cacct(struct _vx_cacct *cacct, char *buffer)
15846 + int i, j, length = 0;
15847 + static char *type[VXA_SOCK_SIZE] = {
15848 + "UNSPEC", "UNIX", "INET", "INET6", "PACKET", "OTHER"
15851 + length += sprintf(buffer + length, VX_SOCKA_TOP);
15852 + for (i = 0; i < VXA_SOCK_SIZE; i++) {
15853 + length += sprintf(buffer + length, "%s:", type[i]);
15854 + for (j = 0; j < 3; j++) {
15855 + length += sprintf(buffer + length,
15856 + "\t%10lu/%-10lu",
15857 + vx_sock_count(cacct, i, j),
15858 + vx_sock_total(cacct, i, j));
15860 + buffer[length++] = '\n';
15863 + length += sprintf(buffer + length, "\n");
15864 + length += sprintf(buffer + length,
15865 + "slab:\t %8u %8u %8u %8u\n",
15866 + atomic_read(&cacct->slab[1]),
15867 + atomic_read(&cacct->slab[4]),
15868 + atomic_read(&cacct->slab[0]),
15869 + atomic_read(&cacct->slab[2]));
15871 + length += sprintf(buffer + length, "\n");
15872 + for (i = 0; i < 5; i++) {
15873 + length += sprintf(buffer + length,
15874 + "page[%d]: %8u %8u %8u %8u\t %8u %8u %8u %8u\n", i,
15875 + atomic_read(&cacct->page[i][0]),
15876 + atomic_read(&cacct->page[i][1]),
15877 + atomic_read(&cacct->page[i][2]),
15878 + atomic_read(&cacct->page[i][3]),
15879 + atomic_read(&cacct->page[i][4]),
15880 + atomic_read(&cacct->page[i][5]),
15881 + atomic_read(&cacct->page[i][6]),
15882 + atomic_read(&cacct->page[i][7]));
15887 +#endif /* _VX_CACCT_PROC_H */
15888 diff -NurpP --minimal linux-3.4.103/kernel/vserver/context.c linux-3.4.103-vs2.3.3.9/kernel/vserver/context.c
15889 --- linux-3.4.103/kernel/vserver/context.c 1970-01-01 00:00:00.000000000 +0000
15890 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/context.c 2012-06-28 14:45:48.000000000 +0000
15893 + * linux/kernel/vserver/context.c
15895 + * Virtual Server: Context Support
15897 + * Copyright (C) 2003-2011 Herbert Pötzl
15899 + * V0.01 context helper
15900 + * V0.02 vx_ctx_kill syscall command
15901 + * V0.03 replaced context_info calls
15902 + * V0.04 redesign of struct (de)alloc
15903 + * V0.05 rlimit basic implementation
15904 + * V0.06 task_xid and info commands
15905 + * V0.07 context flags and caps
15906 + * V0.08 switch to RCU based hash
15907 + * V0.09 revert to non RCU for now
15908 + * V0.10 and back to working RCU hash
15909 + * V0.11 and back to locking again
15910 + * V0.12 referenced context store
15911 + * V0.13 separate per cpu data
15912 + * V0.14 changed vcmds to vxi arg
15913 + * V0.15 added context stat
15914 + * V0.16 have __create claim() the vxi
15915 + * V0.17 removed older and legacy stuff
15916 + * V0.18 added user credentials
15917 + * V0.19 added warn mask
15921 +#include <linux/slab.h>
15922 +#include <linux/types.h>
15923 +#include <linux/security.h>
15924 +#include <linux/pid_namespace.h>
15925 +#include <linux/capability.h>
15927 +#include <linux/vserver/context.h>
15928 +#include <linux/vserver/network.h>
15929 +#include <linux/vserver/debug.h>
15930 +#include <linux/vserver/limit.h>
15931 +#include <linux/vserver/limit_int.h>
15932 +#include <linux/vserver/space.h>
15933 +#include <linux/init_task.h>
15934 +#include <linux/fs_struct.h>
15935 +#include <linux/cred.h>
15937 +#include <linux/vs_context.h>
15938 +#include <linux/vs_limit.h>
15939 +#include <linux/vs_pid.h>
15940 +#include <linux/vserver/context_cmd.h>
15942 +#include "cvirt_init.h"
15943 +#include "cacct_init.h"
15944 +#include "limit_init.h"
15945 +#include "sched_init.h"
15948 +atomic_t vx_global_ctotal = ATOMIC_INIT(0);
15949 +atomic_t vx_global_cactive = ATOMIC_INIT(0);
15952 +/* now inactive context structures */
15954 +static struct hlist_head vx_info_inactive = HLIST_HEAD_INIT;
15956 +static DEFINE_SPINLOCK(vx_info_inactive_lock);
15959 +/* __alloc_vx_info()
15961 + * allocate an initialized vx_info struct
15962 + * doesn't make it visible (hash) */
15964 +static struct vx_info *__alloc_vx_info(xid_t xid)
15966 + struct vx_info *new = NULL;
15969 + vxdprintk(VXD_CBIT(xid, 0), "alloc_vx_info(%d)*", xid);
15971 + /* would this benefit from a slab cache? */
15972 + new = kmalloc(sizeof(struct vx_info), GFP_KERNEL);
15976 + memset(new, 0, sizeof(struct vx_info));
15978 + new->ptr_pc = alloc_percpu(struct _vx_info_pc);
15979 + if (!new->ptr_pc)
15982 + new->vx_id = xid;
15983 + INIT_HLIST_NODE(&new->vx_hlist);
15984 + atomic_set(&new->vx_usecnt, 0);
15985 + atomic_set(&new->vx_tasks, 0);
15986 + new->vx_parent = NULL;
15987 + new->vx_state = 0;
15988 + init_waitqueue_head(&new->vx_wait);
15990 + /* prepare reaper */
15991 + get_task_struct(init_pid_ns.child_reaper);
15992 + new->vx_reaper = init_pid_ns.child_reaper;
15993 + new->vx_badness_bias = 0;
15995 + /* rest of init goes here */
15996 + vx_info_init_limit(&new->limit);
15997 + vx_info_init_sched(&new->sched);
15998 + vx_info_init_cvirt(&new->cvirt);
15999 + vx_info_init_cacct(&new->cacct);
16001 + /* per cpu data structures */
16002 + for_each_possible_cpu(cpu) {
16003 + vx_info_init_sched_pc(
16004 + &vx_per_cpu(new, sched_pc, cpu), cpu);
16005 + vx_info_init_cvirt_pc(
16006 + &vx_per_cpu(new, cvirt_pc, cpu), cpu);
16009 + new->vx_flags = VXF_INIT_SET;
16010 + new->vx_bcaps = CAP_FULL_SET; // maybe ~CAP_SETPCAP
16011 + new->vx_ccaps = 0;
16012 + new->vx_umask = 0;
16013 + new->vx_wmask = 0;
16015 + new->reboot_cmd = 0;
16016 + new->exit_code = 0;
16018 + // preconfig spaces
16019 + for (index = 0; index < VX_SPACES; index++) {
16020 + struct _vx_space *space = &new->space[index];
16023 + spin_lock(&init_fs.lock);
16025 + spin_unlock(&init_fs.lock);
16026 + space->vx_fs = &init_fs;
16028 + /* FIXME: do we want defaults? */
16029 + // space->vx_real_cred = 0;
16030 + // space->vx_cred = 0;
16034 + vxdprintk(VXD_CBIT(xid, 0),
16035 + "alloc_vx_info(%d) = %p", xid, new);
16036 + vxh_alloc_vx_info(new);
16037 + atomic_inc(&vx_global_ctotal);
16046 +/* __dealloc_vx_info()
16048 + * final disposal of vx_info */
16050 +static void __dealloc_vx_info(struct vx_info *vxi)
16052 +#ifdef CONFIG_VSERVER_WARN
16053 + struct vx_info_save vxis;
16056 + vxdprintk(VXD_CBIT(xid, 0),
16057 + "dealloc_vx_info(%p)", vxi);
16058 + vxh_dealloc_vx_info(vxi);
16060 +#ifdef CONFIG_VSERVER_WARN
16061 + enter_vx_info(vxi, &vxis);
16062 + vx_info_exit_limit(&vxi->limit);
16063 + vx_info_exit_sched(&vxi->sched);
16064 + vx_info_exit_cvirt(&vxi->cvirt);
16065 + vx_info_exit_cacct(&vxi->cacct);
16067 + for_each_possible_cpu(cpu) {
16068 + vx_info_exit_sched_pc(
16069 + &vx_per_cpu(vxi, sched_pc, cpu), cpu);
16070 + vx_info_exit_cvirt_pc(
16071 + &vx_per_cpu(vxi, cvirt_pc, cpu), cpu);
16073 + leave_vx_info(&vxis);
16077 + vxi->vx_state |= VXS_RELEASED;
16080 + free_percpu(vxi->ptr_pc);
16083 + atomic_dec(&vx_global_ctotal);
16086 +static void __shutdown_vx_info(struct vx_info *vxi)
16088 + struct nsproxy *nsproxy;
16089 + struct fs_struct *fs;
16090 + struct cred *cred;
16095 + vxi->vx_state |= VXS_SHUTDOWN;
16096 + vs_state_change(vxi, VSC_SHUTDOWN);
16098 + for (index = 0; index < VX_SPACES; index++) {
16099 + struct _vx_space *space = &vxi->space[index];
16101 + nsproxy = xchg(&space->vx_nsproxy, NULL);
16103 + put_nsproxy(nsproxy);
16105 + fs = xchg(&space->vx_fs, NULL);
16106 + spin_lock(&fs->lock);
16107 + kill = !--fs->users;
16108 + spin_unlock(&fs->lock);
16110 + free_fs_struct(fs);
16112 + cred = (struct cred *)xchg(&space->vx_cred, NULL);
16114 + abort_creds(cred);
16118 +/* exported stuff */
16120 +void free_vx_info(struct vx_info *vxi)
16122 + unsigned long flags;
16125 + /* check for reference counts first */
16126 + BUG_ON(atomic_read(&vxi->vx_usecnt));
16127 + BUG_ON(atomic_read(&vxi->vx_tasks));
16129 + /* context must not be hashed */
16130 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16132 + /* context shutdown is mandatory */
16133 + BUG_ON(!vx_info_state(vxi, VXS_SHUTDOWN));
16135 + /* spaces check */
16136 + for (index = 0; index < VX_SPACES; index++) {
16137 + struct _vx_space *space = &vxi->space[index];
16139 + BUG_ON(space->vx_nsproxy);
16140 + BUG_ON(space->vx_fs);
16141 + // BUG_ON(space->vx_real_cred);
16142 + // BUG_ON(space->vx_cred);
16145 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16146 + hlist_del(&vxi->vx_hlist);
16147 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16149 + __dealloc_vx_info(vxi);
16153 +/* hash table for vx_info hash */
16155 +#define VX_HASH_SIZE 13
16157 +static struct hlist_head vx_info_hash[VX_HASH_SIZE] =
16158 + { [0 ... VX_HASH_SIZE-1] = HLIST_HEAD_INIT };
16160 +static DEFINE_SPINLOCK(vx_info_hash_lock);
16163 +static inline unsigned int __hashval(xid_t xid)
16165 + return (xid % VX_HASH_SIZE);
16170 +/* __hash_vx_info()
16172 + * add the vxi to the global hash table
16173 + * requires the hash_lock to be held */
16175 +static inline void __hash_vx_info(struct vx_info *vxi)
16177 + struct hlist_head *head;
16179 + vxd_assert_lock(&vx_info_hash_lock);
16180 + vxdprintk(VXD_CBIT(xid, 4),
16181 + "__hash_vx_info: %p[#%d]", vxi, vxi->vx_id);
16182 + vxh_hash_vx_info(vxi);
16184 + /* context must not be hashed */
16185 + BUG_ON(vx_info_state(vxi, VXS_HASHED));
16187 + vxi->vx_state |= VXS_HASHED;
16188 + head = &vx_info_hash[__hashval(vxi->vx_id)];
16189 + hlist_add_head(&vxi->vx_hlist, head);
16190 + atomic_inc(&vx_global_cactive);
16193 +/* __unhash_vx_info()
16195 + * remove the vxi from the global hash table
16196 + * requires the hash_lock to be held */
16198 +static inline void __unhash_vx_info(struct vx_info *vxi)
16200 + unsigned long flags;
16202 + vxd_assert_lock(&vx_info_hash_lock);
16203 + vxdprintk(VXD_CBIT(xid, 4),
16204 + "__unhash_vx_info: %p[#%d.%d.%d]", vxi, vxi->vx_id,
16205 + atomic_read(&vxi->vx_usecnt), atomic_read(&vxi->vx_tasks));
16206 + vxh_unhash_vx_info(vxi);
16208 + /* context must be hashed */
16209 + BUG_ON(!vx_info_state(vxi, VXS_HASHED));
16210 + /* but without tasks */
16211 + BUG_ON(atomic_read(&vxi->vx_tasks));
16213 + vxi->vx_state &= ~VXS_HASHED;
16214 + hlist_del_init(&vxi->vx_hlist);
16215 + spin_lock_irqsave(&vx_info_inactive_lock, flags);
16216 + hlist_add_head(&vxi->vx_hlist, &vx_info_inactive);
16217 + spin_unlock_irqrestore(&vx_info_inactive_lock, flags);
16218 + atomic_dec(&vx_global_cactive);
16222 +/* __lookup_vx_info()
16224 + * requires the hash_lock to be held
16225 + * doesn't increment the vx_refcnt */
16227 +static inline struct vx_info *__lookup_vx_info(xid_t xid)
16229 + struct hlist_head *head = &vx_info_hash[__hashval(xid)];
16230 + struct hlist_node *pos;
16231 + struct vx_info *vxi;
16233 + vxd_assert_lock(&vx_info_hash_lock);
16234 + hlist_for_each(pos, head) {
16235 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16237 + if (vxi->vx_id == xid)
16242 + vxdprintk(VXD_CBIT(xid, 0),
16243 + "__lookup_vx_info(#%u): %p[#%u]",
16244 + xid, vxi, vxi ? vxi->vx_id : 0);
16245 + vxh_lookup_vx_info(vxi, xid);
16250 +/* __create_vx_info()
16252 + * create the requested context
16253 + * get(), claim() and hash it */
16255 +static struct vx_info *__create_vx_info(int id)
16257 + struct vx_info *new, *vxi = NULL;
16259 + vxdprintk(VXD_CBIT(xid, 1), "create_vx_info(%d)*", id);
16261 + if (!(new = __alloc_vx_info(id)))
16262 + return ERR_PTR(-ENOMEM);
16264 + /* required to make dynamic xids unique */
16265 + spin_lock(&vx_info_hash_lock);
16267 + /* static context requested */
16268 + if ((vxi = __lookup_vx_info(id))) {
16269 + vxdprintk(VXD_CBIT(xid, 0),
16270 + "create_vx_info(%d) = %p (already there)", id, vxi);
16271 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16272 + vxi = ERR_PTR(-EBUSY);
16274 + vxi = ERR_PTR(-EEXIST);
16277 + /* new context */
16278 + vxdprintk(VXD_CBIT(xid, 0),
16279 + "create_vx_info(%d) = %p (new)", id, new);
16280 + claim_vx_info(new, NULL);
16281 + __hash_vx_info(get_vx_info(new));
16282 + vxi = new, new = NULL;
16285 + spin_unlock(&vx_info_hash_lock);
16286 + vxh_create_vx_info(IS_ERR(vxi) ? NULL : vxi, id);
16288 + __dealloc_vx_info(new);
16293 +/* exported stuff */
16296 +void unhash_vx_info(struct vx_info *vxi)
16298 + spin_lock(&vx_info_hash_lock);
16299 + __unhash_vx_info(vxi);
16300 + spin_unlock(&vx_info_hash_lock);
16301 + __shutdown_vx_info(vxi);
16302 + __wakeup_vx_info(vxi);
16306 +/* lookup_vx_info()
16308 + * search for a vx_info and get() it
16309 + * negative id means current */
16311 +struct vx_info *lookup_vx_info(int id)
16313 + struct vx_info *vxi = NULL;
16316 + vxi = get_vx_info(current_vx_info());
16317 + } else if (id > 1) {
16318 + spin_lock(&vx_info_hash_lock);
16319 + vxi = get_vx_info(__lookup_vx_info(id));
16320 + spin_unlock(&vx_info_hash_lock);
16325 +/* xid_is_hashed()
16327 + * verify that xid is still hashed */
16329 +int xid_is_hashed(xid_t xid)
16333 + spin_lock(&vx_info_hash_lock);
16334 + hashed = (__lookup_vx_info(xid) != NULL);
16335 + spin_unlock(&vx_info_hash_lock);
16339 +#ifdef CONFIG_PROC_FS
16343 + * get a subset of hashed xids for proc
16344 + * assumes size is at least one */
16346 +int get_xid_list(int index, unsigned int *xids, int size)
16348 + int hindex, nr_xids = 0;
16350 + /* only show current and children */
16351 + if (!vx_check(0, VS_ADMIN | VS_WATCH)) {
16354 + xids[nr_xids] = vx_current_xid();
16358 + for (hindex = 0; hindex < VX_HASH_SIZE; hindex++) {
16359 + struct hlist_head *head = &vx_info_hash[hindex];
16360 + struct hlist_node *pos;
16362 + spin_lock(&vx_info_hash_lock);
16363 + hlist_for_each(pos, head) {
16364 + struct vx_info *vxi;
16369 + vxi = hlist_entry(pos, struct vx_info, vx_hlist);
16370 + xids[nr_xids] = vxi->vx_id;
16371 + if (++nr_xids >= size) {
16372 + spin_unlock(&vx_info_hash_lock);
16376 + /* keep the lock time short */
16377 + spin_unlock(&vx_info_hash_lock);
16384 +#ifdef CONFIG_VSERVER_DEBUG
16386 +void dump_vx_info_inactive(int level)
16388 + struct hlist_node *entry, *next;
16390 + hlist_for_each_safe(entry, next, &vx_info_inactive) {
16391 + struct vx_info *vxi =
16392 + list_entry(entry, struct vx_info, vx_hlist);
16394 + dump_vx_info(vxi, level);
16401 +int vx_migrate_user(struct task_struct *p, struct vx_info *vxi)
16403 + struct user_struct *new_user, *old_user;
16408 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
16411 + new_user = alloc_uid(vxi->vx_id, p->uid);
16415 + old_user = p->user;
16416 + if (new_user != old_user) {
16417 + atomic_inc(&new_user->processes);
16418 + atomic_dec(&old_user->processes);
16419 + p->user = new_user;
16421 + free_uid(old_user);
16427 +void vx_mask_cap_bset(struct vx_info *vxi, struct task_struct *p)
16429 + // p->cap_effective &= vxi->vx_cap_bset;
16430 + p->cap_effective =
16431 + cap_intersect(p->cap_effective, vxi->cap_bset);
16432 + // p->cap_inheritable &= vxi->vx_cap_bset;
16433 + p->cap_inheritable =
16434 + cap_intersect(p->cap_inheritable, vxi->cap_bset);
16435 + // p->cap_permitted &= vxi->vx_cap_bset;
16436 + p->cap_permitted =
16437 + cap_intersect(p->cap_permitted, vxi->cap_bset);
16442 +#include <linux/file.h>
16443 +#include <linux/fdtable.h>
16445 +static int vx_openfd_task(struct task_struct *tsk)
16447 + struct files_struct *files = tsk->files;
16448 + struct fdtable *fdt;
16449 + const unsigned long *bptr;
16450 + int count, total;
16452 + /* no rcu_read_lock() because of spin_lock() */
16453 + spin_lock(&files->file_lock);
16454 + fdt = files_fdtable(files);
16455 + bptr = fdt->open_fds;
16456 + count = fdt->max_fds / (sizeof(unsigned long) * 8);
16457 + for (total = 0; count > 0; count--) {
16459 + total += hweight_long(*bptr);
16462 + spin_unlock(&files->file_lock);
16467 +/* for *space compatibility */
16469 +asmlinkage long sys_unshare(unsigned long);
16472 + * migrate task to new context
16473 + * gets vxi, puts old_vxi on change
16474 + * optionally unshares namespaces (hack)
16477 +int vx_migrate_task(struct task_struct *p, struct vx_info *vxi, int unshare)
16479 + struct vx_info *old_vxi;
16485 + vxdprintk(VXD_CBIT(xid, 5),
16486 + "vx_migrate_task(%p,%p[#%d.%d])", p, vxi,
16487 + vxi->vx_id, atomic_read(&vxi->vx_usecnt));
16489 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0) &&
16490 + !vx_info_flags(vxi, VXF_STATE_SETUP, 0))
16493 + if (vx_info_state(vxi, VXS_SHUTDOWN))
16496 + old_vxi = task_get_vx_info(p);
16497 + if (old_vxi == vxi)
16500 +// if (!(ret = vx_migrate_user(p, vxi))) {
16505 + openfd = vx_openfd_task(p);
16508 + atomic_dec(&old_vxi->cvirt.nr_threads);
16509 + atomic_dec(&old_vxi->cvirt.nr_running);
16510 + __rlim_dec(&old_vxi->limit, RLIMIT_NPROC);
16511 + /* FIXME: what about the struct files here? */
16512 + __rlim_sub(&old_vxi->limit, VLIMIT_OPENFD, openfd);
16513 + /* account for the executable */
16514 + __rlim_dec(&old_vxi->limit, VLIMIT_DENTRY);
16516 + atomic_inc(&vxi->cvirt.nr_threads);
16517 + atomic_inc(&vxi->cvirt.nr_running);
16518 + __rlim_inc(&vxi->limit, RLIMIT_NPROC);
16519 + /* FIXME: what about the struct files here? */
16520 + __rlim_add(&vxi->limit, VLIMIT_OPENFD, openfd);
16521 + /* account for the executable */
16522 + __rlim_inc(&vxi->limit, VLIMIT_DENTRY);
16525 + release_vx_info(old_vxi, p);
16526 + clr_vx_info(&p->vx_info);
16528 + claim_vx_info(vxi, p);
16529 + set_vx_info(&p->vx_info, vxi);
16530 + p->xid = vxi->vx_id;
16532 + vxdprintk(VXD_CBIT(xid, 5),
16533 + "moved task %p into vxi:%p[#%d]",
16534 + p, vxi, vxi->vx_id);
16536 + // vx_mask_cap_bset(vxi, p);
16539 + /* hack for *spaces to provide compatibility */
16541 + struct nsproxy *old_nsp, *new_nsp;
16543 + ret = unshare_nsproxy_namespaces(
16544 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER,
16549 + old_nsp = xchg(&p->nsproxy, new_nsp);
16550 + vx_set_space(vxi,
16551 + CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER, 0);
16552 + put_nsproxy(old_nsp);
16556 + put_vx_info(old_vxi);
16560 +int vx_set_reaper(struct vx_info *vxi, struct task_struct *p)
16562 + struct task_struct *old_reaper;
16563 + struct vx_info *reaper_vxi;
16568 + vxdprintk(VXD_CBIT(xid, 6),
16569 + "vx_set_reaper(%p[#%d],%p[#%d,%d])",
16570 + vxi, vxi->vx_id, p, p->xid, p->pid);
16572 + old_reaper = vxi->vx_reaper;
16573 + if (old_reaper == p)
16576 + reaper_vxi = task_get_vx_info(p);
16577 + if (reaper_vxi && reaper_vxi != vxi) {
16579 + "Unsuitable reaper [" VS_Q("%s") ",%u:#%u] "
16581 + p->comm, p->pid, p->xid, vx_current_xid());
16585 + /* set new child reaper */
16586 + get_task_struct(p);
16587 + vxi->vx_reaper = p;
16588 + put_task_struct(old_reaper);
16590 + put_vx_info(reaper_vxi);
16594 +int vx_set_init(struct vx_info *vxi, struct task_struct *p)
16599 + vxdprintk(VXD_CBIT(xid, 6),
16600 + "vx_set_init(%p[#%d],%p[#%d,%d,%d])",
16601 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16603 + vxi->vx_flags &= ~VXF_STATE_INIT;
16604 + // vxi->vx_initpid = p->tgid;
16605 + vxi->vx_initpid = p->pid;
16609 +void vx_exit_init(struct vx_info *vxi, struct task_struct *p, int code)
16611 + vxdprintk(VXD_CBIT(xid, 6),
16612 + "vx_exit_init(%p[#%d],%p[#%d,%d,%d])",
16613 + vxi, vxi->vx_id, p, p->xid, p->pid, p->tgid);
16615 + vxi->exit_code = code;
16616 + vxi->vx_initpid = 0;
16620 +void vx_set_persistent(struct vx_info *vxi)
16622 + vxdprintk(VXD_CBIT(xid, 6),
16623 + "vx_set_persistent(%p[#%d])", vxi, vxi->vx_id);
16625 + get_vx_info(vxi);
16626 + claim_vx_info(vxi, NULL);
16629 +void vx_clear_persistent(struct vx_info *vxi)
16631 + vxdprintk(VXD_CBIT(xid, 6),
16632 + "vx_clear_persistent(%p[#%d])", vxi, vxi->vx_id);
16634 + release_vx_info(vxi, NULL);
16635 + put_vx_info(vxi);
16638 +void vx_update_persistent(struct vx_info *vxi)
16640 + if (vx_info_flags(vxi, VXF_PERSISTENT, 0))
16641 + vx_set_persistent(vxi);
16643 + vx_clear_persistent(vxi);
16647 +/* task must be current or locked */
16649 +void exit_vx_info(struct task_struct *p, int code)
16651 + struct vx_info *vxi = p->vx_info;
16654 + atomic_dec(&vxi->cvirt.nr_threads);
16657 + vxi->exit_code = code;
16658 + release_vx_info(vxi, p);
16662 +void exit_vx_info_early(struct task_struct *p, int code)
16664 + struct vx_info *vxi = p->vx_info;
16667 + if (vxi->vx_initpid == p->pid)
16668 + vx_exit_init(vxi, p, code);
16669 + if (vxi->vx_reaper == p)
16670 + vx_set_reaper(vxi, init_pid_ns.child_reaper);
16675 +/* vserver syscall commands below here */
16677 +/* taks xid and vx_info functions */
16679 +#include <asm/uaccess.h>
16682 +int vc_task_xid(uint32_t id)
16687 + struct task_struct *tsk;
16690 + tsk = find_task_by_real_pid(id);
16691 + xid = (tsk) ? tsk->xid : -ESRCH;
16692 + rcu_read_unlock();
16694 + xid = vx_current_xid();
16699 +int vc_vx_info(struct vx_info *vxi, void __user *data)
16701 + struct vcmd_vx_info_v0 vc_data;
16703 + vc_data.xid = vxi->vx_id;
16704 + vc_data.initpid = vxi->vx_initpid;
16706 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16712 +int vc_ctx_stat(struct vx_info *vxi, void __user *data)
16714 + struct vcmd_ctx_stat_v0 vc_data;
16716 + vc_data.usecnt = atomic_read(&vxi->vx_usecnt);
16717 + vc_data.tasks = atomic_read(&vxi->vx_tasks);
16719 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16725 +/* context functions */
16727 +int vc_ctx_create(uint32_t xid, void __user *data)
16729 + struct vcmd_ctx_create vc_data = { .flagword = VXF_INIT_SET };
16730 + struct vx_info *new_vxi;
16733 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16736 + if ((xid > MAX_S_CONTEXT) || (xid < 2))
16739 + new_vxi = __create_vx_info(xid);
16740 + if (IS_ERR(new_vxi))
16741 + return PTR_ERR(new_vxi);
16743 + /* initial flags */
16744 + new_vxi->vx_flags = vc_data.flagword;
16747 + if (vs_state_change(new_vxi, VSC_STARTUP))
16750 + ret = vx_migrate_task(current, new_vxi, (!data));
16754 + /* return context id on success */
16755 + ret = new_vxi->vx_id;
16757 + /* get a reference for persistent contexts */
16758 + if ((vc_data.flagword & VXF_PERSISTENT))
16759 + vx_set_persistent(new_vxi);
16761 + release_vx_info(new_vxi, NULL);
16762 + put_vx_info(new_vxi);
16767 +int vc_ctx_migrate(struct vx_info *vxi, void __user *data)
16769 + struct vcmd_ctx_migrate vc_data = { .flagword = 0 };
16772 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
16775 + ret = vx_migrate_task(current, vxi, 0);
16778 + if (vc_data.flagword & VXM_SET_INIT)
16779 + ret = vx_set_init(vxi, current);
16782 + if (vc_data.flagword & VXM_SET_REAPER)
16783 + ret = vx_set_reaper(vxi, current);
16788 +int vc_get_cflags(struct vx_info *vxi, void __user *data)
16790 + struct vcmd_ctx_flags_v0 vc_data;
16792 + vc_data.flagword = vxi->vx_flags;
16794 + /* special STATE flag handling */
16795 + vc_data.mask = vs_mask_flags(~0ULL, vxi->vx_flags, VXF_ONE_TIME);
16797 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16802 +int vc_set_cflags(struct vx_info *vxi, void __user *data)
16804 + struct vcmd_ctx_flags_v0 vc_data;
16805 + uint64_t mask, trigger;
16807 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16810 + /* special STATE flag handling */
16811 + mask = vs_mask_mask(vc_data.mask, vxi->vx_flags, VXF_ONE_TIME);
16812 + trigger = (mask & vxi->vx_flags) ^ (mask & vc_data.flagword);
16814 + if (vxi == current_vx_info()) {
16815 + /* if (trigger & VXF_STATE_SETUP)
16816 + vx_mask_cap_bset(vxi, current); */
16817 + if (trigger & VXF_STATE_INIT) {
16820 + ret = vx_set_init(vxi, current);
16823 + ret = vx_set_reaper(vxi, current);
16829 + vxi->vx_flags = vs_mask_flags(vxi->vx_flags,
16830 + vc_data.flagword, mask);
16831 + if (trigger & VXF_PERSISTENT)
16832 + vx_update_persistent(vxi);
16838 +static inline uint64_t caps_from_cap_t(kernel_cap_t c)
16840 + uint64_t v = c.cap[0] | ((uint64_t)c.cap[1] << 32);
16842 + // printk("caps_from_cap_t(%08x:%08x) = %016llx\n", c.cap[1], c.cap[0], v);
16846 +static inline kernel_cap_t cap_t_from_caps(uint64_t v)
16848 + kernel_cap_t c = __cap_empty_set;
16850 + c.cap[0] = v & 0xFFFFFFFF;
16851 + c.cap[1] = (v >> 32) & 0xFFFFFFFF;
16853 + // printk("cap_t_from_caps(%016llx) = %08x:%08x\n", v, c.cap[1], c.cap[0]);
16858 +static int do_get_caps(struct vx_info *vxi, uint64_t *bcaps, uint64_t *ccaps)
16861 + *bcaps = caps_from_cap_t(vxi->vx_bcaps);
16863 + *ccaps = vxi->vx_ccaps;
16868 +int vc_get_ccaps(struct vx_info *vxi, void __user *data)
16870 + struct vcmd_ctx_caps_v1 vc_data;
16873 + ret = do_get_caps(vxi, NULL, &vc_data.ccaps);
16876 + vc_data.cmask = ~0ULL;
16878 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16883 +static int do_set_caps(struct vx_info *vxi,
16884 + uint64_t bcaps, uint64_t bmask, uint64_t ccaps, uint64_t cmask)
16886 + uint64_t bcold = caps_from_cap_t(vxi->vx_bcaps);
16889 + printk("do_set_caps(%16llx, %16llx, %16llx, %16llx)\n",
16890 + bcaps, bmask, ccaps, cmask);
16892 + vxi->vx_bcaps = cap_t_from_caps(
16893 + vs_mask_flags(bcold, bcaps, bmask));
16894 + vxi->vx_ccaps = vs_mask_flags(vxi->vx_ccaps, ccaps, cmask);
16899 +int vc_set_ccaps(struct vx_info *vxi, void __user *data)
16901 + struct vcmd_ctx_caps_v1 vc_data;
16903 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16906 + return do_set_caps(vxi, 0, 0, vc_data.ccaps, vc_data.cmask);
16909 +int vc_get_bcaps(struct vx_info *vxi, void __user *data)
16911 + struct vcmd_bcaps vc_data;
16914 + ret = do_get_caps(vxi, &vc_data.bcaps, NULL);
16917 + vc_data.bmask = ~0ULL;
16919 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16924 +int vc_set_bcaps(struct vx_info *vxi, void __user *data)
16926 + struct vcmd_bcaps vc_data;
16928 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16931 + return do_set_caps(vxi, vc_data.bcaps, vc_data.bmask, 0, 0);
16935 +int vc_get_umask(struct vx_info *vxi, void __user *data)
16937 + struct vcmd_umask vc_data;
16939 + vc_data.umask = vxi->vx_umask;
16940 + vc_data.mask = ~0ULL;
16942 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16947 +int vc_set_umask(struct vx_info *vxi, void __user *data)
16949 + struct vcmd_umask vc_data;
16951 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16954 + vxi->vx_umask = vs_mask_flags(vxi->vx_umask,
16955 + vc_data.umask, vc_data.mask);
16960 +int vc_get_wmask(struct vx_info *vxi, void __user *data)
16962 + struct vcmd_wmask vc_data;
16964 + vc_data.wmask = vxi->vx_wmask;
16965 + vc_data.mask = ~0ULL;
16967 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16972 +int vc_set_wmask(struct vx_info *vxi, void __user *data)
16974 + struct vcmd_wmask vc_data;
16976 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
16979 + vxi->vx_wmask = vs_mask_flags(vxi->vx_wmask,
16980 + vc_data.wmask, vc_data.mask);
16985 +int vc_get_badness(struct vx_info *vxi, void __user *data)
16987 + struct vcmd_badness_v0 vc_data;
16989 + vc_data.bias = vxi->vx_badness_bias;
16991 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
16996 +int vc_set_badness(struct vx_info *vxi, void __user *data)
16998 + struct vcmd_badness_v0 vc_data;
17000 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17003 + vxi->vx_badness_bias = vc_data.bias;
17007 +#include <linux/module.h>
17009 +EXPORT_SYMBOL_GPL(free_vx_info);
17011 diff -NurpP --minimal linux-3.4.103/kernel/vserver/cvirt.c linux-3.4.103-vs2.3.3.9/kernel/vserver/cvirt.c
17012 --- linux-3.4.103/kernel/vserver/cvirt.c 1970-01-01 00:00:00.000000000 +0000
17013 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/cvirt.c 2012-05-21 16:15:05.000000000 +0000
17016 + * linux/kernel/vserver/cvirt.c
17018 + * Virtual Server: Context Virtualization
17020 + * Copyright (C) 2004-2007 Herbert Pötzl
17022 + * V0.01 broken out from limit.c
17023 + * V0.02 added utsname stuff
17024 + * V0.03 changed vcmds to vxi arg
17028 +#include <linux/types.h>
17029 +#include <linux/utsname.h>
17030 +#include <linux/vs_cvirt.h>
17031 +#include <linux/vserver/switch.h>
17032 +#include <linux/vserver/cvirt_cmd.h>
17034 +#include <asm/uaccess.h>
17037 +void vx_vsi_boottime(struct timespec *boottime)
17039 + struct vx_info *vxi = current_vx_info();
17041 + set_normalized_timespec(boottime,
17042 + boottime->tv_sec + vxi->cvirt.bias_uptime.tv_sec,
17043 + boottime->tv_nsec + vxi->cvirt.bias_uptime.tv_nsec);
17047 +void vx_vsi_uptime(struct timespec *uptime, struct timespec *idle)
17049 + struct vx_info *vxi = current_vx_info();
17051 + set_normalized_timespec(uptime,
17052 + uptime->tv_sec - vxi->cvirt.bias_uptime.tv_sec,
17053 + uptime->tv_nsec - vxi->cvirt.bias_uptime.tv_nsec);
17056 + set_normalized_timespec(idle,
17057 + idle->tv_sec - vxi->cvirt.bias_idle.tv_sec,
17058 + idle->tv_nsec - vxi->cvirt.bias_idle.tv_nsec);
17062 +uint64_t vx_idle_jiffies(void)
17064 + return init_task.utime + init_task.stime;
17069 +static inline uint32_t __update_loadavg(uint32_t load,
17070 + int wsize, int delta, int n)
17072 + unsigned long long calc, prev;
17074 + /* just set it to n */
17075 + if (unlikely(delta >= wsize))
17076 + return (n << FSHIFT);
17078 + calc = delta * n;
17080 + prev = (wsize - delta);
17083 + do_div(calc, wsize);
17088 +void vx_update_load(struct vx_info *vxi)
17090 + uint32_t now, last, delta;
17091 + unsigned int nr_running, nr_uninterruptible;
17092 + unsigned int total;
17093 + unsigned long flags;
17095 + spin_lock_irqsave(&vxi->cvirt.load_lock, flags);
17098 + last = vxi->cvirt.load_last;
17099 + delta = now - last;
17101 + if (delta < 5*HZ)
17104 + nr_running = atomic_read(&vxi->cvirt.nr_running);
17105 + nr_uninterruptible = atomic_read(&vxi->cvirt.nr_uninterruptible);
17106 + total = nr_running + nr_uninterruptible;
17108 + vxi->cvirt.load[0] = __update_loadavg(vxi->cvirt.load[0],
17109 + 60*HZ, delta, total);
17110 + vxi->cvirt.load[1] = __update_loadavg(vxi->cvirt.load[1],
17111 + 5*60*HZ, delta, total);
17112 + vxi->cvirt.load[2] = __update_loadavg(vxi->cvirt.load[2],
17113 + 15*60*HZ, delta, total);
17115 + vxi->cvirt.load_last = now;
17117 + atomic_inc(&vxi->cvirt.load_updates);
17118 + spin_unlock_irqrestore(&vxi->cvirt.load_lock, flags);
17123 + * Commands to do_syslog:
17125 + * 0 -- Close the log. Currently a NOP.
17126 + * 1 -- Open the log. Currently a NOP.
17127 + * 2 -- Read from the log.
17128 + * 3 -- Read all messages remaining in the ring buffer.
17129 + * 4 -- Read and clear all messages remaining in the ring buffer
17130 + * 5 -- Clear ring buffer.
17131 + * 6 -- Disable printk's to console
17132 + * 7 -- Enable printk's to console
17133 + * 8 -- Set level of messages printed to console
17134 + * 9 -- Return number of unread characters in the log buffer
17135 + * 10 -- Return size of the log buffer
17137 +int vx_do_syslog(int type, char __user *buf, int len)
17140 + int do_clear = 0;
17141 + struct vx_info *vxi = current_vx_info();
17142 + struct _vx_syslog *log;
17146 + log = &vxi->cvirt.syslog;
17149 + case 0: /* Close log */
17150 + case 1: /* Open log */
17152 + case 2: /* Read from log */
17153 + error = wait_event_interruptible(log->log_wait,
17154 + (log->log_start - log->log_end));
17157 + spin_lock_irq(&log->logbuf_lock);
17158 + spin_unlock_irq(&log->logbuf_lock);
17160 + case 4: /* Read/clear last kernel messages */
17162 + /* fall through */
17163 + case 3: /* Read last kernel messages */
17166 + case 5: /* Clear ring buffer */
17169 + case 6: /* Disable logging to console */
17170 + case 7: /* Enable logging to console */
17171 + case 8: /* Set level of messages printed to console */
17174 + case 9: /* Number of chars in the log buffer */
17176 + case 10: /* Size of the log buffer */
17186 +/* virtual host info names */
17188 +static char *vx_vhi_name(struct vx_info *vxi, int id)
17190 + struct nsproxy *nsproxy;
17191 + struct uts_namespace *uts;
17193 + if (id == VHIN_CONTEXT)
17194 + return vxi->vx_name;
17196 + nsproxy = vxi->space[0].vx_nsproxy;
17200 + uts = nsproxy->uts_ns;
17205 + case VHIN_SYSNAME:
17206 + return uts->name.sysname;
17207 + case VHIN_NODENAME:
17208 + return uts->name.nodename;
17209 + case VHIN_RELEASE:
17210 + return uts->name.release;
17211 + case VHIN_VERSION:
17212 + return uts->name.version;
17213 + case VHIN_MACHINE:
17214 + return uts->name.machine;
17215 + case VHIN_DOMAINNAME:
17216 + return uts->name.domainname;
17223 +int vc_set_vhi_name(struct vx_info *vxi, void __user *data)
17225 + struct vcmd_vhi_name_v0 vc_data;
17228 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17231 + name = vx_vhi_name(vxi, vc_data.field);
17235 + memcpy(name, vc_data.name, 65);
17239 +int vc_get_vhi_name(struct vx_info *vxi, void __user *data)
17241 + struct vcmd_vhi_name_v0 vc_data;
17244 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17247 + name = vx_vhi_name(vxi, vc_data.field);
17251 + memcpy(vc_data.name, name, 65);
17252 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17258 +int vc_virt_stat(struct vx_info *vxi, void __user *data)
17260 + struct vcmd_virt_stat_v0 vc_data;
17261 + struct _vx_cvirt *cvirt = &vxi->cvirt;
17262 + struct timespec uptime;
17264 + do_posix_clock_monotonic_gettime(&uptime);
17265 + set_normalized_timespec(&uptime,
17266 + uptime.tv_sec - cvirt->bias_uptime.tv_sec,
17267 + uptime.tv_nsec - cvirt->bias_uptime.tv_nsec);
17269 + vc_data.offset = timespec_to_ns(&cvirt->bias_ts);
17270 + vc_data.uptime = timespec_to_ns(&uptime);
17271 + vc_data.nr_threads = atomic_read(&cvirt->nr_threads);
17272 + vc_data.nr_running = atomic_read(&cvirt->nr_running);
17273 + vc_data.nr_uninterruptible = atomic_read(&cvirt->nr_uninterruptible);
17274 + vc_data.nr_onhold = atomic_read(&cvirt->nr_onhold);
17275 + vc_data.nr_forks = atomic_read(&cvirt->total_forks);
17276 + vc_data.load[0] = cvirt->load[0];
17277 + vc_data.load[1] = cvirt->load[1];
17278 + vc_data.load[2] = cvirt->load[2];
17280 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
17286 +#ifdef CONFIG_VSERVER_VTIME
17288 +/* virtualized time base */
17290 +void vx_adjust_timespec(struct timespec *ts)
17292 + struct vx_info *vxi;
17294 + if (!vx_flags(VXF_VIRT_TIME, 0))
17297 + vxi = current_vx_info();
17298 + ts->tv_sec += vxi->cvirt.bias_ts.tv_sec;
17299 + ts->tv_nsec += vxi->cvirt.bias_ts.tv_nsec;
17301 + if (ts->tv_nsec >= NSEC_PER_SEC) {
17303 + ts->tv_nsec -= NSEC_PER_SEC;
17304 + } else if (ts->tv_nsec < 0) {
17306 + ts->tv_nsec += NSEC_PER_SEC;
17310 +int vx_settimeofday(const struct timespec *ts)
17312 + struct timespec ats, delta;
17313 + struct vx_info *vxi;
17315 + if (!vx_flags(VXF_VIRT_TIME, 0))
17316 + return do_settimeofday(ts);
17318 + getnstimeofday(&ats);
17319 + delta = timespec_sub(*ts, ats);
17321 + vxi = current_vx_info();
17322 + vxi->cvirt.bias_ts = timespec_add(vxi->cvirt.bias_ts, delta);
17328 diff -NurpP --minimal linux-3.4.103/kernel/vserver/cvirt_init.h linux-3.4.103-vs2.3.3.9/kernel/vserver/cvirt_init.h
17329 --- linux-3.4.103/kernel/vserver/cvirt_init.h 1970-01-01 00:00:00.000000000 +0000
17330 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/cvirt_init.h 2012-05-21 16:15:05.000000000 +0000
17334 +extern uint64_t vx_idle_jiffies(void);
17336 +static inline void vx_info_init_cvirt(struct _vx_cvirt *cvirt)
17338 + uint64_t idle_jiffies = vx_idle_jiffies();
17339 + uint64_t nsuptime;
17341 + do_posix_clock_monotonic_gettime(&cvirt->bias_uptime);
17342 + nsuptime = (unsigned long long)cvirt->bias_uptime.tv_sec
17343 + * NSEC_PER_SEC + cvirt->bias_uptime.tv_nsec;
17344 + cvirt->bias_clock = nsec_to_clock_t(nsuptime);
17345 + cvirt->bias_ts.tv_sec = 0;
17346 + cvirt->bias_ts.tv_nsec = 0;
17348 + jiffies_to_timespec(idle_jiffies, &cvirt->bias_idle);
17349 + atomic_set(&cvirt->nr_threads, 0);
17350 + atomic_set(&cvirt->nr_running, 0);
17351 + atomic_set(&cvirt->nr_uninterruptible, 0);
17352 + atomic_set(&cvirt->nr_onhold, 0);
17354 + spin_lock_init(&cvirt->load_lock);
17355 + cvirt->load_last = jiffies;
17356 + atomic_set(&cvirt->load_updates, 0);
17357 + cvirt->load[0] = 0;
17358 + cvirt->load[1] = 0;
17359 + cvirt->load[2] = 0;
17360 + atomic_set(&cvirt->total_forks, 0);
17362 + spin_lock_init(&cvirt->syslog.logbuf_lock);
17363 + init_waitqueue_head(&cvirt->syslog.log_wait);
17364 + cvirt->syslog.log_start = 0;
17365 + cvirt->syslog.log_end = 0;
17366 + cvirt->syslog.con_start = 0;
17367 + cvirt->syslog.logged_chars = 0;
17371 +void vx_info_init_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17373 + // cvirt_pc->cpustat = { 0 };
17376 +static inline void vx_info_exit_cvirt(struct _vx_cvirt *cvirt)
17378 +#ifdef CONFIG_VSERVER_WARN
17381 + vxwprintk_xid((value = atomic_read(&cvirt->nr_threads)),
17382 + "!!! cvirt: %p[nr_threads] = %d on exit.",
17384 + vxwprintk_xid((value = atomic_read(&cvirt->nr_running)),
17385 + "!!! cvirt: %p[nr_running] = %d on exit.",
17387 + vxwprintk_xid((value = atomic_read(&cvirt->nr_uninterruptible)),
17388 + "!!! cvirt: %p[nr_uninterruptible] = %d on exit.",
17390 + vxwprintk_xid((value = atomic_read(&cvirt->nr_onhold)),
17391 + "!!! cvirt: %p[nr_onhold] = %d on exit.",
17397 +void vx_info_exit_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc, int cpu)
17402 diff -NurpP --minimal linux-3.4.103/kernel/vserver/cvirt_proc.h linux-3.4.103-vs2.3.3.9/kernel/vserver/cvirt_proc.h
17403 --- linux-3.4.103/kernel/vserver/cvirt_proc.h 1970-01-01 00:00:00.000000000 +0000
17404 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/cvirt_proc.h 2013-08-13 17:48:39.000000000 +0000
17406 +#ifndef _VX_CVIRT_PROC_H
17407 +#define _VX_CVIRT_PROC_H
17409 +#include <linux/nsproxy.h>
17410 +#include <linux/mnt_namespace.h>
17411 +#include <linux/ipc_namespace.h>
17412 +#include <linux/utsname.h>
17413 +#include <linux/ipc.h>
17415 +extern int vx_info_mnt_namespace(struct mnt_namespace *, char *);
17418 +int vx_info_proc_nsproxy(struct nsproxy *nsproxy, char *buffer)
17420 + struct mnt_namespace *ns;
17421 + struct uts_namespace *uts;
17422 + struct ipc_namespace *ipc;
17428 + length += sprintf(buffer + length,
17429 + "NSProxy:\t%p [%p,%p,%p]\n",
17430 + nsproxy, nsproxy->mnt_ns,
17431 + nsproxy->uts_ns, nsproxy->ipc_ns);
17433 + ns = nsproxy->mnt_ns;
17437 + length += vx_info_mnt_namespace(ns, buffer + length);
17441 + uts = nsproxy->uts_ns;
17445 + length += sprintf(buffer + length,
17446 + "SysName:\t%.*s\n"
17447 + "NodeName:\t%.*s\n"
17448 + "Release:\t%.*s\n"
17449 + "Version:\t%.*s\n"
17450 + "Machine:\t%.*s\n"
17451 + "DomainName:\t%.*s\n",
17452 + __NEW_UTS_LEN, uts->name.sysname,
17453 + __NEW_UTS_LEN, uts->name.nodename,
17454 + __NEW_UTS_LEN, uts->name.release,
17455 + __NEW_UTS_LEN, uts->name.version,
17456 + __NEW_UTS_LEN, uts->name.machine,
17457 + __NEW_UTS_LEN, uts->name.domainname);
17460 + ipc = nsproxy->ipc_ns;
17464 + length += sprintf(buffer + length,
17465 + "SEMS:\t\t%d %d %d %d %d\n"
17466 + "MSG:\t\t%d %d %d\n"
17467 + "SHM:\t\t%lu %lu %d %ld\n",
17468 + ipc->sem_ctls[0], ipc->sem_ctls[1],
17469 + ipc->sem_ctls[2], ipc->sem_ctls[3],
17471 + ipc->msg_ctlmax, ipc->msg_ctlmnb, ipc->msg_ctlmni,
17472 + (unsigned long)ipc->shm_ctlmax,
17473 + (unsigned long)ipc->shm_ctlall,
17474 + ipc->shm_ctlmni, ipc->shm_tot);
17481 +#include <linux/sched.h>
17483 +#define LOAD_INT(x) ((x) >> FSHIFT)
17484 +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * 100)
17487 +int vx_info_proc_cvirt(struct _vx_cvirt *cvirt, char *buffer)
17492 + length += sprintf(buffer + length,
17493 + "BiasUptime:\t%lu.%02lu\n",
17494 + (unsigned long)cvirt->bias_uptime.tv_sec,
17495 + (cvirt->bias_uptime.tv_nsec / (NSEC_PER_SEC / 100)));
17497 + a = cvirt->load[0] + (FIXED_1 / 200);
17498 + b = cvirt->load[1] + (FIXED_1 / 200);
17499 + c = cvirt->load[2] + (FIXED_1 / 200);
17500 + length += sprintf(buffer + length,
17501 + "nr_threads:\t%d\n"
17502 + "nr_running:\t%d\n"
17503 + "nr_unintr:\t%d\n"
17504 + "nr_onhold:\t%d\n"
17505 + "load_updates:\t%d\n"
17506 + "loadavg:\t%d.%02d %d.%02d %d.%02d\n"
17507 + "total_forks:\t%d\n",
17508 + atomic_read(&cvirt->nr_threads),
17509 + atomic_read(&cvirt->nr_running),
17510 + atomic_read(&cvirt->nr_uninterruptible),
17511 + atomic_read(&cvirt->nr_onhold),
17512 + atomic_read(&cvirt->load_updates),
17513 + LOAD_INT(a), LOAD_FRAC(a),
17514 + LOAD_INT(b), LOAD_FRAC(b),
17515 + LOAD_INT(c), LOAD_FRAC(c),
17516 + atomic_read(&cvirt->total_forks));
17521 +int vx_info_proc_cvirt_pc(struct _vx_cvirt_pc *cvirt_pc,
17522 + char *buffer, int cpu)
17528 +#endif /* _VX_CVIRT_PROC_H */
17529 diff -NurpP --minimal linux-3.4.103/kernel/vserver/debug.c linux-3.4.103-vs2.3.3.9/kernel/vserver/debug.c
17530 --- linux-3.4.103/kernel/vserver/debug.c 1970-01-01 00:00:00.000000000 +0000
17531 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/debug.c 2012-05-21 16:15:05.000000000 +0000
17534 + * kernel/vserver/debug.c
17536 + * Copyright (C) 2005-2007 Herbert Pötzl
17538 + * V0.01 vx_info dump support
17542 +#include <linux/module.h>
17544 +#include <linux/vserver/context.h>
17547 +void dump_vx_info(struct vx_info *vxi, int level)
17549 + printk("vx_info %p[#%d, %d.%d, %4x]\n", vxi, vxi->vx_id,
17550 + atomic_read(&vxi->vx_usecnt),
17551 + atomic_read(&vxi->vx_tasks),
17554 + __dump_vx_limit(&vxi->limit);
17555 + __dump_vx_sched(&vxi->sched);
17556 + __dump_vx_cvirt(&vxi->cvirt);
17557 + __dump_vx_cacct(&vxi->cacct);
17563 +EXPORT_SYMBOL_GPL(dump_vx_info);
17565 diff -NurpP --minimal linux-3.4.103/kernel/vserver/device.c linux-3.4.103-vs2.3.3.9/kernel/vserver/device.c
17566 --- linux-3.4.103/kernel/vserver/device.c 1970-01-01 00:00:00.000000000 +0000
17567 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/device.c 2012-05-21 16:15:05.000000000 +0000
17570 + * linux/kernel/vserver/device.c
17572 + * Linux-VServer: Device Support
17574 + * Copyright (C) 2006 Herbert Pötzl
17575 + * Copyright (C) 2007 Daniel Hokka Zakrisson
17577 + * V0.01 device mapping basics
17578 + * V0.02 added defaults
17582 +#include <linux/slab.h>
17583 +#include <linux/rcupdate.h>
17584 +#include <linux/fs.h>
17585 +#include <linux/namei.h>
17586 +#include <linux/hash.h>
17588 +#include <asm/errno.h>
17589 +#include <asm/uaccess.h>
17590 +#include <linux/vserver/base.h>
17591 +#include <linux/vserver/debug.h>
17592 +#include <linux/vserver/context.h>
17593 +#include <linux/vserver/device.h>
17594 +#include <linux/vserver/device_cmd.h>
17597 +#define DMAP_HASH_BITS 4
17600 +struct vs_mapping {
17602 + struct hlist_node hlist;
17603 + struct list_head list;
17605 +#define dm_hlist u.hlist
17606 +#define dm_list u.list
17609 + struct vx_dmap_target target;
17613 +static struct hlist_head dmap_main_hash[1 << DMAP_HASH_BITS];
17615 +static DEFINE_SPINLOCK(dmap_main_hash_lock);
17617 +static struct vx_dmap_target dmap_defaults[2] = {
17618 + { .flags = DATTR_OPEN },
17619 + { .flags = DATTR_OPEN },
17623 +struct kmem_cache *dmap_cachep __read_mostly;
17625 +int __init dmap_cache_init(void)
17627 + dmap_cachep = kmem_cache_create("dmap_cache",
17628 + sizeof(struct vs_mapping), 0,
17629 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
17633 +__initcall(dmap_cache_init);
17636 +static inline unsigned int __hashval(dev_t dev, int bits)
17638 + return hash_long((unsigned long)dev, bits);
17642 +/* __hash_mapping()
17643 + * add the mapping to the hash table
17645 +static inline void __hash_mapping(struct vx_info *vxi, struct vs_mapping *vdm)
17647 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17648 + struct hlist_head *head, *hash = dmap_main_hash;
17649 + int device = vdm->device;
17651 + spin_lock(hash_lock);
17652 + vxdprintk(VXD_CBIT(misc, 8), "__hash_mapping: %p[#%d] %08x:%08x",
17653 + vxi, vxi ? vxi->vx_id : 0, device, vdm->target.target);
17655 + head = &hash[__hashval(device, DMAP_HASH_BITS)];
17656 + hlist_add_head(&vdm->dm_hlist, head);
17657 + spin_unlock(hash_lock);
17661 +static inline int __mode_to_default(umode_t mode)
17674 +/* __set_default()
17677 +static inline void __set_default(struct vx_info *vxi, umode_t mode,
17678 + struct vx_dmap_target *vdmt)
17680 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17681 + spin_lock(hash_lock);
17684 + vxi->dmap.targets[__mode_to_default(mode)] = *vdmt;
17686 + dmap_defaults[__mode_to_default(mode)] = *vdmt;
17689 + spin_unlock(hash_lock);
17691 + vxdprintk(VXD_CBIT(misc, 8), "__set_default: %p[#%u] %08x %04x",
17692 + vxi, vxi ? vxi->vx_id : 0, vdmt->target, vdmt->flags);
17696 +/* __remove_default()
17697 + * remove a default
17699 +static inline int __remove_default(struct vx_info *vxi, umode_t mode)
17701 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17702 + spin_lock(hash_lock);
17705 + vxi->dmap.targets[__mode_to_default(mode)].flags = 0;
17706 + else /* remove == reset */
17707 + dmap_defaults[__mode_to_default(mode)].flags = DATTR_OPEN | mode;
17709 + spin_unlock(hash_lock);
17714 +/* __find_mapping()
17715 + * find a mapping in the hash table
17717 + * caller must hold hash_lock
17719 +static inline int __find_mapping(xid_t xid, dev_t device, umode_t mode,
17720 + struct vs_mapping **local, struct vs_mapping **global)
17722 + struct hlist_head *hash = dmap_main_hash;
17723 + struct hlist_head *head = &hash[__hashval(device, DMAP_HASH_BITS)];
17724 + struct hlist_node *pos;
17725 + struct vs_mapping *vdm;
17731 + hlist_for_each(pos, head) {
17732 + vdm = hlist_entry(pos, struct vs_mapping, dm_hlist);
17734 + if ((vdm->device == device) &&
17735 + !((vdm->target.flags ^ mode) & S_IFMT)) {
17736 + if (vdm->xid == xid) {
17739 + } else if (global && vdm->xid == 0)
17744 + if (global && *global)
17751 +/* __lookup_mapping()
17752 + * find a mapping and store the result in target and flags
17754 +static inline int __lookup_mapping(struct vx_info *vxi,
17755 + dev_t device, dev_t *target, int *flags, umode_t mode)
17757 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17758 + struct vs_mapping *vdm, *global;
17759 + struct vx_dmap_target *vdmt;
17761 + xid_t xid = vxi->vx_id;
17764 + spin_lock(hash_lock);
17765 + if (__find_mapping(xid, device, mode, &vdm, &global) > 0) {
17767 + vdmt = &vdm->target;
17771 + index = __mode_to_default(mode);
17772 + if (vxi && vxi->dmap.targets[index].flags) {
17774 + vdmt = &vxi->dmap.targets[index];
17775 + } else if (global) {
17777 + vdmt = &global->target;
17781 + vdmt = &dmap_defaults[index];
17785 + if (target && (vdmt->flags & DATTR_REMAP))
17786 + *target = vdmt->target;
17788 + *target = device;
17790 + *flags = vdmt->flags;
17792 + spin_unlock(hash_lock);
17798 +/* __remove_mapping()
17799 + * remove a mapping from the hash table
17801 +static inline int __remove_mapping(struct vx_info *vxi, dev_t device,
17804 + spinlock_t *hash_lock = &dmap_main_hash_lock;
17805 + struct vs_mapping *vdm = NULL;
17808 + spin_lock(hash_lock);
17810 + ret = __find_mapping((vxi ? vxi->vx_id : 0), device, mode, &vdm,
17812 + vxdprintk(VXD_CBIT(misc, 8), "__remove_mapping: %p[#%d] %08x %04x",
17813 + vxi, vxi ? vxi->vx_id : 0, device, mode);
17816 + hlist_del(&vdm->dm_hlist);
17819 + spin_unlock(hash_lock);
17821 + kmem_cache_free(dmap_cachep, vdm);
17827 +int vs_map_device(struct vx_info *vxi,
17828 + dev_t device, dev_t *target, umode_t mode)
17830 + int ret, flags = DATTR_MASK;
17834 + *target = device;
17837 + ret = __lookup_mapping(vxi, device, target, &flags, mode);
17838 + vxdprintk(VXD_CBIT(misc, 8), "vs_map_device: %08x target: %08x flags: %04x mode: %04x mapped=%d",
17839 + device, target ? *target : 0, flags, mode, ret);
17841 + return (flags & DATTR_MASK);
17846 +static int do_set_mapping(struct vx_info *vxi,
17847 + dev_t device, dev_t target, int flags, umode_t mode)
17850 + struct vs_mapping *new;
17852 + new = kmem_cache_alloc(dmap_cachep, GFP_KERNEL);
17856 + INIT_HLIST_NODE(&new->dm_hlist);
17857 + new->device = device;
17858 + new->target.target = target;
17859 + new->target.flags = flags | mode;
17860 + new->xid = (vxi ? vxi->vx_id : 0);
17862 + vxdprintk(VXD_CBIT(misc, 8), "do_set_mapping: %08x target: %08x flags: %04x", device, target, flags);
17863 + __hash_mapping(vxi, new);
17865 + struct vx_dmap_target new = {
17866 + .target = target,
17867 + .flags = flags | mode,
17869 + __set_default(vxi, mode, &new);
17875 +static int do_unset_mapping(struct vx_info *vxi,
17876 + dev_t device, dev_t target, int flags, umode_t mode)
17878 + int ret = -EINVAL;
17881 + ret = __remove_mapping(vxi, device, mode);
17885 + ret = __remove_default(vxi, mode);
17895 +static inline int __user_device(const char __user *name, dev_t *dev,
17898 + struct nameidata nd;
17905 + ret = user_lpath(name, &nd.path);
17908 + if (nd.path.dentry->d_inode) {
17909 + *dev = nd.path.dentry->d_inode->i_rdev;
17910 + *mode = nd.path.dentry->d_inode->i_mode;
17912 + path_put(&nd.path);
17916 +static inline int __mapping_mode(dev_t device, dev_t target,
17917 + umode_t device_mode, umode_t target_mode, umode_t *mode)
17920 + *mode = device_mode & S_IFMT;
17922 + *mode = target_mode & S_IFMT;
17926 + /* if both given, device and target mode have to match */
17927 + if (device && target &&
17928 + ((device_mode ^ target_mode) & S_IFMT))
17934 +static inline int do_mapping(struct vx_info *vxi, const char __user *device_path,
17935 + const char __user *target_path, int flags, int set)
17937 + dev_t device = ~0, target = ~0;
17938 + umode_t device_mode = 0, target_mode = 0, mode;
17941 + ret = __user_device(device_path, &device, &device_mode);
17944 + ret = __user_device(target_path, &target, &target_mode);
17948 + ret = __mapping_mode(device, target,
17949 + device_mode, target_mode, &mode);
17954 + return do_set_mapping(vxi, device, target,
17957 + return do_unset_mapping(vxi, device, target,
17962 +int vc_set_mapping(struct vx_info *vxi, void __user *data)
17964 + struct vcmd_set_mapping_v0 vc_data;
17966 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17969 + return do_mapping(vxi, vc_data.device, vc_data.target,
17970 + vc_data.flags, 1);
17973 +int vc_unset_mapping(struct vx_info *vxi, void __user *data)
17975 + struct vcmd_set_mapping_v0 vc_data;
17977 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17980 + return do_mapping(vxi, vc_data.device, vc_data.target,
17981 + vc_data.flags, 0);
17985 +#ifdef CONFIG_COMPAT
17987 +int vc_set_mapping_x32(struct vx_info *vxi, void __user *data)
17989 + struct vcmd_set_mapping_v0_x32 vc_data;
17991 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
17994 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
17995 + compat_ptr(vc_data.target_ptr), vc_data.flags, 1);
17998 +int vc_unset_mapping_x32(struct vx_info *vxi, void __user *data)
18000 + struct vcmd_set_mapping_v0_x32 vc_data;
18002 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18005 + return do_mapping(vxi, compat_ptr(vc_data.device_ptr),
18006 + compat_ptr(vc_data.target_ptr), vc_data.flags, 0);
18009 +#endif /* CONFIG_COMPAT */
18012 diff -NurpP --minimal linux-3.4.103/kernel/vserver/dlimit.c linux-3.4.103-vs2.3.3.9/kernel/vserver/dlimit.c
18013 --- linux-3.4.103/kernel/vserver/dlimit.c 1970-01-01 00:00:00.000000000 +0000
18014 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/dlimit.c 2012-05-21 16:15:05.000000000 +0000
18017 + * linux/kernel/vserver/dlimit.c
18019 + * Virtual Server: Context Disk Limits
18021 + * Copyright (C) 2004-2009 Herbert Pötzl
18023 + * V0.01 initial version
18024 + * V0.02 compat32 splitup
18025 + * V0.03 extended interface
18029 +#include <linux/statfs.h>
18030 +#include <linux/sched.h>
18031 +#include <linux/namei.h>
18032 +#include <linux/vs_tag.h>
18033 +#include <linux/vs_dlimit.h>
18034 +#include <linux/vserver/dlimit_cmd.h>
18035 +#include <linux/slab.h>
18036 +// #include <linux/gfp.h>
18038 +#include <asm/uaccess.h>
18040 +/* __alloc_dl_info()
18042 + * allocate an initialized dl_info struct
18043 + * doesn't make it visible (hash) */
18045 +static struct dl_info *__alloc_dl_info(struct super_block *sb, tag_t tag)
18047 + struct dl_info *new = NULL;
18049 + vxdprintk(VXD_CBIT(dlim, 5),
18050 + "alloc_dl_info(%p,%d)*", sb, tag);
18052 + /* would this benefit from a slab cache? */
18053 + new = kmalloc(sizeof(struct dl_info), GFP_KERNEL);
18057 + memset(new, 0, sizeof(struct dl_info));
18058 + new->dl_tag = tag;
18060 + // INIT_RCU_HEAD(&new->dl_rcu);
18061 + INIT_HLIST_NODE(&new->dl_hlist);
18062 + spin_lock_init(&new->dl_lock);
18063 + atomic_set(&new->dl_refcnt, 0);
18064 + atomic_set(&new->dl_usecnt, 0);
18066 + /* rest of init goes here */
18068 + vxdprintk(VXD_CBIT(dlim, 4),
18069 + "alloc_dl_info(%p,%d) = %p", sb, tag, new);
18073 +/* __dealloc_dl_info()
18075 + * final disposal of dl_info */
18077 +static void __dealloc_dl_info(struct dl_info *dli)
18079 + vxdprintk(VXD_CBIT(dlim, 4),
18080 + "dealloc_dl_info(%p)", dli);
18082 + dli->dl_hlist.next = LIST_POISON1;
18083 + dli->dl_tag = -1;
18086 + BUG_ON(atomic_read(&dli->dl_usecnt));
18087 + BUG_ON(atomic_read(&dli->dl_refcnt));
18093 +/* hash table for dl_info hash */
18095 +#define DL_HASH_SIZE 13
18097 +struct hlist_head dl_info_hash[DL_HASH_SIZE];
18099 +static DEFINE_SPINLOCK(dl_info_hash_lock);
18102 +static inline unsigned int __hashval(struct super_block *sb, tag_t tag)
18104 + return ((tag ^ (unsigned long)sb) % DL_HASH_SIZE);
18109 +/* __hash_dl_info()
18111 + * add the dli to the global hash table
18112 + * requires the hash_lock to be held */
18114 +static inline void __hash_dl_info(struct dl_info *dli)
18116 + struct hlist_head *head;
18118 + vxdprintk(VXD_CBIT(dlim, 6),
18119 + "__hash_dl_info: %p[#%d]", dli, dli->dl_tag);
18120 + get_dl_info(dli);
18121 + head = &dl_info_hash[__hashval(dli->dl_sb, dli->dl_tag)];
18122 + hlist_add_head_rcu(&dli->dl_hlist, head);
18125 +/* __unhash_dl_info()
18127 + * remove the dli from the global hash table
18128 + * requires the hash_lock to be held */
18130 +static inline void __unhash_dl_info(struct dl_info *dli)
18132 + vxdprintk(VXD_CBIT(dlim, 6),
18133 + "__unhash_dl_info: %p[#%d]", dli, dli->dl_tag);
18134 + hlist_del_rcu(&dli->dl_hlist);
18135 + put_dl_info(dli);
18139 +/* __lookup_dl_info()
18141 + * requires the rcu_read_lock()
18142 + * doesn't increment the dl_refcnt */
18144 +static inline struct dl_info *__lookup_dl_info(struct super_block *sb, tag_t tag)
18146 + struct hlist_head *head = &dl_info_hash[__hashval(sb, tag)];
18147 + struct hlist_node *pos;
18148 + struct dl_info *dli;
18150 + hlist_for_each_entry_rcu(dli, pos, head, dl_hlist) {
18152 + if (dli->dl_tag == tag && dli->dl_sb == sb) {
18160 +struct dl_info *locate_dl_info(struct super_block *sb, tag_t tag)
18162 + struct dl_info *dli;
18165 + dli = get_dl_info(__lookup_dl_info(sb, tag));
18166 + vxdprintk(VXD_CBIT(dlim, 7),
18167 + "locate_dl_info(%p,#%d) = %p", sb, tag, dli);
18168 + rcu_read_unlock();
18172 +void rcu_free_dl_info(struct rcu_head *head)
18174 + struct dl_info *dli = container_of(head, struct dl_info, dl_rcu);
18175 + int usecnt, refcnt;
18177 + BUG_ON(!dli || !head);
18179 + usecnt = atomic_read(&dli->dl_usecnt);
18180 + BUG_ON(usecnt < 0);
18182 + refcnt = atomic_read(&dli->dl_refcnt);
18183 + BUG_ON(refcnt < 0);
18185 + vxdprintk(VXD_CBIT(dlim, 3),
18186 + "rcu_free_dl_info(%p)", dli);
18188 + __dealloc_dl_info(dli);
18190 + printk("!!! rcu didn't free\n");
18196 +static int do_addrem_dlimit(uint32_t id, const char __user *name,
18197 + uint32_t flags, int add)
18199 + struct path path;
18202 + ret = user_lpath(name, &path);
18204 + struct super_block *sb;
18205 + struct dl_info *dli;
18208 + if (!path.dentry->d_inode)
18209 + goto out_release;
18210 + if (!(sb = path.dentry->d_inode->i_sb))
18211 + goto out_release;
18214 + dli = __alloc_dl_info(sb, id);
18215 + spin_lock(&dl_info_hash_lock);
18218 + if (__lookup_dl_info(sb, id))
18220 + __hash_dl_info(dli);
18223 + spin_lock(&dl_info_hash_lock);
18224 + dli = __lookup_dl_info(sb, id);
18229 + __unhash_dl_info(dli);
18233 + spin_unlock(&dl_info_hash_lock);
18235 + __dealloc_dl_info(dli);
18242 +int vc_add_dlimit(uint32_t id, void __user *data)
18244 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18246 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18249 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 1);
18252 +int vc_rem_dlimit(uint32_t id, void __user *data)
18254 + struct vcmd_ctx_dlimit_base_v0 vc_data;
18256 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18259 + return do_addrem_dlimit(id, vc_data.name, vc_data.flags, 0);
18262 +#ifdef CONFIG_COMPAT
18264 +int vc_add_dlimit_x32(uint32_t id, void __user *data)
18266 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18268 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18271 + return do_addrem_dlimit(id,
18272 + compat_ptr(vc_data.name_ptr), vc_data.flags, 1);
18275 +int vc_rem_dlimit_x32(uint32_t id, void __user *data)
18277 + struct vcmd_ctx_dlimit_base_v0_x32 vc_data;
18279 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18282 + return do_addrem_dlimit(id,
18283 + compat_ptr(vc_data.name_ptr), vc_data.flags, 0);
18286 +#endif /* CONFIG_COMPAT */
18290 +int do_set_dlimit(uint32_t id, const char __user *name,
18291 + uint32_t space_used, uint32_t space_total,
18292 + uint32_t inodes_used, uint32_t inodes_total,
18293 + uint32_t reserved, uint32_t flags)
18295 + struct path path;
18298 + ret = user_lpath(name, &path);
18300 + struct super_block *sb;
18301 + struct dl_info *dli;
18304 + if (!path.dentry->d_inode)
18305 + goto out_release;
18306 + if (!(sb = path.dentry->d_inode->i_sb))
18307 + goto out_release;
18309 + /* sanity checks */
18310 + if ((reserved != CDLIM_KEEP &&
18311 + reserved > 100) ||
18312 + (inodes_used != CDLIM_KEEP &&
18313 + inodes_used > inodes_total) ||
18314 + (space_used != CDLIM_KEEP &&
18315 + space_used > space_total))
18316 + goto out_release;
18319 + dli = locate_dl_info(sb, id);
18321 + goto out_release;
18323 + spin_lock(&dli->dl_lock);
18325 + if (inodes_used != CDLIM_KEEP)
18326 + dli->dl_inodes_used = inodes_used;
18327 + if (inodes_total != CDLIM_KEEP)
18328 + dli->dl_inodes_total = inodes_total;
18329 + if (space_used != CDLIM_KEEP)
18330 + dli->dl_space_used = dlimit_space_32to64(
18331 + space_used, flags, DLIMS_USED);
18333 + if (space_total == CDLIM_INFINITY)
18334 + dli->dl_space_total = DLIM_INFINITY;
18335 + else if (space_total != CDLIM_KEEP)
18336 + dli->dl_space_total = dlimit_space_32to64(
18337 + space_total, flags, DLIMS_TOTAL);
18339 + if (reserved != CDLIM_KEEP)
18340 + dli->dl_nrlmult = (1 << 10) * (100 - reserved) / 100;
18342 + spin_unlock(&dli->dl_lock);
18344 + put_dl_info(dli);
18353 +int vc_set_dlimit(uint32_t id, void __user *data)
18355 + struct vcmd_ctx_dlimit_v0 vc_data;
18357 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18360 + return do_set_dlimit(id, vc_data.name,
18361 + vc_data.space_used, vc_data.space_total,
18362 + vc_data.inodes_used, vc_data.inodes_total,
18363 + vc_data.reserved, vc_data.flags);
18366 +#ifdef CONFIG_COMPAT
18368 +int vc_set_dlimit_x32(uint32_t id, void __user *data)
18370 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18372 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18375 + return do_set_dlimit(id, compat_ptr(vc_data.name_ptr),
18376 + vc_data.space_used, vc_data.space_total,
18377 + vc_data.inodes_used, vc_data.inodes_total,
18378 + vc_data.reserved, vc_data.flags);
18381 +#endif /* CONFIG_COMPAT */
18385 +int do_get_dlimit(uint32_t id, const char __user *name,
18386 + uint32_t *space_used, uint32_t *space_total,
18387 + uint32_t *inodes_used, uint32_t *inodes_total,
18388 + uint32_t *reserved, uint32_t *flags)
18390 + struct path path;
18393 + ret = user_lpath(name, &path);
18395 + struct super_block *sb;
18396 + struct dl_info *dli;
18399 + if (!path.dentry->d_inode)
18400 + goto out_release;
18401 + if (!(sb = path.dentry->d_inode->i_sb))
18402 + goto out_release;
18405 + dli = locate_dl_info(sb, id);
18407 + goto out_release;
18409 + spin_lock(&dli->dl_lock);
18410 + *inodes_used = dli->dl_inodes_used;
18411 + *inodes_total = dli->dl_inodes_total;
18413 + *space_used = dlimit_space_64to32(
18414 + dli->dl_space_used, flags, DLIMS_USED);
18416 + if (dli->dl_space_total == DLIM_INFINITY)
18417 + *space_total = CDLIM_INFINITY;
18419 + *space_total = dlimit_space_64to32(
18420 + dli->dl_space_total, flags, DLIMS_TOTAL);
18422 + *reserved = 100 - ((dli->dl_nrlmult * 100 + 512) >> 10);
18423 + spin_unlock(&dli->dl_lock);
18425 + put_dl_info(dli);
18436 +int vc_get_dlimit(uint32_t id, void __user *data)
18438 + struct vcmd_ctx_dlimit_v0 vc_data;
18441 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18444 + ret = do_get_dlimit(id, vc_data.name,
18445 + &vc_data.space_used, &vc_data.space_total,
18446 + &vc_data.inodes_used, &vc_data.inodes_total,
18447 + &vc_data.reserved, &vc_data.flags);
18451 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18456 +#ifdef CONFIG_COMPAT
18458 +int vc_get_dlimit_x32(uint32_t id, void __user *data)
18460 + struct vcmd_ctx_dlimit_v0_x32 vc_data;
18463 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
18466 + ret = do_get_dlimit(id, compat_ptr(vc_data.name_ptr),
18467 + &vc_data.space_used, &vc_data.space_total,
18468 + &vc_data.inodes_used, &vc_data.inodes_total,
18469 + &vc_data.reserved, &vc_data.flags);
18473 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
18478 +#endif /* CONFIG_COMPAT */
18481 +void vx_vsi_statfs(struct super_block *sb, struct kstatfs *buf)
18483 + struct dl_info *dli;
18484 + __u64 blimit, bfree, bavail;
18487 + dli = locate_dl_info(sb, dx_current_tag());
18491 + spin_lock(&dli->dl_lock);
18492 + if (dli->dl_inodes_total == (unsigned long)DLIM_INFINITY)
18495 + /* reduce max inodes available to limit */
18496 + if (buf->f_files > dli->dl_inodes_total)
18497 + buf->f_files = dli->dl_inodes_total;
18499 + ifree = dli->dl_inodes_total - dli->dl_inodes_used;
18500 + /* reduce free inodes to min */
18501 + if (ifree < buf->f_ffree)
18502 + buf->f_ffree = ifree;
18505 + if (dli->dl_space_total == DLIM_INFINITY)
18508 + blimit = dli->dl_space_total >> sb->s_blocksize_bits;
18510 + if (dli->dl_space_total < dli->dl_space_used)
18513 + bfree = (dli->dl_space_total - dli->dl_space_used)
18514 + >> sb->s_blocksize_bits;
18516 + bavail = ((dli->dl_space_total >> 10) * dli->dl_nrlmult);
18517 + if (bavail < dli->dl_space_used)
18520 + bavail = (bavail - dli->dl_space_used)
18521 + >> sb->s_blocksize_bits;
18523 + /* reduce max space available to limit */
18524 + if (buf->f_blocks > blimit)
18525 + buf->f_blocks = blimit;
18527 + /* reduce free space to min */
18528 + if (bfree < buf->f_bfree)
18529 + buf->f_bfree = bfree;
18531 + /* reduce avail space to min */
18532 + if (bavail < buf->f_bavail)
18533 + buf->f_bavail = bavail;
18536 + spin_unlock(&dli->dl_lock);
18537 + put_dl_info(dli);
18542 +#include <linux/module.h>
18544 +EXPORT_SYMBOL_GPL(locate_dl_info);
18545 +EXPORT_SYMBOL_GPL(rcu_free_dl_info);
18547 diff -NurpP --minimal linux-3.4.103/kernel/vserver/helper.c linux-3.4.103-vs2.3.3.9/kernel/vserver/helper.c
18548 --- linux-3.4.103/kernel/vserver/helper.c 1970-01-01 00:00:00.000000000 +0000
18549 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/helper.c 2012-09-16 18:49:44.000000000 +0000
18552 + * linux/kernel/vserver/helper.c
18554 + * Virtual Context Support
18556 + * Copyright (C) 2004-2007 Herbert Pötzl
18558 + * V0.01 basic helper
18562 +#include <linux/kmod.h>
18563 +#include <linux/reboot.h>
18564 +#include <linux/vs_context.h>
18565 +#include <linux/vs_network.h>
18566 +#include <linux/vserver/signal.h>
18569 +char vshelper_path[255] = "/sbin/vshelper";
18571 +static int vshelper_init(struct subprocess_info *info, struct cred *new_cred)
18573 + current->flags &= ~PF_THREAD_BOUND;
18577 +static int do_vshelper(char *name, char *argv[], char *envp[], int sync)
18581 + if ((ret = call_usermodehelper_fns(name, argv, envp,
18582 + sync ? UMH_WAIT_PROC : UMH_WAIT_EXEC,
18583 + vshelper_init, NULL, NULL))) {
18584 + printk(KERN_WARNING "%s: (%s %s) returned %s with %d\n",
18585 + name, argv[1], argv[2],
18586 + sync ? "sync" : "async", ret);
18588 + vxdprintk(VXD_CBIT(switch, 4),
18589 + "%s: (%s %s) returned %s with %d",
18590 + name, argv[1], argv[2], sync ? "sync" : "async", ret);
18595 + * vshelper path is set via /proc/sys
18596 + * invoked by vserver sys_reboot(), with
18597 + * the following arguments
18599 + * argv [0] = vshelper_path;
18600 + * argv [1] = action: "restart", "halt", "poweroff", ...
18601 + * argv [2] = context identifier
18603 + * envp [*] = type-specific parameters
18606 +long vs_reboot_helper(struct vx_info *vxi, int cmd, void __user *arg)
18608 + char id_buf[8], cmd_buf[16];
18609 + char uid_buf[16], pid_buf[16];
18612 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18613 + char *envp[] = {"HOME=/", "TERM=linux",
18614 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
18615 + uid_buf, pid_buf, cmd_buf, 0};
18617 + if (vx_info_state(vxi, VXS_HELPER))
18619 + vxi->vx_state |= VXS_HELPER;
18621 + snprintf(id_buf, sizeof(id_buf), "%d", vxi->vx_id);
18623 + snprintf(cmd_buf, sizeof(cmd_buf), "VS_CMD=%08x", cmd);
18624 + snprintf(uid_buf, sizeof(uid_buf), "VS_UID=%d", current_uid());
18625 + snprintf(pid_buf, sizeof(pid_buf), "VS_PID=%d", current->pid);
18628 + case LINUX_REBOOT_CMD_RESTART:
18629 + argv[1] = "restart";
18632 + case LINUX_REBOOT_CMD_HALT:
18633 + argv[1] = "halt";
18636 + case LINUX_REBOOT_CMD_POWER_OFF:
18637 + argv[1] = "poweroff";
18640 + case LINUX_REBOOT_CMD_SW_SUSPEND:
18641 + argv[1] = "swsusp";
18644 + case LINUX_REBOOT_CMD_OOM:
18649 + vxi->vx_state &= ~VXS_HELPER;
18653 + ret = do_vshelper(vshelper_path, argv, envp, 0);
18654 + vxi->vx_state &= ~VXS_HELPER;
18655 + __wakeup_vx_info(vxi);
18656 + return (ret) ? -EPERM : 0;
18660 +long vs_reboot(unsigned int cmd, void __user *arg)
18662 + struct vx_info *vxi = current_vx_info();
18665 + vxdprintk(VXD_CBIT(misc, 5),
18666 + "vs_reboot(%p[#%d],%u)",
18667 + vxi, vxi ? vxi->vx_id : 0, cmd);
18669 + ret = vs_reboot_helper(vxi, cmd, arg);
18673 + vxi->reboot_cmd = cmd;
18674 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18676 + case LINUX_REBOOT_CMD_RESTART:
18677 + case LINUX_REBOOT_CMD_HALT:
18678 + case LINUX_REBOOT_CMD_POWER_OFF:
18679 + vx_info_kill(vxi, 0, SIGKILL);
18680 + vx_info_kill(vxi, 1, SIGKILL);
18688 +long vs_oom_action(unsigned int cmd)
18690 + struct vx_info *vxi = current_vx_info();
18693 + vxdprintk(VXD_CBIT(misc, 5),
18694 + "vs_oom_action(%p[#%d],%u)",
18695 + vxi, vxi ? vxi->vx_id : 0, cmd);
18697 + ret = vs_reboot_helper(vxi, cmd, NULL);
18701 + vxi->reboot_cmd = cmd;
18702 + if (vx_info_flags(vxi, VXF_REBOOT_KILL, 0)) {
18703 + vx_info_kill(vxi, 0, SIGKILL);
18704 + vx_info_kill(vxi, 1, SIGKILL);
18710 + * argv [0] = vshelper_path;
18711 + * argv [1] = action: "startup", "shutdown"
18712 + * argv [2] = context identifier
18714 + * envp [*] = type-specific parameters
18717 +long vs_state_change(struct vx_info *vxi, unsigned int cmd)
18719 + char id_buf[8], cmd_buf[16];
18720 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18721 + char *envp[] = {"HOME=/", "TERM=linux",
18722 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18724 + if (!vx_info_flags(vxi, VXF_SC_HELPER, 0))
18727 + snprintf(id_buf, sizeof(id_buf), "%d", vxi->vx_id);
18728 + snprintf(cmd_buf, sizeof(cmd_buf), "VS_CMD=%08x", cmd);
18731 + case VSC_STARTUP:
18732 + argv[1] = "startup";
18734 + case VSC_SHUTDOWN:
18735 + argv[1] = "shutdown";
18741 + return do_vshelper(vshelper_path, argv, envp, 1);
18746 + * argv [0] = vshelper_path;
18747 + * argv [1] = action: "netup", "netdown"
18748 + * argv [2] = context identifier
18750 + * envp [*] = type-specific parameters
18753 +long vs_net_change(struct nx_info *nxi, unsigned int cmd)
18755 + char id_buf[8], cmd_buf[16];
18756 + char *argv[] = {vshelper_path, NULL, id_buf, 0};
18757 + char *envp[] = {"HOME=/", "TERM=linux",
18758 + "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0};
18760 + if (!nx_info_flags(nxi, NXF_SC_HELPER, 0))
18763 + snprintf(id_buf, sizeof(id_buf), "%d", nxi->nx_id);
18764 + snprintf(cmd_buf, sizeof(cmd_buf), "VS_CMD=%08x", cmd);
18768 + argv[1] = "netup";
18770 + case VSC_NETDOWN:
18771 + argv[1] = "netdown";
18777 + return do_vshelper(vshelper_path, argv, envp, 1);
18780 diff -NurpP --minimal linux-3.4.103/kernel/vserver/history.c linux-3.4.103-vs2.3.3.9/kernel/vserver/history.c
18781 --- linux-3.4.103/kernel/vserver/history.c 1970-01-01 00:00:00.000000000 +0000
18782 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/history.c 2012-05-21 16:15:05.000000000 +0000
18785 + * kernel/vserver/history.c
18787 + * Virtual Context History Backtrace
18789 + * Copyright (C) 2004-2007 Herbert Pötzl
18791 + * V0.01 basic structure
18792 + * V0.02 hash/unhash and trace
18793 + * V0.03 preemption fixes
18797 +#include <linux/module.h>
18798 +#include <asm/uaccess.h>
18800 +#include <linux/vserver/context.h>
18801 +#include <linux/vserver/debug.h>
18802 +#include <linux/vserver/debug_cmd.h>
18803 +#include <linux/vserver/history.h>
18806 +#ifdef CONFIG_VSERVER_HISTORY
18807 +#define VXH_SIZE CONFIG_VSERVER_HISTORY_SIZE
18809 +#define VXH_SIZE 64
18812 +struct _vx_history {
18813 + unsigned int counter;
18815 + struct _vx_hist_entry entry[VXH_SIZE + 1];
18819 +DEFINE_PER_CPU(struct _vx_history, vx_history_buffer);
18821 +unsigned volatile int vxh_active = 1;
18823 +static atomic_t sequence = ATOMIC_INIT(0);
18828 + * requires disabled preemption */
18830 +struct _vx_hist_entry *vxh_advance(void *loc)
18832 + unsigned int cpu = smp_processor_id();
18833 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
18834 + struct _vx_hist_entry *entry;
18835 + unsigned int index;
18837 + index = vxh_active ? (hist->counter++ % VXH_SIZE) : VXH_SIZE;
18838 + entry = &hist->entry[index];
18840 + entry->seq = atomic_inc_return(&sequence);
18841 + entry->loc = loc;
18845 +EXPORT_SYMBOL_GPL(vxh_advance);
18848 +#define VXH_LOC_FMTS "(#%04x,*%d):%p"
18850 +#define VXH_LOC_ARGS(e) (e)->seq, cpu, (e)->loc
18853 +#define VXH_VXI_FMTS "%p[#%d,%d.%d]"
18855 +#define VXH_VXI_ARGS(e) (e)->vxi.ptr, \
18856 + (e)->vxi.ptr ? (e)->vxi.xid : 0, \
18857 + (e)->vxi.ptr ? (e)->vxi.usecnt : 0, \
18858 + (e)->vxi.ptr ? (e)->vxi.tasks : 0
18860 +void vxh_dump_entry(struct _vx_hist_entry *e, unsigned cpu)
18862 + switch (e->type) {
18863 + case VXH_THROW_OOPS:
18864 + printk( VXH_LOC_FMTS " oops \n", VXH_LOC_ARGS(e));
18867 + case VXH_GET_VX_INFO:
18868 + case VXH_PUT_VX_INFO:
18869 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
18871 + (e->type == VXH_GET_VX_INFO) ? "get" : "put",
18872 + VXH_VXI_ARGS(e));
18875 + case VXH_INIT_VX_INFO:
18876 + case VXH_SET_VX_INFO:
18877 + case VXH_CLR_VX_INFO:
18878 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
18880 + (e->type == VXH_INIT_VX_INFO) ? "init" :
18881 + ((e->type == VXH_SET_VX_INFO) ? "set" : "clr"),
18882 + VXH_VXI_ARGS(e), e->sc.data);
18885 + case VXH_CLAIM_VX_INFO:
18886 + case VXH_RELEASE_VX_INFO:
18887 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS " @%p\n",
18889 + (e->type == VXH_CLAIM_VX_INFO) ? "claim" : "release",
18890 + VXH_VXI_ARGS(e), e->sc.data);
18893 + case VXH_ALLOC_VX_INFO:
18894 + case VXH_DEALLOC_VX_INFO:
18895 + printk( VXH_LOC_FMTS " %s_vx_info " VXH_VXI_FMTS "\n",
18897 + (e->type == VXH_ALLOC_VX_INFO) ? "alloc" : "dealloc",
18898 + VXH_VXI_ARGS(e));
18901 + case VXH_HASH_VX_INFO:
18902 + case VXH_UNHASH_VX_INFO:
18903 + printk( VXH_LOC_FMTS " __%s_vx_info " VXH_VXI_FMTS "\n",
18905 + (e->type == VXH_HASH_VX_INFO) ? "hash" : "unhash",
18906 + VXH_VXI_ARGS(e));
18909 + case VXH_LOC_VX_INFO:
18910 + case VXH_LOOKUP_VX_INFO:
18911 + case VXH_CREATE_VX_INFO:
18912 + printk( VXH_LOC_FMTS " __%s_vx_info [#%d] -> " VXH_VXI_FMTS "\n",
18914 + (e->type == VXH_CREATE_VX_INFO) ? "create" :
18915 + ((e->type == VXH_LOC_VX_INFO) ? "loc" : "lookup"),
18916 + e->ll.arg, VXH_VXI_ARGS(e));
18921 +static void __vxh_dump_history(void)
18923 + unsigned int i, cpu;
18925 + printk("History:\tSEQ: %8x\tNR_CPUS: %d\n",
18926 + atomic_read(&sequence), NR_CPUS);
18928 + for (i = 0; i < VXH_SIZE; i++) {
18929 + for_each_online_cpu(cpu) {
18930 + struct _vx_history *hist =
18931 + &per_cpu(vx_history_buffer, cpu);
18932 + unsigned int index = (hist->counter - i) % VXH_SIZE;
18933 + struct _vx_hist_entry *entry = &hist->entry[index];
18935 + vxh_dump_entry(entry, cpu);
18940 +void vxh_dump_history(void)
18944 + local_irq_enable();
18946 + local_irq_disable();
18948 + __vxh_dump_history();
18952 +/* vserver syscall commands below here */
18955 +int vc_dump_history(uint32_t id)
18958 + __vxh_dump_history();
18965 +int do_read_history(struct __user _vx_hist_entry *data,
18966 + int cpu, uint32_t *index, uint32_t *count)
18968 + int pos, ret = 0;
18969 + struct _vx_history *hist = &per_cpu(vx_history_buffer, cpu);
18970 + int end = hist->counter;
18971 + int start = end - VXH_SIZE + 2;
18972 + int idx = *index;
18974 + /* special case: get current pos */
18980 + /* have we lost some data? */
18984 + for (pos = 0; (pos < *count) && (idx < end); pos++, idx++) {
18985 + struct _vx_hist_entry *entry =
18986 + &hist->entry[idx % VXH_SIZE];
18988 + /* send entry to userspace */
18989 + ret = copy_to_user(&data[pos], entry, sizeof(*entry));
18993 + /* save new index and count */
18996 + return ret ? ret : (*index < end);
18999 +int vc_read_history(uint32_t id, void __user *data)
19001 + struct vcmd_read_history_v0 vc_data;
19004 + if (id >= NR_CPUS)
19007 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19010 + ret = do_read_history((struct __user _vx_hist_entry *)vc_data.data,
19011 + id, &vc_data.index, &vc_data.count);
19013 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19018 +#ifdef CONFIG_COMPAT
19020 +int vc_read_history_x32(uint32_t id, void __user *data)
19022 + struct vcmd_read_history_v0_x32 vc_data;
19025 + if (id >= NR_CPUS)
19028 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19031 + ret = do_read_history((struct __user _vx_hist_entry *)
19032 + compat_ptr(vc_data.data_ptr),
19033 + id, &vc_data.index, &vc_data.count);
19035 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19040 +#endif /* CONFIG_COMPAT */
19042 diff -NurpP --minimal linux-3.4.103/kernel/vserver/inet.c linux-3.4.103-vs2.3.3.9/kernel/vserver/inet.c
19043 --- linux-3.4.103/kernel/vserver/inet.c 1970-01-01 00:00:00.000000000 +0000
19044 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/inet.c 2012-05-21 16:15:05.000000000 +0000
19047 +#include <linux/in.h>
19048 +#include <linux/inetdevice.h>
19049 +#include <linux/export.h>
19050 +#include <linux/vs_inet.h>
19051 +#include <linux/vs_inet6.h>
19052 +#include <linux/vserver/debug.h>
19053 +#include <net/route.h>
19054 +#include <net/addrconf.h>
19057 +int nx_v4_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19061 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19064 + struct nx_addr_v4 *ptr;
19066 + for (ptr = &nxi1->v4; ptr; ptr = ptr->next) {
19067 + if (v4_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19074 + vxdprintk(VXD_CBIT(net, 2),
19075 + "nx_v4_addr_conflict(%p,%p): %d",
19076 + nxi1, nxi2, ret);
19082 +#ifdef CONFIG_IPV6
19084 +int nx_v6_addr_conflict(struct nx_info *nxi1, struct nx_info *nxi2)
19088 + if (!nxi1 || !nxi2 || nxi1 == nxi2)
19091 + struct nx_addr_v6 *ptr;
19093 + for (ptr = &nxi1->v6; ptr; ptr = ptr->next) {
19094 + if (v6_nx_addr_in_nx_info(nxi2, ptr, -1)) {
19101 + vxdprintk(VXD_CBIT(net, 2),
19102 + "nx_v6_addr_conflict(%p,%p): %d",
19103 + nxi1, nxi2, ret);
19110 +int v4_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19112 + struct in_device *in_dev;
19113 + struct in_ifaddr **ifap;
19114 + struct in_ifaddr *ifa;
19119 + in_dev = in_dev_get(dev);
19123 + for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
19124 + ifap = &ifa->ifa_next) {
19125 + if (v4_addr_in_nx_info(nxi, ifa->ifa_local, NXA_MASK_SHOW)) {
19130 + in_dev_put(in_dev);
19136 +#ifdef CONFIG_IPV6
19138 +int v6_dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19140 + struct inet6_dev *in_dev;
19141 + struct inet6_ifaddr *ifa;
19146 + in_dev = in6_dev_get(dev);
19150 + // for (ifap = &in_dev->addr_list; (ifa = *ifap) != NULL;
19151 + list_for_each_entry(ifa, &in_dev->addr_list, if_list) {
19152 + if (v6_addr_in_nx_info(nxi, &ifa->addr, -1)) {
19157 + in6_dev_put(in_dev);
19164 +int dev_in_nx_info(struct net_device *dev, struct nx_info *nxi)
19170 + if (nxi->v4.type && v4_dev_in_nx_info(dev, nxi))
19172 +#ifdef CONFIG_IPV6
19174 + if (nxi->v6.type && v6_dev_in_nx_info(dev, nxi))
19179 + vxdprintk(VXD_CBIT(net, 3),
19180 + "dev_in_nx_info(%p,%p[#%d]) = %d",
19181 + dev, nxi, nxi ? nxi->nx_id : 0, ret);
19185 +struct rtable *ip_v4_find_src(struct net *net, struct nx_info *nxi,
19186 + struct flowi4 *fl4)
19188 + struct rtable *rt;
19193 + /* FIXME: handle lback only case */
19194 + if (!NX_IPV4(nxi))
19195 + return ERR_PTR(-EPERM);
19197 + vxdprintk(VXD_CBIT(net, 4),
19198 + "ip_v4_find_src(%p[#%u]) " NIPQUAD_FMT " -> " NIPQUAD_FMT,
19199 + nxi, nxi ? nxi->nx_id : 0,
19200 + NIPQUAD(fl4->saddr), NIPQUAD(fl4->daddr));
19202 + /* single IP is unconditional */
19203 + if (nx_info_flags(nxi, NXF_SINGLE_IP, 0) &&
19204 + (fl4->saddr == INADDR_ANY))
19205 + fl4->saddr = nxi->v4.ip[0].s_addr;
19207 + if (fl4->saddr == INADDR_ANY) {
19208 + struct nx_addr_v4 *ptr;
19209 + __be32 found = 0;
19211 + rt = __ip_route_output_key(net, fl4);
19212 + if (!IS_ERR(rt)) {
19213 + found = fl4->saddr;
19215 + vxdprintk(VXD_CBIT(net, 4),
19216 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19217 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(found));
19218 + if (v4_addr_in_nx_info(nxi, found, NXA_MASK_BIND))
19222 + for (ptr = &nxi->v4; ptr; ptr = ptr->next) {
19223 + __be32 primary = ptr->ip[0].s_addr;
19224 + __be32 mask = ptr->mask.s_addr;
19225 + __be32 neta = primary & mask;
19227 + vxdprintk(VXD_CBIT(net, 4), "ip_v4_find_src(%p[#%u]) chk: "
19228 + NIPQUAD_FMT "/" NIPQUAD_FMT "/" NIPQUAD_FMT,
19229 + nxi, nxi ? nxi->nx_id : 0, NIPQUAD(primary),
19230 + NIPQUAD(mask), NIPQUAD(neta));
19231 + if ((found & mask) != neta)
19234 + fl4->saddr = primary;
19235 + rt = __ip_route_output_key(net, fl4);
19236 + vxdprintk(VXD_CBIT(net, 4),
19237 + "ip_v4_find_src(%p[#%u]) rok[%u]: " NIPQUAD_FMT,
19238 + nxi, nxi ? nxi->nx_id : 0, fl4->flowi4_oif, NIPQUAD(primary));
19239 + if (!IS_ERR(rt)) {
19240 + found = fl4->saddr;
19242 + if (found == primary)
19246 + /* still no source ip? */
19247 + found = ipv4_is_loopback(fl4->daddr)
19248 + ? IPI_LOOPBACK : nxi->v4.ip[0].s_addr;
19250 + /* assign src ip to flow */
19251 + fl4->saddr = found;
19254 + if (!v4_addr_in_nx_info(nxi, fl4->saddr, NXA_MASK_BIND))
19255 + return ERR_PTR(-EPERM);
19258 + if (nx_info_flags(nxi, NXF_LBACK_REMAP, 0)) {
19259 + if (ipv4_is_loopback(fl4->daddr))
19260 + fl4->daddr = nxi->v4_lback.s_addr;
19261 + if (ipv4_is_loopback(fl4->saddr))
19262 + fl4->saddr = nxi->v4_lback.s_addr;
19263 + } else if (ipv4_is_loopback(fl4->daddr) &&
19264 + !nx_info_flags(nxi, NXF_LBACK_ALLOW, 0))
19265 + return ERR_PTR(-EPERM);
19270 +EXPORT_SYMBOL_GPL(ip_v4_find_src);
19272 diff -NurpP --minimal linux-3.4.103/kernel/vserver/init.c linux-3.4.103-vs2.3.3.9/kernel/vserver/init.c
19273 --- linux-3.4.103/kernel/vserver/init.c 1970-01-01 00:00:00.000000000 +0000
19274 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/init.c 2012-05-21 16:15:05.000000000 +0000
19277 + * linux/kernel/init.c
19279 + * Virtual Server Init
19281 + * Copyright (C) 2004-2007 Herbert Pötzl
19283 + * V0.01 basic structure
19287 +#include <linux/init.h>
19289 +int vserver_register_sysctl(void);
19290 +void vserver_unregister_sysctl(void);
19293 +static int __init init_vserver(void)
19297 +#ifdef CONFIG_VSERVER_DEBUG
19298 + vserver_register_sysctl();
19304 +static void __exit exit_vserver(void)
19307 +#ifdef CONFIG_VSERVER_DEBUG
19308 + vserver_unregister_sysctl();
19313 +/* FIXME: GFP_ZONETYPES gone
19314 +long vx_slab[GFP_ZONETYPES]; */
19318 +module_init(init_vserver);
19319 +module_exit(exit_vserver);
19321 diff -NurpP --minimal linux-3.4.103/kernel/vserver/inode.c linux-3.4.103-vs2.3.3.9/kernel/vserver/inode.c
19322 --- linux-3.4.103/kernel/vserver/inode.c 1970-01-01 00:00:00.000000000 +0000
19323 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/inode.c 2012-05-21 16:15:05.000000000 +0000
19326 + * linux/kernel/vserver/inode.c
19328 + * Virtual Server: File System Support
19330 + * Copyright (C) 2004-2007 Herbert Pötzl
19332 + * V0.01 separated from vcontext V0.05
19333 + * V0.02 moved to tag (instead of xid)
19337 +#include <linux/tty.h>
19338 +#include <linux/proc_fs.h>
19339 +#include <linux/devpts_fs.h>
19340 +#include <linux/fs.h>
19341 +#include <linux/file.h>
19342 +#include <linux/mount.h>
19343 +#include <linux/parser.h>
19344 +#include <linux/namei.h>
19345 +#include <linux/vserver/inode.h>
19346 +#include <linux/vserver/inode_cmd.h>
19347 +#include <linux/vs_base.h>
19348 +#include <linux/vs_tag.h>
19350 +#include <asm/uaccess.h>
19353 +static int __vc_get_iattr(struct inode *in, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19355 + struct proc_dir_entry *entry;
19357 + if (!in || !in->i_sb)
19360 + *flags = IATTR_TAG
19361 + | (IS_IMMUTABLE(in) ? IATTR_IMMUTABLE : 0)
19362 + | (IS_IXUNLINK(in) ? IATTR_IXUNLINK : 0)
19363 + | (IS_BARRIER(in) ? IATTR_BARRIER : 0)
19364 + | (IS_COW(in) ? IATTR_COW : 0);
19365 + *mask = IATTR_IXUNLINK | IATTR_IMMUTABLE | IATTR_COW;
19367 + if (S_ISDIR(in->i_mode))
19368 + *mask |= IATTR_BARRIER;
19370 + if (IS_TAGGED(in)) {
19371 + *tag = in->i_tag;
19372 + *mask |= IATTR_TAG;
19375 + switch (in->i_sb->s_magic) {
19376 + case PROC_SUPER_MAGIC:
19377 + entry = PROC_I(in)->pde;
19379 + /* check for specific inodes? */
19381 + *mask |= IATTR_FLAGS;
19383 + *flags |= (entry->vx_flags & IATTR_FLAGS);
19385 + *flags |= (PROC_I(in)->vx_flags & IATTR_FLAGS);
19388 + case DEVPTS_SUPER_MAGIC:
19389 + *tag = in->i_tag;
19390 + *mask |= IATTR_TAG;
19399 +int vc_get_iattr(void __user *data)
19401 + struct path path;
19402 + struct vcmd_ctx_iattr_v1 vc_data = { .tag = -1 };
19405 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19408 + ret = user_lpath(vc_data.name, &path);
19410 + ret = __vc_get_iattr(path.dentry->d_inode,
19411 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19417 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19422 +#ifdef CONFIG_COMPAT
19424 +int vc_get_iattr_x32(void __user *data)
19426 + struct path path;
19427 + struct vcmd_ctx_iattr_v1_x32 vc_data = { .tag = -1 };
19430 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19433 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19435 + ret = __vc_get_iattr(path.dentry->d_inode,
19436 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19442 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19447 +#endif /* CONFIG_COMPAT */
19450 +int vc_fget_iattr(uint32_t fd, void __user *data)
19452 + struct file *filp;
19453 + struct vcmd_ctx_fiattr_v0 vc_data = { .tag = -1 };
19456 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19460 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19463 + ret = __vc_get_iattr(filp->f_dentry->d_inode,
19464 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19468 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19474 +static int __vc_set_iattr(struct dentry *de, uint32_t *tag, uint32_t *flags, uint32_t *mask)
19476 + struct inode *in = de->d_inode;
19477 + int error = 0, is_proc = 0, has_tag = 0;
19478 + struct iattr attr = { 0 };
19480 + if (!in || !in->i_sb)
19483 + is_proc = (in->i_sb->s_magic == PROC_SUPER_MAGIC);
19484 + if ((*mask & IATTR_FLAGS) && !is_proc)
19487 + has_tag = IS_TAGGED(in) ||
19488 + (in->i_sb->s_magic == DEVPTS_SUPER_MAGIC);
19489 + if ((*mask & IATTR_TAG) && !has_tag)
19492 + mutex_lock(&in->i_mutex);
19493 + if (*mask & IATTR_TAG) {
19494 + attr.ia_tag = *tag;
19495 + attr.ia_valid |= ATTR_TAG;
19498 + if (*mask & IATTR_FLAGS) {
19499 + struct proc_dir_entry *entry = PROC_I(in)->pde;
19500 + unsigned int iflags = PROC_I(in)->vx_flags;
19502 + iflags = (iflags & ~(*mask & IATTR_FLAGS))
19503 + | (*flags & IATTR_FLAGS);
19504 + PROC_I(in)->vx_flags = iflags;
19506 + entry->vx_flags = iflags;
19509 + if (*mask & (IATTR_IMMUTABLE | IATTR_IXUNLINK |
19510 + IATTR_BARRIER | IATTR_COW)) {
19511 + int iflags = in->i_flags;
19512 + int vflags = in->i_vflags;
19514 + if (*mask & IATTR_IMMUTABLE) {
19515 + if (*flags & IATTR_IMMUTABLE)
19516 + iflags |= S_IMMUTABLE;
19518 + iflags &= ~S_IMMUTABLE;
19520 + if (*mask & IATTR_IXUNLINK) {
19521 + if (*flags & IATTR_IXUNLINK)
19522 + iflags |= S_IXUNLINK;
19524 + iflags &= ~S_IXUNLINK;
19526 + if (S_ISDIR(in->i_mode) && (*mask & IATTR_BARRIER)) {
19527 + if (*flags & IATTR_BARRIER)
19528 + vflags |= V_BARRIER;
19530 + vflags &= ~V_BARRIER;
19532 + if (S_ISREG(in->i_mode) && (*mask & IATTR_COW)) {
19533 + if (*flags & IATTR_COW)
19536 + vflags &= ~V_COW;
19538 + if (in->i_op && in->i_op->sync_flags) {
19539 + error = in->i_op->sync_flags(in, iflags, vflags);
19545 + if (attr.ia_valid) {
19546 + if (in->i_op && in->i_op->setattr)
19547 + error = in->i_op->setattr(de, &attr);
19549 + error = inode_change_ok(in, &attr);
19551 + setattr_copy(in, &attr);
19552 + mark_inode_dirty(in);
19558 + mutex_unlock(&in->i_mutex);
19562 +int vc_set_iattr(void __user *data)
19564 + struct path path;
19565 + struct vcmd_ctx_iattr_v1 vc_data;
19568 + if (!capable(CAP_LINUX_IMMUTABLE))
19570 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19573 + ret = user_lpath(vc_data.name, &path);
19575 + ret = __vc_set_iattr(path.dentry,
19576 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19580 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19585 +#ifdef CONFIG_COMPAT
19587 +int vc_set_iattr_x32(void __user *data)
19589 + struct path path;
19590 + struct vcmd_ctx_iattr_v1_x32 vc_data;
19593 + if (!capable(CAP_LINUX_IMMUTABLE))
19595 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19598 + ret = user_lpath(compat_ptr(vc_data.name_ptr), &path);
19600 + ret = __vc_set_iattr(path.dentry,
19601 + &vc_data.tag, &vc_data.flags, &vc_data.mask);
19605 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19610 +#endif /* CONFIG_COMPAT */
19612 +int vc_fset_iattr(uint32_t fd, void __user *data)
19614 + struct file *filp;
19615 + struct vcmd_ctx_fiattr_v0 vc_data;
19618 + if (!capable(CAP_LINUX_IMMUTABLE))
19620 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19624 + if (!filp || !filp->f_dentry || !filp->f_dentry->d_inode)
19627 + ret = __vc_set_iattr(filp->f_dentry, &vc_data.tag,
19628 + &vc_data.flags, &vc_data.mask);
19632 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19638 +enum { Opt_notagcheck, Opt_tag, Opt_notag, Opt_tagid, Opt_err };
19640 +static match_table_t tokens = {
19641 + {Opt_notagcheck, "notagcheck"},
19642 +#ifdef CONFIG_PROPAGATE
19643 + {Opt_notag, "notag"},
19644 + {Opt_tag, "tag"},
19645 + {Opt_tagid, "tagid=%u"},
19651 +static void __dx_parse_remove(char *string, char *opt)
19653 + char *p = strstr(string, opt);
19657 + while (*q != '\0' && *q != ',')
19666 +int dx_parse_tag(char *string, tag_t *tag, int remove, int *mnt_flags,
19667 + unsigned long *flags)
19670 + substring_t args[MAX_OPT_ARGS];
19672 + char *s, *p, *opts;
19673 +#if defined(CONFIG_PROPAGATE) || defined(CONFIG_VSERVER_DEBUG)
19679 + s = kstrdup(string, GFP_KERNEL | GFP_ATOMIC);
19684 + while ((p = strsep(&opts, ",")) != NULL) {
19685 + token = match_token(p, tokens, args);
19688 +#ifdef CONFIG_PROPAGATE
19693 + __dx_parse_remove(s, "tag");
19694 + *mnt_flags |= MNT_TAGID;
19695 + set |= MNT_TAGID;
19699 + __dx_parse_remove(s, "notag");
19700 + *mnt_flags |= MNT_NOTAG;
19701 + set |= MNT_NOTAG;
19704 + if (tag && !match_int(args, &option))
19707 + __dx_parse_remove(s, "tagid");
19708 + *mnt_flags |= MNT_TAGID;
19709 + set |= MNT_TAGID;
19711 +#endif /* CONFIG_PROPAGATE */
19712 + case Opt_notagcheck:
19714 + __dx_parse_remove(s, "notagcheck");
19715 + *flags |= MS_NOTAGCHECK;
19716 + set |= MS_NOTAGCHECK;
19719 + vxdprintk(VXD_CBIT(tag, 7),
19720 + "dx_parse_tag(" VS_Q("%s") "): %d:#%d",
19721 + p, token, option);
19724 + strcpy(string, s);
19729 +#ifdef CONFIG_PROPAGATE
19731 +void __dx_propagate_tag(struct nameidata *nd, struct inode *inode)
19733 + tag_t new_tag = 0;
19734 + struct vfsmount *mnt;
19739 + mnt = nd->path.mnt;
19743 + propagate = (mnt->mnt_flags & MNT_TAGID);
19745 + new_tag = mnt->mnt_tag;
19747 + vxdprintk(VXD_CBIT(tag, 7),
19748 + "dx_propagate_tag(%p[#%lu.%d]): %d,%d",
19749 + inode, inode->i_ino, inode->i_tag,
19750 + new_tag, (propagate) ? 1 : 0);
19753 + inode->i_tag = new_tag;
19756 +#include <linux/module.h>
19758 +EXPORT_SYMBOL_GPL(__dx_propagate_tag);
19760 +#endif /* CONFIG_PROPAGATE */
19762 diff -NurpP --minimal linux-3.4.103/kernel/vserver/limit.c linux-3.4.103-vs2.3.3.9/kernel/vserver/limit.c
19763 --- linux-3.4.103/kernel/vserver/limit.c 1970-01-01 00:00:00.000000000 +0000
19764 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/limit.c 2012-09-01 09:15:21.000000000 +0000
19767 + * linux/kernel/vserver/limit.c
19769 + * Virtual Server: Context Limits
19771 + * Copyright (C) 2004-2010 Herbert Pötzl
19773 + * V0.01 broken out from vcontext V0.05
19774 + * V0.02 changed vcmds to vxi arg
19775 + * V0.03 added memory cgroup support
19779 +#include <linux/sched.h>
19780 +#include <linux/module.h>
19781 +#include <linux/memcontrol.h>
19782 +#include <linux/res_counter.h>
19783 +#include <linux/vs_limit.h>
19784 +#include <linux/vserver/limit.h>
19785 +#include <linux/vserver/limit_cmd.h>
19787 +#include <asm/uaccess.h>
19790 +const char *vlimit_name[NUM_LIMITS] = {
19791 + [RLIMIT_CPU] = "CPU",
19792 + [RLIMIT_NPROC] = "NPROC",
19793 + [RLIMIT_NOFILE] = "NOFILE",
19794 + [RLIMIT_LOCKS] = "LOCKS",
19795 + [RLIMIT_SIGPENDING] = "SIGP",
19796 + [RLIMIT_MSGQUEUE] = "MSGQ",
19798 + [VLIMIT_NSOCK] = "NSOCK",
19799 + [VLIMIT_OPENFD] = "OPENFD",
19800 + [VLIMIT_SHMEM] = "SHMEM",
19801 + [VLIMIT_DENTRY] = "DENTRY",
19804 +EXPORT_SYMBOL_GPL(vlimit_name);
19806 +#define MASK_ENTRY(x) (1 << (x))
19808 +const struct vcmd_ctx_rlimit_mask_v0 vlimit_mask = {
19811 + , /* softlimit */
19814 + MASK_ENTRY( RLIMIT_NPROC ) |
19815 + MASK_ENTRY( RLIMIT_NOFILE ) |
19816 + MASK_ENTRY( RLIMIT_LOCKS ) |
19817 + MASK_ENTRY( RLIMIT_MSGQUEUE ) |
19819 + MASK_ENTRY( VLIMIT_NSOCK ) |
19820 + MASK_ENTRY( VLIMIT_OPENFD ) |
19821 + MASK_ENTRY( VLIMIT_SHMEM ) |
19822 + MASK_ENTRY( VLIMIT_DENTRY ) |
19825 + /* accounting only */
19826 +uint32_t account_mask =
19827 + MASK_ENTRY( VLIMIT_SEMARY ) |
19828 + MASK_ENTRY( VLIMIT_NSEMS ) |
19829 + MASK_ENTRY( VLIMIT_MAPPED ) |
19833 +static int is_valid_vlimit(int id)
19835 + uint32_t mask = vlimit_mask.minimum |
19836 + vlimit_mask.softlimit | vlimit_mask.maximum;
19837 + return mask & (1 << id);
19840 +static int is_accounted_vlimit(int id)
19842 + if (is_valid_vlimit(id))
19844 + return account_mask & (1 << id);
19848 +static inline uint64_t vc_get_soft(struct vx_info *vxi, int id)
19850 + rlim_t limit = __rlim_soft(&vxi->limit, id);
19851 + return VX_VLIM(limit);
19854 +static inline uint64_t vc_get_hard(struct vx_info *vxi, int id)
19856 + rlim_t limit = __rlim_hard(&vxi->limit, id);
19857 + return VX_VLIM(limit);
19860 +static int do_get_rlimit(struct vx_info *vxi, uint32_t id,
19861 + uint64_t *minimum, uint64_t *softlimit, uint64_t *maximum)
19863 + if (!is_valid_vlimit(id))
19867 + *minimum = CRLIM_UNSET;
19869 + *softlimit = vc_get_soft(vxi, id);
19871 + *maximum = vc_get_hard(vxi, id);
19875 +int vc_get_rlimit(struct vx_info *vxi, void __user *data)
19877 + struct vcmd_ctx_rlimit_v0 vc_data;
19880 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19883 + ret = do_get_rlimit(vxi, vc_data.id,
19884 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
19888 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19893 +static int do_set_rlimit(struct vx_info *vxi, uint32_t id,
19894 + uint64_t minimum, uint64_t softlimit, uint64_t maximum)
19896 + if (!is_valid_vlimit(id))
19899 + if (maximum != CRLIM_KEEP)
19900 + __rlim_hard(&vxi->limit, id) = VX_RLIM(maximum);
19901 + if (softlimit != CRLIM_KEEP)
19902 + __rlim_soft(&vxi->limit, id) = VX_RLIM(softlimit);
19904 + /* clamp soft limit */
19905 + if (__rlim_soft(&vxi->limit, id) > __rlim_hard(&vxi->limit, id))
19906 + __rlim_soft(&vxi->limit, id) = __rlim_hard(&vxi->limit, id);
19911 +int vc_set_rlimit(struct vx_info *vxi, void __user *data)
19913 + struct vcmd_ctx_rlimit_v0 vc_data;
19915 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19918 + return do_set_rlimit(vxi, vc_data.id,
19919 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
19922 +#ifdef CONFIG_IA32_EMULATION
19924 +int vc_set_rlimit_x32(struct vx_info *vxi, void __user *data)
19926 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
19928 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19931 + return do_set_rlimit(vxi, vc_data.id,
19932 + vc_data.minimum, vc_data.softlimit, vc_data.maximum);
19935 +int vc_get_rlimit_x32(struct vx_info *vxi, void __user *data)
19937 + struct vcmd_ctx_rlimit_v0_x32 vc_data;
19940 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
19943 + ret = do_get_rlimit(vxi, vc_data.id,
19944 + &vc_data.minimum, &vc_data.softlimit, &vc_data.maximum);
19948 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
19953 +#endif /* CONFIG_IA32_EMULATION */
19956 +int vc_get_rlimit_mask(uint32_t id, void __user *data)
19958 + if (copy_to_user(data, &vlimit_mask, sizeof(vlimit_mask)))
19964 +static inline void vx_reset_hits(struct _vx_limit *limit)
19968 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19969 + atomic_set(&__rlim_lhit(limit, lim), 0);
19973 +int vc_reset_hits(struct vx_info *vxi, void __user *data)
19975 + vx_reset_hits(&vxi->limit);
19979 +static inline void vx_reset_minmax(struct _vx_limit *limit)
19984 + for (lim = 0; lim < NUM_LIMITS; lim++) {
19985 + value = __rlim_get(limit, lim);
19986 + __rlim_rmax(limit, lim) = value;
19987 + __rlim_rmin(limit, lim) = value;
19991 +int vc_reset_minmax(struct vx_info *vxi, void __user *data)
19993 + vx_reset_minmax(&vxi->limit);
19998 +int vc_rlimit_stat(struct vx_info *vxi, void __user *data)
20000 + struct vcmd_rlimit_stat_v0 vc_data;
20001 + struct _vx_limit *limit = &vxi->limit;
20004 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
20008 + if (!is_accounted_vlimit(id))
20011 + vx_limit_fixup(limit, id);
20012 + vc_data.hits = atomic_read(&__rlim_lhit(limit, id));
20013 + vc_data.value = __rlim_get(limit, id);
20014 + vc_data.minimum = __rlim_rmin(limit, id);
20015 + vc_data.maximum = __rlim_rmax(limit, id);
20017 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20023 +void vx_vsi_meminfo(struct sysinfo *val)
20025 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20026 + struct mem_cgroup *mcg;
20027 + u64 res_limit, res_usage;
20030 + mcg = mem_cgroup_from_task(current);
20034 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
20035 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20037 + if (res_limit != RESOURCE_MAX)
20038 + val->totalram = (res_limit >> PAGE_SHIFT);
20039 + val->freeram = val->totalram - (res_usage >> PAGE_SHIFT);
20040 + val->bufferram = 0;
20041 + val->totalhigh = 0;
20042 + val->freehigh = 0;
20044 + rcu_read_unlock();
20045 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20049 +void vx_vsi_swapinfo(struct sysinfo *val)
20051 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20052 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
20053 + struct mem_cgroup *mcg;
20054 + u64 res_limit, res_usage, memsw_limit, memsw_usage;
20055 + s64 swap_limit, swap_usage;
20058 + mcg = mem_cgroup_from_task(current);
20062 + res_limit = mem_cgroup_res_read_u64(mcg, RES_LIMIT);
20063 + res_usage = mem_cgroup_res_read_u64(mcg, RES_USAGE);
20064 + memsw_limit = mem_cgroup_memsw_read_u64(mcg, RES_LIMIT);
20065 + memsw_usage = mem_cgroup_memsw_read_u64(mcg, RES_USAGE);
20067 + /* memory unlimited */
20068 + if (res_limit == RESOURCE_MAX)
20071 + swap_limit = memsw_limit - res_limit;
20072 + /* we have a swap limit? */
20073 + if (memsw_limit != RESOURCE_MAX)
20074 + val->totalswap = swap_limit >> PAGE_SHIFT;
20076 + /* calculate swap part */
20077 + swap_usage = (memsw_usage > res_usage) ?
20078 + memsw_usage - res_usage : 0;
20080 + /* total shown minus usage gives free swap */
20081 + val->freeswap = (swap_usage < swap_limit) ?
20082 + val->totalswap - (swap_usage >> PAGE_SHIFT) : 0;
20084 + rcu_read_unlock();
20085 +#else /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20086 + val->totalswap = 0;
20087 + val->freeswap = 0;
20088 +#endif /* !CONFIG_CGROUP_MEM_RES_CTLR_SWAP */
20089 +#endif /* CONFIG_CGROUP_MEM_RES_CTLR */
20093 +long vx_vsi_cached(struct sysinfo *val)
20096 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
20097 + struct mem_cgroup *mcg;
20100 + mcg = mem_cgroup_from_task(current);
20104 + cache = mem_cgroup_stat_read_cache(mcg);
20106 + rcu_read_unlock();
20111 diff -NurpP --minimal linux-3.4.103/kernel/vserver/limit_init.h linux-3.4.103-vs2.3.3.9/kernel/vserver/limit_init.h
20112 --- linux-3.4.103/kernel/vserver/limit_init.h 1970-01-01 00:00:00.000000000 +0000
20113 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/limit_init.h 2012-05-21 16:15:05.000000000 +0000
20117 +static inline void vx_info_init_limit(struct _vx_limit *limit)
20121 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20122 + __rlim_soft(limit, lim) = RLIM_INFINITY;
20123 + __rlim_hard(limit, lim) = RLIM_INFINITY;
20124 + __rlim_set(limit, lim, 0);
20125 + atomic_set(&__rlim_lhit(limit, lim), 0);
20126 + __rlim_rmin(limit, lim) = 0;
20127 + __rlim_rmax(limit, lim) = 0;
20131 +static inline void vx_info_exit_limit(struct _vx_limit *limit)
20136 + for (lim = 0; lim < NUM_LIMITS; lim++) {
20137 + if ((1 << lim) & VLIM_NOCHECK)
20139 + value = __rlim_get(limit, lim);
20140 + vxwprintk_xid(value,
20141 + "!!! limit: %p[%s,%d] = %ld on exit.",
20142 + limit, vlimit_name[lim], lim, (long)value);
20146 diff -NurpP --minimal linux-3.4.103/kernel/vserver/limit_proc.h linux-3.4.103-vs2.3.3.9/kernel/vserver/limit_proc.h
20147 --- linux-3.4.103/kernel/vserver/limit_proc.h 1970-01-01 00:00:00.000000000 +0000
20148 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/limit_proc.h 2012-05-21 16:15:05.000000000 +0000
20150 +#ifndef _VX_LIMIT_PROC_H
20151 +#define _VX_LIMIT_PROC_H
20153 +#include <linux/vserver/limit_int.h>
20156 +#define VX_LIMIT_FMT ":\t%8ld\t%8ld/%8ld\t%8lld/%8lld\t%6d\n"
20157 +#define VX_LIMIT_TOP \
20158 + "Limit\t current\t min/max\t\t soft/hard\t\thits\n"
20160 +#define VX_LIMIT_ARG(r) \
20161 + (unsigned long)__rlim_get(limit, r), \
20162 + (unsigned long)__rlim_rmin(limit, r), \
20163 + (unsigned long)__rlim_rmax(limit, r), \
20164 + VX_VLIM(__rlim_soft(limit, r)), \
20165 + VX_VLIM(__rlim_hard(limit, r)), \
20166 + atomic_read(&__rlim_lhit(limit, r))
20168 +static inline int vx_info_proc_limit(struct _vx_limit *limit, char *buffer)
20170 + vx_limit_fixup(limit, -1);
20171 + return sprintf(buffer, VX_LIMIT_TOP
20172 + "PROC" VX_LIMIT_FMT
20173 + "VM" VX_LIMIT_FMT
20174 + "VML" VX_LIMIT_FMT
20175 + "RSS" VX_LIMIT_FMT
20176 + "ANON" VX_LIMIT_FMT
20177 + "RMAP" VX_LIMIT_FMT
20178 + "FILES" VX_LIMIT_FMT
20179 + "OFD" VX_LIMIT_FMT
20180 + "LOCKS" VX_LIMIT_FMT
20181 + "SOCK" VX_LIMIT_FMT
20182 + "MSGQ" VX_LIMIT_FMT
20183 + "SHM" VX_LIMIT_FMT
20184 + "SEMA" VX_LIMIT_FMT
20185 + "SEMS" VX_LIMIT_FMT
20186 + "DENT" VX_LIMIT_FMT,
20187 + VX_LIMIT_ARG(RLIMIT_NPROC),
20188 + VX_LIMIT_ARG(RLIMIT_AS),
20189 + VX_LIMIT_ARG(RLIMIT_MEMLOCK),
20190 + VX_LIMIT_ARG(RLIMIT_RSS),
20191 + VX_LIMIT_ARG(VLIMIT_ANON),
20192 + VX_LIMIT_ARG(VLIMIT_MAPPED),
20193 + VX_LIMIT_ARG(RLIMIT_NOFILE),
20194 + VX_LIMIT_ARG(VLIMIT_OPENFD),
20195 + VX_LIMIT_ARG(RLIMIT_LOCKS),
20196 + VX_LIMIT_ARG(VLIMIT_NSOCK),
20197 + VX_LIMIT_ARG(RLIMIT_MSGQUEUE),
20198 + VX_LIMIT_ARG(VLIMIT_SHMEM),
20199 + VX_LIMIT_ARG(VLIMIT_SEMARY),
20200 + VX_LIMIT_ARG(VLIMIT_NSEMS),
20201 + VX_LIMIT_ARG(VLIMIT_DENTRY));
20204 +#endif /* _VX_LIMIT_PROC_H */
20207 diff -NurpP --minimal linux-3.4.103/kernel/vserver/network.c linux-3.4.103-vs2.3.3.9/kernel/vserver/network.c
20208 --- linux-3.4.103/kernel/vserver/network.c 1970-01-01 00:00:00.000000000 +0000
20209 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/network.c 2012-05-21 16:15:05.000000000 +0000
20212 + * linux/kernel/vserver/network.c
20214 + * Virtual Server: Network Support
20216 + * Copyright (C) 2003-2007 Herbert Pötzl
20218 + * V0.01 broken out from vcontext V0.05
20219 + * V0.02 cleaned up implementation
20220 + * V0.03 added equiv nx commands
20221 + * V0.04 switch to RCU based hash
20222 + * V0.05 and back to locking again
20223 + * V0.06 changed vcmds to nxi arg
20224 + * V0.07 have __create claim() the nxi
20228 +#include <linux/err.h>
20229 +#include <linux/slab.h>
20230 +#include <linux/rcupdate.h>
20232 +#include <linux/vs_network.h>
20233 +#include <linux/vs_pid.h>
20234 +#include <linux/vserver/network_cmd.h>
20237 +atomic_t nx_global_ctotal = ATOMIC_INIT(0);
20238 +atomic_t nx_global_cactive = ATOMIC_INIT(0);
20240 +static struct kmem_cache *nx_addr_v4_cachep = NULL;
20241 +static struct kmem_cache *nx_addr_v6_cachep = NULL;
20244 +static int __init init_network(void)
20246 + nx_addr_v4_cachep = kmem_cache_create("nx_v4_addr_cache",
20247 + sizeof(struct nx_addr_v4), 0,
20248 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20249 + nx_addr_v6_cachep = kmem_cache_create("nx_v6_addr_cache",
20250 + sizeof(struct nx_addr_v6), 0,
20251 + SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
20256 +/* __alloc_nx_addr_v4() */
20258 +static inline struct nx_addr_v4 *__alloc_nx_addr_v4(void)
20260 + struct nx_addr_v4 *nxa = kmem_cache_alloc(
20261 + nx_addr_v4_cachep, GFP_KERNEL);
20263 + if (!IS_ERR(nxa))
20264 + memset(nxa, 0, sizeof(*nxa));
20268 +/* __dealloc_nx_addr_v4() */
20270 +static inline void __dealloc_nx_addr_v4(struct nx_addr_v4 *nxa)
20272 + kmem_cache_free(nx_addr_v4_cachep, nxa);
20275 +/* __dealloc_nx_addr_v4_all() */
20277 +static inline void __dealloc_nx_addr_v4_all(struct nx_addr_v4 *nxa)
20280 + struct nx_addr_v4 *next = nxa->next;
20282 + __dealloc_nx_addr_v4(nxa);
20288 +#ifdef CONFIG_IPV6
20290 +/* __alloc_nx_addr_v6() */
20292 +static inline struct nx_addr_v6 *__alloc_nx_addr_v6(void)
20294 + struct nx_addr_v6 *nxa = kmem_cache_alloc(
20295 + nx_addr_v6_cachep, GFP_KERNEL);
20297 + if (!IS_ERR(nxa))
20298 + memset(nxa, 0, sizeof(*nxa));
20302 +/* __dealloc_nx_addr_v6() */
20304 +static inline void __dealloc_nx_addr_v6(struct nx_addr_v6 *nxa)
20306 + kmem_cache_free(nx_addr_v6_cachep, nxa);
20309 +/* __dealloc_nx_addr_v6_all() */
20311 +static inline void __dealloc_nx_addr_v6_all(struct nx_addr_v6 *nxa)
20314 + struct nx_addr_v6 *next = nxa->next;
20316 + __dealloc_nx_addr_v6(nxa);
20321 +#endif /* CONFIG_IPV6 */
20323 +/* __alloc_nx_info()
20325 + * allocate an initialized nx_info struct
20326 + * doesn't make it visible (hash) */
20328 +static struct nx_info *__alloc_nx_info(nid_t nid)
20330 + struct nx_info *new = NULL;
20332 + vxdprintk(VXD_CBIT(nid, 1), "alloc_nx_info(%d)*", nid);
20334 + /* would this benefit from a slab cache? */
20335 + new = kmalloc(sizeof(struct nx_info), GFP_KERNEL);
20339 + memset(new, 0, sizeof(struct nx_info));
20340 + new->nx_id = nid;
20341 + INIT_HLIST_NODE(&new->nx_hlist);
20342 + atomic_set(&new->nx_usecnt, 0);
20343 + atomic_set(&new->nx_tasks, 0);
20344 + new->nx_state = 0;
20346 + new->nx_flags = NXF_INIT_SET;
20348 + /* rest of init goes here */
20350 + new->v4_lback.s_addr = htonl(INADDR_LOOPBACK);
20351 + new->v4_bcast.s_addr = htonl(INADDR_BROADCAST);
20353 + vxdprintk(VXD_CBIT(nid, 0),
20354 + "alloc_nx_info(%d) = %p", nid, new);
20355 + atomic_inc(&nx_global_ctotal);
20359 +/* __dealloc_nx_info()
20361 + * final disposal of nx_info */
20363 +static void __dealloc_nx_info(struct nx_info *nxi)
20365 + vxdprintk(VXD_CBIT(nid, 0),
20366 + "dealloc_nx_info(%p)", nxi);
20368 + nxi->nx_hlist.next = LIST_POISON1;
20371 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20372 + BUG_ON(atomic_read(&nxi->nx_tasks));
20374 + __dealloc_nx_addr_v4_all(nxi->v4.next);
20376 + nxi->nx_state |= NXS_RELEASED;
20378 + atomic_dec(&nx_global_ctotal);
20381 +static void __shutdown_nx_info(struct nx_info *nxi)
20383 + nxi->nx_state |= NXS_SHUTDOWN;
20384 + vs_net_change(nxi, VSC_NETDOWN);
20387 +/* exported stuff */
20389 +void free_nx_info(struct nx_info *nxi)
20391 + /* context shutdown is mandatory */
20392 + BUG_ON(nxi->nx_state != NXS_SHUTDOWN);
20394 + /* context must not be hashed */
20395 + BUG_ON(nxi->nx_state & NXS_HASHED);
20397 + BUG_ON(atomic_read(&nxi->nx_usecnt));
20398 + BUG_ON(atomic_read(&nxi->nx_tasks));
20400 + __dealloc_nx_info(nxi);
20404 +void __nx_set_lback(struct nx_info *nxi)
20406 + int nid = nxi->nx_id;
20407 + __be32 lback = htonl(INADDR_LOOPBACK ^ ((nid & 0xFFFF) << 8));
20409 + nxi->v4_lback.s_addr = lback;
20412 +extern int __nx_inet_add_lback(__be32 addr);
20413 +extern int __nx_inet_del_lback(__be32 addr);
20416 +/* hash table for nx_info hash */
20418 +#define NX_HASH_SIZE 13
20420 +struct hlist_head nx_info_hash[NX_HASH_SIZE];
20422 +static DEFINE_SPINLOCK(nx_info_hash_lock);
20425 +static inline unsigned int __hashval(nid_t nid)
20427 + return (nid % NX_HASH_SIZE);
20432 +/* __hash_nx_info()
20434 + * add the nxi to the global hash table
20435 + * requires the hash_lock to be held */
20437 +static inline void __hash_nx_info(struct nx_info *nxi)
20439 + struct hlist_head *head;
20441 + vxd_assert_lock(&nx_info_hash_lock);
20442 + vxdprintk(VXD_CBIT(nid, 4),
20443 + "__hash_nx_info: %p[#%d]", nxi, nxi->nx_id);
20445 + /* context must not be hashed */
20446 + BUG_ON(nx_info_state(nxi, NXS_HASHED));
20448 + nxi->nx_state |= NXS_HASHED;
20449 + head = &nx_info_hash[__hashval(nxi->nx_id)];
20450 + hlist_add_head(&nxi->nx_hlist, head);
20451 + atomic_inc(&nx_global_cactive);
20454 +/* __unhash_nx_info()
20456 + * remove the nxi from the global hash table
20457 + * requires the hash_lock to be held */
20459 +static inline void __unhash_nx_info(struct nx_info *nxi)
20461 + vxd_assert_lock(&nx_info_hash_lock);
20462 + vxdprintk(VXD_CBIT(nid, 4),
20463 + "__unhash_nx_info: %p[#%d.%d.%d]", nxi, nxi->nx_id,
20464 + atomic_read(&nxi->nx_usecnt), atomic_read(&nxi->nx_tasks));
20466 + /* context must be hashed */
20467 + BUG_ON(!nx_info_state(nxi, NXS_HASHED));
20468 + /* but without tasks */
20469 + BUG_ON(atomic_read(&nxi->nx_tasks));
20471 + nxi->nx_state &= ~NXS_HASHED;
20472 + hlist_del(&nxi->nx_hlist);
20473 + atomic_dec(&nx_global_cactive);
20477 +/* __lookup_nx_info()
20479 + * requires the hash_lock to be held
20480 + * doesn't increment the nx_refcnt */
20482 +static inline struct nx_info *__lookup_nx_info(nid_t nid)
20484 + struct hlist_head *head = &nx_info_hash[__hashval(nid)];
20485 + struct hlist_node *pos;
20486 + struct nx_info *nxi;
20488 + vxd_assert_lock(&nx_info_hash_lock);
20489 + hlist_for_each(pos, head) {
20490 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20492 + if (nxi->nx_id == nid)
20497 + vxdprintk(VXD_CBIT(nid, 0),
20498 + "__lookup_nx_info(#%u): %p[#%u]",
20499 + nid, nxi, nxi ? nxi->nx_id : 0);
20504 +/* __create_nx_info()
20506 + * create the requested context
20507 + * get(), claim() and hash it */
20509 +static struct nx_info *__create_nx_info(int id)
20511 + struct nx_info *new, *nxi = NULL;
20513 + vxdprintk(VXD_CBIT(nid, 1), "create_nx_info(%d)*", id);
20515 + if (!(new = __alloc_nx_info(id)))
20516 + return ERR_PTR(-ENOMEM);
20518 + /* required to make dynamic xids unique */
20519 + spin_lock(&nx_info_hash_lock);
20521 + /* static context requested */
20522 + if ((nxi = __lookup_nx_info(id))) {
20523 + vxdprintk(VXD_CBIT(nid, 0),
20524 + "create_nx_info(%d) = %p (already there)", id, nxi);
20525 + if (nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20526 + nxi = ERR_PTR(-EBUSY);
20528 + nxi = ERR_PTR(-EEXIST);
20531 + /* new context */
20532 + vxdprintk(VXD_CBIT(nid, 0),
20533 + "create_nx_info(%d) = %p (new)", id, new);
20534 + claim_nx_info(new, NULL);
20535 + __nx_set_lback(new);
20536 + __hash_nx_info(get_nx_info(new));
20537 + nxi = new, new = NULL;
20540 + spin_unlock(&nx_info_hash_lock);
20542 + __dealloc_nx_info(new);
20548 +/* exported stuff */
20551 +void unhash_nx_info(struct nx_info *nxi)
20553 + __shutdown_nx_info(nxi);
20554 + spin_lock(&nx_info_hash_lock);
20555 + __unhash_nx_info(nxi);
20556 + spin_unlock(&nx_info_hash_lock);
20559 +/* lookup_nx_info()
20561 + * search for a nx_info and get() it
20562 + * negative id means current */
20564 +struct nx_info *lookup_nx_info(int id)
20566 + struct nx_info *nxi = NULL;
20569 + nxi = get_nx_info(current_nx_info());
20570 + } else if (id > 1) {
20571 + spin_lock(&nx_info_hash_lock);
20572 + nxi = get_nx_info(__lookup_nx_info(id));
20573 + spin_unlock(&nx_info_hash_lock);
20578 +/* nid_is_hashed()
20580 + * verify that nid is still hashed */
20582 +int nid_is_hashed(nid_t nid)
20586 + spin_lock(&nx_info_hash_lock);
20587 + hashed = (__lookup_nx_info(nid) != NULL);
20588 + spin_unlock(&nx_info_hash_lock);
20593 +#ifdef CONFIG_PROC_FS
20597 + * get a subset of hashed nids for proc
20598 + * assumes size is at least one */
20600 +int get_nid_list(int index, unsigned int *nids, int size)
20602 + int hindex, nr_nids = 0;
20604 + /* only show current and children */
20605 + if (!nx_check(0, VS_ADMIN | VS_WATCH)) {
20608 + nids[nr_nids] = nx_current_nid();
20612 + for (hindex = 0; hindex < NX_HASH_SIZE; hindex++) {
20613 + struct hlist_head *head = &nx_info_hash[hindex];
20614 + struct hlist_node *pos;
20616 + spin_lock(&nx_info_hash_lock);
20617 + hlist_for_each(pos, head) {
20618 + struct nx_info *nxi;
20623 + nxi = hlist_entry(pos, struct nx_info, nx_hlist);
20624 + nids[nr_nids] = nxi->nx_id;
20625 + if (++nr_nids >= size) {
20626 + spin_unlock(&nx_info_hash_lock);
20630 + /* keep the lock time short */
20631 + spin_unlock(&nx_info_hash_lock);
20640 + * migrate task to new network
20641 + * gets nxi, puts old_nxi on change
20644 +int nx_migrate_task(struct task_struct *p, struct nx_info *nxi)
20646 + struct nx_info *old_nxi;
20652 + vxdprintk(VXD_CBIT(nid, 5),
20653 + "nx_migrate_task(%p,%p[#%d.%d.%d])",
20654 + p, nxi, nxi->nx_id,
20655 + atomic_read(&nxi->nx_usecnt),
20656 + atomic_read(&nxi->nx_tasks));
20658 + if (nx_info_flags(nxi, NXF_INFO_PRIVATE, 0) &&
20659 + !nx_info_flags(nxi, NXF_STATE_SETUP, 0))
20662 + if (nx_info_state(nxi, NXS_SHUTDOWN))
20665 + /* maybe disallow this completely? */
20666 + old_nxi = task_get_nx_info(p);
20667 + if (old_nxi == nxi)
20672 + clr_nx_info(&p->nx_info);
20673 + claim_nx_info(nxi, p);
20674 + set_nx_info(&p->nx_info, nxi);
20675 + p->nid = nxi->nx_id;
20678 + vxdprintk(VXD_CBIT(nid, 5),
20679 + "moved task %p into nxi:%p[#%d]",
20680 + p, nxi, nxi->nx_id);
20683 + release_nx_info(old_nxi, p);
20686 + put_nx_info(old_nxi);
20691 +void nx_set_persistent(struct nx_info *nxi)
20693 + vxdprintk(VXD_CBIT(nid, 6),
20694 + "nx_set_persistent(%p[#%d])", nxi, nxi->nx_id);
20696 + get_nx_info(nxi);
20697 + claim_nx_info(nxi, NULL);
20700 +void nx_clear_persistent(struct nx_info *nxi)
20702 + vxdprintk(VXD_CBIT(nid, 6),
20703 + "nx_clear_persistent(%p[#%d])", nxi, nxi->nx_id);
20705 + release_nx_info(nxi, NULL);
20706 + put_nx_info(nxi);
20709 +void nx_update_persistent(struct nx_info *nxi)
20711 + if (nx_info_flags(nxi, NXF_PERSISTENT, 0))
20712 + nx_set_persistent(nxi);
20714 + nx_clear_persistent(nxi);
20717 +/* vserver syscall commands below here */
20719 +/* taks nid and nx_info functions */
20721 +#include <asm/uaccess.h>
20724 +int vc_task_nid(uint32_t id)
20729 + struct task_struct *tsk;
20732 + tsk = find_task_by_real_pid(id);
20733 + nid = (tsk) ? tsk->nid : -ESRCH;
20734 + rcu_read_unlock();
20736 + nid = nx_current_nid();
20741 +int vc_nx_info(struct nx_info *nxi, void __user *data)
20743 + struct vcmd_nx_info_v0 vc_data;
20745 + vc_data.nid = nxi->nx_id;
20747 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
20753 +/* network functions */
20755 +int vc_net_create(uint32_t nid, void __user *data)
20757 + struct vcmd_net_create vc_data = { .flagword = NXF_INIT_SET };
20758 + struct nx_info *new_nxi;
20761 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20764 + if ((nid > MAX_S_CONTEXT) || (nid < 2))
20767 + new_nxi = __create_nx_info(nid);
20768 + if (IS_ERR(new_nxi))
20769 + return PTR_ERR(new_nxi);
20771 + /* initial flags */
20772 + new_nxi->nx_flags = vc_data.flagword;
20775 + if (vs_net_change(new_nxi, VSC_NETUP))
20778 + ret = nx_migrate_task(current, new_nxi);
20782 + /* return context id on success */
20783 + ret = new_nxi->nx_id;
20785 + /* get a reference for persistent contexts */
20786 + if ((vc_data.flagword & NXF_PERSISTENT))
20787 + nx_set_persistent(new_nxi);
20789 + release_nx_info(new_nxi, NULL);
20790 + put_nx_info(new_nxi);
20795 +int vc_net_migrate(struct nx_info *nxi, void __user *data)
20797 + return nx_migrate_task(current, nxi);
20802 +int do_add_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
20803 + uint16_t type, uint16_t flags)
20805 + struct nx_addr_v4 *nxa = &nxi->v4;
20807 + if (NX_IPV4(nxi)) {
20808 + /* locate last entry */
20809 + for (; nxa->next; nxa = nxa->next);
20810 + nxa->next = __alloc_nx_addr_v4();
20814 + return PTR_ERR(nxa);
20817 + if (nxi->v4.next)
20818 + /* remove single ip for ip list */
20819 + nxi->nx_flags &= ~NXF_SINGLE_IP;
20821 + nxa->ip[0].s_addr = ip;
20822 + nxa->ip[1].s_addr = ip2;
20823 + nxa->mask.s_addr = mask;
20824 + nxa->type = type;
20825 + nxa->flags = flags;
20829 +int do_remove_v4_addr(struct nx_info *nxi, __be32 ip, __be32 ip2, __be32 mask,
20830 + uint16_t type, uint16_t flags)
20832 + struct nx_addr_v4 *nxa = &nxi->v4;
20835 +/* case NXA_TYPE_ADDR:
20838 + case NXA_TYPE_ANY:
20839 + __dealloc_nx_addr_v4_all(xchg(&nxa->next, NULL));
20840 + memset(nxa, 0, sizeof(*nxa));
20850 +int vc_net_add(struct nx_info *nxi, void __user *data)
20852 + struct vcmd_net_addr_v0 vc_data;
20853 + int index, ret = 0;
20855 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20858 + switch (vc_data.type) {
20859 + case NXA_TYPE_IPV4:
20860 + if ((vc_data.count < 1) || (vc_data.count > 4))
20864 + while (index < vc_data.count) {
20865 + ret = do_add_v4_addr(nxi, vc_data.ip[index].s_addr, 0,
20866 + vc_data.mask[index].s_addr, NXA_TYPE_ADDR, 0);
20874 + case NXA_TYPE_IPV4|NXA_MOD_BCAST:
20875 + nxi->v4_bcast = vc_data.ip[0];
20879 + case NXA_TYPE_IPV4|NXA_MOD_LBACK:
20880 + nxi->v4_lback = vc_data.ip[0];
20891 +int vc_net_remove(struct nx_info *nxi, void __user *data)
20893 + struct vcmd_net_addr_v0 vc_data;
20895 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20898 + switch (vc_data.type) {
20899 + case NXA_TYPE_ANY:
20900 + __dealloc_nx_addr_v4_all(xchg(&nxi->v4.next, NULL));
20901 + memset(&nxi->v4, 0, sizeof(nxi->v4));
20911 +int vc_net_add_ipv4_v1(struct nx_info *nxi, void __user *data)
20913 + struct vcmd_net_addr_ipv4_v1 vc_data;
20915 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20918 + switch (vc_data.type) {
20919 + case NXA_TYPE_ADDR:
20920 + case NXA_TYPE_MASK:
20921 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, 0,
20922 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20924 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
20925 + nxi->v4_bcast = vc_data.ip;
20928 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
20929 + nxi->v4_lback = vc_data.ip;
20938 +int vc_net_add_ipv4(struct nx_info *nxi, void __user *data)
20940 + struct vcmd_net_addr_ipv4_v2 vc_data;
20942 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20945 + switch (vc_data.type) {
20946 + case NXA_TYPE_ADDR:
20947 + case NXA_TYPE_MASK:
20948 + case NXA_TYPE_RANGE:
20949 + return do_add_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
20950 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20952 + case NXA_TYPE_ADDR | NXA_MOD_BCAST:
20953 + nxi->v4_bcast = vc_data.ip;
20956 + case NXA_TYPE_ADDR | NXA_MOD_LBACK:
20957 + nxi->v4_lback = vc_data.ip;
20966 +int vc_net_rem_ipv4_v1(struct nx_info *nxi, void __user *data)
20968 + struct vcmd_net_addr_ipv4_v1 vc_data;
20970 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20973 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, 0,
20974 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20977 +int vc_net_rem_ipv4(struct nx_info *nxi, void __user *data)
20979 + struct vcmd_net_addr_ipv4_v2 vc_data;
20981 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
20984 + return do_remove_v4_addr(nxi, vc_data.ip.s_addr, vc_data.ip2.s_addr,
20985 + vc_data.mask.s_addr, vc_data.type, vc_data.flags);
20988 +#ifdef CONFIG_IPV6
20990 +int do_add_v6_addr(struct nx_info *nxi,
20991 + struct in6_addr *ip, struct in6_addr *mask,
20992 + uint32_t prefix, uint16_t type, uint16_t flags)
20994 + struct nx_addr_v6 *nxa = &nxi->v6;
20996 + if (NX_IPV6(nxi)) {
20997 + /* locate last entry */
20998 + for (; nxa->next; nxa = nxa->next);
20999 + nxa->next = __alloc_nx_addr_v6();
21003 + return PTR_ERR(nxa);
21007 + nxa->mask = *mask;
21008 + nxa->prefix = prefix;
21009 + nxa->type = type;
21010 + nxa->flags = flags;
21015 +int vc_net_add_ipv6(struct nx_info *nxi, void __user *data)
21017 + struct vcmd_net_addr_ipv6_v1 vc_data;
21019 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21022 + switch (vc_data.type) {
21023 + case NXA_TYPE_ADDR:
21024 + memset(&vc_data.mask, ~0, sizeof(vc_data.mask));
21025 + /* fallthrough */
21026 + case NXA_TYPE_MASK:
21027 + return do_add_v6_addr(nxi, &vc_data.ip, &vc_data.mask,
21028 + vc_data.prefix, vc_data.type, vc_data.flags);
21035 +int vc_net_remove_ipv6(struct nx_info *nxi, void __user *data)
21037 + struct vcmd_net_addr_ipv6_v1 vc_data;
21039 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
21042 + switch (vc_data.type) {
21043 + case NXA_TYPE_ANY:
21044 + __dealloc_nx_addr_v6_all(xchg(&nxi->v6.next, NULL));
21045 + memset(&nxi->v6, 0, sizeof(nxi->v6));
21054 +#endif /* CONFIG_IPV6 */
21057 +int vc_get_nflags(struct nx_info *nxi, void __user *data)
21059 + struct vcmd_net_flags_v0 vc_data;
21061 + vc_data.flagword = nxi->nx_flags;
21063 + /* special STATE flag handling */
21064 + vc_data.mask = vs_mask_flags(~0ULL, nxi->nx_flags, NXF_ONE_TIME);
21066 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21071 +int vc_set_nflags(struct nx_info *nxi, void __user *data)
21073 + struct vcmd_net_flags_v0 vc_data;
21074 + uint64_t mask, trigger;
21076 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21079 + /* special STATE flag handling */
21080 + mask = vs_mask_mask(vc_data.mask, nxi->nx_flags, NXF_ONE_TIME);
21081 + trigger = (mask & nxi->nx_flags) ^ (mask & vc_data.flagword);
21083 + nxi->nx_flags = vs_mask_flags(nxi->nx_flags,
21084 + vc_data.flagword, mask);
21085 + if (trigger & NXF_PERSISTENT)
21086 + nx_update_persistent(nxi);
21091 +int vc_get_ncaps(struct nx_info *nxi, void __user *data)
21093 + struct vcmd_net_caps_v0 vc_data;
21095 + vc_data.ncaps = nxi->nx_ncaps;
21096 + vc_data.cmask = ~0ULL;
21098 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
21103 +int vc_set_ncaps(struct nx_info *nxi, void __user *data)
21105 + struct vcmd_net_caps_v0 vc_data;
21107 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
21110 + nxi->nx_ncaps = vs_mask_flags(nxi->nx_ncaps,
21111 + vc_data.ncaps, vc_data.cmask);
21116 +#include <linux/module.h>
21118 +module_init(init_network);
21120 +EXPORT_SYMBOL_GPL(free_nx_info);
21121 +EXPORT_SYMBOL_GPL(unhash_nx_info);
21123 diff -NurpP --minimal linux-3.4.103/kernel/vserver/proc.c linux-3.4.103-vs2.3.3.9/kernel/vserver/proc.c
21124 --- linux-3.4.103/kernel/vserver/proc.c 1970-01-01 00:00:00.000000000 +0000
21125 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/proc.c 2012-05-21 16:15:05.000000000 +0000
21128 + * linux/kernel/vserver/proc.c
21130 + * Virtual Context Support
21132 + * Copyright (C) 2003-2011 Herbert Pötzl
21134 + * V0.01 basic structure
21135 + * V0.02 adaptation vs1.3.0
21136 + * V0.03 proc permissions
21137 + * V0.04 locking/generic
21138 + * V0.05 next generation procfs
21139 + * V0.06 inode validation
21140 + * V0.07 generic rewrite vid
21141 + * V0.08 remove inode type
21142 + * V0.09 added u/wmask info
21146 +#include <linux/proc_fs.h>
21147 +#include <linux/fs_struct.h>
21148 +#include <linux/mount.h>
21149 +#include <asm/unistd.h>
21151 +#include <linux/vs_context.h>
21152 +#include <linux/vs_network.h>
21153 +#include <linux/vs_cvirt.h>
21155 +#include <linux/in.h>
21156 +#include <linux/inetdevice.h>
21157 +#include <linux/vs_inet.h>
21158 +#include <linux/vs_inet6.h>
21160 +#include <linux/vserver/global.h>
21162 +#include "cvirt_proc.h"
21163 +#include "cacct_proc.h"
21164 +#include "limit_proc.h"
21165 +#include "sched_proc.h"
21166 +#include "vci_config.h"
21169 +static inline char *print_cap_t(char *buffer, kernel_cap_t *c)
21173 + CAP_FOR_EACH_U32(__capi) {
21174 + buffer += sprintf(buffer, "%08x",
21175 + c->cap[(_KERNEL_CAPABILITY_U32S-1) - __capi]);
21181 +static struct proc_dir_entry *proc_virtual;
21183 +static struct proc_dir_entry *proc_virtnet;
21186 +/* first the actual feeds */
21189 +static int proc_vci(char *buffer)
21191 + return sprintf(buffer,
21192 + "VCIVersion:\t%04x:%04x\n"
21193 + "VCISyscall:\t%d\n"
21194 + "VCIKernel:\t%08x\n",
21195 + VCI_VERSION >> 16,
21196 + VCI_VERSION & 0xFFFF,
21198 + vci_kernel_config());
21201 +static int proc_virtual_info(char *buffer)
21203 + return proc_vci(buffer);
21206 +static int proc_virtual_status(char *buffer)
21208 + return sprintf(buffer,
21210 + "#CActive:\t%d\n"
21211 + "#NSProxy:\t%d\t%d %d %d %d %d %d\n"
21212 + "#InitTask:\t%d\t%d %d\n",
21213 + atomic_read(&vx_global_ctotal),
21214 + atomic_read(&vx_global_cactive),
21215 + atomic_read(&vs_global_nsproxy),
21216 + atomic_read(&vs_global_fs),
21217 + atomic_read(&vs_global_mnt_ns),
21218 + atomic_read(&vs_global_uts_ns),
21219 + atomic_read(&nr_ipc_ns),
21220 + atomic_read(&vs_global_user_ns),
21221 + atomic_read(&vs_global_pid_ns),
21222 + atomic_read(&init_task.usage),
21223 + atomic_read(&init_task.nsproxy->count),
21224 + init_task.fs->users);
21228 +int proc_vxi_info(struct vx_info *vxi, char *buffer)
21232 + length = sprintf(buffer,
21240 + vxi->vx_badness_bias);
21244 +int proc_vxi_status(struct vx_info *vxi, char *buffer)
21246 + char *orig = buffer;
21248 + buffer += sprintf(buffer,
21251 + "Flags:\t%016llx\n",
21252 + atomic_read(&vxi->vx_usecnt),
21253 + atomic_read(&vxi->vx_tasks),
21254 + (unsigned long long)vxi->vx_flags);
21256 + buffer += sprintf(buffer, "BCaps:\t");
21257 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
21258 + buffer += sprintf(buffer, "\n");
21260 + buffer += sprintf(buffer,
21261 + "CCaps:\t%016llx\n"
21262 + "Umask:\t%16llx\n"
21263 + "Wmask:\t%16llx\n"
21264 + "Spaces:\t%08lx %08lx\n",
21265 + (unsigned long long)vxi->vx_ccaps,
21266 + (unsigned long long)vxi->vx_umask,
21267 + (unsigned long long)vxi->vx_wmask,
21268 + vxi->space[0].vx_nsmask, vxi->space[1].vx_nsmask);
21269 + return buffer - orig;
21272 +int proc_vxi_limit(struct vx_info *vxi, char *buffer)
21274 + return vx_info_proc_limit(&vxi->limit, buffer);
21277 +int proc_vxi_sched(struct vx_info *vxi, char *buffer)
21281 + length = vx_info_proc_sched(&vxi->sched, buffer);
21282 + for_each_online_cpu(cpu) {
21283 + length += vx_info_proc_sched_pc(
21284 + &vx_per_cpu(vxi, sched_pc, cpu),
21285 + buffer + length, cpu);
21290 +int proc_vxi_nsproxy0(struct vx_info *vxi, char *buffer)
21292 + return vx_info_proc_nsproxy(vxi->space[0].vx_nsproxy, buffer);
21295 +int proc_vxi_nsproxy1(struct vx_info *vxi, char *buffer)
21297 + return vx_info_proc_nsproxy(vxi->space[1].vx_nsproxy, buffer);
21300 +int proc_vxi_cvirt(struct vx_info *vxi, char *buffer)
21304 + vx_update_load(vxi);
21305 + length = vx_info_proc_cvirt(&vxi->cvirt, buffer);
21306 + for_each_online_cpu(cpu) {
21307 + length += vx_info_proc_cvirt_pc(
21308 + &vx_per_cpu(vxi, cvirt_pc, cpu),
21309 + buffer + length, cpu);
21314 +int proc_vxi_cacct(struct vx_info *vxi, char *buffer)
21316 + return vx_info_proc_cacct(&vxi->cacct, buffer);
21320 +static int proc_virtnet_info(char *buffer)
21322 + return proc_vci(buffer);
21325 +static int proc_virtnet_status(char *buffer)
21327 + return sprintf(buffer,
21329 + "#CActive:\t%d\n",
21330 + atomic_read(&nx_global_ctotal),
21331 + atomic_read(&nx_global_cactive));
21334 +int proc_nxi_info(struct nx_info *nxi, char *buffer)
21336 + struct nx_addr_v4 *v4a;
21337 +#ifdef CONFIG_IPV6
21338 + struct nx_addr_v6 *v6a;
21342 + length = sprintf(buffer,
21345 + "Bcast:\t" NIPQUAD_FMT "\n"
21346 + "Lback:\t" NIPQUAD_FMT "\n",
21349 + NIPQUAD(nxi->v4_bcast.s_addr),
21350 + NIPQUAD(nxi->v4_lback.s_addr));
21352 + if (!NX_IPV4(nxi))
21354 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
21355 + length += sprintf(buffer + length, "%d:\t" NXAV4_FMT "\n",
21358 +#ifdef CONFIG_IPV6
21359 + if (!NX_IPV6(nxi))
21361 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
21362 + length += sprintf(buffer + length, "%d:\t" NXAV6_FMT "\n",
21369 +int proc_nxi_status(struct nx_info *nxi, char *buffer)
21373 + length = sprintf(buffer,
21376 + "Flags:\t%016llx\n"
21377 + "NCaps:\t%016llx\n",
21378 + atomic_read(&nxi->nx_usecnt),
21379 + atomic_read(&nxi->nx_tasks),
21380 + (unsigned long long)nxi->nx_flags,
21381 + (unsigned long long)nxi->nx_ncaps);
21387 +/* here the inode helpers */
21393 + struct inode_operations *iop;
21394 + struct file_operations *fop;
21395 + union proc_op op;
21398 +static struct inode *vs_proc_make_inode(struct super_block *sb, struct vs_entry *p)
21400 + struct inode *inode = new_inode(sb);
21405 + inode->i_mode = p->mode;
21407 + inode->i_op = p->iop;
21409 + inode->i_fop = p->fop;
21411 + set_nlink(inode, (p->mode & S_IFDIR) ? 2 : 1);
21412 + inode->i_flags |= S_IMMUTABLE;
21414 + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
21416 + inode->i_uid = 0;
21417 + inode->i_gid = 0;
21418 + inode->i_tag = 0;
21423 +static struct dentry *vs_proc_instantiate(struct inode *dir,
21424 + struct dentry *dentry, int id, void *ptr)
21426 + struct vs_entry *p = ptr;
21427 + struct inode *inode = vs_proc_make_inode(dir->i_sb, p);
21428 + struct dentry *error = ERR_PTR(-EINVAL);
21433 + PROC_I(inode)->op = p->op;
21434 + PROC_I(inode)->fd = id;
21435 + d_add(dentry, inode);
21443 +typedef struct dentry *instantiate_t(struct inode *, struct dentry *, int, void *);
21446 + * Fill a directory entry.
21448 + * If possible create the dcache entry and derive our inode number and
21449 + * file type from dcache entry.
21451 + * Since all of the proc inode numbers are dynamically generated, the inode
21452 + * numbers do not exist until the inode is cache. This means creating the
21453 + * the dcache entry in readdir is necessary to keep the inode numbers
21454 + * reported by readdir in sync with the inode numbers reported
21457 +static int proc_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
21458 + char *name, int len, instantiate_t instantiate, int id, void *ptr)
21460 + struct dentry *child, *dir = filp->f_dentry;
21461 + struct inode *inode;
21462 + struct qstr qname;
21464 + unsigned type = DT_UNKNOWN;
21466 + qname.name = name;
21468 + qname.hash = full_name_hash(name, len);
21470 + child = d_lookup(dir, &qname);
21472 + struct dentry *new;
21473 + new = d_alloc(dir, &qname);
21475 + child = instantiate(dir->d_inode, new, id, ptr);
21482 + if (!child || IS_ERR(child) || !child->d_inode)
21483 + goto end_instantiate;
21484 + inode = child->d_inode;
21486 + ino = inode->i_ino;
21487 + type = inode->i_mode >> 12;
21492 + ino = find_inode_number(dir, &qname);
21495 + return filldir(dirent, name, len, filp->f_pos, ino, type);
21500 +/* get and revalidate vx_info/xid */
21503 +struct vx_info *get_proc_vx_info(struct inode *inode)
21505 + return lookup_vx_info(PROC_I(inode)->fd);
21508 +static int proc_xid_revalidate(struct dentry *dentry, struct nameidata *nd)
21510 + struct inode *inode = dentry->d_inode;
21511 + xid_t xid = PROC_I(inode)->fd;
21513 + if (!xid || xid_is_hashed(xid))
21520 +/* get and revalidate nx_info/nid */
21522 +static int proc_nid_revalidate(struct dentry *dentry, struct nameidata *nd)
21524 + struct inode *inode = dentry->d_inode;
21525 + nid_t nid = PROC_I(inode)->fd;
21527 + if (!nid || nid_is_hashed(nid))
21535 +#define PROC_BLOCK_SIZE (PAGE_SIZE - 1024)
21537 +static ssize_t proc_vs_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 + unsigned long page;
21542 + ssize_t length = 0;
21544 + if (count > PROC_BLOCK_SIZE)
21545 + count = PROC_BLOCK_SIZE;
21547 + /* fade that out as soon as stable */
21548 + WARN_ON(PROC_I(inode)->fd);
21550 + if (!(page = __get_free_page(GFP_KERNEL)))
21553 + BUG_ON(!PROC_I(inode)->op.proc_vs_read);
21554 + length = PROC_I(inode)->op.proc_vs_read((char *)page);
21557 + length = simple_read_from_buffer(buf, count, ppos,
21558 + (char *)page, length);
21564 +static ssize_t proc_vx_info_read(struct file *file, char __user *buf,
21565 + size_t count, loff_t *ppos)
21567 + struct inode *inode = file->f_dentry->d_inode;
21568 + struct vx_info *vxi = NULL;
21569 + xid_t xid = PROC_I(inode)->fd;
21570 + unsigned long page;
21571 + ssize_t length = 0;
21573 + if (count > PROC_BLOCK_SIZE)
21574 + count = PROC_BLOCK_SIZE;
21576 + /* fade that out as soon as stable */
21578 + vxi = lookup_vx_info(xid);
21582 + length = -ENOMEM;
21583 + if (!(page = __get_free_page(GFP_KERNEL)))
21586 + BUG_ON(!PROC_I(inode)->op.proc_vxi_read);
21587 + length = PROC_I(inode)->op.proc_vxi_read(vxi, (char *)page);
21590 + length = simple_read_from_buffer(buf, count, ppos,
21591 + (char *)page, length);
21595 + put_vx_info(vxi);
21600 +static ssize_t proc_nx_info_read(struct file *file, char __user *buf,
21601 + size_t count, loff_t *ppos)
21603 + struct inode *inode = file->f_dentry->d_inode;
21604 + struct nx_info *nxi = NULL;
21605 + nid_t nid = PROC_I(inode)->fd;
21606 + unsigned long page;
21607 + ssize_t length = 0;
21609 + if (count > PROC_BLOCK_SIZE)
21610 + count = PROC_BLOCK_SIZE;
21612 + /* fade that out as soon as stable */
21614 + nxi = lookup_nx_info(nid);
21618 + length = -ENOMEM;
21619 + if (!(page = __get_free_page(GFP_KERNEL)))
21622 + BUG_ON(!PROC_I(inode)->op.proc_nxi_read);
21623 + length = PROC_I(inode)->op.proc_nxi_read(nxi, (char *)page);
21626 + length = simple_read_from_buffer(buf, count, ppos,
21627 + (char *)page, length);
21631 + put_nx_info(nxi);
21638 +/* here comes the lower level */
21641 +#define NOD(NAME, MODE, IOP, FOP, OP) { \
21642 + .len = sizeof(NAME) - 1, \
21643 + .name = (NAME), \
21651 +#define DIR(NAME, MODE, OTYPE) \
21652 + NOD(NAME, (S_IFDIR | (MODE)), \
21653 + &proc_ ## OTYPE ## _inode_operations, \
21654 + &proc_ ## OTYPE ## _file_operations, { } )
21656 +#define INF(NAME, MODE, OTYPE) \
21657 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21658 + &proc_vs_info_file_operations, \
21659 + { .proc_vs_read = &proc_##OTYPE } )
21661 +#define VINF(NAME, MODE, OTYPE) \
21662 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21663 + &proc_vx_info_file_operations, \
21664 + { .proc_vxi_read = &proc_##OTYPE } )
21666 +#define NINF(NAME, MODE, OTYPE) \
21667 + NOD(NAME, (S_IFREG | (MODE)), NULL, \
21668 + &proc_nx_info_file_operations, \
21669 + { .proc_nxi_read = &proc_##OTYPE } )
21672 +static struct file_operations proc_vs_info_file_operations = {
21673 + .read = proc_vs_info_read,
21676 +static struct file_operations proc_vx_info_file_operations = {
21677 + .read = proc_vx_info_read,
21680 +static struct dentry_operations proc_xid_dentry_operations = {
21681 + .d_revalidate = proc_xid_revalidate,
21684 +static struct vs_entry vx_base_stuff[] = {
21685 + VINF("info", S_IRUGO, vxi_info),
21686 + VINF("status", S_IRUGO, vxi_status),
21687 + VINF("limit", S_IRUGO, vxi_limit),
21688 + VINF("sched", S_IRUGO, vxi_sched),
21689 + VINF("nsproxy", S_IRUGO, vxi_nsproxy0),
21690 + VINF("nsproxy1",S_IRUGO, vxi_nsproxy1),
21691 + VINF("cvirt", S_IRUGO, vxi_cvirt),
21692 + VINF("cacct", S_IRUGO, vxi_cacct),
21699 +static struct dentry *proc_xid_instantiate(struct inode *dir,
21700 + struct dentry *dentry, int id, void *ptr)
21702 + dentry->d_op = &proc_xid_dentry_operations;
21703 + return vs_proc_instantiate(dir, dentry, id, ptr);
21706 +static struct dentry *proc_xid_lookup(struct inode *dir,
21707 + struct dentry *dentry, struct nameidata *nd)
21709 + struct vs_entry *p = vx_base_stuff;
21710 + struct dentry *error = ERR_PTR(-ENOENT);
21712 + for (; p->name; p++) {
21713 + if (p->len != dentry->d_name.len)
21715 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21721 + error = proc_xid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
21726 +static int proc_xid_readdir(struct file *filp,
21727 + void *dirent, filldir_t filldir)
21729 + struct dentry *dentry = filp->f_dentry;
21730 + struct inode *inode = dentry->d_inode;
21731 + struct vs_entry *p = vx_base_stuff;
21732 + int size = sizeof(vx_base_stuff) / sizeof(struct vs_entry);
21736 + pos = filp->f_pos;
21739 + ino = inode->i_ino;
21740 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21743 + /* fall through */
21745 + ino = parent_ino(dentry);
21746 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21749 + /* fall through */
21752 + if (index >= size)
21754 + for (p += index; p->name; p++) {
21755 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21756 + vs_proc_instantiate, PROC_I(inode)->fd, p))
21762 + filp->f_pos = pos;
21768 +static struct file_operations proc_nx_info_file_operations = {
21769 + .read = proc_nx_info_read,
21772 +static struct dentry_operations proc_nid_dentry_operations = {
21773 + .d_revalidate = proc_nid_revalidate,
21776 +static struct vs_entry nx_base_stuff[] = {
21777 + NINF("info", S_IRUGO, nxi_info),
21778 + NINF("status", S_IRUGO, nxi_status),
21783 +static struct dentry *proc_nid_instantiate(struct inode *dir,
21784 + struct dentry *dentry, int id, void *ptr)
21786 + dentry->d_op = &proc_nid_dentry_operations;
21787 + return vs_proc_instantiate(dir, dentry, id, ptr);
21790 +static struct dentry *proc_nid_lookup(struct inode *dir,
21791 + struct dentry *dentry, struct nameidata *nd)
21793 + struct vs_entry *p = nx_base_stuff;
21794 + struct dentry *error = ERR_PTR(-ENOENT);
21796 + for (; p->name; p++) {
21797 + if (p->len != dentry->d_name.len)
21799 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21805 + error = proc_nid_instantiate(dir, dentry, PROC_I(dir)->fd, p);
21810 +static int proc_nid_readdir(struct file *filp,
21811 + void *dirent, filldir_t filldir)
21813 + struct dentry *dentry = filp->f_dentry;
21814 + struct inode *inode = dentry->d_inode;
21815 + struct vs_entry *p = nx_base_stuff;
21816 + int size = sizeof(nx_base_stuff) / sizeof(struct vs_entry);
21820 + pos = filp->f_pos;
21823 + ino = inode->i_ino;
21824 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21827 + /* fall through */
21829 + ino = parent_ino(dentry);
21830 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21833 + /* fall through */
21836 + if (index >= size)
21838 + for (p += index; p->name; p++) {
21839 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21840 + vs_proc_instantiate, PROC_I(inode)->fd, p))
21846 + filp->f_pos = pos;
21851 +#define MAX_MULBY10 ((~0U - 9) / 10)
21853 +static inline int atovid(const char *str, int len)
21858 + while (len-- > 0) {
21863 + if (vid >= MAX_MULBY10)
21873 +/* now the upper level (virtual) */
21876 +static struct file_operations proc_xid_file_operations = {
21877 + .read = generic_read_dir,
21878 + .readdir = proc_xid_readdir,
21881 +static struct inode_operations proc_xid_inode_operations = {
21882 + .lookup = proc_xid_lookup,
21885 +static struct vs_entry vx_virtual_stuff[] = {
21886 + INF("info", S_IRUGO, virtual_info),
21887 + INF("status", S_IRUGO, virtual_status),
21888 + DIR(NULL, S_IRUGO | S_IXUGO, xid),
21892 +static struct dentry *proc_virtual_lookup(struct inode *dir,
21893 + struct dentry *dentry, struct nameidata *nd)
21895 + struct vs_entry *p = vx_virtual_stuff;
21896 + struct dentry *error = ERR_PTR(-ENOENT);
21899 + for (; p->name; p++) {
21900 + if (p->len != dentry->d_name.len)
21902 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21906 + goto instantiate;
21908 + id = atovid(dentry->d_name.name, dentry->d_name.len);
21909 + if ((id < 0) || !xid_is_hashed(id))
21913 + error = proc_xid_instantiate(dir, dentry, id, p);
21918 +static struct file_operations proc_nid_file_operations = {
21919 + .read = generic_read_dir,
21920 + .readdir = proc_nid_readdir,
21923 +static struct inode_operations proc_nid_inode_operations = {
21924 + .lookup = proc_nid_lookup,
21927 +static struct vs_entry nx_virtnet_stuff[] = {
21928 + INF("info", S_IRUGO, virtnet_info),
21929 + INF("status", S_IRUGO, virtnet_status),
21930 + DIR(NULL, S_IRUGO | S_IXUGO, nid),
21934 +static struct dentry *proc_virtnet_lookup(struct inode *dir,
21935 + struct dentry *dentry, struct nameidata *nd)
21937 + struct vs_entry *p = nx_virtnet_stuff;
21938 + struct dentry *error = ERR_PTR(-ENOENT);
21941 + for (; p->name; p++) {
21942 + if (p->len != dentry->d_name.len)
21944 + if (!memcmp(dentry->d_name.name, p->name, p->len))
21948 + goto instantiate;
21950 + id = atovid(dentry->d_name.name, dentry->d_name.len);
21951 + if ((id < 0) || !nid_is_hashed(id))
21955 + error = proc_nid_instantiate(dir, dentry, id, p);
21961 +#define PROC_MAXVIDS 32
21963 +int proc_virtual_readdir(struct file *filp,
21964 + void *dirent, filldir_t filldir)
21966 + struct dentry *dentry = filp->f_dentry;
21967 + struct inode *inode = dentry->d_inode;
21968 + struct vs_entry *p = vx_virtual_stuff;
21969 + int size = sizeof(vx_virtual_stuff) / sizeof(struct vs_entry);
21971 + unsigned int xid_array[PROC_MAXVIDS];
21972 + char buf[PROC_NUMBUF];
21973 + unsigned int nr_xids, i;
21976 + pos = filp->f_pos;
21979 + ino = inode->i_ino;
21980 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
21983 + /* fall through */
21985 + ino = parent_ino(dentry);
21986 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
21989 + /* fall through */
21992 + if (index >= size)
21994 + for (p += index; p->name; p++) {
21995 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
21996 + vs_proc_instantiate, 0, p))
22001 + index = pos - size;
22002 + p = &vx_virtual_stuff[size - 1];
22003 + nr_xids = get_xid_list(index, xid_array, PROC_MAXVIDS);
22004 + for (i = 0; i < nr_xids; i++) {
22005 + int n, xid = xid_array[i];
22006 + unsigned int j = PROC_NUMBUF;
22010 + buf[--j] = '0' + (n % 10);
22013 + if (proc_fill_cache(filp, dirent, filldir,
22014 + buf + j, PROC_NUMBUF - j,
22015 + vs_proc_instantiate, xid, p))
22021 + filp->f_pos = pos;
22025 +static int proc_virtual_getattr(struct vfsmount *mnt,
22026 + struct dentry *dentry, struct kstat *stat)
22028 + struct inode *inode = dentry->d_inode;
22030 + generic_fillattr(inode, stat);
22031 + stat->nlink = 2 + atomic_read(&vx_global_cactive);
22035 +static struct file_operations proc_virtual_dir_operations = {
22036 + .read = generic_read_dir,
22037 + .readdir = proc_virtual_readdir,
22040 +static struct inode_operations proc_virtual_dir_inode_operations = {
22041 + .getattr = proc_virtual_getattr,
22042 + .lookup = proc_virtual_lookup,
22049 +int proc_virtnet_readdir(struct file *filp,
22050 + void *dirent, filldir_t filldir)
22052 + struct dentry *dentry = filp->f_dentry;
22053 + struct inode *inode = dentry->d_inode;
22054 + struct vs_entry *p = nx_virtnet_stuff;
22055 + int size = sizeof(nx_virtnet_stuff) / sizeof(struct vs_entry);
22057 + unsigned int nid_array[PROC_MAXVIDS];
22058 + char buf[PROC_NUMBUF];
22059 + unsigned int nr_nids, i;
22062 + pos = filp->f_pos;
22065 + ino = inode->i_ino;
22066 + if (filldir(dirent, ".", 1, pos, ino, DT_DIR) < 0)
22069 + /* fall through */
22071 + ino = parent_ino(dentry);
22072 + if (filldir(dirent, "..", 2, pos, ino, DT_DIR) < 0)
22075 + /* fall through */
22078 + if (index >= size)
22080 + for (p += index; p->name; p++) {
22081 + if (proc_fill_cache(filp, dirent, filldir, p->name, p->len,
22082 + vs_proc_instantiate, 0, p))
22087 + index = pos - size;
22088 + p = &nx_virtnet_stuff[size - 1];
22089 + nr_nids = get_nid_list(index, nid_array, PROC_MAXVIDS);
22090 + for (i = 0; i < nr_nids; i++) {
22091 + int n, nid = nid_array[i];
22092 + unsigned int j = PROC_NUMBUF;
22096 + buf[--j] = '0' + (n % 10);
22099 + if (proc_fill_cache(filp, dirent, filldir,
22100 + buf + j, PROC_NUMBUF - j,
22101 + vs_proc_instantiate, nid, p))
22107 + filp->f_pos = pos;
22111 +static int proc_virtnet_getattr(struct vfsmount *mnt,
22112 + struct dentry *dentry, struct kstat *stat)
22114 + struct inode *inode = dentry->d_inode;
22116 + generic_fillattr(inode, stat);
22117 + stat->nlink = 2 + atomic_read(&nx_global_cactive);
22121 +static struct file_operations proc_virtnet_dir_operations = {
22122 + .read = generic_read_dir,
22123 + .readdir = proc_virtnet_readdir,
22126 +static struct inode_operations proc_virtnet_dir_inode_operations = {
22127 + .getattr = proc_virtnet_getattr,
22128 + .lookup = proc_virtnet_lookup,
22133 +void proc_vx_init(void)
22135 + struct proc_dir_entry *ent;
22137 + ent = proc_mkdir("virtual", 0);
22139 + ent->proc_fops = &proc_virtual_dir_operations;
22140 + ent->proc_iops = &proc_virtual_dir_inode_operations;
22142 + proc_virtual = ent;
22144 + ent = proc_mkdir("virtnet", 0);
22146 + ent->proc_fops = &proc_virtnet_dir_operations;
22147 + ent->proc_iops = &proc_virtnet_dir_inode_operations;
22149 + proc_virtnet = ent;
22155 +/* per pid info */
22158 +int proc_pid_vx_info(struct task_struct *p, char *buffer)
22160 + struct vx_info *vxi;
22161 + char *orig = buffer;
22163 + buffer += sprintf(buffer, "XID:\t%d\n", vx_task_xid(p));
22165 + vxi = task_get_vx_info(p);
22169 + buffer += sprintf(buffer, "BCaps:\t");
22170 + buffer = print_cap_t(buffer, &vxi->vx_bcaps);
22171 + buffer += sprintf(buffer, "\n");
22172 + buffer += sprintf(buffer, "CCaps:\t%016llx\n",
22173 + (unsigned long long)vxi->vx_ccaps);
22174 + buffer += sprintf(buffer, "CFlags:\t%016llx\n",
22175 + (unsigned long long)vxi->vx_flags);
22176 + buffer += sprintf(buffer, "CIPid:\t%d\n", vxi->vx_initpid);
22178 + put_vx_info(vxi);
22180 + return buffer - orig;
22184 +int proc_pid_nx_info(struct task_struct *p, char *buffer)
22186 + struct nx_info *nxi;
22187 + struct nx_addr_v4 *v4a;
22188 +#ifdef CONFIG_IPV6
22189 + struct nx_addr_v6 *v6a;
22191 + char *orig = buffer;
22194 + buffer += sprintf(buffer, "NID:\t%d\n", nx_task_nid(p));
22196 + nxi = task_get_nx_info(p);
22200 + buffer += sprintf(buffer, "NCaps:\t%016llx\n",
22201 + (unsigned long long)nxi->nx_ncaps);
22202 + buffer += sprintf(buffer, "NFlags:\t%016llx\n",
22203 + (unsigned long long)nxi->nx_flags);
22205 + buffer += sprintf(buffer,
22206 + "V4Root[bcast]:\t" NIPQUAD_FMT "\n",
22207 + NIPQUAD(nxi->v4_bcast.s_addr));
22208 + buffer += sprintf (buffer,
22209 + "V4Root[lback]:\t" NIPQUAD_FMT "\n",
22210 + NIPQUAD(nxi->v4_lback.s_addr));
22211 + if (!NX_IPV4(nxi))
22213 + for (i = 0, v4a = &nxi->v4; v4a; i++, v4a = v4a->next)
22214 + buffer += sprintf(buffer, "V4Root[%d]:\t" NXAV4_FMT "\n",
22217 +#ifdef CONFIG_IPV6
22218 + if (!NX_IPV6(nxi))
22220 + for (i = 0, v6a = &nxi->v6; v6a; i++, v6a = v6a->next)
22221 + buffer += sprintf(buffer, "V6Root[%d]:\t" NXAV6_FMT "\n",
22225 + put_nx_info(nxi);
22227 + return buffer - orig;
22230 diff -NurpP --minimal linux-3.4.103/kernel/vserver/sched.c linux-3.4.103-vs2.3.3.9/kernel/vserver/sched.c
22231 --- linux-3.4.103/kernel/vserver/sched.c 1970-01-01 00:00:00.000000000 +0000
22232 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/sched.c 2012-05-21 16:25:11.000000000 +0000
22235 + * linux/kernel/vserver/sched.c
22237 + * Virtual Server: Scheduler Support
22239 + * Copyright (C) 2004-2010 Herbert Pötzl
22241 + * V0.01 adapted Sam Vilains version to 2.6.3
22242 + * V0.02 removed legacy interface
22243 + * V0.03 changed vcmds to vxi arg
22244 + * V0.04 removed older and legacy interfaces
22245 + * V0.05 removed scheduler code/commands
22249 +#include <linux/vs_context.h>
22250 +#include <linux/vs_sched.h>
22251 +#include <linux/cpumask.h>
22252 +#include <linux/vserver/sched_cmd.h>
22254 +#include <asm/uaccess.h>
22257 +void vx_update_sched_param(struct _vx_sched *sched,
22258 + struct _vx_sched_pc *sched_pc)
22260 + sched_pc->prio_bias = sched->prio_bias;
22263 +static int do_set_prio_bias(struct vx_info *vxi, struct vcmd_prio_bias *data)
22267 + if (data->prio_bias > MAX_PRIO_BIAS)
22268 + data->prio_bias = MAX_PRIO_BIAS;
22269 + if (data->prio_bias < MIN_PRIO_BIAS)
22270 + data->prio_bias = MIN_PRIO_BIAS;
22272 + if (data->cpu_id != ~0) {
22273 + vxi->sched.update = cpumask_of_cpu(data->cpu_id);
22274 + cpumask_and(&vxi->sched.update, &vxi->sched.update,
22275 + cpu_online_mask);
22277 + cpumask_copy(&vxi->sched.update, cpu_online_mask);
22279 + for_each_cpu_mask(cpu, vxi->sched.update)
22280 + vx_update_sched_param(&vxi->sched,
22281 + &vx_per_cpu(vxi, sched_pc, cpu));
22285 +int vc_set_prio_bias(struct vx_info *vxi, void __user *data)
22287 + struct vcmd_prio_bias vc_data;
22289 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22292 + return do_set_prio_bias(vxi, &vc_data);
22295 +int vc_get_prio_bias(struct vx_info *vxi, void __user *data)
22297 + struct vcmd_prio_bias vc_data;
22298 + struct _vx_sched_pc *pcd;
22301 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22304 + cpu = vc_data.cpu_id;
22306 + if (!cpu_possible(cpu))
22309 + pcd = &vx_per_cpu(vxi, sched_pc, cpu);
22310 + vc_data.prio_bias = pcd->prio_bias;
22312 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22317 diff -NurpP --minimal linux-3.4.103/kernel/vserver/sched_init.h linux-3.4.103-vs2.3.3.9/kernel/vserver/sched_init.h
22318 --- linux-3.4.103/kernel/vserver/sched_init.h 1970-01-01 00:00:00.000000000 +0000
22319 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/sched_init.h 2012-05-21 16:15:05.000000000 +0000
22322 +static inline void vx_info_init_sched(struct _vx_sched *sched)
22324 + /* scheduling; hard code starting values as constants */
22325 + sched->prio_bias = 0;
22329 +void vx_info_init_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22331 + sched_pc->prio_bias = 0;
22333 + sched_pc->user_ticks = 0;
22334 + sched_pc->sys_ticks = 0;
22335 + sched_pc->hold_ticks = 0;
22338 +static inline void vx_info_exit_sched(struct _vx_sched *sched)
22344 +void vx_info_exit_sched_pc(struct _vx_sched_pc *sched_pc, int cpu)
22348 diff -NurpP --minimal linux-3.4.103/kernel/vserver/sched_proc.h linux-3.4.103-vs2.3.3.9/kernel/vserver/sched_proc.h
22349 --- linux-3.4.103/kernel/vserver/sched_proc.h 1970-01-01 00:00:00.000000000 +0000
22350 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/sched_proc.h 2012-05-21 16:15:05.000000000 +0000
22352 +#ifndef _VX_SCHED_PROC_H
22353 +#define _VX_SCHED_PROC_H
22357 +int vx_info_proc_sched(struct _vx_sched *sched, char *buffer)
22361 + length += sprintf(buffer,
22362 + "PrioBias:\t%8d\n",
22363 + sched->prio_bias);
22368 +int vx_info_proc_sched_pc(struct _vx_sched_pc *sched_pc,
22369 + char *buffer, int cpu)
22373 + length += sprintf(buffer + length,
22374 + "cpu %d: %lld %lld %lld", cpu,
22375 + (unsigned long long)sched_pc->user_ticks,
22376 + (unsigned long long)sched_pc->sys_ticks,
22377 + (unsigned long long)sched_pc->hold_ticks);
22378 + length += sprintf(buffer + length,
22379 + " %d\n", sched_pc->prio_bias);
22383 +#endif /* _VX_SCHED_PROC_H */
22384 diff -NurpP --minimal linux-3.4.103/kernel/vserver/signal.c linux-3.4.103-vs2.3.3.9/kernel/vserver/signal.c
22385 --- linux-3.4.103/kernel/vserver/signal.c 1970-01-01 00:00:00.000000000 +0000
22386 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/signal.c 2012-05-21 16:15:05.000000000 +0000
22389 + * linux/kernel/vserver/signal.c
22391 + * Virtual Server: Signal Support
22393 + * Copyright (C) 2003-2007 Herbert Pötzl
22395 + * V0.01 broken out from vcontext V0.05
22396 + * V0.02 changed vcmds to vxi arg
22397 + * V0.03 adjusted siginfo for kill
22401 +#include <asm/uaccess.h>
22403 +#include <linux/vs_context.h>
22404 +#include <linux/vs_pid.h>
22405 +#include <linux/vserver/signal_cmd.h>
22408 +int vx_info_kill(struct vx_info *vxi, int pid, int sig)
22410 + int retval, count = 0;
22411 + struct task_struct *p;
22412 + struct siginfo *sip = SEND_SIG_PRIV;
22415 + vxdprintk(VXD_CBIT(misc, 4),
22416 + "vx_info_kill(%p[#%d],%d,%d)*",
22417 + vxi, vxi->vx_id, pid, sig);
22418 + read_lock(&tasklist_lock);
22422 + for_each_process(p) {
22425 + if (vx_task_xid(p) != vxi->vx_id || p->pid <= 1 ||
22426 + (pid && vxi->vx_initpid == p->pid))
22429 + err = group_send_sig_info(sig, sip, p);
22431 + if (err != -EPERM)
22437 + if (vxi->vx_initpid) {
22438 + pid = vxi->vx_initpid;
22439 + /* for now, only SIGINT to private init ... */
22440 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22441 + /* ... as long as there are tasks left */
22442 + (atomic_read(&vxi->vx_tasks) > 1))
22445 + /* fallthrough */
22448 + p = find_task_by_real_pid(pid);
22449 + rcu_read_unlock();
22451 + if (vx_task_xid(p) == vxi->vx_id)
22452 + retval = group_send_sig_info(sig, sip, p);
22456 + read_unlock(&tasklist_lock);
22457 + vxdprintk(VXD_CBIT(misc, 4),
22458 + "vx_info_kill(%p[#%d],%d,%d,%ld) = %d",
22459 + vxi, vxi->vx_id, pid, sig, (long)sip, retval);
22463 +int vc_ctx_kill(struct vx_info *vxi, void __user *data)
22465 + struct vcmd_ctx_kill_v0 vc_data;
22467 + if (copy_from_user(&vc_data, data, sizeof(vc_data)))
22470 + /* special check to allow guest shutdown */
22471 + if (!vx_info_flags(vxi, VXF_STATE_ADMIN, 0) &&
22472 + /* forbid killall pid=0 when init is present */
22473 + (((vc_data.pid < 1) && vxi->vx_initpid) ||
22474 + (vc_data.pid > 1)))
22477 + return vx_info_kill(vxi, vc_data.pid, vc_data.sig);
22481 +static int __wait_exit(struct vx_info *vxi)
22483 + DECLARE_WAITQUEUE(wait, current);
22486 + add_wait_queue(&vxi->vx_wait, &wait);
22487 + set_current_state(TASK_INTERRUPTIBLE);
22490 + if (vx_info_state(vxi,
22491 + VXS_SHUTDOWN | VXS_HASHED | VXS_HELPER) == VXS_SHUTDOWN)
22493 + if (signal_pending(current)) {
22494 + ret = -ERESTARTSYS;
22501 + set_current_state(TASK_RUNNING);
22502 + remove_wait_queue(&vxi->vx_wait, &wait);
22508 +int vc_wait_exit(struct vx_info *vxi, void __user *data)
22510 + struct vcmd_wait_exit_v0 vc_data;
22513 + ret = __wait_exit(vxi);
22514 + vc_data.reboot_cmd = vxi->reboot_cmd;
22515 + vc_data.exit_code = vxi->exit_code;
22517 + if (copy_to_user(data, &vc_data, sizeof(vc_data)))
22522 diff -NurpP --minimal linux-3.4.103/kernel/vserver/space.c linux-3.4.103-vs2.3.3.9/kernel/vserver/space.c
22523 --- linux-3.4.103/kernel/vserver/space.c 1970-01-01 00:00:00.000000000 +0000
22524 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/space.c 2013-02-12 00:16:04.000000000 +0000
22527 + * linux/kernel/vserver/space.c
22529 + * Virtual Server: Context Space Support
22531 + * Copyright (C) 2003-2010 Herbert Pötzl
22533 + * V0.01 broken out from context.c 0.07
22534 + * V0.02 added task locking for namespace
22535 + * V0.03 broken out vx_enter_namespace
22536 + * V0.04 added *space support and commands
22537 + * V0.05 added credential support
22541 +#include <linux/utsname.h>
22542 +#include <linux/nsproxy.h>
22543 +#include <linux/err.h>
22544 +#include <linux/fs_struct.h>
22545 +#include <linux/cred.h>
22546 +#include <asm/uaccess.h>
22548 +#include <linux/vs_context.h>
22549 +#include <linux/vserver/space.h>
22550 +#include <linux/vserver/space_cmd.h>
22552 +atomic_t vs_global_nsproxy = ATOMIC_INIT(0);
22553 +atomic_t vs_global_fs = ATOMIC_INIT(0);
22554 +atomic_t vs_global_mnt_ns = ATOMIC_INIT(0);
22555 +atomic_t vs_global_uts_ns = ATOMIC_INIT(0);
22556 +atomic_t vs_global_user_ns = ATOMIC_INIT(0);
22557 +atomic_t vs_global_pid_ns = ATOMIC_INIT(0);
22560 +/* namespace functions */
22562 +#include <linux/mnt_namespace.h>
22563 +#include <linux/user_namespace.h>
22564 +#include <linux/pid_namespace.h>
22565 +#include <linux/ipc_namespace.h>
22566 +#include <net/net_namespace.h>
22567 +#include "../fs/mount.h"
22570 +static const struct vcmd_space_mask_v1 space_mask_v0 = {
22571 + .mask = CLONE_FS |
22573 +#ifdef CONFIG_UTS_NS
22576 +#ifdef CONFIG_IPC_NS
22579 +#ifdef CONFIG_USER_NS
22585 +static const struct vcmd_space_mask_v1 space_mask = {
22586 + .mask = CLONE_FS |
22588 +#ifdef CONFIG_UTS_NS
22591 +#ifdef CONFIG_IPC_NS
22594 +#ifdef CONFIG_USER_NS
22597 +#ifdef CONFIG_PID_NS
22600 +#ifdef CONFIG_NET_NS
22606 +static const struct vcmd_space_mask_v1 default_space_mask = {
22607 + .mask = CLONE_FS |
22609 +#ifdef CONFIG_UTS_NS
22612 +#ifdef CONFIG_IPC_NS
22615 +#ifdef CONFIG_USER_NS
22618 +#ifdef CONFIG_PID_NS
22625 + * build a new nsproxy mix
22626 + * assumes that both proxies are 'const'
22627 + * does not touch nsproxy refcounts
22628 + * will hold a reference on the result.
22631 +struct nsproxy *vs_mix_nsproxy(struct nsproxy *old_nsproxy,
22632 + struct nsproxy *new_nsproxy, unsigned long mask)
22634 + struct mnt_namespace *old_ns;
22635 + struct uts_namespace *old_uts;
22636 + struct ipc_namespace *old_ipc;
22637 +#ifdef CONFIG_PID_NS
22638 + struct pid_namespace *old_pid;
22640 +#ifdef CONFIG_NET_NS
22641 + struct net *old_net;
22643 + struct nsproxy *nsproxy;
22645 + nsproxy = copy_nsproxy(old_nsproxy);
22649 + if (mask & CLONE_NEWNS) {
22650 + old_ns = nsproxy->mnt_ns;
22651 + nsproxy->mnt_ns = new_nsproxy->mnt_ns;
22652 + if (nsproxy->mnt_ns)
22653 + get_mnt_ns(nsproxy->mnt_ns);
22657 + if (mask & CLONE_NEWUTS) {
22658 + old_uts = nsproxy->uts_ns;
22659 + nsproxy->uts_ns = new_nsproxy->uts_ns;
22660 + if (nsproxy->uts_ns)
22661 + get_uts_ns(nsproxy->uts_ns);
22665 + if (mask & CLONE_NEWIPC) {
22666 + old_ipc = nsproxy->ipc_ns;
22667 + nsproxy->ipc_ns = new_nsproxy->ipc_ns;
22668 + if (nsproxy->ipc_ns)
22669 + get_ipc_ns(nsproxy->ipc_ns);
22673 +#ifdef CONFIG_PID_NS
22674 + if (mask & CLONE_NEWPID) {
22675 + old_pid = nsproxy->pid_ns;
22676 + nsproxy->pid_ns = new_nsproxy->pid_ns;
22677 + if (nsproxy->pid_ns)
22678 + get_pid_ns(nsproxy->pid_ns);
22682 +#ifdef CONFIG_NET_NS
22683 + if (mask & CLONE_NEWNET) {
22684 + old_net = nsproxy->net_ns;
22685 + nsproxy->net_ns = new_nsproxy->net_ns;
22686 + if (nsproxy->net_ns)
22687 + get_net(nsproxy->net_ns);
22692 + put_mnt_ns(old_ns);
22694 + put_uts_ns(old_uts);
22696 + put_ipc_ns(old_ipc);
22697 +#ifdef CONFIG_PID_NS
22699 + put_pid_ns(old_pid);
22701 +#ifdef CONFIG_NET_NS
22703 + put_net(old_net);
22711 + * merge two nsproxy structs into a new one.
22712 + * will hold a reference on the result.
22716 +struct nsproxy *__vs_merge_nsproxy(struct nsproxy *old,
22717 + struct nsproxy *proxy, unsigned long mask)
22719 + struct nsproxy null_proxy = { .mnt_ns = NULL };
22725 + /* vs_mix_nsproxy returns with reference */
22726 + return vs_mix_nsproxy(old ? old : &null_proxy,
22729 + get_nsproxy(proxy);
22734 +int vx_enter_space(struct vx_info *vxi, unsigned long mask, unsigned index)
22736 + struct nsproxy *proxy, *proxy_cur, *proxy_new;
22737 + struct fs_struct *fs_cur, *fs = NULL;
22738 + struct _vx_space *space;
22739 + int ret, kill = 0;
22741 + vxdprintk(VXD_CBIT(space, 8), "vx_enter_space(%p[#%u],0x%08lx,%d)",
22742 + vxi, vxi->vx_id, mask, index);
22744 + if (vx_info_flags(vxi, VXF_INFO_PRIVATE, 0))
22747 + if (index >= VX_SPACES)
22750 + space = &vxi->space[index];
22753 + mask = space->vx_nsmask;
22755 + if ((mask & space->vx_nsmask) != mask)
22758 + if (mask & CLONE_FS) {
22759 + fs = copy_fs_struct(space->vx_fs);
22763 + proxy = space->vx_nsproxy;
22765 + vxdprintk(VXD_CBIT(space, 9),
22766 + "vx_enter_space(%p[#%u],0x%08lx,%d) -> (%p,%p)",
22767 + vxi, vxi->vx_id, mask, index, proxy, fs);
22769 + task_lock(current);
22770 + fs_cur = current->fs;
22772 + if (mask & CLONE_FS) {
22773 + spin_lock(&fs_cur->lock);
22774 + current->fs = fs;
22775 + kill = !--fs_cur->users;
22776 + spin_unlock(&fs_cur->lock);
22779 + proxy_cur = current->nsproxy;
22780 + get_nsproxy(proxy_cur);
22781 + task_unlock(current);
22784 + free_fs_struct(fs_cur);
22786 + proxy_new = __vs_merge_nsproxy(proxy_cur, proxy, mask);
22787 + if (IS_ERR(proxy_new)) {
22788 + ret = PTR_ERR(proxy_new);
22792 + proxy_new = xchg(¤t->nsproxy, proxy_new);
22794 + if (mask & CLONE_NEWUSER) {
22795 + struct cred *cred;
22797 + vxdprintk(VXD_CBIT(space, 10),
22798 + "vx_enter_space(%p[#%u],%p) cred (%p,%p)",
22799 + vxi, vxi->vx_id, space->vx_cred,
22800 + current->real_cred, current->cred);
22802 + if (space->vx_cred) {
22803 + cred = __prepare_creds(space->vx_cred);
22805 + commit_creds(cred);
22812 + put_nsproxy(proxy_new);
22815 + put_nsproxy(proxy_cur);
22820 +int vx_set_space(struct vx_info *vxi, unsigned long mask, unsigned index)
22822 + struct nsproxy *proxy_vxi, *proxy_cur, *proxy_new;
22823 + struct fs_struct *fs_vxi, *fs = NULL;
22824 + struct _vx_space *space;
22825 + int ret, kill = 0;
22827 + vxdprintk(VXD_CBIT(space, 8), "vx_set_space(%p[#%u],0x%08lx,%d)",
22828 + vxi, vxi->vx_id, mask, index);
22830 + if ((mask & space_mask.mask) != mask)
22833 + if (index >= VX_SPACES)
22836 + space = &vxi->space[index];
22838 + proxy_vxi = space->vx_nsproxy;
22839 + fs_vxi = space->vx_fs;
22841 + if (mask & CLONE_FS) {
22842 + fs = copy_fs_struct(current->fs);
22847 + task_lock(current);
22849 + if (mask & CLONE_FS) {
22850 + spin_lock(&fs_vxi->lock);
22851 + space->vx_fs = fs;
22852 + kill = !--fs_vxi->users;
22853 + spin_unlock(&fs_vxi->lock);
22856 + proxy_cur = current->nsproxy;
22857 + get_nsproxy(proxy_cur);
22858 + task_unlock(current);
22861 + free_fs_struct(fs_vxi);
22863 + proxy_new = __vs_merge_nsproxy(proxy_vxi, proxy_cur, mask);
22864 + if (IS_ERR(proxy_new)) {
22865 + ret = PTR_ERR(proxy_new);
22869 + proxy_new = xchg(&space->vx_nsproxy, proxy_new);
22870 + space->vx_nsmask |= mask;
22872 + if (mask & CLONE_NEWUSER) {
22873 + struct cred *cred;
22875 + vxdprintk(VXD_CBIT(space, 10),
22876 + "vx_set_space(%p[#%u],%p) cred (%p,%p)",
22877 + vxi, vxi->vx_id, space->vx_cred,
22878 + current->real_cred, current->cred);
22880 + cred = prepare_creds();
22881 + cred = (struct cred *)xchg(&space->vx_cred, cred);
22883 + abort_creds(cred);
22889 + put_nsproxy(proxy_new);
22892 + put_nsproxy(proxy_cur);
22897 +int vc_enter_space_v1(struct vx_info *vxi, void __user *data)
22899 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
22901 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22904 + return vx_enter_space(vxi, vc_data.mask, 0);
22907 +int vc_enter_space(struct vx_info *vxi, void __user *data)
22909 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
22911 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22914 + if (vc_data.index >= VX_SPACES)
22917 + return vx_enter_space(vxi, vc_data.mask, vc_data.index);
22920 +int vc_set_space_v1(struct vx_info *vxi, void __user *data)
22922 + struct vcmd_space_mask_v1 vc_data = { .mask = 0 };
22924 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22927 + return vx_set_space(vxi, vc_data.mask, 0);
22930 +int vc_set_space(struct vx_info *vxi, void __user *data)
22932 + struct vcmd_space_mask_v2 vc_data = { .mask = 0 };
22934 + if (data && copy_from_user(&vc_data, data, sizeof(vc_data)))
22937 + if (vc_data.index >= VX_SPACES)
22940 + return vx_set_space(vxi, vc_data.mask, vc_data.index);
22943 +int vc_get_space_mask(void __user *data, int type)
22945 + const struct vcmd_space_mask_v1 *mask;
22948 + mask = &space_mask_v0;
22949 + else if (type == 1)
22950 + mask = &space_mask;
22952 + mask = &default_space_mask;
22954 + vxdprintk(VXD_CBIT(space, 10),
22955 + "vc_get_space_mask(%d) = %08llx", type, mask->mask);
22957 + if (copy_to_user(data, mask, sizeof(*mask)))
22962 diff -NurpP --minimal linux-3.4.103/kernel/vserver/switch.c linux-3.4.103-vs2.3.3.9/kernel/vserver/switch.c
22963 --- linux-3.4.103/kernel/vserver/switch.c 1970-01-01 00:00:00.000000000 +0000
22964 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/switch.c 2012-05-21 16:15:05.000000000 +0000
22967 + * linux/kernel/vserver/switch.c
22969 + * Virtual Server: Syscall Switch
22971 + * Copyright (C) 2003-2011 Herbert Pötzl
22973 + * V0.01 syscall switch
22974 + * V0.02 added signal to context
22975 + * V0.03 added rlimit functions
22976 + * V0.04 added iattr, task/xid functions
22977 + * V0.05 added debug/history stuff
22978 + * V0.06 added compat32 layer
22979 + * V0.07 vcmd args and perms
22980 + * V0.08 added status commands
22981 + * V0.09 added tag commands
22982 + * V0.10 added oom bias
22983 + * V0.11 added device commands
22984 + * V0.12 added warn mask
22988 +#include <linux/vs_context.h>
22989 +#include <linux/vs_network.h>
22990 +#include <linux/vserver/switch.h>
22992 +#include "vci_config.h"
22996 +int vc_get_version(uint32_t id)
22998 + return VCI_VERSION;
23002 +int vc_get_vci(uint32_t id)
23004 + return vci_kernel_config();
23007 +#include <linux/vserver/context_cmd.h>
23008 +#include <linux/vserver/cvirt_cmd.h>
23009 +#include <linux/vserver/cacct_cmd.h>
23010 +#include <linux/vserver/limit_cmd.h>
23011 +#include <linux/vserver/network_cmd.h>
23012 +#include <linux/vserver/sched_cmd.h>
23013 +#include <linux/vserver/debug_cmd.h>
23014 +#include <linux/vserver/inode_cmd.h>
23015 +#include <linux/vserver/dlimit_cmd.h>
23016 +#include <linux/vserver/signal_cmd.h>
23017 +#include <linux/vserver/space_cmd.h>
23018 +#include <linux/vserver/tag_cmd.h>
23019 +#include <linux/vserver/device_cmd.h>
23021 +#include <linux/vserver/inode.h>
23022 +#include <linux/vserver/dlimit.h>
23025 +#ifdef CONFIG_COMPAT
23026 +#define __COMPAT(name, id, data, compat) \
23027 + (compat) ? name ## _x32(id, data) : name(id, data)
23028 +#define __COMPAT_NO_ID(name, data, compat) \
23029 + (compat) ? name ## _x32(data) : name(data)
23031 +#define __COMPAT(name, id, data, compat) \
23033 +#define __COMPAT_NO_ID(name, data, compat) \
23039 +long do_vcmd(uint32_t cmd, uint32_t id,
23040 + struct vx_info *vxi, struct nx_info *nxi,
23041 + void __user *data, int compat)
23045 + case VCMD_get_version:
23046 + return vc_get_version(id);
23047 + case VCMD_get_vci:
23048 + return vc_get_vci(id);
23050 + case VCMD_task_xid:
23051 + return vc_task_xid(id);
23052 + case VCMD_vx_info:
23053 + return vc_vx_info(vxi, data);
23055 + case VCMD_task_nid:
23056 + return vc_task_nid(id);
23057 + case VCMD_nx_info:
23058 + return vc_nx_info(nxi, data);
23060 + case VCMD_task_tag:
23061 + return vc_task_tag(id);
23063 + case VCMD_set_space_v1:
23064 + return vc_set_space_v1(vxi, data);
23065 + /* this is version 2 */
23066 + case VCMD_set_space:
23067 + return vc_set_space(vxi, data);
23069 + case VCMD_get_space_mask_v0:
23070 + return vc_get_space_mask(data, 0);
23071 + /* this is version 1 */
23072 + case VCMD_get_space_mask:
23073 + return vc_get_space_mask(data, 1);
23075 + case VCMD_get_space_default:
23076 + return vc_get_space_mask(data, -1);
23078 + case VCMD_set_umask:
23079 + return vc_set_umask(vxi, data);
23081 + case VCMD_get_umask:
23082 + return vc_get_umask(vxi, data);
23084 + case VCMD_set_wmask:
23085 + return vc_set_wmask(vxi, data);
23087 + case VCMD_get_wmask:
23088 + return vc_get_wmask(vxi, data);
23089 +#ifdef CONFIG_IA32_EMULATION
23090 + case VCMD_get_rlimit:
23091 + return __COMPAT(vc_get_rlimit, vxi, data, compat);
23092 + case VCMD_set_rlimit:
23093 + return __COMPAT(vc_set_rlimit, vxi, data, compat);
23095 + case VCMD_get_rlimit:
23096 + return vc_get_rlimit(vxi, data);
23097 + case VCMD_set_rlimit:
23098 + return vc_set_rlimit(vxi, data);
23100 + case VCMD_get_rlimit_mask:
23101 + return vc_get_rlimit_mask(id, data);
23102 + case VCMD_reset_hits:
23103 + return vc_reset_hits(vxi, data);
23104 + case VCMD_reset_minmax:
23105 + return vc_reset_minmax(vxi, data);
23107 + case VCMD_get_vhi_name:
23108 + return vc_get_vhi_name(vxi, data);
23109 + case VCMD_set_vhi_name:
23110 + return vc_set_vhi_name(vxi, data);
23112 + case VCMD_ctx_stat:
23113 + return vc_ctx_stat(vxi, data);
23114 + case VCMD_virt_stat:
23115 + return vc_virt_stat(vxi, data);
23116 + case VCMD_sock_stat:
23117 + return vc_sock_stat(vxi, data);
23118 + case VCMD_rlimit_stat:
23119 + return vc_rlimit_stat(vxi, data);
23121 + case VCMD_set_cflags:
23122 + return vc_set_cflags(vxi, data);
23123 + case VCMD_get_cflags:
23124 + return vc_get_cflags(vxi, data);
23126 + /* this is version 1 */
23127 + case VCMD_set_ccaps:
23128 + return vc_set_ccaps(vxi, data);
23129 + /* this is version 1 */
23130 + case VCMD_get_ccaps:
23131 + return vc_get_ccaps(vxi, data);
23132 + case VCMD_set_bcaps:
23133 + return vc_set_bcaps(vxi, data);
23134 + case VCMD_get_bcaps:
23135 + return vc_get_bcaps(vxi, data);
23137 + case VCMD_set_badness:
23138 + return vc_set_badness(vxi, data);
23139 + case VCMD_get_badness:
23140 + return vc_get_badness(vxi, data);
23142 + case VCMD_set_nflags:
23143 + return vc_set_nflags(nxi, data);
23144 + case VCMD_get_nflags:
23145 + return vc_get_nflags(nxi, data);
23147 + case VCMD_set_ncaps:
23148 + return vc_set_ncaps(nxi, data);
23149 + case VCMD_get_ncaps:
23150 + return vc_get_ncaps(nxi, data);
23152 + case VCMD_set_prio_bias:
23153 + return vc_set_prio_bias(vxi, data);
23154 + case VCMD_get_prio_bias:
23155 + return vc_get_prio_bias(vxi, data);
23156 + case VCMD_add_dlimit:
23157 + return __COMPAT(vc_add_dlimit, id, data, compat);
23158 + case VCMD_rem_dlimit:
23159 + return __COMPAT(vc_rem_dlimit, id, data, compat);
23160 + case VCMD_set_dlimit:
23161 + return __COMPAT(vc_set_dlimit, id, data, compat);
23162 + case VCMD_get_dlimit:
23163 + return __COMPAT(vc_get_dlimit, id, data, compat);
23165 + case VCMD_ctx_kill:
23166 + return vc_ctx_kill(vxi, data);
23168 + case VCMD_wait_exit:
23169 + return vc_wait_exit(vxi, data);
23171 + case VCMD_get_iattr:
23172 + return __COMPAT_NO_ID(vc_get_iattr, data, compat);
23173 + case VCMD_set_iattr:
23174 + return __COMPAT_NO_ID(vc_set_iattr, data, compat);
23176 + case VCMD_fget_iattr:
23177 + return vc_fget_iattr(id, data);
23178 + case VCMD_fset_iattr:
23179 + return vc_fset_iattr(id, data);
23181 + case VCMD_enter_space_v0:
23182 + return vc_enter_space_v1(vxi, NULL);
23183 + case VCMD_enter_space_v1:
23184 + return vc_enter_space_v1(vxi, data);
23185 + /* this is version 2 */
23186 + case VCMD_enter_space:
23187 + return vc_enter_space(vxi, data);
23189 + case VCMD_ctx_create_v0:
23190 + return vc_ctx_create(id, NULL);
23191 + case VCMD_ctx_create:
23192 + return vc_ctx_create(id, data);
23193 + case VCMD_ctx_migrate_v0:
23194 + return vc_ctx_migrate(vxi, NULL);
23195 + case VCMD_ctx_migrate:
23196 + return vc_ctx_migrate(vxi, data);
23198 + case VCMD_net_create_v0:
23199 + return vc_net_create(id, NULL);
23200 + case VCMD_net_create:
23201 + return vc_net_create(id, data);
23202 + case VCMD_net_migrate:
23203 + return vc_net_migrate(nxi, data);
23205 + case VCMD_tag_migrate:
23206 + return vc_tag_migrate(id);
23208 + case VCMD_net_add:
23209 + return vc_net_add(nxi, data);
23210 + case VCMD_net_remove:
23211 + return vc_net_remove(nxi, data);
23213 + case VCMD_net_add_ipv4_v1:
23214 + return vc_net_add_ipv4_v1(nxi, data);
23215 + /* this is version 2 */
23216 + case VCMD_net_add_ipv4:
23217 + return vc_net_add_ipv4(nxi, data);
23219 + case VCMD_net_rem_ipv4_v1:
23220 + return vc_net_rem_ipv4_v1(nxi, data);
23221 + /* this is version 2 */
23222 + case VCMD_net_rem_ipv4:
23223 + return vc_net_rem_ipv4(nxi, data);
23224 +#ifdef CONFIG_IPV6
23225 + case VCMD_net_add_ipv6:
23226 + return vc_net_add_ipv6(nxi, data);
23227 + case VCMD_net_remove_ipv6:
23228 + return vc_net_remove_ipv6(nxi, data);
23230 +/* case VCMD_add_match_ipv4:
23231 + return vc_add_match_ipv4(nxi, data);
23232 + case VCMD_get_match_ipv4:
23233 + return vc_get_match_ipv4(nxi, data);
23234 +#ifdef CONFIG_IPV6
23235 + case VCMD_add_match_ipv6:
23236 + return vc_add_match_ipv6(nxi, data);
23237 + case VCMD_get_match_ipv6:
23238 + return vc_get_match_ipv6(nxi, data);
23241 +#ifdef CONFIG_VSERVER_DEVICE
23242 + case VCMD_set_mapping:
23243 + return __COMPAT(vc_set_mapping, vxi, data, compat);
23244 + case VCMD_unset_mapping:
23245 + return __COMPAT(vc_unset_mapping, vxi, data, compat);
23247 +#ifdef CONFIG_VSERVER_HISTORY
23248 + case VCMD_dump_history:
23249 + return vc_dump_history(id);
23250 + case VCMD_read_history:
23251 + return __COMPAT(vc_read_history, id, data, compat);
23254 + vxwprintk_task(1, "unimplemented VCMD_%02d_%d[%d]",
23255 + VC_CATEGORY(cmd), VC_COMMAND(cmd), VC_VERSION(cmd));
23261 +#define __VCMD(vcmd, _perm, _args, _flags) \
23262 + case VCMD_ ## vcmd: perm = _perm; \
23263 + args = _args; flags = _flags; break
23266 +#define VCA_NONE 0x00
23267 +#define VCA_VXI 0x01
23268 +#define VCA_NXI 0x02
23270 +#define VCF_NONE 0x00
23271 +#define VCF_INFO 0x01
23272 +#define VCF_ADMIN 0x02
23273 +#define VCF_ARES 0x06 /* includes admin */
23274 +#define VCF_SETUP 0x08
23276 +#define VCF_ZIDOK 0x10 /* zero id okay */
23280 +long do_vserver(uint32_t cmd, uint32_t id, void __user *data, int compat)
23283 + int permit = -1, state = 0;
23284 + int perm = -1, args = 0, flags = 0;
23285 + struct vx_info *vxi = NULL;
23286 + struct nx_info *nxi = NULL;
23289 + /* unpriviledged commands */
23290 + __VCMD(get_version, 0, VCA_NONE, 0);
23291 + __VCMD(get_vci, 0, VCA_NONE, 0);
23292 + __VCMD(get_rlimit_mask, 0, VCA_NONE, 0);
23293 + __VCMD(get_space_mask_v0,0, VCA_NONE, 0);
23294 + __VCMD(get_space_mask, 0, VCA_NONE, 0);
23295 + __VCMD(get_space_default,0, VCA_NONE, 0);
23297 + /* info commands */
23298 + __VCMD(task_xid, 2, VCA_NONE, 0);
23299 + __VCMD(reset_hits, 2, VCA_VXI, 0);
23300 + __VCMD(reset_minmax, 2, VCA_VXI, 0);
23301 + __VCMD(vx_info, 3, VCA_VXI, VCF_INFO);
23302 + __VCMD(get_bcaps, 3, VCA_VXI, VCF_INFO);
23303 + __VCMD(get_ccaps, 3, VCA_VXI, VCF_INFO);
23304 + __VCMD(get_cflags, 3, VCA_VXI, VCF_INFO);
23305 + __VCMD(get_umask, 3, VCA_VXI, VCF_INFO);
23306 + __VCMD(get_wmask, 3, VCA_VXI, VCF_INFO);
23307 + __VCMD(get_badness, 3, VCA_VXI, VCF_INFO);
23308 + __VCMD(get_vhi_name, 3, VCA_VXI, VCF_INFO);
23309 + __VCMD(get_rlimit, 3, VCA_VXI, VCF_INFO);
23311 + __VCMD(ctx_stat, 3, VCA_VXI, VCF_INFO);
23312 + __VCMD(virt_stat, 3, VCA_VXI, VCF_INFO);
23313 + __VCMD(sock_stat, 3, VCA_VXI, VCF_INFO);
23314 + __VCMD(rlimit_stat, 3, VCA_VXI, VCF_INFO);
23316 + __VCMD(task_nid, 2, VCA_NONE, 0);
23317 + __VCMD(nx_info, 3, VCA_NXI, VCF_INFO);
23318 + __VCMD(get_ncaps, 3, VCA_NXI, VCF_INFO);
23319 + __VCMD(get_nflags, 3, VCA_NXI, VCF_INFO);
23321 + __VCMD(task_tag, 2, VCA_NONE, 0);
23323 + __VCMD(get_iattr, 2, VCA_NONE, 0);
23324 + __VCMD(fget_iattr, 2, VCA_NONE, 0);
23325 + __VCMD(get_dlimit, 3, VCA_NONE, VCF_INFO);
23326 + __VCMD(get_prio_bias, 3, VCA_VXI, VCF_INFO);
23328 + /* lower admin commands */
23329 + __VCMD(wait_exit, 4, VCA_VXI, VCF_INFO);
23330 + __VCMD(ctx_create_v0, 5, VCA_NONE, 0);
23331 + __VCMD(ctx_create, 5, VCA_NONE, 0);
23332 + __VCMD(ctx_migrate_v0, 5, VCA_VXI, VCF_ADMIN);
23333 + __VCMD(ctx_migrate, 5, VCA_VXI, VCF_ADMIN);
23334 + __VCMD(enter_space_v0, 5, VCA_VXI, VCF_ADMIN);
23335 + __VCMD(enter_space_v1, 5, VCA_VXI, VCF_ADMIN);
23336 + __VCMD(enter_space, 5, VCA_VXI, VCF_ADMIN);
23338 + __VCMD(net_create_v0, 5, VCA_NONE, 0);
23339 + __VCMD(net_create, 5, VCA_NONE, 0);
23340 + __VCMD(net_migrate, 5, VCA_NXI, VCF_ADMIN);
23342 + __VCMD(tag_migrate, 5, VCA_NONE, VCF_ADMIN);
23344 + /* higher admin commands */
23345 + __VCMD(ctx_kill, 6, VCA_VXI, VCF_ARES);
23346 + __VCMD(set_space_v1, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23347 + __VCMD(set_space, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23349 + __VCMD(set_ccaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23350 + __VCMD(set_bcaps, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23351 + __VCMD(set_cflags, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23352 + __VCMD(set_umask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23353 + __VCMD(set_wmask, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23354 + __VCMD(set_badness, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23356 + __VCMD(set_vhi_name, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23357 + __VCMD(set_rlimit, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23358 + __VCMD(set_prio_bias, 7, VCA_VXI, VCF_ARES | VCF_SETUP);
23360 + __VCMD(set_ncaps, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23361 + __VCMD(set_nflags, 7, VCA_NXI, VCF_ARES | VCF_SETUP);
23362 + __VCMD(net_add, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23363 + __VCMD(net_remove, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23364 + __VCMD(net_add_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23365 + __VCMD(net_rem_ipv4_v1, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23366 + __VCMD(net_add_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23367 + __VCMD(net_rem_ipv4, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23368 +#ifdef CONFIG_IPV6
23369 + __VCMD(net_add_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23370 + __VCMD(net_remove_ipv6, 8, VCA_NXI, VCF_ARES | VCF_SETUP);
23372 + __VCMD(set_iattr, 7, VCA_NONE, 0);
23373 + __VCMD(fset_iattr, 7, VCA_NONE, 0);
23374 + __VCMD(set_dlimit, 7, VCA_NONE, VCF_ARES);
23375 + __VCMD(add_dlimit, 8, VCA_NONE, VCF_ARES);
23376 + __VCMD(rem_dlimit, 8, VCA_NONE, VCF_ARES);
23378 +#ifdef CONFIG_VSERVER_DEVICE
23379 + __VCMD(set_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23380 + __VCMD(unset_mapping, 8, VCA_VXI, VCF_ARES|VCF_ZIDOK);
23382 + /* debug level admin commands */
23383 +#ifdef CONFIG_VSERVER_HISTORY
23384 + __VCMD(dump_history, 9, VCA_NONE, 0);
23385 + __VCMD(read_history, 9, VCA_NONE, 0);
23392 + vxdprintk(VXD_CBIT(switch, 0),
23393 + "vc: VCMD_%02d_%d[%d], %d,%p [%d,%d,%x,%x]",
23394 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23395 + VC_VERSION(cmd), id, data, compat,
23396 + perm, args, flags);
23403 + if (!capable(CAP_CONTEXT))
23407 + /* moved here from the individual commands */
23409 + if ((perm > 1) && !capable(CAP_SYS_ADMIN))
23413 + /* vcmd involves resource management */
23415 + if ((flags & VCF_ARES) && !capable(CAP_SYS_RESOURCE))
23419 + /* various legacy exceptions */
23421 + /* will go away when spectator is a cap */
23422 + case VCMD_ctx_migrate_v0:
23423 + case VCMD_ctx_migrate:
23425 + current->xid = 1;
23431 + /* will go away when spectator is a cap */
23432 + case VCMD_net_migrate:
23434 + current->nid = 1;
23441 + /* vcmds are fine by default */
23444 + /* admin type vcmds require admin ... */
23445 + if (flags & VCF_ADMIN)
23446 + permit = vx_check(0, VS_ADMIN) ? 1 : 0;
23448 + /* ... but setup type vcmds override that */
23449 + if (!permit && (flags & VCF_SETUP))
23450 + permit = vx_flags(VXF_STATE_SETUP, 0) ? 2 : 0;
23458 + if (!id && (flags & VCF_ZIDOK))
23462 + if (args & VCA_VXI) {
23463 + vxi = lookup_vx_info(id);
23467 + if ((flags & VCF_ADMIN) &&
23468 + /* special case kill for shutdown */
23469 + (cmd != VCMD_ctx_kill) &&
23470 + /* can context be administrated? */
23471 + !vx_info_flags(vxi, VXF_STATE_ADMIN, 0)) {
23477 + if (args & VCA_NXI) {
23478 + nxi = lookup_nx_info(id);
23482 + if ((flags & VCF_ADMIN) &&
23483 + /* can context be administrated? */
23484 + !nx_info_flags(nxi, NXF_STATE_ADMIN, 0)) {
23491 + ret = do_vcmd(cmd, id, vxi, nxi, data, compat);
23494 + if ((args & VCA_NXI) && nxi)
23495 + put_nx_info(nxi);
23497 + if ((args & VCA_VXI) && vxi)
23498 + put_vx_info(vxi);
23500 + vxdprintk(VXD_CBIT(switch, 1),
23501 + "vc: VCMD_%02d_%d[%d] = %08lx(%ld) [%d,%d]",
23502 + VC_CATEGORY(cmd), VC_COMMAND(cmd),
23503 + VC_VERSION(cmd), ret, ret, state, permit);
23508 +sys_vserver(uint32_t cmd, uint32_t id, void __user *data)
23510 + return do_vserver(cmd, id, data, 0);
23513 +#ifdef CONFIG_COMPAT
23516 +sys32_vserver(uint32_t cmd, uint32_t id, void __user *data)
23518 + return do_vserver(cmd, id, data, 1);
23521 +#endif /* CONFIG_COMPAT */
23522 diff -NurpP --minimal linux-3.4.103/kernel/vserver/sysctl.c linux-3.4.103-vs2.3.3.9/kernel/vserver/sysctl.c
23523 --- linux-3.4.103/kernel/vserver/sysctl.c 1970-01-01 00:00:00.000000000 +0000
23524 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/sysctl.c 2012-05-21 16:15:05.000000000 +0000
23527 + * kernel/vserver/sysctl.c
23529 + * Virtual Context Support
23531 + * Copyright (C) 2004-2007 Herbert Pötzl
23533 + * V0.01 basic structure
23537 +#include <linux/module.h>
23538 +#include <linux/ctype.h>
23539 +#include <linux/sysctl.h>
23540 +#include <linux/parser.h>
23541 +#include <asm/uaccess.h>
23544 + CTL_DEBUG_ERROR = 0,
23545 + CTL_DEBUG_SWITCH = 1,
23561 +unsigned int vs_debug_switch = 0;
23562 +unsigned int vs_debug_xid = 0;
23563 +unsigned int vs_debug_nid = 0;
23564 +unsigned int vs_debug_tag = 0;
23565 +unsigned int vs_debug_net = 0;
23566 +unsigned int vs_debug_limit = 0;
23567 +unsigned int vs_debug_cres = 0;
23568 +unsigned int vs_debug_dlim = 0;
23569 +unsigned int vs_debug_quota = 0;
23570 +unsigned int vs_debug_cvirt = 0;
23571 +unsigned int vs_debug_space = 0;
23572 +unsigned int vs_debug_perm = 0;
23573 +unsigned int vs_debug_misc = 0;
23576 +static struct ctl_table_header *vserver_table_header;
23577 +static ctl_table vserver_root_table[];
23580 +void vserver_register_sysctl(void)
23582 + if (!vserver_table_header) {
23583 + vserver_table_header = register_sysctl_table(vserver_root_table);
23588 +void vserver_unregister_sysctl(void)
23590 + if (vserver_table_header) {
23591 + unregister_sysctl_table(vserver_table_header);
23592 + vserver_table_header = NULL;
23597 +static int proc_dodebug(ctl_table *table, int write,
23598 + void __user *buffer, size_t *lenp, loff_t *ppos)
23600 + char tmpbuf[20], *p, c;
23601 + unsigned int value;
23602 + size_t left, len;
23604 + if ((*ppos && !write) || !*lenp) {
23612 + if (!access_ok(VERIFY_READ, buffer, left))
23614 + p = (char *)buffer;
23615 + while (left && __get_user(c, p) >= 0 && isspace(c))
23620 + if (left > sizeof(tmpbuf) - 1)
23622 + if (copy_from_user(tmpbuf, p, left))
23624 + tmpbuf[left] = '\0';
23626 + for (p = tmpbuf, value = 0; '0' <= *p && *p <= '9'; p++, left--)
23627 + value = 10 * value + (*p - '0');
23628 + if (*p && !isspace(*p))
23630 + while (left && isspace(*p))
23632 + *(unsigned int *)table->data = value;
23634 + if (!access_ok(VERIFY_WRITE, buffer, left))
23636 + len = sprintf(tmpbuf, "%d", *(unsigned int *)table->data);
23639 + if (__copy_to_user(buffer, tmpbuf, len))
23641 + if ((left -= len) > 0) {
23642 + if (put_user('\n', (char *)buffer + len))
23656 +#define CTL_ENTRY(ctl, name) \
23658 + .procname = #name, \
23659 + .data = &vs_ ## name, \
23660 + .maxlen = sizeof(int), \
23662 + .proc_handler = &proc_dodebug, \
23663 + .extra1 = &zero, \
23664 + .extra2 = &zero, \
23667 +static ctl_table vserver_debug_table[] = {
23668 + CTL_ENTRY(CTL_DEBUG_SWITCH, debug_switch),
23669 + CTL_ENTRY(CTL_DEBUG_XID, debug_xid),
23670 + CTL_ENTRY(CTL_DEBUG_NID, debug_nid),
23671 + CTL_ENTRY(CTL_DEBUG_TAG, debug_tag),
23672 + CTL_ENTRY(CTL_DEBUG_NET, debug_net),
23673 + CTL_ENTRY(CTL_DEBUG_LIMIT, debug_limit),
23674 + CTL_ENTRY(CTL_DEBUG_CRES, debug_cres),
23675 + CTL_ENTRY(CTL_DEBUG_DLIM, debug_dlim),
23676 + CTL_ENTRY(CTL_DEBUG_QUOTA, debug_quota),
23677 + CTL_ENTRY(CTL_DEBUG_CVIRT, debug_cvirt),
23678 + CTL_ENTRY(CTL_DEBUG_SPACE, debug_space),
23679 + CTL_ENTRY(CTL_DEBUG_PERM, debug_perm),
23680 + CTL_ENTRY(CTL_DEBUG_MISC, debug_misc),
23684 +static ctl_table vserver_root_table[] = {
23686 + .procname = "vserver",
23688 + .child = vserver_debug_table
23694 +static match_table_t tokens = {
23695 + { CTL_DEBUG_SWITCH, "switch=%x" },
23696 + { CTL_DEBUG_XID, "xid=%x" },
23697 + { CTL_DEBUG_NID, "nid=%x" },
23698 + { CTL_DEBUG_TAG, "tag=%x" },
23699 + { CTL_DEBUG_NET, "net=%x" },
23700 + { CTL_DEBUG_LIMIT, "limit=%x" },
23701 + { CTL_DEBUG_CRES, "cres=%x" },
23702 + { CTL_DEBUG_DLIM, "dlim=%x" },
23703 + { CTL_DEBUG_QUOTA, "quota=%x" },
23704 + { CTL_DEBUG_CVIRT, "cvirt=%x" },
23705 + { CTL_DEBUG_SPACE, "space=%x" },
23706 + { CTL_DEBUG_PERM, "perm=%x" },
23707 + { CTL_DEBUG_MISC, "misc=%x" },
23708 + { CTL_DEBUG_ERROR, NULL }
23711 +#define HANDLE_CASE(id, name, val) \
23712 + case CTL_DEBUG_ ## id: \
23713 + vs_debug_ ## name = val; \
23714 + printk("vs_debug_" #name "=0x%x\n", val); \
23718 +static int __init vs_debug_setup(char *str)
23723 + printk("vs_debug_setup(%s)\n", str);
23724 + while ((p = strsep(&str, ",")) != NULL) {
23725 + substring_t args[MAX_OPT_ARGS];
23726 + unsigned int value;
23731 + token = match_token(p, tokens, args);
23732 + value = (token > 0) ? simple_strtoul(args[0].from, NULL, 0) : 0;
23735 + HANDLE_CASE(SWITCH, switch, value);
23736 + HANDLE_CASE(XID, xid, value);
23737 + HANDLE_CASE(NID, nid, value);
23738 + HANDLE_CASE(TAG, tag, value);
23739 + HANDLE_CASE(NET, net, value);
23740 + HANDLE_CASE(LIMIT, limit, value);
23741 + HANDLE_CASE(CRES, cres, value);
23742 + HANDLE_CASE(DLIM, dlim, value);
23743 + HANDLE_CASE(QUOTA, quota, value);
23744 + HANDLE_CASE(CVIRT, cvirt, value);
23745 + HANDLE_CASE(SPACE, space, value);
23746 + HANDLE_CASE(PERM, perm, value);
23747 + HANDLE_CASE(MISC, misc, value);
23756 +__setup("vsdebug=", vs_debug_setup);
23760 +EXPORT_SYMBOL_GPL(vs_debug_switch);
23761 +EXPORT_SYMBOL_GPL(vs_debug_xid);
23762 +EXPORT_SYMBOL_GPL(vs_debug_nid);
23763 +EXPORT_SYMBOL_GPL(vs_debug_net);
23764 +EXPORT_SYMBOL_GPL(vs_debug_limit);
23765 +EXPORT_SYMBOL_GPL(vs_debug_cres);
23766 +EXPORT_SYMBOL_GPL(vs_debug_dlim);
23767 +EXPORT_SYMBOL_GPL(vs_debug_quota);
23768 +EXPORT_SYMBOL_GPL(vs_debug_cvirt);
23769 +EXPORT_SYMBOL_GPL(vs_debug_space);
23770 +EXPORT_SYMBOL_GPL(vs_debug_perm);
23771 +EXPORT_SYMBOL_GPL(vs_debug_misc);
23773 diff -NurpP --minimal linux-3.4.103/kernel/vserver/tag.c linux-3.4.103-vs2.3.3.9/kernel/vserver/tag.c
23774 --- linux-3.4.103/kernel/vserver/tag.c 1970-01-01 00:00:00.000000000 +0000
23775 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/tag.c 2012-05-21 16:15:05.000000000 +0000
23778 + * linux/kernel/vserver/tag.c
23780 + * Virtual Server: Shallow Tag Space
23782 + * Copyright (C) 2007 Herbert Pötzl
23784 + * V0.01 basic implementation
23788 +#include <linux/sched.h>
23789 +#include <linux/vserver/debug.h>
23790 +#include <linux/vs_pid.h>
23791 +#include <linux/vs_tag.h>
23793 +#include <linux/vserver/tag_cmd.h>
23796 +int dx_migrate_task(struct task_struct *p, tag_t tag)
23801 + vxdprintk(VXD_CBIT(tag, 5),
23802 + "dx_migrate_task(%p[#%d],#%d)", p, p->tag, tag);
23808 + vxdprintk(VXD_CBIT(tag, 5),
23809 + "moved task %p into [#%d]", p, tag);
23813 +/* vserver syscall commands below here */
23815 +/* taks xid and vx_info functions */
23818 +int vc_task_tag(uint32_t id)
23823 + struct task_struct *tsk;
23825 + tsk = find_task_by_real_pid(id);
23826 + tag = (tsk) ? tsk->tag : -ESRCH;
23827 + rcu_read_unlock();
23829 + tag = dx_current_tag();
23834 +int vc_tag_migrate(uint32_t tag)
23836 + return dx_migrate_task(current, tag & 0xFFFF);
23840 diff -NurpP --minimal linux-3.4.103/kernel/vserver/vci_config.h linux-3.4.103-vs2.3.3.9/kernel/vserver/vci_config.h
23841 --- linux-3.4.103/kernel/vserver/vci_config.h 1970-01-01 00:00:00.000000000 +0000
23842 +++ linux-3.4.103-vs2.3.3.9/kernel/vserver/vci_config.h 2012-05-21 16:15:05.000000000 +0000
23845 +/* interface version */
23847 +#define VCI_VERSION 0x00020308
23851 + VCI_KCBIT_NO_DYNAMIC = 0,
23853 + VCI_KCBIT_PROC_SECURE = 4,
23854 + /* VCI_KCBIT_HARDCPU = 5, */
23855 + /* VCI_KCBIT_IDLELIMIT = 6, */
23856 + /* VCI_KCBIT_IDLETIME = 7, */
23858 + VCI_KCBIT_COWBL = 8,
23859 + VCI_KCBIT_FULLCOWBL = 9,
23860 + VCI_KCBIT_SPACES = 10,
23861 + VCI_KCBIT_NETV2 = 11,
23862 + VCI_KCBIT_MEMCG = 12,
23864 + VCI_KCBIT_DEBUG = 16,
23865 + VCI_KCBIT_HISTORY = 20,
23866 + VCI_KCBIT_TAGGED = 24,
23867 + VCI_KCBIT_PPTAG = 28,
23869 + VCI_KCBIT_MORE = 31,
23873 +static inline uint32_t vci_kernel_config(void)
23876 + (1 << VCI_KCBIT_NO_DYNAMIC) |
23878 + /* configured features */
23879 +#ifdef CONFIG_VSERVER_PROC_SECURE
23880 + (1 << VCI_KCBIT_PROC_SECURE) |
23882 +#ifdef CONFIG_VSERVER_COWBL
23883 + (1 << VCI_KCBIT_COWBL) |
23884 + (1 << VCI_KCBIT_FULLCOWBL) |
23886 + (1 << VCI_KCBIT_SPACES) |
23887 + (1 << VCI_KCBIT_NETV2) |
23888 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
23889 + (1 << VCI_KCBIT_MEMCG) |
23892 + /* debug options */
23893 +#ifdef CONFIG_VSERVER_DEBUG
23894 + (1 << VCI_KCBIT_DEBUG) |
23896 +#ifdef CONFIG_VSERVER_HISTORY
23897 + (1 << VCI_KCBIT_HISTORY) |
23900 + /* inode context tagging */
23901 +#if defined(CONFIG_TAGGING_NONE)
23902 + (0 << VCI_KCBIT_TAGGED) |
23903 +#elif defined(CONFIG_TAGGING_UID16)
23904 + (1 << VCI_KCBIT_TAGGED) |
23905 +#elif defined(CONFIG_TAGGING_GID16)
23906 + (2 << VCI_KCBIT_TAGGED) |
23907 +#elif defined(CONFIG_TAGGING_ID24)
23908 + (3 << VCI_KCBIT_TAGGED) |
23909 +#elif defined(CONFIG_TAGGING_INTERN)
23910 + (4 << VCI_KCBIT_TAGGED) |
23911 +#elif defined(CONFIG_TAGGING_RUNTIME)
23912 + (5 << VCI_KCBIT_TAGGED) |
23914 + (7 << VCI_KCBIT_TAGGED) |
23916 + (1 << VCI_KCBIT_PPTAG) |
23920 diff -NurpP --minimal linux-3.4.103/mm/memcontrol.c linux-3.4.103-vs2.3.3.9/mm/memcontrol.c
23921 --- linux-3.4.103/mm/memcontrol.c 2014-08-30 13:37:19.000000000 +0000
23922 +++ linux-3.4.103-vs2.3.3.9/mm/memcontrol.c 2013-10-26 18:10:23.000000000 +0000
23923 @@ -846,6 +846,31 @@ struct mem_cgroup *mem_cgroup_from_task(
23924 struct mem_cgroup, css);
23927 +u64 mem_cgroup_res_read_u64(struct mem_cgroup *mem, int member)
23929 + return res_counter_read_u64(&mem->res, member);
23932 +u64 mem_cgroup_memsw_read_u64(struct mem_cgroup *mem, int member)
23934 + return res_counter_read_u64(&mem->memsw, member);
23937 +s64 mem_cgroup_stat_read_cache(struct mem_cgroup *mem)
23939 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_CACHE);
23942 +s64 mem_cgroup_stat_read_anon(struct mem_cgroup *mem)
23944 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_RSS);
23947 +s64 mem_cgroup_stat_read_mapped(struct mem_cgroup *mem)
23949 + return mem_cgroup_read_stat(mem, MEM_CGROUP_STAT_FILE_MAPPED);
23952 struct mem_cgroup *try_get_mem_cgroup_from_mm(struct mm_struct *mm)
23954 struct mem_cgroup *memcg = NULL;
23955 diff -NurpP --minimal linux-3.4.103/mm/oom_kill.c linux-3.4.103-vs2.3.3.9/mm/oom_kill.c
23956 --- linux-3.4.103/mm/oom_kill.c 2014-08-30 13:37:19.000000000 +0000
23957 +++ linux-3.4.103-vs2.3.3.9/mm/oom_kill.c 2013-10-26 18:10:23.000000000 +0000
23959 #include <linux/freezer.h>
23960 #include <linux/ftrace.h>
23961 #include <linux/ratelimit.h>
23962 +#include <linux/reboot.h>
23963 +#include <linux/vs_context.h>
23965 #define CREATE_TRACE_POINTS
23966 #include <trace/events/oom.h>
23967 @@ -155,11 +157,18 @@ struct task_struct *find_lock_task_mm(st
23968 static bool oom_unkillable_task(struct task_struct *p,
23969 const struct mem_cgroup *memcg, const nodemask_t *nodemask)
23971 - if (is_global_init(p))
23972 + unsigned xid = vx_current_xid();
23974 + /* skip the init task, global and per guest */
23975 + if (task_is_init(p))
23977 if (p->flags & PF_KTHREAD)
23980 + /* skip other guest and host processes if oom in guest */
23981 + if (xid && vx_task_xid(p) != xid)
23984 /* When mem_cgroup_out_of_memory() and p is not member of the group */
23985 if (memcg && !task_in_mem_cgroup(p, memcg))
23987 @@ -462,8 +471,8 @@ static void oom_kill_process(struct task
23988 dump_header(p, gfp_mask, order, memcg, nodemask);
23991 - pr_err("%s: Kill process %d (%s) score %d or sacrifice child\n",
23992 - message, task_pid_nr(p), p->comm, points);
23993 + pr_err("%s: Kill process %d:#%u (%s) score %d or sacrifice child\n",
23994 + message, task_pid_nr(p), p->xid, p->comm, points);
23998 @@ -496,8 +505,8 @@ static void oom_kill_process(struct task
24000 /* mm cannot safely be dereferenced after task_unlock(victim) */
24002 - pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
24003 - task_pid_nr(victim), victim->comm, K(victim->mm->total_vm),
24004 + pr_err("Killed process %d:#%u (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n",
24005 + task_pid_nr(victim), victim->xid, victim->comm, K(victim->mm->total_vm),
24006 K(get_mm_counter(victim->mm, MM_ANONPAGES)),
24007 K(get_mm_counter(victim->mm, MM_FILEPAGES)));
24008 task_unlock(victim);
24009 @@ -596,6 +605,8 @@ int unregister_oom_notifier(struct notif
24011 EXPORT_SYMBOL_GPL(unregister_oom_notifier);
24013 +long vs_oom_action(unsigned int);
24016 * Try to acquire the OOM killer lock for the zones in zonelist. Returns zero
24017 * if a parallel OOM killing is already taking place that includes a zone in
24018 @@ -747,7 +758,12 @@ void out_of_memory(struct zonelist *zone
24020 dump_header(NULL, gfp_mask, order, NULL, mpol_mask);
24021 read_unlock(&tasklist_lock);
24022 - panic("Out of memory and no killable processes...\n");
24024 + /* avoid panic for guest OOM */
24025 + if (current->xid)
24026 + vs_oom_action(LINUX_REBOOT_CMD_OOM);
24028 + panic("Out of memory and no killable processes...\n");
24030 if (PTR_ERR(p) != -1UL) {
24031 oom_kill_process(p, gfp_mask, order, points, totalpages, NULL,
24032 diff -NurpP --minimal linux-3.4.103/mm/page_alloc.c linux-3.4.103-vs2.3.3.9/mm/page_alloc.c
24033 --- linux-3.4.103/mm/page_alloc.c 2014-08-30 13:37:19.000000000 +0000
24034 +++ linux-3.4.103-vs2.3.3.9/mm/page_alloc.c 2014-08-30 13:55:46.000000000 +0000
24036 #include <linux/memcontrol.h>
24037 #include <linux/prefetch.h>
24038 #include <linux/page-debug-flags.h>
24039 +#include <linux/vs_base.h>
24040 +#include <linux/vs_limit.h>
24042 #include <asm/tlbflush.h>
24043 #include <asm/div64.h>
24044 @@ -2662,6 +2664,9 @@ void si_meminfo(struct sysinfo *val)
24045 val->totalhigh = totalhigh_pages;
24046 val->freehigh = nr_free_highpages();
24047 val->mem_unit = PAGE_SIZE;
24049 + if (vx_flags(VXF_VIRT_MEM, 0))
24050 + vx_vsi_meminfo(val);
24053 EXPORT_SYMBOL(si_meminfo);
24054 @@ -2682,6 +2687,9 @@ void si_meminfo_node(struct sysinfo *val
24057 val->mem_unit = PAGE_SIZE;
24059 + if (vx_flags(VXF_VIRT_MEM, 0))
24060 + vx_vsi_meminfo(val);
24064 diff -NurpP --minimal linux-3.4.103/mm/pgtable-generic.c linux-3.4.103-vs2.3.3.9/mm/pgtable-generic.c
24065 --- linux-3.4.103/mm/pgtable-generic.c 2012-05-21 16:07:35.000000000 +0000
24066 +++ linux-3.4.103-vs2.3.3.9/mm/pgtable-generic.c 2012-05-21 16:15:05.000000000 +0000
24068 * Copyright (C) 2010 Linus Torvalds
24071 +#include <linux/mm.h>
24073 #include <linux/pagemap.h>
24074 #include <asm/tlb.h>
24075 #include <asm-generic/pgtable.h>
24076 diff -NurpP --minimal linux-3.4.103/mm/shmem.c linux-3.4.103-vs2.3.3.9/mm/shmem.c
24077 --- linux-3.4.103/mm/shmem.c 2014-08-30 13:37:19.000000000 +0000
24078 +++ linux-3.4.103-vs2.3.3.9/mm/shmem.c 2014-08-30 13:55:46.000000000 +0000
24079 @@ -1588,7 +1588,7 @@ static int shmem_statfs(struct dentry *d
24081 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb);
24083 - buf->f_type = TMPFS_MAGIC;
24084 + buf->f_type = TMPFS_SUPER_MAGIC;
24085 buf->f_bsize = PAGE_CACHE_SIZE;
24086 buf->f_namelen = NAME_MAX;
24087 if (sbinfo->max_blocks) {
24088 @@ -2402,7 +2402,7 @@ int shmem_fill_super(struct super_block
24089 sb->s_maxbytes = MAX_LFS_FILESIZE;
24090 sb->s_blocksize = PAGE_CACHE_SIZE;
24091 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
24092 - sb->s_magic = TMPFS_MAGIC;
24093 + sb->s_magic = TMPFS_SUPER_MAGIC;
24094 sb->s_op = &shmem_ops;
24095 sb->s_time_gran = 1;
24096 #ifdef CONFIG_TMPFS_XATTR
24097 diff -NurpP --minimal linux-3.4.103/mm/slab.c linux-3.4.103-vs2.3.3.9/mm/slab.c
24098 --- linux-3.4.103/mm/slab.c 2014-08-30 13:37:19.000000000 +0000
24099 +++ linux-3.4.103-vs2.3.3.9/mm/slab.c 2012-10-22 13:09:53.000000000 +0000
24100 @@ -413,6 +413,8 @@ static void kmem_list3_init(struct kmem_
24101 #define STATS_INC_FREEMISS(x) do { } while (0)
24104 +#include "slab_vs.h"
24109 @@ -3466,6 +3468,7 @@ retry:
24111 obj = slab_get_obj(cachep, slabp, nodeid);
24112 check_slabp(cachep, slabp);
24113 + vx_slab_alloc(cachep, flags);
24114 l3->free_objects--;
24115 /* move slabp to correct slabp list: */
24116 list_del(&slabp->list);
24117 @@ -3543,6 +3546,7 @@ __cache_alloc_node(struct kmem_cache *ca
24118 /* ___cache_alloc_node can fall back to other nodes */
24119 ptr = ____cache_alloc_node(cachep, flags, nodeid);
24121 + vx_slab_alloc(cachep, flags);
24122 local_irq_restore(save_flags);
24123 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
24124 kmemleak_alloc_recursive(ptr, obj_size(cachep), 1, cachep->flags,
24125 @@ -3730,6 +3734,7 @@ static inline void __cache_free(struct k
24127 kmemleak_free_recursive(objp, cachep->flags);
24128 objp = cache_free_debugcheck(cachep, objp, caller);
24129 + vx_slab_free(cachep);
24131 kmemcheck_slab_free(cachep, objp, obj_size(cachep));
24133 diff -NurpP --minimal linux-3.4.103/mm/slab_vs.h linux-3.4.103-vs2.3.3.9/mm/slab_vs.h
24134 --- linux-3.4.103/mm/slab_vs.h 1970-01-01 00:00:00.000000000 +0000
24135 +++ linux-3.4.103-vs2.3.3.9/mm/slab_vs.h 2012-05-21 16:15:05.000000000 +0000
24138 +#include <linux/vserver/context.h>
24140 +#include <linux/vs_context.h>
24143 +void vx_slab_alloc(struct kmem_cache *cachep, gfp_t flags)
24145 + int what = gfp_zone(cachep->gfpflags);
24146 + struct vx_info *vxi = current_vx_info();
24151 + atomic_add(cachep->buffer_size, &vxi->cacct.slab[what]);
24155 +void vx_slab_free(struct kmem_cache *cachep)
24157 + int what = gfp_zone(cachep->gfpflags);
24158 + struct vx_info *vxi = current_vx_info();
24163 + atomic_sub(cachep->buffer_size, &vxi->cacct.slab[what]);
24166 diff -NurpP --minimal linux-3.4.103/mm/swapfile.c linux-3.4.103-vs2.3.3.9/mm/swapfile.c
24167 --- linux-3.4.103/mm/swapfile.c 2014-08-30 13:37:19.000000000 +0000
24168 +++ linux-3.4.103-vs2.3.3.9/mm/swapfile.c 2012-06-28 14:45:07.000000000 +0000
24170 #include <asm/tlbflush.h>
24171 #include <linux/swapops.h>
24172 #include <linux/page_cgroup.h>
24173 +#include <linux/vs_base.h>
24175 static bool swap_count_continued(struct swap_info_struct *, pgoff_t,
24177 @@ -1754,6 +1755,16 @@ static int swap_show(struct seq_file *sw
24179 if (si == SEQ_START_TOKEN) {
24180 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
24181 + if (vx_flags(VXF_VIRT_MEM, 0)) {
24182 + struct sysinfo si;
24184 + vx_vsi_swapinfo(&si);
24185 + if (si.totalswap < (1 << 10))
24187 + seq_printf(swap, "%s\t\t\t\t\t%s\t%lu\t%lu\t%d\n",
24188 + "hdv0", "partition", si.totalswap >> 10,
24189 + (si.totalswap - si.freeswap) >> 10, -1);
24194 @@ -2176,6 +2187,8 @@ void si_swapinfo(struct sysinfo *val)
24195 val->freeswap = nr_swap_pages + nr_to_be_unused;
24196 val->totalswap = total_swap_pages + nr_to_be_unused;
24197 spin_unlock(&swap_lock);
24198 + if (vx_flags(VXF_VIRT_MEM, 0))
24199 + vx_vsi_swapinfo(val);
24203 diff -NurpP --minimal linux-3.4.103/net/bridge/br_multicast.c linux-3.4.103-vs2.3.3.9/net/bridge/br_multicast.c
24204 --- linux-3.4.103/net/bridge/br_multicast.c 2014-08-30 13:37:19.000000000 +0000
24205 +++ linux-3.4.103-vs2.3.3.9/net/bridge/br_multicast.c 2014-05-20 04:30:31.000000000 +0000
24206 @@ -445,7 +445,7 @@ static struct sk_buff *br_ip6_multicast_
24207 ip6h->hop_limit = 1;
24208 ipv6_addr_set(&ip6h->daddr, htonl(0xff020000), 0, 0, htonl(1));
24209 if (ipv6_dev_get_saddr(dev_net(br->dev), br->dev, &ip6h->daddr, 0,
24211 + &ip6h->saddr, NULL)) {
24215 diff -NurpP --minimal linux-3.4.103/net/core/dev.c linux-3.4.103-vs2.3.3.9/net/core/dev.c
24216 --- linux-3.4.103/net/core/dev.c 2014-08-30 13:37:20.000000000 +0000
24217 +++ linux-3.4.103-vs2.3.3.9/net/core/dev.c 2014-06-12 11:34:39.000000000 +0000
24218 @@ -126,6 +126,7 @@
24219 #include <linux/in.h>
24220 #include <linux/jhash.h>
24221 #include <linux/random.h>
24222 +#include <linux/vs_inet.h>
24223 #include <trace/events/napi.h>
24224 #include <trace/events/net.h>
24225 #include <trace/events/skb.h>
24226 @@ -621,7 +622,8 @@ struct net_device *__dev_get_by_name(str
24227 struct hlist_head *head = dev_name_hash(net, name);
24229 hlist_for_each_entry(dev, p, head, name_hlist)
24230 - if (!strncmp(dev->name, name, IFNAMSIZ))
24231 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24232 + nx_dev_visible(current_nx_info(), dev))
24236 @@ -647,7 +649,8 @@ struct net_device *dev_get_by_name_rcu(s
24237 struct hlist_head *head = dev_name_hash(net, name);
24239 hlist_for_each_entry_rcu(dev, p, head, name_hlist)
24240 - if (!strncmp(dev->name, name, IFNAMSIZ))
24241 + if (!strncmp(dev->name, name, IFNAMSIZ) &&
24242 + nx_dev_visible(current_nx_info(), dev))
24246 @@ -698,7 +701,8 @@ struct net_device *__dev_get_by_index(st
24247 struct hlist_head *head = dev_index_hash(net, ifindex);
24249 hlist_for_each_entry(dev, p, head, index_hlist)
24250 - if (dev->ifindex == ifindex)
24251 + if ((dev->ifindex == ifindex) &&
24252 + nx_dev_visible(current_nx_info(), dev))
24256 @@ -716,7 +720,7 @@ EXPORT_SYMBOL(__dev_get_by_index);
24257 * about locking. The caller must hold RCU lock.
24260 -struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
24261 +struct net_device *dev_get_by_index_real_rcu(struct net *net, int ifindex)
24263 struct hlist_node *p;
24264 struct net_device *dev;
24265 @@ -728,6 +732,16 @@ struct net_device *dev_get_by_index_rcu(
24269 +EXPORT_SYMBOL(dev_get_by_index_real_rcu);
24271 +struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex)
24273 + struct net_device *dev = dev_get_by_index_real_rcu(net, ifindex);
24275 + if (nx_dev_visible(current_nx_info(), dev))
24279 EXPORT_SYMBOL(dev_get_by_index_rcu);
24282 @@ -776,7 +790,8 @@ struct net_device *dev_getbyhwaddr_rcu(s
24284 for_each_netdev_rcu(net, dev)
24285 if (dev->type == type &&
24286 - !memcmp(dev->dev_addr, ha, dev->addr_len))
24287 + !memcmp(dev->dev_addr, ha, dev->addr_len) &&
24288 + nx_dev_visible(current_nx_info(), dev))
24292 @@ -788,9 +803,11 @@ struct net_device *__dev_getfirstbyhwtyp
24293 struct net_device *dev;
24296 - for_each_netdev(net, dev)
24297 - if (dev->type == type)
24298 + for_each_netdev(net, dev) {
24299 + if ((dev->type == type) &&
24300 + nx_dev_visible(current_nx_info(), dev))
24306 @@ -908,6 +925,8 @@ static int __dev_alloc_name(struct net *
24308 if (i < 0 || i >= max_netdevices)
24310 + if (!nx_dev_visible(current_nx_info(), d))
24313 /* avoid cases where sscanf is not exact inverse of printf */
24314 snprintf(buf, IFNAMSIZ, name, i);
24315 @@ -4010,6 +4029,8 @@ static int dev_ifconf(struct net *net, c
24318 for_each_netdev(net, dev) {
24319 + if (!nx_dev_visible(current_nx_info(), dev))
24321 for (i = 0; i < NPROTO; i++) {
24322 if (gifconf_list[i]) {
24324 @@ -4112,6 +4133,10 @@ static void dev_seq_printf_stats(struct
24325 struct rtnl_link_stats64 temp;
24326 const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
24328 + /* device visible inside network context? */
24329 + if (!nx_dev_visible(current_nx_info(), dev))
24332 seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
24333 "%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
24334 dev->name, stats->rx_bytes, stats->rx_packets,
24335 diff -NurpP --minimal linux-3.4.103/net/core/rtnetlink.c linux-3.4.103-vs2.3.3.9/net/core/rtnetlink.c
24336 --- linux-3.4.103/net/core/rtnetlink.c 2014-08-30 13:37:20.000000000 +0000
24337 +++ linux-3.4.103-vs2.3.3.9/net/core/rtnetlink.c 2014-06-12 11:35:21.000000000 +0000
24338 @@ -1084,6 +1084,8 @@ static int rtnl_dump_ifinfo(struct sk_bu
24339 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
24342 + if (!nx_dev_visible(skb->sk->sk_nx_info, dev))
24344 err = rtnl_fill_ifinfo(skb, dev, RTM_NEWLINK,
24345 NETLINK_CB(cb->skb).pid,
24346 cb->nlh->nlmsg_seq, 0,
24347 @@ -1973,6 +1975,9 @@ void rtmsg_ifinfo(int type, struct net_d
24348 int err = -ENOBUFS;
24349 size_t if_info_size;
24351 + if (!nx_dev_visible(current_nx_info(), dev))
24354 skb = nlmsg_new((if_info_size = if_nlmsg_size(dev, 0)), GFP_KERNEL);
24357 diff -NurpP --minimal linux-3.4.103/net/core/sock.c linux-3.4.103-vs2.3.3.9/net/core/sock.c
24358 --- linux-3.4.103/net/core/sock.c 2014-08-30 13:37:20.000000000 +0000
24359 +++ linux-3.4.103-vs2.3.3.9/net/core/sock.c 2014-03-12 09:55:28.000000000 +0000
24360 @@ -129,6 +129,10 @@
24361 #include <net/netprio_cgroup.h>
24363 #include <linux/filter.h>
24364 +#include <linux/vs_socket.h>
24365 +#include <linux/vs_limit.h>
24366 +#include <linux/vs_context.h>
24367 +#include <linux/vs_network.h>
24369 #include <trace/events/sock.h>
24371 @@ -1141,6 +1145,8 @@ static struct sock *sk_prot_alloc(struct
24373 sk_tx_queue_clear(sk);
24375 + sock_vx_init(sk);
24376 + sock_nx_init(sk);
24380 @@ -1249,6 +1255,11 @@ static void __sk_free(struct sock *sk)
24381 put_cred(sk->sk_peer_cred);
24382 put_pid(sk->sk_peer_pid);
24383 put_net(sock_net(sk));
24385 + clr_vx_info(&sk->sk_vx_info);
24387 + clr_nx_info(&sk->sk_nx_info);
24389 sk_prot_free(sk->sk_prot_creator, sk);
24392 @@ -1309,6 +1320,8 @@ struct sock *sk_clone_lock(const struct
24395 get_net(sock_net(newsk));
24396 + sock_vx_init(newsk);
24397 + sock_nx_init(newsk);
24398 sk_node_init(&newsk->sk_node);
24399 sock_lock_init(newsk);
24400 bh_lock_sock(newsk);
24401 @@ -1365,6 +1378,12 @@ struct sock *sk_clone_lock(const struct
24403 atomic_set(&newsk->sk_refcnt, 2);
24405 + set_vx_info(&newsk->sk_vx_info, sk->sk_vx_info);
24406 + newsk->sk_xid = sk->sk_xid;
24407 + vx_sock_inc(newsk);
24408 + set_nx_info(&newsk->sk_nx_info, sk->sk_nx_info);
24409 + newsk->sk_nid = sk->sk_nid;
24412 * Increment the counter in the same struct proto as the master
24413 * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that
24414 @@ -2121,6 +2140,12 @@ void sock_init_data(struct socket *sock,
24416 sk->sk_stamp = ktime_set(-1L, 0);
24418 + set_vx_info(&sk->sk_vx_info, current_vx_info());
24419 + sk->sk_xid = vx_current_xid();
24421 + set_nx_info(&sk->sk_nx_info, current_nx_info());
24422 + sk->sk_nid = nx_current_nid();
24425 * Before updating sk_refcnt, we must commit prior changes to memory
24426 * (Documentation/RCU/rculist_nulls.txt for details)
24427 diff -NurpP --minimal linux-3.4.103/net/ipv4/af_inet.c linux-3.4.103-vs2.3.3.9/net/ipv4/af_inet.c
24428 --- linux-3.4.103/net/ipv4/af_inet.c 2014-08-30 13:37:20.000000000 +0000
24429 +++ linux-3.4.103-vs2.3.3.9/net/ipv4/af_inet.c 2013-03-02 15:26:44.000000000 +0000
24430 @@ -118,6 +118,7 @@
24431 #ifdef CONFIG_IP_MROUTE
24432 #include <linux/mroute.h>
24434 +#include <linux/vs_limit.h>
24437 /* The inetsw table contains everything that inet_create needs to
24438 @@ -332,9 +333,13 @@ lookup_protocol:
24442 + if ((protocol == IPPROTO_ICMP) &&
24443 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
24446 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
24447 goto out_rcu_unlock;
24450 err = -EAFNOSUPPORT;
24451 if (!inet_netns_ok(net, protocol))
24452 goto out_rcu_unlock;
24453 @@ -459,6 +464,7 @@ int inet_bind(struct socket *sock, struc
24454 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
24455 struct sock *sk = sock->sk;
24456 struct inet_sock *inet = inet_sk(sk);
24457 + struct nx_v4_sock_addr nsa;
24458 unsigned short snum;
24461 @@ -482,7 +488,11 @@ int inet_bind(struct socket *sock, struc
24465 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
24466 + err = v4_map_sock_addr(inet, addr, &nsa);
24470 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
24472 /* Not specified by any standard per-se, however it breaks too
24473 * many applications when removed. It is unfortunate since
24474 @@ -494,7 +504,7 @@ int inet_bind(struct socket *sock, struc
24475 err = -EADDRNOTAVAIL;
24476 if (!sysctl_ip_nonlocal_bind &&
24477 !(inet->freebind || inet->transparent) &&
24478 - addr->sin_addr.s_addr != htonl(INADDR_ANY) &&
24479 + nsa.saddr != htonl(INADDR_ANY) &&
24480 chk_addr_ret != RTN_LOCAL &&
24481 chk_addr_ret != RTN_MULTICAST &&
24482 chk_addr_ret != RTN_BROADCAST)
24483 @@ -519,7 +529,7 @@ int inet_bind(struct socket *sock, struc
24484 if (sk->sk_state != TCP_CLOSE || inet->inet_num)
24485 goto out_release_sock;
24487 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24488 + v4_set_sock_addr(inet, &nsa);
24489 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24490 inet->inet_saddr = 0; /* Use device */
24492 @@ -722,11 +732,13 @@ int inet_getname(struct socket *sock, st
24495 sin->sin_port = inet->inet_dport;
24496 - sin->sin_addr.s_addr = inet->inet_daddr;
24497 + sin->sin_addr.s_addr =
24498 + nx_map_sock_lback(sk->sk_nx_info, inet->inet_daddr);
24500 __be32 addr = inet->inet_rcv_saddr;
24502 addr = inet->inet_saddr;
24503 + addr = nx_map_sock_lback(sk->sk_nx_info, addr);
24504 sin->sin_port = inet->inet_sport;
24505 sin->sin_addr.s_addr = addr;
24507 diff -NurpP --minimal linux-3.4.103/net/ipv4/arp.c linux-3.4.103-vs2.3.3.9/net/ipv4/arp.c
24508 --- linux-3.4.103/net/ipv4/arp.c 2012-05-21 16:07:40.000000000 +0000
24509 +++ linux-3.4.103-vs2.3.3.9/net/ipv4/arp.c 2012-05-21 16:15:05.000000000 +0000
24510 @@ -1328,6 +1328,7 @@ static void arp_format_neigh_entry(struc
24511 struct net_device *dev = n->dev;
24512 int hatype = dev->type;
24514 + /* FIXME: check for network context */
24515 read_lock(&n->lock);
24516 /* Convert hardware address to XX:XX:XX:XX ... form. */
24517 #if IS_ENABLED(CONFIG_AX25)
24518 @@ -1359,6 +1360,7 @@ static void arp_format_pneigh_entry(stru
24519 int hatype = dev ? dev->type : 0;
24522 + /* FIXME: check for network context */
24523 sprintf(tbuf, "%pI4", n->key);
24524 seq_printf(seq, "%-16s 0x%-10x0x%-10x%s * %s\n",
24525 tbuf, hatype, ATF_PUBL | ATF_PERM, "00:00:00:00:00:00",
24526 diff -NurpP --minimal linux-3.4.103/net/ipv4/devinet.c linux-3.4.103-vs2.3.3.9/net/ipv4/devinet.c
24527 --- linux-3.4.103/net/ipv4/devinet.c 2012-05-21 16:07:40.000000000 +0000
24528 +++ linux-3.4.103-vs2.3.3.9/net/ipv4/devinet.c 2012-05-21 16:15:05.000000000 +0000
24529 @@ -517,6 +517,7 @@ struct in_device *inetdev_by_index(struc
24531 EXPORT_SYMBOL(inetdev_by_index);
24534 /* Called only from RTNL semaphored context. No locks. */
24536 struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix,
24537 @@ -758,6 +759,8 @@ int devinet_ioctl(struct net *net, unsig
24539 in_dev = __in_dev_get_rtnl(dev);
24541 + struct nx_info *nxi = current_nx_info();
24543 if (tryaddrmatch) {
24544 /* Matthias Andree */
24545 /* compare label and address (4.4BSD style) */
24546 @@ -766,6 +769,8 @@ int devinet_ioctl(struct net *net, unsig
24547 This is checked above. */
24548 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24549 ifap = &ifa->ifa_next) {
24550 + if (!nx_v4_ifa_visible(nxi, ifa))
24552 if (!strcmp(ifr.ifr_name, ifa->ifa_label) &&
24553 sin_orig.sin_addr.s_addr ==
24555 @@ -778,9 +783,12 @@ int devinet_ioctl(struct net *net, unsig
24556 comparing just the label */
24558 for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
24559 - ifap = &ifa->ifa_next)
24560 + ifap = &ifa->ifa_next) {
24561 + if (!nx_v4_ifa_visible(nxi, ifa))
24563 if (!strcmp(ifr.ifr_name, ifa->ifa_label))
24569 @@ -933,6 +941,8 @@ static int inet_gifconf(struct net_devic
24572 for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
24573 + if (!nx_v4_ifa_visible(current_nx_info(), ifa))
24576 done += sizeof(ifr);
24578 @@ -1294,6 +1304,7 @@ static int inet_dump_ifaddr(struct sk_bu
24579 struct net_device *dev;
24580 struct in_device *in_dev;
24581 struct in_ifaddr *ifa;
24582 + struct sock *sk = skb->sk;
24583 struct hlist_head *head;
24584 struct hlist_node *node;
24586 @@ -1316,6 +1327,8 @@ static int inet_dump_ifaddr(struct sk_bu
24588 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
24589 ifa = ifa->ifa_next, ip_idx++) {
24590 + if (sk && !nx_v4_ifa_visible(sk->sk_nx_info, ifa))
24592 if (ip_idx < s_ip_idx)
24594 if (inet_fill_ifaddr(skb, ifa,
24595 diff -NurpP --minimal linux-3.4.103/net/ipv4/fib_trie.c linux-3.4.103-vs2.3.3.9/net/ipv4/fib_trie.c
24596 --- linux-3.4.103/net/ipv4/fib_trie.c 2014-08-30 13:37:20.000000000 +0000
24597 +++ linux-3.4.103-vs2.3.3.9/net/ipv4/fib_trie.c 2013-10-26 18:10:23.000000000 +0000
24598 @@ -2553,6 +2553,7 @@ static int fib_route_seq_show(struct seq
24599 || fa->fa_type == RTN_MULTICAST)
24602 + /* FIXME: check for network context? */
24605 "%s\t%08X\t%08X\t%04X\t%d\t%u\t"
24606 diff -NurpP --minimal linux-3.4.103/net/ipv4/inet_connection_sock.c linux-3.4.103-vs2.3.3.9/net/ipv4/inet_connection_sock.c
24607 --- linux-3.4.103/net/ipv4/inet_connection_sock.c 2014-08-30 13:37:20.000000000 +0000
24608 +++ linux-3.4.103-vs2.3.3.9/net/ipv4/inet_connection_sock.c 2013-01-16 00:15:57.000000000 +0000
24609 @@ -52,6 +52,37 @@ void inet_get_local_port_range(int *low,
24611 EXPORT_SYMBOL(inet_get_local_port_range);
24613 +int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
24615 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1),
24616 + sk2_rcv_saddr = sk_rcv_saddr(sk2);
24618 + if (inet_v6_ipv6only(sk2))
24621 + if (sk1_rcv_saddr &&
24623 + sk1_rcv_saddr == sk2_rcv_saddr)
24626 + if (sk1_rcv_saddr &&
24627 + !sk2_rcv_saddr &&
24628 + v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, NXA_MASK_BIND))
24631 + if (sk2_rcv_saddr &&
24632 + !sk1_rcv_saddr &&
24633 + v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, NXA_MASK_BIND))
24636 + if (!sk1_rcv_saddr &&
24637 + !sk2_rcv_saddr &&
24638 + nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info))
24644 int inet_csk_bind_conflict(const struct sock *sk,
24645 const struct inet_bind_bucket *tb)
24647 @@ -74,9 +105,7 @@ int inet_csk_bind_conflict(const struct
24648 sk->sk_bound_dev_if == sk2->sk_bound_dev_if)) {
24649 if (!reuse || !sk2->sk_reuse ||
24650 sk2->sk_state == TCP_LISTEN) {
24651 - const __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
24652 - if (!sk2_rcv_saddr || !sk_rcv_saddr(sk) ||
24653 - sk2_rcv_saddr == sk_rcv_saddr(sk))
24654 + if (ipv4_rcv_saddr_equal(sk, sk2))
24658 diff -NurpP --minimal linux-3.4.103/net/ipv4/inet_diag.c linux-3.4.103-vs2.3.3.9/net/ipv4/inet_diag.c
24659 --- linux-3.4.103/net/ipv4/inet_diag.c 2014-08-30 13:37:20.000000000 +0000
24660 +++ linux-3.4.103-vs2.3.3.9/net/ipv4/inet_diag.c 2014-03-12 09:58:38.000000000 +0000
24663 #include <linux/inet.h>
24664 #include <linux/stddef.h>
24665 +#include <linux/vs_network.h>
24666 +#include <linux/vs_inet.h>
24668 #include <linux/inet_diag.h>
24669 #include <linux/sock_diag.h>
24670 @@ -114,8 +116,10 @@ int inet_sk_diag_fill(struct sock *sk, s
24671 memset(&r->id.idiag_src, 0, sizeof(r->id.idiag_src));
24672 memset(&r->id.idiag_dst, 0, sizeof(r->id.idiag_dst));
24674 - r->id.idiag_src[0] = inet->inet_rcv_saddr;
24675 - r->id.idiag_dst[0] = inet->inet_daddr;
24676 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info,
24677 + inet->inet_rcv_saddr);
24678 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info,
24679 + inet->inet_daddr);
24681 /* IPv6 dual-stack sockets use inet->tos for IPv4 connections,
24682 * hence this needs to be included regardless of socket family.
24683 @@ -241,8 +245,8 @@ static int inet_twsk_diag_fill(struct in
24684 memset(&r->id.idiag_src, 0, sizeof(r->id.idiag_src));
24685 memset(&r->id.idiag_dst, 0, sizeof(r->id.idiag_dst));
24687 - r->id.idiag_src[0] = tw->tw_rcv_saddr;
24688 - r->id.idiag_dst[0] = tw->tw_daddr;
24689 + r->id.idiag_src[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_rcv_saddr);
24690 + r->id.idiag_dst[0] = nx_map_sock_lback(tw->tw_nx_info, tw->tw_daddr);
24692 r->idiag_state = tw->tw_substate;
24693 r->idiag_timer = 3;
24694 @@ -287,12 +291,14 @@ int inet_diag_dump_one_icsk(struct inet_
24697 if (req->sdiag_family == AF_INET) {
24698 + /* TODO: lback */
24699 sk = inet_lookup(&init_net, hashinfo, req->id.idiag_dst[0],
24700 req->id.idiag_dport, req->id.idiag_src[0],
24701 req->id.idiag_sport, req->id.idiag_if);
24703 #if IS_ENABLED(CONFIG_IPV6)
24704 else if (req->sdiag_family == AF_INET6) {
24705 + /* TODO: lback */
24706 sk = inet6_lookup(&init_net, hashinfo,
24707 (struct in6_addr *)req->id.idiag_dst,
24708 req->id.idiag_dport,
24709 @@ -493,6 +499,7 @@ int inet_diag_bc_sk(const struct nlattr
24713 + /* TODO: lback */
24714 entry.saddr = &inet->inet_rcv_saddr;
24715 entry.daddr = &inet->inet_daddr;
24717 @@ -650,6 +657,7 @@ static int inet_twsk_diag_dump(struct in
24721 + /* TODO: lback */
24722 entry.saddr = &tw->tw_rcv_saddr;
24723 entry.daddr = &tw->tw_daddr;
24725 @@ -729,8 +737,8 @@ static int inet_diag_fill_req(struct sk_
24726 memset(&r->id.idiag_src, 0, sizeof(r->id.idiag_src));
24727 memset(&r->id.idiag_dst, 0, sizeof(r->id.idiag_dst));
24729 - r->id.idiag_src[0] = ireq->loc_addr;
24730 - r->id.idiag_dst[0] = ireq->rmt_addr;
24731 + r->id.idiag_src[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->loc_addr);
24732 + r->id.idiag_dst[0] = nx_map_sock_lback(sk->sk_nx_info, ireq->rmt_addr);
24734 r->idiag_expires = jiffies_to_msecs(tmo);
24735 r->idiag_rqueue = 0;
24736 @@ -800,6 +808,7 @@ static int inet_diag_dump_reqs(struct sk
24740 + /* TODO: lback */
24741 inet_diag_req_addrs(sk, req, &entry);
24742 entry.dport = ntohs(ireq->rmt_port);
24744 @@ -850,6 +859,8 @@ void inet_diag_dump_icsk(struct inet_has
24745 sk_nulls_for_each(sk, node, &ilb->head) {
24746 struct inet_sock *inet = inet_sk(sk);
24748 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24753 @@ -920,6 +931,8 @@ skip_listen_ht:
24754 sk_nulls_for_each(sk, node, &head->chain) {
24755 struct inet_sock *inet = inet_sk(sk);
24757 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24761 if (!(r->idiag_states & (1 << sk->sk_state)))
24762 @@ -947,6 +960,8 @@ next_normal:
24763 inet_twsk_for_each(tw, node,
24766 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
24770 if (!(r->idiag_states & (1 << tw->tw_substate)))
24771 diff -NurpP --minimal linux-3.4.103/net/ipv4/inet_hashtables.c linux-3.4.103-vs2.3.3.9/net/ipv4/inet_hashtables.c
24772 --- linux-3.4.103/net/ipv4/inet_hashtables.c 2014-08-30 13:37:20.000000000 +0000
24773 +++ linux-3.4.103-vs2.3.3.9/net/ipv4/inet_hashtables.c 2014-03-12 09:55:28.000000000 +0000
24775 #include <net/inet_connection_sock.h>
24776 #include <net/inet_hashtables.h>
24777 #include <net/secure_seq.h>
24778 +#include <net/route.h>
24779 #include <net/ip.h>
24782 @@ -156,6 +157,11 @@ static inline int compute_score(struct s
24783 if (rcv_saddr != daddr)
24787 + /* block non nx_info ips */
24788 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
24789 + daddr, NXA_MASK_BIND))
24792 if (sk->sk_bound_dev_if) {
24793 if (sk->sk_bound_dev_if != dif)
24794 @@ -173,7 +179,6 @@ static inline int compute_score(struct s
24795 * wildcarded during the search since they can never be otherwise.
24799 struct sock *__inet_lookup_listener(struct net *net,
24800 struct inet_hashinfo *hashinfo,
24801 const __be32 daddr, const unsigned short hnum,
24802 @@ -196,6 +201,7 @@ begin:
24808 * if the nulls value we got at the end of this lookup is
24809 * not the expected one, we must restart lookup.
24810 diff -NurpP --minimal linux-3.4.103/net/ipv4/netfilter/nf_nat_helper.c linux-3.4.103-vs2.3.3.9/net/ipv4/netfilter/nf_nat_helper.c
24811 --- linux-3.4.103/net/ipv4/netfilter/nf_nat_helper.c 2012-03-19 18:47:33.000000000 +0000
24812 +++ linux-3.4.103-vs2.3.3.9/net/ipv4/netfilter/nf_nat_helper.c 2012-05-21 16:15:05.000000000 +0000
24814 #include <net/route.h>
24816 #include <linux/netfilter_ipv4.h>
24817 +#include <net/route.h>
24818 #include <net/netfilter/nf_conntrack.h>
24819 #include <net/netfilter/nf_conntrack_helper.h>
24820 #include <net/netfilter/nf_conntrack_ecache.h>
24821 diff -NurpP --minimal linux-3.4.103/net/ipv4/netfilter.c linux-3.4.103-vs2.3.3.9/net/ipv4/netfilter.c
24822 --- linux-3.4.103/net/ipv4/netfilter.c 2012-01-09 15:15:03.000000000 +0000
24823 +++ linux-3.4.103-vs2.3.3.9/net/ipv4/netfilter.c 2012-05-21 16:15:05.000000000 +0000
24825 #include <linux/skbuff.h>
24826 #include <linux/gfp.h>
24827 #include <linux/export.h>
24828 -#include <net/route.h>
24829 +// #include <net/route.h>
24830 #include <net/xfrm.h>
24831 #include <net/ip.h>
24832 #include <net/netfilter/nf_queue.h>
24833 diff -NurpP --minimal linux-3.4.103/net/ipv4/raw.c linux-3.4.103-vs2.3.3.9/net/ipv4/raw.c
24834 --- linux-3.4.103/net/ipv4/raw.c 2014-08-30 13:37:21.000000000 +0000
24835 +++ linux-3.4.103-vs2.3.3.9/net/ipv4/raw.c 2014-08-30 13:55:47.000000000 +0000
24836 @@ -118,7 +118,7 @@ static struct sock *__raw_v4_lookup(stru
24838 if (net_eq(sock_net(sk), net) && inet->inet_num == num &&
24839 !(inet->inet_daddr && inet->inet_daddr != raddr) &&
24840 - !(inet->inet_rcv_saddr && inet->inet_rcv_saddr != laddr) &&
24841 + v4_sock_addr_match(sk->sk_nx_info, inet, laddr) &&
24842 !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
24843 goto found; /* gotcha */
24845 @@ -392,6 +392,12 @@ static int raw_send_hdrinc(struct sock *
24846 icmp_out_count(net, ((struct icmphdr *)
24847 skb_transport_header(skb))->type);
24850 + if (!nx_check(0, VS_ADMIN) && !capable(CAP_NET_RAW) &&
24851 + sk->sk_nx_info &&
24852 + !v4_addr_in_nx_info(sk->sk_nx_info, iph->saddr, NXA_MASK_BIND))
24855 err = NF_HOOK(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL,
24856 rt->dst.dev, dst_output);
24858 @@ -577,6 +583,16 @@ static int raw_sendmsg(struct kiocb *ioc
24862 + if (sk->sk_nx_info) {
24863 + rt = ip_v4_find_src(sock_net(sk), sk->sk_nx_info, &fl4);
24864 + if (IS_ERR(rt)) {
24865 + err = PTR_ERR(rt);
24872 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4));
24873 rt = ip_route_output_flow(sock_net(sk), &fl4, sk);
24875 @@ -653,17 +669,19 @@ static int raw_bind(struct sock *sk, str
24877 struct inet_sock *inet = inet_sk(sk);
24878 struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
24879 + struct nx_v4_sock_addr nsa = { 0 };
24883 if (sk->sk_state != TCP_CLOSE || addr_len < sizeof(struct sockaddr_in))
24885 - chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr);
24886 + v4_map_sock_addr(inet, addr, &nsa);
24887 + chk_addr_ret = inet_addr_type(sock_net(sk), nsa.saddr);
24888 ret = -EADDRNOTAVAIL;
24889 - if (addr->sin_addr.s_addr && chk_addr_ret != RTN_LOCAL &&
24890 + if (nsa.saddr && chk_addr_ret != RTN_LOCAL &&
24891 chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST)
24893 - inet->inet_rcv_saddr = inet->inet_saddr = addr->sin_addr.s_addr;
24894 + v4_set_sock_addr(inet, &nsa);
24895 if (chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST)
24896 inet->inet_saddr = 0; /* Use device */
24898 @@ -712,7 +730,8 @@ static int raw_recvmsg(struct kiocb *ioc
24899 /* Copy the address. */
24901 sin->sin_family = AF_INET;
24902 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
24903 + sin->sin_addr.s_addr =
24904 + nx_map_sock_lback(sk->sk_nx_info, ip_hdr(skb)->saddr);
24906 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
24907 *addr_len = sizeof(*sin);
24908 @@ -909,7 +928,8 @@ static struct sock *raw_get_first(struct
24909 struct hlist_node *node;
24911 sk_for_each(sk, node, &state->h->ht[state->bucket])
24912 - if (sock_net(sk) == seq_file_net(seq))
24913 + if ((sock_net(sk) == seq_file_net(seq)) &&
24914 + nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24918 @@ -925,7 +945,8 @@ static struct sock *raw_get_next(struct
24922 - } while (sk && sock_net(sk) != seq_file_net(seq));
24923 + } while (sk && ((sock_net(sk) != seq_file_net(seq)) ||
24924 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
24926 if (!sk && ++state->bucket < RAW_HTABLE_SIZE) {
24927 sk = sk_head(&state->h->ht[state->bucket]);
24928 diff -NurpP --minimal linux-3.4.103/net/ipv4/route.c linux-3.4.103-vs2.3.3.9/net/ipv4/route.c
24929 --- linux-3.4.103/net/ipv4/route.c 2014-08-30 13:37:21.000000000 +0000
24930 +++ linux-3.4.103-vs2.3.3.9/net/ipv4/route.c 2014-08-30 13:55:47.000000000 +0000
24931 @@ -2703,7 +2703,7 @@ static struct rtable *ip_route_output_sl
24934 if (fl4->flowi4_oif) {
24935 - dev_out = dev_get_by_index_rcu(net, fl4->flowi4_oif);
24936 + dev_out = dev_get_by_index_real_rcu(net, fl4->flowi4_oif);
24937 rth = ERR_PTR(-ENODEV);
24938 if (dev_out == NULL)
24940 diff -NurpP --minimal linux-3.4.103/net/ipv4/tcp.c linux-3.4.103-vs2.3.3.9/net/ipv4/tcp.c
24941 --- linux-3.4.103/net/ipv4/tcp.c 2014-08-30 13:37:21.000000000 +0000
24942 +++ linux-3.4.103-vs2.3.3.9/net/ipv4/tcp.c 2013-07-14 13:38:37.000000000 +0000
24943 @@ -268,6 +268,7 @@
24944 #include <linux/crypto.h>
24945 #include <linux/time.h>
24946 #include <linux/slab.h>
24947 +#include <linux/in.h>
24949 #include <net/icmp.h>
24950 #include <net/tcp.h>
24951 diff -NurpP --minimal linux-3.4.103/net/ipv4/tcp_ipv4.c linux-3.4.103-vs2.3.3.9/net/ipv4/tcp_ipv4.c
24952 --- linux-3.4.103/net/ipv4/tcp_ipv4.c 2014-08-30 13:37:21.000000000 +0000
24953 +++ linux-3.4.103-vs2.3.3.9/net/ipv4/tcp_ipv4.c 2014-03-12 09:55:28.000000000 +0000
24954 @@ -2037,6 +2037,12 @@ static void *listening_get_next(struct s
24955 req = req->dl_next;
24958 + vxdprintk(VXD_CBIT(net, 6),
24959 + "sk,req: %p [#%d] (from %d)", req->sk,
24960 + (req->sk)?req->sk->sk_nid:0, nx_current_nid());
24962 + !nx_check(req->sk->sk_nid, VS_WATCH_P | VS_IDENT))
24964 if (req->rsk_ops->family == st->family) {
24967 @@ -2061,6 +2067,10 @@ get_req:
24970 sk_nulls_for_each_from(sk, node) {
24971 + vxdprintk(VXD_CBIT(net, 6), "sk: %p [#%d] (from %d)",
24972 + sk, sk->sk_nid, nx_current_nid());
24973 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24975 if (!net_eq(sock_net(sk), net))
24977 if (sk->sk_family == st->family) {
24978 @@ -2137,6 +2147,11 @@ static void *established_get_first(struc
24980 spin_lock_bh(lock);
24981 sk_nulls_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
24982 + vxdprintk(VXD_CBIT(net, 6),
24983 + "sk,egf: %p [#%d] (from %d)",
24984 + sk, sk->sk_nid, nx_current_nid());
24985 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
24987 if (sk->sk_family != st->family ||
24988 !net_eq(sock_net(sk), net)) {
24990 @@ -2147,6 +2162,11 @@ static void *established_get_first(struc
24991 st->state = TCP_SEQ_STATE_TIME_WAIT;
24992 inet_twsk_for_each(tw, node,
24993 &tcp_hashinfo.ehash[st->bucket].twchain) {
24994 + vxdprintk(VXD_CBIT(net, 6),
24995 + "tw: %p [#%d] (from %d)",
24996 + tw, tw->tw_nid, nx_current_nid());
24997 + if (!nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))
24999 if (tw->tw_family != st->family ||
25000 !net_eq(twsk_net(tw), net)) {
25002 @@ -2176,7 +2196,9 @@ static void *established_get_next(struct
25006 - while (tw && (tw->tw_family != st->family || !net_eq(twsk_net(tw), net))) {
25007 + while (tw && (tw->tw_family != st->family ||
25008 + !net_eq(twsk_net(tw), net) ||
25009 + !nx_check(tw->tw_nid, VS_WATCH_P | VS_IDENT))) {
25013 @@ -2200,6 +2222,11 @@ get_tw:
25014 sk = sk_nulls_next(sk);
25016 sk_nulls_for_each_from(sk, node) {
25017 + vxdprintk(VXD_CBIT(net, 6),
25018 + "sk,egn: %p [#%d] (from %d)",
25019 + sk, sk->sk_nid, nx_current_nid());
25020 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25022 if (sk->sk_family == st->family && net_eq(sock_net(sk), net))
25025 @@ -2405,9 +2432,9 @@ static void get_openreq4(const struct so
25026 seq_printf(f, "%4d: %08X:%04X %08X:%04X"
25027 " %02X %08X:%08X %02X:%08lX %08X %5d %8d %u %d %pK%n",
25030 + nx_map_sock_lback(current_nx_info(), ireq->loc_addr),
25031 ntohs(inet_sk(sk)->inet_sport),
25033 + nx_map_sock_lback(current_nx_info(), ireq->rmt_addr),
25034 ntohs(ireq->rmt_port),
25036 0, 0, /* could print option size, but that is af dependent. */
25037 @@ -2429,8 +2456,8 @@ static void get_tcp4_sock(struct sock *s
25038 const struct tcp_sock *tp = tcp_sk(sk);
25039 const struct inet_connection_sock *icsk = inet_csk(sk);
25040 const struct inet_sock *inet = inet_sk(sk);
25041 - __be32 dest = inet->inet_daddr;
25042 - __be32 src = inet->inet_rcv_saddr;
25043 + __be32 dest = nx_map_sock_lback(current_nx_info(), inet->inet_daddr);
25044 + __be32 src = nx_map_sock_lback(current_nx_info(), inet->inet_rcv_saddr);
25045 __u16 destp = ntohs(inet->inet_dport);
25046 __u16 srcp = ntohs(inet->inet_sport);
25048 @@ -2487,8 +2514,8 @@ static void get_timewait4_sock(const str
25052 - dest = tw->tw_daddr;
25053 - src = tw->tw_rcv_saddr;
25054 + dest = nx_map_sock_lback(current_nx_info(), tw->tw_daddr);
25055 + src = nx_map_sock_lback(current_nx_info(), tw->tw_rcv_saddr);
25056 destp = ntohs(tw->tw_dport);
25057 srcp = ntohs(tw->tw_sport);
25059 diff -NurpP --minimal linux-3.4.103/net/ipv4/tcp_minisocks.c linux-3.4.103-vs2.3.3.9/net/ipv4/tcp_minisocks.c
25060 --- linux-3.4.103/net/ipv4/tcp_minisocks.c 2012-05-21 16:07:40.000000000 +0000
25061 +++ linux-3.4.103-vs2.3.3.9/net/ipv4/tcp_minisocks.c 2012-05-21 16:15:05.000000000 +0000
25063 #include <linux/slab.h>
25064 #include <linux/sysctl.h>
25065 #include <linux/workqueue.h>
25066 +#include <linux/vs_limit.h>
25067 +#include <linux/vs_socket.h>
25068 +#include <linux/vs_context.h>
25069 #include <net/tcp.h>
25070 #include <net/inet_common.h>
25071 #include <net/xfrm.h>
25072 @@ -336,6 +339,11 @@ void tcp_time_wait(struct sock *sk, int
25073 tcptw->tw_ts_recent = tp->rx_opt.ts_recent;
25074 tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp;
25076 + tw->tw_xid = sk->sk_xid;
25077 + tw->tw_vx_info = NULL;
25078 + tw->tw_nid = sk->sk_nid;
25079 + tw->tw_nx_info = NULL;
25081 #if IS_ENABLED(CONFIG_IPV6)
25082 if (tw->tw_family == PF_INET6) {
25083 struct ipv6_pinfo *np = inet6_sk(sk);
25084 diff -NurpP --minimal linux-3.4.103/net/ipv4/udp.c linux-3.4.103-vs2.3.3.9/net/ipv4/udp.c
25085 --- linux-3.4.103/net/ipv4/udp.c 2014-08-30 13:37:22.000000000 +0000
25086 +++ linux-3.4.103-vs2.3.3.9/net/ipv4/udp.c 2014-03-12 09:55:28.000000000 +0000
25087 @@ -298,14 +298,7 @@ fail:
25089 EXPORT_SYMBOL(udp_lib_get_port);
25091 -static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25093 - struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2);
25095 - return (!ipv6_only_sock(sk2) &&
25096 - (!inet1->inet_rcv_saddr || !inet2->inet_rcv_saddr ||
25097 - inet1->inet_rcv_saddr == inet2->inet_rcv_saddr));
25099 +extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
25101 static unsigned int udp4_portaddr_hash(struct net *net, __be32 saddr,
25103 @@ -340,6 +333,11 @@ static inline int compute_score(struct s
25104 if (inet->inet_rcv_saddr != daddr)
25108 + /* block non nx_info ips */
25109 + if (!v4_addr_in_nx_info(sk->sk_nx_info,
25110 + daddr, NXA_MASK_BIND))
25113 if (inet->inet_daddr) {
25114 if (inet->inet_daddr != saddr)
25115 @@ -443,6 +441,7 @@ exact_match:
25120 /* UDP is nearly always wildcards out the wazoo, it makes no sense to try
25121 * harder than this. -DaveM
25123 @@ -488,6 +487,11 @@ begin:
25124 sk_nulls_for_each_rcu(sk, node, &hslot->head) {
25125 score = compute_score(sk, net, saddr, hnum, sport,
25126 daddr, dport, dif);
25127 + /* FIXME: disabled?
25128 + if (score == 9) {
25132 if (score > badness) {
25135 @@ -501,6 +505,7 @@ begin:
25136 if (get_nulls_value(node) != slot)
25141 if (unlikely(!atomic_inc_not_zero_hint(&result->sk_refcnt, 2)))
25143 @@ -510,6 +515,7 @@ begin:
25151 @@ -553,8 +559,7 @@ static inline struct sock *udp_v4_mcast_
25152 udp_sk(s)->udp_port_hash != hnum ||
25153 (inet->inet_daddr && inet->inet_daddr != rmt_addr) ||
25154 (inet->inet_dport != rmt_port && inet->inet_dport) ||
25155 - (inet->inet_rcv_saddr &&
25156 - inet->inet_rcv_saddr != loc_addr) ||
25157 + !v4_sock_addr_match(sk->sk_nx_info, inet, loc_addr) ||
25158 ipv6_only_sock(s) ||
25159 (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
25161 @@ -934,6 +939,16 @@ int udp_sendmsg(struct kiocb *iocb, stru
25162 inet_sk_flowi_flags(sk)|FLOWI_FLAG_CAN_SLEEP,
25163 faddr, saddr, dport, inet->inet_sport);
25165 + if (sk->sk_nx_info) {
25166 + rt = ip_v4_find_src(net, sk->sk_nx_info, fl4);
25167 + if (IS_ERR(rt)) {
25168 + err = PTR_ERR(rt);
25175 security_sk_classify_flow(sk, flowi4_to_flowi(fl4));
25176 rt = ip_route_output_flow(net, fl4, sk);
25178 @@ -1229,7 +1244,8 @@ try_again:
25180 sin->sin_family = AF_INET;
25181 sin->sin_port = udp_hdr(skb)->source;
25182 - sin->sin_addr.s_addr = ip_hdr(skb)->saddr;
25183 + sin->sin_addr.s_addr = nx_map_sock_lback(
25184 + skb->sk->sk_nx_info, ip_hdr(skb)->saddr);
25185 memset(sin->sin_zero, 0, sizeof(sin->sin_zero));
25186 *addr_len = sizeof(*sin);
25188 @@ -1969,6 +1985,8 @@ static struct sock *udp_get_first(struct
25189 sk_nulls_for_each(sk, node, &hslot->head) {
25190 if (!net_eq(sock_net(sk), net))
25192 + if (!nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT))
25194 if (sk->sk_family == state->family)
25197 @@ -1986,7 +2004,9 @@ static struct sock *udp_get_next(struct
25200 sk = sk_nulls_next(sk);
25201 - } while (sk && (!net_eq(sock_net(sk), net) || sk->sk_family != state->family));
25202 + } while (sk && (!net_eq(sock_net(sk), net) ||
25203 + sk->sk_family != state->family ||
25204 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)));
25207 if (state->bucket <= state->udp_table->mask)
25208 @@ -2082,8 +2102,8 @@ static void udp4_format_sock(struct sock
25209 int bucket, int *len)
25211 struct inet_sock *inet = inet_sk(sp);
25212 - __be32 dest = inet->inet_daddr;
25213 - __be32 src = inet->inet_rcv_saddr;
25214 + __be32 dest = nx_map_sock_lback(current_nx_info(), inet->inet_daddr);
25215 + __be32 src = nx_map_sock_lback(current_nx_info(), inet->inet_rcv_saddr);
25216 __u16 destp = ntohs(inet->inet_dport);
25217 __u16 srcp = ntohs(inet->inet_sport);
25219 diff -NurpP --minimal linux-3.4.103/net/ipv6/Kconfig linux-3.4.103-vs2.3.3.9/net/ipv6/Kconfig
25220 --- linux-3.4.103/net/ipv6/Kconfig 2010-08-02 14:52:59.000000000 +0000
25221 +++ linux-3.4.103-vs2.3.3.9/net/ipv6/Kconfig 2012-05-21 16:15:05.000000000 +0000
25224 # IPv6 as module will cause a CRASH if you try to unload it
25226 - tristate "The IPv6 protocol"
25228 + bool "The IPv6 protocol"
25231 This is complemental support for the IP version 6.
25232 You will still be able to do traditional IPv4 networking as well.
25233 diff -NurpP --minimal linux-3.4.103/net/ipv6/addrconf.c linux-3.4.103-vs2.3.3.9/net/ipv6/addrconf.c
25234 --- linux-3.4.103/net/ipv6/addrconf.c 2014-08-30 13:37:22.000000000 +0000
25235 +++ linux-3.4.103-vs2.3.3.9/net/ipv6/addrconf.c 2014-08-30 13:55:47.000000000 +0000
25237 #include <linux/proc_fs.h>
25238 #include <linux/seq_file.h>
25239 #include <linux/export.h>
25240 +#include <linux/vs_network.h>
25241 +#include <linux/vs_inet6.h>
25243 /* Set to 3 to get tracing... */
25244 #define ACONF_DEBUG 2
25245 @@ -1109,7 +1111,7 @@ out:
25247 int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev,
25248 const struct in6_addr *daddr, unsigned int prefs,
25249 - struct in6_addr *saddr)
25250 + struct in6_addr *saddr, struct nx_info *nxi)
25252 struct ipv6_saddr_score scores[2],
25253 *score = &scores[0], *hiscore = &scores[1];
25254 @@ -1181,6 +1183,8 @@ int ipv6_dev_get_saddr(struct net *net,
25258 + if (!v6_addr_in_nx_info(nxi, &score->ifa->addr, -1))
25262 bitmap_zero(score->scorebits, IPV6_SADDR_RULE_MAX);
25263 @@ -3217,7 +3221,10 @@ static void if6_seq_stop(struct seq_file
25264 static int if6_seq_show(struct seq_file *seq, void *v)
25266 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v;
25267 - seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25269 + if (nx_check(0, VS_ADMIN|VS_WATCH) ||
25270 + v6_addr_in_nx_info(current_nx_info(), &ifp->addr, -1))
25271 + seq_printf(seq, "%pi6 %02x %02x %02x %02x %8s\n",
25273 ifp->idev->dev->ifindex,
25275 @@ -3723,6 +3730,11 @@ static int in6_dump_addrs(struct inet6_d
25276 struct ifacaddr6 *ifaca;
25278 int ip_idx = *p_ip_idx;
25279 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25281 + /* disable ipv6 on non v6 guests */
25282 + if (nxi && !nx_info_has_v6(nxi))
25285 read_lock_bh(&idev->lock);
25287 @@ -3733,6 +3745,8 @@ static int in6_dump_addrs(struct inet6_d
25288 list_for_each_entry(ifa, &idev->addr_list, if_list) {
25289 if (++ip_idx < s_ip_idx)
25291 + if (!v6_addr_in_nx_info(nxi, &ifa->addr, -1))
25293 err = inet6_fill_ifaddr(skb, ifa,
25294 NETLINK_CB(cb->skb).pid,
25295 cb->nlh->nlmsg_seq,
25296 @@ -3749,6 +3763,8 @@ static int in6_dump_addrs(struct inet6_d
25297 ifmca = ifmca->next, ip_idx++) {
25298 if (ip_idx < s_ip_idx)
25300 + if (!v6_addr_in_nx_info(nxi, &ifmca->mca_addr, -1))
25302 err = inet6_fill_ifmcaddr(skb, ifmca,
25303 NETLINK_CB(cb->skb).pid,
25304 cb->nlh->nlmsg_seq,
25305 @@ -3764,6 +3780,8 @@ static int in6_dump_addrs(struct inet6_d
25306 ifaca = ifaca->aca_next, ip_idx++) {
25307 if (ip_idx < s_ip_idx)
25309 + if (!v6_addr_in_nx_info(nxi, &ifaca->aca_addr, -1))
25311 err = inet6_fill_ifacaddr(skb, ifaca,
25312 NETLINK_CB(cb->skb).pid,
25313 cb->nlh->nlmsg_seq,
25314 @@ -4149,6 +4167,11 @@ static int inet6_dump_ifinfo(struct sk_b
25315 struct inet6_dev *idev;
25316 struct hlist_head *head;
25317 struct hlist_node *node;
25318 + struct nx_info *nxi = skb->sk ? skb->sk->sk_nx_info : NULL;
25320 + /* FIXME: maybe disable ipv6 on non v6 guests?
25321 + if (skb->sk && skb->sk->sk_vx_info)
25322 + return skb->len; */
25325 s_idx = cb->args[1];
25326 @@ -4160,6 +4183,8 @@ static int inet6_dump_ifinfo(struct sk_b
25327 hlist_for_each_entry_rcu(dev, node, head, index_hlist) {
25330 + if (!v6_dev_in_nx_info(dev, nxi))
25332 idev = __in6_dev_get(dev);
25335 diff -NurpP --minimal linux-3.4.103/net/ipv6/af_inet6.c linux-3.4.103-vs2.3.3.9/net/ipv6/af_inet6.c
25336 --- linux-3.4.103/net/ipv6/af_inet6.c 2012-05-21 16:07:40.000000000 +0000
25337 +++ linux-3.4.103-vs2.3.3.9/net/ipv6/af_inet6.c 2012-09-01 09:15:04.000000000 +0000
25339 #include <linux/netdevice.h>
25340 #include <linux/icmpv6.h>
25341 #include <linux/netfilter_ipv6.h>
25342 +#include <linux/vs_inet.h>
25343 +#include <linux/vs_inet6.h>
25345 #include <net/ip.h>
25346 #include <net/ipv6.h>
25347 @@ -159,9 +161,12 @@ lookup_protocol:
25351 + if ((protocol == IPPROTO_ICMPV6) &&
25352 + nx_capable(CAP_NET_RAW, NXC_RAW_ICMP))
25354 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
25355 goto out_rcu_unlock;
25358 sock->ops = answer->ops;
25359 answer_prot = answer->prot;
25360 answer_no_check = answer->no_check;
25361 @@ -261,6 +266,7 @@ int inet6_bind(struct socket *sock, stru
25362 struct inet_sock *inet = inet_sk(sk);
25363 struct ipv6_pinfo *np = inet6_sk(sk);
25364 struct net *net = sock_net(sk);
25365 + struct nx_v6_sock_addr nsa;
25367 unsigned short snum;
25369 @@ -276,6 +282,10 @@ int inet6_bind(struct socket *sock, stru
25370 if (addr->sin6_family != AF_INET6)
25371 return -EAFNOSUPPORT;
25373 + err = v6_map_sock_addr(inet, addr, &nsa);
25377 addr_type = ipv6_addr_type(&addr->sin6_addr);
25378 if ((addr_type & IPV6_ADDR_MULTICAST) && sock->type == SOCK_STREAM)
25380 @@ -307,6 +317,7 @@ int inet6_bind(struct socket *sock, stru
25381 /* Reproduce AF_INET checks to make the bindings consistent */
25382 v4addr = addr->sin6_addr.s6_addr32[3];
25383 chk_addr_ret = inet_addr_type(net, v4addr);
25385 if (!sysctl_ip_nonlocal_bind &&
25386 !(inet->freebind || inet->transparent) &&
25387 v4addr != htonl(INADDR_ANY) &&
25388 @@ -316,6 +327,10 @@ int inet6_bind(struct socket *sock, stru
25389 err = -EADDRNOTAVAIL;
25392 + if (!v4_addr_in_nx_info(sk->sk_nx_info, v4addr, NXA_MASK_BIND)) {
25393 + err = -EADDRNOTAVAIL;
25397 if (addr_type != IPV6_ADDR_ANY) {
25398 struct net_device *dev = NULL;
25399 @@ -342,6 +357,11 @@ int inet6_bind(struct socket *sock, stru
25403 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25404 + err = -EADDRNOTAVAIL;
25408 /* ipv4 addr of the socket is invalid. Only the
25409 * unspecified and mapped address have a v4 equivalent.
25411 @@ -358,6 +378,9 @@ int inet6_bind(struct socket *sock, stru
25415 + /* what's that for? */
25416 + v6_set_sock_addr(inet, &nsa);
25418 inet->inet_rcv_saddr = v4addr;
25419 inet->inet_saddr = v4addr;
25421 @@ -459,9 +482,11 @@ int inet6_getname(struct socket *sock, s
25423 sin->sin6_port = inet->inet_dport;
25424 sin->sin6_addr = np->daddr;
25425 + /* FIXME: remap lback? */
25427 sin->sin6_flowinfo = np->flow_label;
25429 + /* FIXME: remap lback? */
25430 if (ipv6_addr_any(&np->rcv_saddr))
25431 sin->sin6_addr = np->saddr;
25433 diff -NurpP --minimal linux-3.4.103/net/ipv6/datagram.c linux-3.4.103-vs2.3.3.9/net/ipv6/datagram.c
25434 --- linux-3.4.103/net/ipv6/datagram.c 2014-08-30 13:37:22.000000000 +0000
25435 +++ linux-3.4.103-vs2.3.3.9/net/ipv6/datagram.c 2014-03-12 09:55:28.000000000 +0000
25436 @@ -646,7 +646,7 @@ int datagram_send_ctl(struct net *net, s
25439 if (fl6->flowi6_oif) {
25440 - dev = dev_get_by_index_rcu(net, fl6->flowi6_oif);
25441 + dev = dev_get_by_index_real_rcu(net, fl6->flowi6_oif);
25445 diff -NurpP --minimal linux-3.4.103/net/ipv6/fib6_rules.c linux-3.4.103-vs2.3.3.9/net/ipv6/fib6_rules.c
25446 --- linux-3.4.103/net/ipv6/fib6_rules.c 2012-03-19 18:47:33.000000000 +0000
25447 +++ linux-3.4.103-vs2.3.3.9/net/ipv6/fib6_rules.c 2012-05-21 16:15:05.000000000 +0000
25448 @@ -91,7 +91,7 @@ static int fib6_rule_action(struct fib_r
25449 ip6_dst_idev(&rt->dst)->dev,
25451 rt6_flags2srcprefs(flags),
25455 if (!ipv6_prefix_equal(&saddr, &r->src.addr,
25457 diff -NurpP --minimal linux-3.4.103/net/ipv6/inet6_hashtables.c linux-3.4.103-vs2.3.3.9/net/ipv6/inet6_hashtables.c
25458 --- linux-3.4.103/net/ipv6/inet6_hashtables.c 2014-08-30 13:37:22.000000000 +0000
25459 +++ linux-3.4.103-vs2.3.3.9/net/ipv6/inet6_hashtables.c 2014-03-12 09:55:28.000000000 +0000
25462 #include <linux/module.h>
25463 #include <linux/random.h>
25464 +#include <linux/vs_inet6.h>
25466 #include <net/inet_connection_sock.h>
25467 #include <net/inet_hashtables.h>
25468 @@ -83,7 +84,6 @@ struct sock *__inet6_lookup_established(
25469 unsigned int slot = hash & hashinfo->ehash_mask;
25470 struct inet_ehash_bucket *head = &hashinfo->ehash[slot];
25475 sk_nulls_for_each_rcu(sk, node, &head->chain) {
25476 @@ -95,7 +95,7 @@ begin:
25484 if (get_nulls_value(node) != slot)
25485 @@ -141,6 +141,9 @@ static inline int compute_score(struct s
25486 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25490 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25493 if (sk->sk_bound_dev_if) {
25494 if (sk->sk_bound_dev_if != dif)
25495 diff -NurpP --minimal linux-3.4.103/net/ipv6/ip6_output.c linux-3.4.103-vs2.3.3.9/net/ipv6/ip6_output.c
25496 --- linux-3.4.103/net/ipv6/ip6_output.c 2014-08-30 13:37:22.000000000 +0000
25497 +++ linux-3.4.103-vs2.3.3.9/net/ipv6/ip6_output.c 2014-08-30 13:55:47.000000000 +0000
25498 @@ -964,7 +964,8 @@ static int ip6_dst_lookup_tail(struct so
25499 struct rt6_info *rt = (struct rt6_info *) *dst;
25500 err = ip6_route_get_saddr(net, rt, &fl6->daddr,
25501 sk ? inet6_sk(sk)->srcprefs : 0,
25504 + sk ? sk->sk_nx_info : NULL);
25506 goto out_err_release;
25508 diff -NurpP --minimal linux-3.4.103/net/ipv6/ndisc.c linux-3.4.103-vs2.3.3.9/net/ipv6/ndisc.c
25509 --- linux-3.4.103/net/ipv6/ndisc.c 2014-08-30 13:37:22.000000000 +0000
25510 +++ linux-3.4.103-vs2.3.3.9/net/ipv6/ndisc.c 2013-10-26 18:10:23.000000000 +0000
25511 @@ -577,7 +577,7 @@ static void ndisc_send_na(struct net_dev
25513 if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr,
25514 inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs,
25518 src_addr = &tmpaddr;
25520 diff -NurpP --minimal linux-3.4.103/net/ipv6/raw.c linux-3.4.103-vs2.3.3.9/net/ipv6/raw.c
25521 --- linux-3.4.103/net/ipv6/raw.c 2014-08-30 13:37:22.000000000 +0000
25522 +++ linux-3.4.103-vs2.3.3.9/net/ipv6/raw.c 2014-03-12 09:55:28.000000000 +0000
25524 #include <linux/icmpv6.h>
25525 #include <linux/netfilter.h>
25526 #include <linux/netfilter_ipv6.h>
25527 +#include <linux/vs_inet6.h>
25528 #include <linux/skbuff.h>
25529 #include <linux/compat.h>
25530 #include <asm/uaccess.h>
25531 @@ -284,6 +285,13 @@ static int rawv6_bind(struct sock *sk, s
25535 + if (!v6_addr_in_nx_info(sk->sk_nx_info, &addr->sin6_addr, -1)) {
25536 + err = -EADDRNOTAVAIL;
25542 /* ipv4 addr of the socket is invalid. Only the
25543 * unspecified and mapped address have a v4 equivalent.
25545 diff -NurpP --minimal linux-3.4.103/net/ipv6/route.c linux-3.4.103-vs2.3.3.9/net/ipv6/route.c
25546 --- linux-3.4.103/net/ipv6/route.c 2014-08-30 13:37:22.000000000 +0000
25547 +++ linux-3.4.103-vs2.3.3.9/net/ipv6/route.c 2014-06-12 11:34:39.000000000 +0000
25549 #include <net/xfrm.h>
25550 #include <net/netevent.h>
25551 #include <net/netlink.h>
25552 +#include <linux/vs_inet6.h>
25554 #include <asm/uaccess.h>
25556 @@ -2153,15 +2154,17 @@ int ip6_route_get_saddr(struct net *net,
25557 struct rt6_info *rt,
25558 const struct in6_addr *daddr,
25559 unsigned int prefs,
25560 - struct in6_addr *saddr)
25561 + struct in6_addr *saddr,
25562 + struct nx_info *nxi)
25564 struct inet6_dev *idev = ip6_dst_idev((struct dst_entry*)rt);
25566 - if (rt->rt6i_prefsrc.plen)
25567 + if (rt->rt6i_prefsrc.plen && (!nxi ||
25568 + v6_addr_in_nx_info(nxi, &rt->rt6i_prefsrc.addr, NXA_TYPE_ADDR)))
25569 *saddr = rt->rt6i_prefsrc.addr;
25571 err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
25572 - daddr, prefs, saddr);
25573 + daddr, prefs, saddr, nxi);
25577 @@ -2492,7 +2495,8 @@ static int rt6_fill_node(struct net *net
25578 NLA_PUT_U32(skb, RTA_IIF, iif);
25580 struct in6_addr saddr_buf;
25581 - if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf) == 0)
25582 + if (ip6_route_get_saddr(net, rt, dst, 0, &saddr_buf,
25583 + (skb->sk ? skb->sk->sk_nx_info : NULL)) == 0)
25584 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
25587 @@ -2719,6 +2723,7 @@ static int rt6_info_route(struct rt6_inf
25588 struct seq_file *m = p_arg;
25589 struct neighbour *n;
25591 + /* FIXME: check for network context? */
25592 seq_printf(m, "%pi6 %02x ", &rt->rt6i_dst.addr, rt->rt6i_dst.plen);
25594 #ifdef CONFIG_IPV6_SUBTREES
25595 diff -NurpP --minimal linux-3.4.103/net/ipv6/tcp_ipv6.c linux-3.4.103-vs2.3.3.9/net/ipv6/tcp_ipv6.c
25596 --- linux-3.4.103/net/ipv6/tcp_ipv6.c 2014-08-30 13:37:22.000000000 +0000
25597 +++ linux-3.4.103-vs2.3.3.9/net/ipv6/tcp_ipv6.c 2013-10-26 18:10:23.000000000 +0000
25600 #include <linux/crypto.h>
25601 #include <linux/scatterlist.h>
25602 +#include <linux/vs_inet6.h>
25604 static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb);
25605 static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb,
25606 @@ -163,8 +164,15 @@ static int tcp_v6_connect(struct sock *s
25607 * connect() to INADDR_ANY means loopback (BSD'ism).
25610 - if(ipv6_addr_any(&usin->sin6_addr))
25611 - usin->sin6_addr.s6_addr[15] = 0x1;
25612 + if(ipv6_addr_any(&usin->sin6_addr)) {
25613 + struct nx_info *nxi = sk->sk_nx_info;
25615 + if (nxi && nx_info_has_v6(nxi))
25616 + /* FIXME: remap lback? */
25617 + usin->sin6_addr = nxi->v6.ip;
25619 + usin->sin6_addr.s6_addr[15] = 0x1;
25622 addr_type = ipv6_addr_type(&usin->sin6_addr);
25624 diff -NurpP --minimal linux-3.4.103/net/ipv6/udp.c linux-3.4.103-vs2.3.3.9/net/ipv6/udp.c
25625 --- linux-3.4.103/net/ipv6/udp.c 2014-08-30 13:37:22.000000000 +0000
25626 +++ linux-3.4.103-vs2.3.3.9/net/ipv6/udp.c 2014-03-12 09:55:28.000000000 +0000
25627 @@ -45,41 +45,67 @@
25628 #include <net/tcp_states.h>
25629 #include <net/ip6_checksum.h>
25630 #include <net/xfrm.h>
25631 +#include <linux/vs_inet6.h>
25633 #include <linux/proc_fs.h>
25634 #include <linux/seq_file.h>
25635 #include "udp_impl.h"
25637 -int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
25638 +int ipv6_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2)
25640 - const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
25641 + const struct in6_addr *sk1_rcv_saddr6 = &inet6_sk(sk1)->rcv_saddr;
25642 const struct in6_addr *sk2_rcv_saddr6 = inet6_rcv_saddr(sk2);
25643 - __be32 sk1_rcv_saddr = sk_rcv_saddr(sk);
25644 + __be32 sk1_rcv_saddr = sk_rcv_saddr(sk1);
25645 __be32 sk2_rcv_saddr = sk_rcv_saddr(sk2);
25646 - int sk_ipv6only = ipv6_only_sock(sk);
25647 + int sk1_ipv6only = ipv6_only_sock(sk1);
25648 int sk2_ipv6only = inet_v6_ipv6only(sk2);
25649 - int addr_type = ipv6_addr_type(sk_rcv_saddr6);
25650 + int addr_type = ipv6_addr_type(sk1_rcv_saddr6);
25651 int addr_type2 = sk2_rcv_saddr6 ? ipv6_addr_type(sk2_rcv_saddr6) : IPV6_ADDR_MAPPED;
25653 /* if both are mapped, treat as IPv4 */
25654 - if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED)
25655 - return (!sk2_ipv6only &&
25656 + if (addr_type == IPV6_ADDR_MAPPED && addr_type2 == IPV6_ADDR_MAPPED) {
25657 + if (!sk2_ipv6only &&
25658 (!sk1_rcv_saddr || !sk2_rcv_saddr ||
25659 - sk1_rcv_saddr == sk2_rcv_saddr));
25660 + sk1_rcv_saddr == sk2_rcv_saddr))
25666 if (addr_type2 == IPV6_ADDR_ANY &&
25667 !(sk2_ipv6only && addr_type == IPV6_ADDR_MAPPED))
25671 if (addr_type == IPV6_ADDR_ANY &&
25672 - !(sk_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
25674 + !(sk1_ipv6only && addr_type2 == IPV6_ADDR_MAPPED))
25677 if (sk2_rcv_saddr6 &&
25678 - ipv6_addr_equal(sk_rcv_saddr6, sk2_rcv_saddr6))
25680 + ipv6_addr_equal(sk1_rcv_saddr6, sk2_rcv_saddr6))
25686 + if (!sk1_rcv_saddr && !sk2_rcv_saddr)
25687 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25688 + if (!sk2_rcv_saddr)
25689 + return v4_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr, -1);
25690 + if (!sk1_rcv_saddr)
25691 + return v4_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr, -1);
25694 + if (addr_type2 == IPV6_ADDR_ANY && addr_type == IPV6_ADDR_ANY)
25695 + return nx_v6_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25696 + else if (addr_type2 == IPV6_ADDR_ANY)
25697 + return v6_addr_in_nx_info(sk2->sk_nx_info, sk1_rcv_saddr6, -1);
25698 + else if (addr_type == IPV6_ADDR_ANY) {
25699 + if (addr_type2 == IPV6_ADDR_MAPPED)
25700 + return nx_v4_addr_conflict(sk1->sk_nx_info, sk2->sk_nx_info);
25702 + return v6_addr_in_nx_info(sk1->sk_nx_info, sk2_rcv_saddr6, -1);
25707 static unsigned int udp6_portaddr_hash(struct net *net,
25708 @@ -143,6 +169,10 @@ static inline int compute_score(struct s
25709 if (!ipv6_addr_equal(&np->rcv_saddr, daddr))
25713 + /* block non nx_info ips */
25714 + if (!v6_addr_in_nx_info(sk->sk_nx_info, daddr, -1))
25717 if (!ipv6_addr_any(&np->daddr)) {
25718 if (!ipv6_addr_equal(&np->daddr, saddr))
25719 diff -NurpP --minimal linux-3.4.103/net/ipv6/xfrm6_policy.c linux-3.4.103-vs2.3.3.9/net/ipv6/xfrm6_policy.c
25720 --- linux-3.4.103/net/ipv6/xfrm6_policy.c 2014-08-30 13:37:22.000000000 +0000
25721 +++ linux-3.4.103-vs2.3.3.9/net/ipv6/xfrm6_policy.c 2013-07-14 13:38:37.000000000 +0000
25722 @@ -63,7 +63,7 @@ static int xfrm6_get_saddr(struct net *n
25723 dev = ip6_dst_idev(dst)->dev;
25724 ipv6_dev_get_saddr(dev_net(dev), dev,
25725 (struct in6_addr *)&daddr->a6, 0,
25726 - (struct in6_addr *)&saddr->a6);
25727 + (struct in6_addr *)&saddr->a6, NULL);
25731 diff -NurpP --minimal linux-3.4.103/net/netfilter/ipvs/ip_vs_xmit.c linux-3.4.103-vs2.3.3.9/net/netfilter/ipvs/ip_vs_xmit.c
25732 --- linux-3.4.103/net/netfilter/ipvs/ip_vs_xmit.c 2014-08-30 13:37:22.000000000 +0000
25733 +++ linux-3.4.103-vs2.3.3.9/net/netfilter/ipvs/ip_vs_xmit.c 2014-08-30 13:55:47.000000000 +0000
25734 @@ -226,7 +226,7 @@ __ip_vs_route_output_v6(struct net *net,
25736 if (ipv6_addr_any(&fl6.saddr) &&
25737 ipv6_dev_get_saddr(net, ip6_dst_idev(dst)->dev,
25738 - &fl6.daddr, 0, &fl6.saddr) < 0)
25739 + &fl6.daddr, 0, &fl6.saddr, NULL) < 0)
25742 dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
25743 diff -NurpP --minimal linux-3.4.103/net/netlink/af_netlink.c linux-3.4.103-vs2.3.3.9/net/netlink/af_netlink.c
25744 --- linux-3.4.103/net/netlink/af_netlink.c 2014-08-30 13:37:22.000000000 +0000
25745 +++ linux-3.4.103-vs2.3.3.9/net/netlink/af_netlink.c 2014-03-12 09:55:29.000000000 +0000
25747 #include <linux/types.h>
25748 #include <linux/audit.h>
25749 #include <linux/mutex.h>
25750 +#include <linux/vs_context.h>
25751 +#include <linux/vs_network.h>
25752 +#include <linux/vs_limit.h>
25754 #include <net/net_namespace.h>
25755 #include <net/sock.h>
25756 @@ -1949,6 +1952,8 @@ static struct sock *netlink_seq_socket_i
25757 sk_for_each(s, node, &hash->table[j]) {
25758 if (sock_net(s) != seq_file_net(seq))
25760 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
25764 iter->hash_idx = j;
25765 @@ -1983,7 +1988,8 @@ static void *netlink_seq_next(struct seq
25769 - } while (s && sock_net(s) != seq_file_net(seq));
25770 + } while (s && (sock_net(s) != seq_file_net(seq) ||
25771 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)));
25775 @@ -1995,7 +2001,8 @@ static void *netlink_seq_next(struct seq
25777 for (; j <= hash->mask; j++) {
25778 s = sk_head(&hash->table[j]);
25779 - while (s && sock_net(s) != seq_file_net(seq))
25780 + while (s && (sock_net(s) != seq_file_net(seq) ||
25781 + !nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT)))
25785 diff -NurpP --minimal linux-3.4.103/net/socket.c linux-3.4.103-vs2.3.3.9/net/socket.c
25786 --- linux-3.4.103/net/socket.c 2014-08-30 13:37:22.000000000 +0000
25787 +++ linux-3.4.103-vs2.3.3.9/net/socket.c 2014-05-20 04:30:31.000000000 +0000
25790 #include <net/sock.h>
25791 #include <linux/netfilter.h>
25792 +#include <linux/vs_base.h>
25793 +#include <linux/vs_socket.h>
25794 +#include <linux/vs_inet.h>
25795 +#include <linux/vs_inet6.h>
25797 #include <linux/if_tun.h>
25798 #include <linux/ipv6_route.h>
25799 @@ -552,6 +556,7 @@ static inline int __sock_sendmsg_nosec(s
25800 struct msghdr *msg, size_t size)
25802 struct sock_iocb *si = kiocb_to_siocb(iocb);
25805 sock_update_classid(sock->sk);
25807 @@ -562,7 +567,22 @@ static inline int __sock_sendmsg_nosec(s
25811 - return sock->ops->sendmsg(iocb, sock, msg, size);
25812 + len = sock->ops->sendmsg(iocb, sock, msg, size);
25815 + vx_sock_send(sock->sk, size);
25817 + vx_sock_fail(sock->sk, size);
25819 + vxdprintk(VXD_CBIT(net, 7),
25820 + "__sock_sendmsg: %p[%p,%p,%p;%d/%d]:%d/%zu",
25822 + (sock->sk)?sock->sk->sk_nx_info:0,
25823 + (sock->sk)?sock->sk->sk_vx_info:0,
25824 + (sock->sk)?sock->sk->sk_xid:0,
25825 + (sock->sk)?sock->sk->sk_nid:0,
25826 + (unsigned int)size, len);
25830 static inline int __sock_sendmsg(struct kiocb *iocb, struct socket *sock,
25831 @@ -718,6 +738,7 @@ static inline int __sock_recvmsg_nosec(s
25832 struct msghdr *msg, size_t size, int flags)
25834 struct sock_iocb *si = kiocb_to_siocb(iocb);
25837 sock_update_classid(sock->sk);
25839 @@ -727,7 +748,18 @@ static inline int __sock_recvmsg_nosec(s
25843 - return sock->ops->recvmsg(iocb, sock, msg, size, flags);
25844 + len = sock->ops->recvmsg(iocb, sock, msg, size, flags);
25845 + if ((len >= 0) && sock->sk)
25846 + vx_sock_recv(sock->sk, len);
25847 + vxdprintk(VXD_CBIT(net, 7),
25848 + "__sock_recvmsg: %p[%p,%p,%p;%d/%d]:%d/%d",
25850 + (sock->sk)?sock->sk->sk_nx_info:0,
25851 + (sock->sk)?sock->sk->sk_vx_info:0,
25852 + (sock->sk)?sock->sk->sk_xid:0,
25853 + (sock->sk)?sock->sk->sk_nid:0,
25854 + (unsigned int)size, len);
25858 static inline int __sock_recvmsg(struct kiocb *iocb, struct socket *sock,
25859 @@ -1212,6 +1244,13 @@ int __sock_create(struct net *net, int f
25860 if (type < 0 || type >= SOCK_MAX)
25863 + if (!nx_check(0, VS_ADMIN)) {
25864 + if (family == PF_INET && !current_nx_info_has_v4())
25865 + return -EAFNOSUPPORT;
25866 + if (family == PF_INET6 && !current_nx_info_has_v6())
25867 + return -EAFNOSUPPORT;
25872 This uglymoron is moved from INET layer to here to avoid
25873 @@ -1347,6 +1386,7 @@ SYSCALL_DEFINE3(socket, int, family, int
25877 + set_bit(SOCK_USER_SOCKET, &sock->flags);
25878 retval = sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
25881 @@ -1388,10 +1428,12 @@ SYSCALL_DEFINE4(socketpair, int, family,
25882 err = sock_create(family, type, protocol, &sock1);
25885 + set_bit(SOCK_USER_SOCKET, &sock1->flags);
25887 err = sock_create(family, type, protocol, &sock2);
25889 goto out_release_1;
25890 + set_bit(SOCK_USER_SOCKET, &sock2->flags);
25892 err = sock1->ops->socketpair(sock1, sock2);
25894 diff -NurpP --minimal linux-3.4.103/net/sunrpc/auth.c linux-3.4.103-vs2.3.3.9/net/sunrpc/auth.c
25895 --- linux-3.4.103/net/sunrpc/auth.c 2011-10-24 16:45:34.000000000 +0000
25896 +++ linux-3.4.103-vs2.3.3.9/net/sunrpc/auth.c 2012-05-21 16:15:05.000000000 +0000
25898 #include <linux/hash.h>
25899 #include <linux/sunrpc/clnt.h>
25900 #include <linux/spinlock.h>
25901 +#include <linux/vs_tag.h>
25904 # define RPCDBG_FACILITY RPCDBG_AUTH
25905 @@ -427,6 +428,7 @@ rpcauth_lookupcred(struct rpc_auth *auth
25906 memset(&acred, 0, sizeof(acred));
25907 acred.uid = cred->fsuid;
25908 acred.gid = cred->fsgid;
25909 + acred.tag = dx_current_tag();
25910 acred.group_info = get_group_info(((struct cred *)cred)->group_info);
25912 ret = auth->au_ops->lookup_cred(auth, &acred, flags);
25913 @@ -467,6 +469,7 @@ rpcauth_bind_root_cred(struct rpc_task *
25914 struct auth_cred acred = {
25917 + .tag = dx_current_tag(),
25920 dprintk("RPC: %5u looking up %s cred\n",
25921 diff -NurpP --minimal linux-3.4.103/net/sunrpc/auth_unix.c linux-3.4.103-vs2.3.3.9/net/sunrpc/auth_unix.c
25922 --- linux-3.4.103/net/sunrpc/auth_unix.c 2012-01-09 15:15:04.000000000 +0000
25923 +++ linux-3.4.103-vs2.3.3.9/net/sunrpc/auth_unix.c 2012-05-21 16:15:05.000000000 +0000
25924 @@ -12,12 +12,14 @@
25925 #include <linux/module.h>
25926 #include <linux/sunrpc/clnt.h>
25927 #include <linux/sunrpc/auth.h>
25928 +#include <linux/vs_tag.h>
25930 #define NFS_NGROUPS 16
25933 struct rpc_cred uc_base;
25936 gid_t uc_gids[NFS_NGROUPS];
25938 #define uc_uid uc_base.cr_uid
25939 @@ -78,6 +80,7 @@ unx_create_cred(struct rpc_auth *auth, s
25940 groups = NFS_NGROUPS;
25942 cred->uc_gid = acred->gid;
25943 + cred->uc_tag = acred->tag;
25944 for (i = 0; i < groups; i++)
25945 cred->uc_gids[i] = GROUP_AT(acred->group_info, i);
25946 if (i < NFS_NGROUPS)
25947 @@ -119,7 +122,9 @@ unx_match(struct auth_cred *acred, struc
25951 - if (cred->uc_uid != acred->uid || cred->uc_gid != acred->gid)
25952 + if (cred->uc_uid != acred->uid ||
25953 + cred->uc_gid != acred->gid ||
25954 + cred->uc_tag != acred->tag)
25957 if (acred->group_info != NULL)
25958 @@ -145,7 +150,7 @@ unx_marshal(struct rpc_task *task, __be3
25959 struct rpc_clnt *clnt = task->tk_client;
25960 struct unx_cred *cred = container_of(task->tk_rqstp->rq_cred, struct unx_cred, uc_base);
25961 __be32 *base, *hold;
25965 *p++ = htonl(RPC_AUTH_UNIX);
25967 @@ -155,9 +160,12 @@ unx_marshal(struct rpc_task *task, __be3
25968 * Copy the UTS nodename captured when the client was created.
25970 p = xdr_encode_array(p, clnt->cl_nodename, clnt->cl_nodelen);
25971 + tag = task->tk_client->cl_tag;
25973 - *p++ = htonl((u32) cred->uc_uid);
25974 - *p++ = htonl((u32) cred->uc_gid);
25975 + *p++ = htonl((u32) TAGINO_UID(tag,
25976 + cred->uc_uid, cred->uc_tag));
25977 + *p++ = htonl((u32) TAGINO_GID(tag,
25978 + cred->uc_gid, cred->uc_tag));
25980 for (i = 0; i < 16 && cred->uc_gids[i] != (gid_t) NOGROUP; i++)
25981 *p++ = htonl((u32) cred->uc_gids[i]);
25982 diff -NurpP --minimal linux-3.4.103/net/sunrpc/clnt.c linux-3.4.103-vs2.3.3.9/net/sunrpc/clnt.c
25983 --- linux-3.4.103/net/sunrpc/clnt.c 2014-08-30 13:37:22.000000000 +0000
25984 +++ linux-3.4.103-vs2.3.3.9/net/sunrpc/clnt.c 2014-03-12 09:55:29.000000000 +0000
25986 #include <linux/in6.h>
25987 #include <linux/un.h>
25988 #include <linux/rcupdate.h>
25989 +#include <linux/vs_cvirt.h>
25991 #include <linux/sunrpc/clnt.h>
25992 #include <linux/sunrpc/rpc_pipe_fs.h>
25993 @@ -483,6 +484,9 @@ struct rpc_clnt *rpc_create(struct rpc_c
25994 if (!(args->flags & RPC_CLNT_CREATE_QUIET))
25995 clnt->cl_chatty = 1;
25997 + /* TODO: handle RPC_CLNT_CREATE_TAGGED
25998 + if (args->flags & RPC_CLNT_CREATE_TAGGED)
25999 + clnt->cl_tag = 1; */
26002 EXPORT_SYMBOL_GPL(rpc_create);
26003 diff -NurpP --minimal linux-3.4.103/net/unix/af_unix.c linux-3.4.103-vs2.3.3.9/net/unix/af_unix.c
26004 --- linux-3.4.103/net/unix/af_unix.c 2014-08-30 13:37:22.000000000 +0000
26005 +++ linux-3.4.103-vs2.3.3.9/net/unix/af_unix.c 2014-05-20 04:30:31.000000000 +0000
26006 @@ -114,6 +114,8 @@
26007 #include <linux/mount.h>
26008 #include <net/checksum.h>
26009 #include <linux/security.h>
26010 +#include <linux/vs_context.h>
26011 +#include <linux/vs_limit.h>
26013 struct hlist_head unix_socket_table[UNIX_HASH_SIZE + 1];
26014 EXPORT_SYMBOL_GPL(unix_socket_table);
26015 @@ -261,6 +263,8 @@ static struct sock *__unix_find_socket_b
26016 if (!net_eq(sock_net(s), net))
26019 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26021 if (u->addr->len == len &&
26022 !memcmp(u->addr->name, sunname, len))
26024 @@ -2285,6 +2289,8 @@ static struct sock *unix_seq_idx(struct
26025 for (s = first_unix_socket(&iter->i); s; s = next_unix_socket(&iter->i, s)) {
26026 if (sock_net(s) != seq_file_net(seq))
26028 + if (!nx_check(s->sk_nid, VS_WATCH_P | VS_IDENT))
26033 @@ -2309,7 +2315,8 @@ static void *unix_seq_next(struct seq_fi
26034 sk = first_unix_socket(&iter->i);
26036 sk = next_unix_socket(&iter->i, sk);
26037 - while (sk && (sock_net(sk) != seq_file_net(seq)))
26038 + while (sk && (sock_net(sk) != seq_file_net(seq) ||
26039 + !nx_check(sk->sk_nid, VS_WATCH_P | VS_IDENT)))
26040 sk = next_unix_socket(&iter->i, sk);
26043 diff -NurpP --minimal linux-3.4.103/scripts/checksyscalls.sh linux-3.4.103-vs2.3.3.9/scripts/checksyscalls.sh
26044 --- linux-3.4.103/scripts/checksyscalls.sh 2012-03-19 18:47:34.000000000 +0000
26045 +++ linux-3.4.103-vs2.3.3.9/scripts/checksyscalls.sh 2012-05-21 16:15:05.000000000 +0000
26046 @@ -193,7 +193,6 @@ cat << EOF
26047 #define __IGNORE_afs_syscall
26048 #define __IGNORE_getpmsg
26049 #define __IGNORE_putpmsg
26050 -#define __IGNORE_vserver
26054 diff -NurpP --minimal linux-3.4.103/security/commoncap.c linux-3.4.103-vs2.3.3.9/security/commoncap.c
26055 --- linux-3.4.103/security/commoncap.c 2012-05-21 16:07:41.000000000 +0000
26056 +++ linux-3.4.103-vs2.3.3.9/security/commoncap.c 2012-05-21 16:15:05.000000000 +0000
26057 @@ -76,14 +76,20 @@ int cap_netlink_send(struct sock *sk, st
26058 int cap_capable(const struct cred *cred, struct user_namespace *targ_ns,
26059 int cap, int audit)
26061 + struct vx_info *vxi = current_vx_info(); /* FIXME: get vxi from cred? */
26064 /* The creator of the user namespace has all caps. */
26065 if (targ_ns != &init_user_ns && targ_ns->creator == cred->user)
26068 /* Do we have the necessary capabilities? */
26069 - if (targ_ns == cred->user->user_ns)
26070 - return cap_raised(cred->cap_effective, cap) ? 0 : -EPERM;
26071 + if (targ_ns == cred->user->user_ns) {
26072 + if (vx_info_flags(vxi, VXF_STATE_SETUP, 0) &&
26073 + cap_raised(cred->cap_effective, cap))
26075 + return vx_cap_raised(vxi, cred->cap_effective, cap) ? 0 : -EPERM;
26078 /* Have we tried all of the parent namespaces? */
26079 if (targ_ns == &init_user_ns)
26080 @@ -612,7 +618,7 @@ int cap_inode_setxattr(struct dentry *de
26082 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26083 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26084 - !capable(CAP_SYS_ADMIN))
26085 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26089 @@ -638,7 +644,7 @@ int cap_inode_removexattr(struct dentry
26091 if (!strncmp(name, XATTR_SECURITY_PREFIX,
26092 sizeof(XATTR_SECURITY_PREFIX) - 1) &&
26093 - !capable(CAP_SYS_ADMIN))
26094 + !vx_capable(CAP_SYS_ADMIN, VXC_FS_SECURITY))
26098 diff -NurpP --minimal linux-3.4.103/security/selinux/hooks.c linux-3.4.103-vs2.3.3.9/security/selinux/hooks.c
26099 --- linux-3.4.103/security/selinux/hooks.c 2014-08-30 13:37:23.000000000 +0000
26100 +++ linux-3.4.103-vs2.3.3.9/security/selinux/hooks.c 2014-04-21 18:56:35.000000000 +0000
26102 #include <linux/dccp.h>
26103 #include <linux/quota.h>
26104 #include <linux/un.h> /* for Unix socket types */
26105 -#include <net/af_unix.h> /* for Unix socket types */
26106 #include <linux/parser.h>
26107 #include <linux/nfs_mount.h>
26108 #include <net/ipv6.h>