diff -Nurp linux-2.6.16.38/arch/alpha/Kconfig linux-2.6.16.38-vs2.0.3-rc1/arch/alpha/Kconfig --- linux-2.6.16.38/arch/alpha/Kconfig 2007-01-23 13:44:34.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/alpha/Kconfig 2007-01-23 13:45:32.000000000 +0100 @@ -619,6 +619,8 @@ source "arch/alpha/oprofile/Kconfig" source "arch/alpha/Kconfig.debug" +source "kernel/vserver/Kconfig" + source "security/Kconfig" source "crypto/Kconfig" diff -Nurp linux-2.6.16.38/arch/alpha/kernel/entry.S linux-2.6.16.38-vs2.0.3-rc1/arch/alpha/kernel/entry.S --- linux-2.6.16.38/arch/alpha/kernel/entry.S 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/alpha/kernel/entry.S 2007-01-23 13:45:32.000000000 +0100 @@ -874,24 +874,15 @@ sys_getxgid: .globl sys_getxpid .ent sys_getxpid sys_getxpid: + lda $sp, -16($sp) + stq $26, 0($sp) .prologue 0 - ldq $2, TI_TASK($8) - /* See linux/kernel/timer.c sys_getppid for discussion - about this loop. */ - ldq $3, TASK_GROUP_LEADER($2) - ldq $4, TASK_REAL_PARENT($3) - ldl $0, TASK_TGID($2) -1: ldl $1, TASK_TGID($4) -#ifdef CONFIG_SMP - mov $4, $5 - mb - ldq $3, TASK_GROUP_LEADER($2) - ldq $4, TASK_REAL_PARENT($3) - cmpeq $4, $5, $5 - beq $5, 1b -#endif - stq $1, 80($sp) + lda $16, 96($sp) + jsr $26, do_getxpid + ldq $26, 0($sp) + + lda $sp, 16($sp) ret .end sys_getxpid diff -Nurp linux-2.6.16.38/arch/alpha/kernel/osf_sys.c linux-2.6.16.38-vs2.0.3-rc1/arch/alpha/kernel/osf_sys.c --- linux-2.6.16.38/arch/alpha/kernel/osf_sys.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/alpha/kernel/osf_sys.c 2007-01-23 13:45:32.000000000 +0100 @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -399,18 +400,20 @@ asmlinkage int osf_utsname(char __user *name) { int error; + struct new_utsname *ptr; down_read(&uts_sem); + ptr = vx_new_utsname(); error = -EFAULT; - if (copy_to_user(name + 0, system_utsname.sysname, 32)) + if (copy_to_user(name + 0, ptr->sysname, 32)) goto out; - if (copy_to_user(name + 32, system_utsname.nodename, 32)) + if (copy_to_user(name + 32, ptr->nodename, 32)) goto out; - if (copy_to_user(name + 64, system_utsname.release, 32)) + if (copy_to_user(name + 64, ptr->release, 32)) goto out; - if (copy_to_user(name + 96, system_utsname.version, 32)) + if (copy_to_user(name + 96, ptr->version, 32)) goto out; - if (copy_to_user(name + 128, system_utsname.machine, 32)) + if (copy_to_user(name + 128, ptr->machine, 32)) goto out; error = 0; @@ -439,6 +442,7 @@ osf_getdomainname(char __user *name, int { unsigned len; int i; + char *domainname; if (!access_ok(VERIFY_WRITE, name, namelen)) return -EFAULT; @@ -448,9 +452,10 @@ osf_getdomainname(char __user *name, int len = 32; down_read(&uts_sem); + domainname = vx_new_uts(domainname); for (i = 0; i < len; ++i) { - __put_user(system_utsname.domainname[i], name + i); - if (system_utsname.domainname[i] == '\0') + __put_user(domainname[i], name + i); + if (domainname[i] == '\0') break; } up_read(&uts_sem); @@ -607,17 +612,6 @@ osf_sigstack(struct sigstack __user *uss asmlinkage long osf_sysinfo(int command, char __user *buf, long count) { - static char * sysinfo_table[] = { - system_utsname.sysname, - system_utsname.nodename, - system_utsname.release, - system_utsname.version, - system_utsname.machine, - "alpha", /* instruction set architecture */ - "dummy", /* hardware serial number */ - "dummy", /* hardware manufacturer */ - "dummy", /* secure RPC domain */ - }; unsigned long offset; char *res; long len, err = -EINVAL; @@ -630,7 +624,18 @@ osf_sysinfo(int command, char __user *bu } down_read(&uts_sem); - res = sysinfo_table[offset]; + switch (offset) + { + case 0: res = vx_new_uts(sysname); break; + case 1: res = vx_new_uts(nodename); break; + case 2: res = vx_new_uts(release); break; + case 3: res = vx_new_uts(version); break; + case 4: res = vx_new_uts(machine); break; + case 5: res = "alpha"; break; + default: + res = "dummy"; + break; + } len = strlen(res)+1; if (len > count) len = count; diff -Nurp linux-2.6.16.38/arch/alpha/kernel/ptrace.c linux-2.6.16.38-vs2.0.3-rc1/arch/alpha/kernel/ptrace.c --- linux-2.6.16.38/arch/alpha/kernel/ptrace.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/alpha/kernel/ptrace.c 2007-01-23 13:45:32.000000000 +0100 @@ -283,6 +283,11 @@ do_sys_ptrace(long request, long pid, lo goto out_notsk; } + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT)) { + ret = -EPERM; + goto out; + } + if (request == PTRACE_ATTACH) { ret = ptrace_attach(child); goto out; diff -Nurp linux-2.6.16.38/arch/alpha/kernel/systbls.S linux-2.6.16.38-vs2.0.3-rc1/arch/alpha/kernel/systbls.S --- linux-2.6.16.38/arch/alpha/kernel/systbls.S 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/alpha/kernel/systbls.S 2007-01-23 13:45:32.000000000 +0100 @@ -447,7 +447,7 @@ sys_call_table: .quad sys_stat64 /* 425 */ .quad sys_lstat64 .quad sys_fstat64 - .quad sys_ni_syscall /* sys_vserver */ + .quad sys_vserver /* sys_vserver */ .quad sys_ni_syscall /* sys_mbind */ .quad sys_ni_syscall /* sys_get_mempolicy */ .quad sys_ni_syscall /* sys_set_mempolicy */ diff -Nurp linux-2.6.16.38/arch/alpha/mm/init.c linux-2.6.16.38-vs2.0.3-rc1/arch/alpha/mm/init.c --- linux-2.6.16.38/arch/alpha/mm/init.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/alpha/mm/init.c 2007-01-23 13:45:32.000000000 +0100 @@ -21,6 +21,7 @@ #include #include /* max_low_pfn */ #include +#include #include #include diff -Nurp linux-2.6.16.38/arch/arm/Kconfig linux-2.6.16.38-vs2.0.3-rc1/arch/arm/Kconfig --- linux-2.6.16.38/arch/arm/Kconfig 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/arm/Kconfig 2007-01-23 13:45:32.000000000 +0100 @@ -827,6 +827,8 @@ source "arch/arm/oprofile/Kconfig" source "arch/arm/Kconfig.debug" +source "kernel/vserver/Kconfig" + source "security/Kconfig" source "crypto/Kconfig" diff -Nurp linux-2.6.16.38/arch/arm/kernel/calls.S linux-2.6.16.38-vs2.0.3-rc1/arch/arm/kernel/calls.S --- linux-2.6.16.38/arch/arm/kernel/calls.S 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/arm/kernel/calls.S 2007-01-23 13:45:32.000000000 +0100 @@ -322,7 +322,7 @@ /* 310 */ CALL(sys_request_key) CALL(sys_keyctl) CALL(ABI(sys_semtimedop, sys_oabi_semtimedop)) -/* vserver */ CALL(sys_ni_syscall) + CALL(sys_vserver) CALL(sys_ioprio_set) /* 315 */ CALL(sys_ioprio_get) CALL(sys_inotify_init) diff -Nurp linux-2.6.16.38/arch/arm26/Kconfig linux-2.6.16.38-vs2.0.3-rc1/arch/arm26/Kconfig --- linux-2.6.16.38/arch/arm26/Kconfig 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/arm26/Kconfig 2007-01-23 13:45:33.000000000 +0100 @@ -230,6 +230,8 @@ source "drivers/usb/Kconfig" source "arch/arm26/Kconfig.debug" +source "kernel/vserver/Kconfig" + source "security/Kconfig" source "crypto/Kconfig" diff -Nurp linux-2.6.16.38/arch/arm26/kernel/calls.S linux-2.6.16.38-vs2.0.3-rc1/arch/arm26/kernel/calls.S --- linux-2.6.16.38/arch/arm26/kernel/calls.S 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/arm26/kernel/calls.S 2007-01-23 13:45:33.000000000 +0100 @@ -257,6 +257,11 @@ __syscall_start: .long sys_lremovexattr .long sys_fremovexattr .long sys_tkill + + .rept 313 - (. - __syscall_start) / 4 + .long sys_ni_syscall + .endr + .long sys_vserver /* 313 */ __syscall_end: .rept NR_syscalls - (__syscall_end - __syscall_start) / 4 diff -Nurp linux-2.6.16.38/arch/arm26/kernel/traps.c linux-2.6.16.38-vs2.0.3-rc1/arch/arm26/kernel/traps.c --- linux-2.6.16.38/arch/arm26/kernel/traps.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/arm26/kernel/traps.c 2007-01-23 13:45:33.000000000 +0100 @@ -186,8 +186,9 @@ NORET_TYPE void die(const char *str, str printk("Internal error: %s: %x\n", str, err); printk("CPU: %d\n", smp_processor_id()); show_regs(regs); - printk("Process %s (pid: %d, stack limit = 0x%p)\n", - current->comm, current->pid, end_of_stack(tsk)); + printk("Process %s (pid: %d[#%u], stack limit = 0x%p)\n", + current->comm, current->pid, + current->xid, end_of_stack(tsk)); if (!user_mode(regs) || in_interrupt()) { __dump_stack(tsk, (unsigned long)(regs + 1)); diff -Nurp linux-2.6.16.38/arch/cris/Kconfig linux-2.6.16.38-vs2.0.3-rc1/arch/cris/Kconfig --- linux-2.6.16.38/arch/cris/Kconfig 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/cris/Kconfig 2007-01-23 13:45:33.000000000 +0100 @@ -173,6 +173,8 @@ source "drivers/usb/Kconfig" source "arch/cris/Kconfig.debug" +source "kernel/vserver/Kconfig" + source "security/Kconfig" source "crypto/Kconfig" diff -Nurp linux-2.6.16.38/arch/frv/mm/mmu-context.c linux-2.6.16.38-vs2.0.3-rc1/arch/frv/mm/mmu-context.c --- linux-2.6.16.38/arch/frv/mm/mmu-context.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/frv/mm/mmu-context.c 2007-01-23 13:45:33.000000000 +0100 @@ -11,6 +11,7 @@ #include #include +#include #include #define NR_CXN 4096 diff -Nurp linux-2.6.16.38/arch/h8300/Kconfig linux-2.6.16.38-vs2.0.3-rc1/arch/h8300/Kconfig --- linux-2.6.16.38/arch/h8300/Kconfig 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/h8300/Kconfig 2007-01-23 13:45:33.000000000 +0100 @@ -191,6 +191,8 @@ source "fs/Kconfig" source "arch/h8300/Kconfig.debug" +source "kernel/vserver/Kconfig" + source "security/Kconfig" source "crypto/Kconfig" diff -Nurp linux-2.6.16.38/arch/i386/boot/compressed/misc.c linux-2.6.16.38-vs2.0.3-rc1/arch/i386/boot/compressed/misc.c --- linux-2.6.16.38/arch/i386/boot/compressed/misc.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/i386/boot/compressed/misc.c 2007-01-23 13:45:33.000000000 +0100 @@ -309,7 +309,7 @@ static void setup_normal_output_buffer(v #else if ((RM_ALT_MEM_K > RM_EXT_MEM_K ? RM_ALT_MEM_K : RM_EXT_MEM_K) < 1024) error("Less than 2MB of memory"); #endif - output_data = (char *)__PHYSICAL_START; /* Normally Points to 1M */ + output_data = (char *)PHYSICAL_START; /* Normally Points to 1M */ free_mem_end_ptr = (long)real_mode; } @@ -334,8 +334,8 @@ static void setup_output_buffer_if_we_ru low_buffer_size = low_buffer_end - LOW_BUFFER_START; high_loaded = 1; free_mem_end_ptr = (long)high_buffer_start; - if ( (__PHYSICAL_START + low_buffer_size) > ((ulg)high_buffer_start)) { - high_buffer_start = (uch *)(__PHYSICAL_START + low_buffer_size); + if ((PHYSICAL_START + low_buffer_size) > ((ulg)high_buffer_start)) { + high_buffer_start = (uch *)(PHYSICAL_START + low_buffer_size); mv->hcount = 0; /* say: we need not to move high_buffer */ } else mv->hcount = -1; diff -Nurp linux-2.6.16.38/arch/i386/Kconfig linux-2.6.16.38-vs2.0.3-rc1/arch/i386/Kconfig --- linux-2.6.16.38/arch/i386/Kconfig 2007-01-23 13:44:16.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/i386/Kconfig 2007-01-23 13:45:33.000000000 +0100 @@ -466,23 +466,43 @@ choice will also likely make your kernel incompatible with binary-only kernel modules. - If you are not absolutely sure what you are doing, leave this - option alone! - config VMSPLIT_3G - bool "3G/1G user/kernel split" - config VMSPLIT_3G_OPT - bool "3G/1G user/kernel split (for full 1G low memory)" + bool "3G/1G user/kernel split (Default)" + help + This is the default split of 3GB userspace to 1GB kernel + space, which will result in about 860MB of lowmem. + + config VMSPLIT_25G + bool "2.5G/1.5G user/kernel split" + help + This split provides 2.5GB userspace and 1.5GB kernel + space, which will result in about 1370MB of lowmem. + config VMSPLIT_2G bool "2G/2G user/kernel split" + help + This split provides 2GB userspace and 2GB kernel + space, which will result in about 1880MB of lowmem. + + config VMSPLIT_15G + bool "1.5G/2.5G user/kernel split" + help + This split provides 1.5GB userspace and 2.5GB kernel + space, which will result in about 2390MB of lowmem. + config VMSPLIT_1G bool "1G/3G user/kernel split" + help + This split provides 1GB userspace and 3GB kernel + space, which will result in about 2900MB of lowmem. + endchoice config PAGE_OFFSET hex - default 0xB0000000 if VMSPLIT_3G_OPT - default 0x78000000 if VMSPLIT_2G + default 0xA0000000 if VMSPLIT_25G + default 0x80000000 if VMSPLIT_2G + default 0x60000000 if VMSPLIT_15G default 0x40000000 if VMSPLIT_1G default 0xC0000000 @@ -1074,6 +1094,8 @@ endmenu source "arch/i386/Kconfig.debug" +source "kernel/vserver/Kconfig" + source "security/Kconfig" source "crypto/Kconfig" diff -Nurp linux-2.6.16.38/arch/i386/kernel/setup.c linux-2.6.16.38-vs2.0.3-rc1/arch/i386/kernel/setup.c --- linux-2.6.16.38/arch/i386/kernel/setup.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/i386/kernel/setup.c 2007-01-23 13:45:33.000000000 +0100 @@ -1192,8 +1192,8 @@ void __init setup_bootmem_allocator(void * the (very unlikely) case of us accidentally initializing the * bootmem allocator with an invalid RAM area. */ - reserve_bootmem(__PHYSICAL_START, (PFN_PHYS(min_low_pfn) + - bootmap_size + PAGE_SIZE-1) - (__PHYSICAL_START)); + reserve_bootmem(PHYSICAL_START, (PFN_PHYS(min_low_pfn) + + bootmap_size + PAGE_SIZE-1) - (PHYSICAL_START)); /* * reserve physical page 0 - it's a special BIOS page on many boxes, diff -Nurp linux-2.6.16.38/arch/i386/kernel/syscall_table.S linux-2.6.16.38-vs2.0.3-rc1/arch/i386/kernel/syscall_table.S --- linux-2.6.16.38/arch/i386/kernel/syscall_table.S 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/i386/kernel/syscall_table.S 2007-01-23 13:45:33.000000000 +0100 @@ -272,7 +272,7 @@ ENTRY(sys_call_table) .long sys_tgkill /* 270 */ .long sys_utimes .long sys_fadvise64_64 - .long sys_ni_syscall /* sys_vserver */ + .long sys_vserver .long sys_mbind .long sys_get_mempolicy .long sys_set_mempolicy diff -Nurp linux-2.6.16.38/arch/i386/kernel/sys_i386.c linux-2.6.16.38-vs2.0.3-rc1/arch/i386/kernel/sys_i386.c --- linux-2.6.16.38/arch/i386/kernel/sys_i386.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/i386/kernel/sys_i386.c 2007-01-23 13:45:33.000000000 +0100 @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -217,7 +218,7 @@ asmlinkage int sys_uname(struct old_utsn if (!name) return -EFAULT; down_read(&uts_sem); - err=copy_to_user(name, &system_utsname, sizeof (*name)); + err=copy_to_user(name, vx_new_utsname(), sizeof (*name)); up_read(&uts_sem); return err?-EFAULT:0; } @@ -225,6 +226,7 @@ asmlinkage int sys_uname(struct old_utsn asmlinkage int sys_olduname(struct oldold_utsname __user * name) { int error; + struct new_utsname *ptr; if (!name) return -EFAULT; @@ -233,15 +235,16 @@ asmlinkage int sys_olduname(struct oldol down_read(&uts_sem); - error = __copy_to_user(&name->sysname,&system_utsname.sysname,__OLD_UTS_LEN); + ptr = vx_new_utsname(); + error = __copy_to_user(&name->sysname,ptr->sysname,__OLD_UTS_LEN); error |= __put_user(0,name->sysname+__OLD_UTS_LEN); - error |= __copy_to_user(&name->nodename,&system_utsname.nodename,__OLD_UTS_LEN); + error |= __copy_to_user(&name->nodename,ptr->nodename,__OLD_UTS_LEN); error |= __put_user(0,name->nodename+__OLD_UTS_LEN); - error |= __copy_to_user(&name->release,&system_utsname.release,__OLD_UTS_LEN); + error |= __copy_to_user(&name->release,ptr->release,__OLD_UTS_LEN); error |= __put_user(0,name->release+__OLD_UTS_LEN); - error |= __copy_to_user(&name->version,&system_utsname.version,__OLD_UTS_LEN); + error |= __copy_to_user(&name->version,ptr->version,__OLD_UTS_LEN); error |= __put_user(0,name->version+__OLD_UTS_LEN); - error |= __copy_to_user(&name->machine,&system_utsname.machine,__OLD_UTS_LEN); + error |= __copy_to_user(&name->machine,ptr->machine,__OLD_UTS_LEN); error |= __put_user(0,name->machine+__OLD_UTS_LEN); up_read(&uts_sem); diff -Nurp linux-2.6.16.38/arch/i386/kernel/traps.c linux-2.6.16.38-vs2.0.3-rc1/arch/i386/kernel/traps.c --- linux-2.6.16.38/arch/i386/kernel/traps.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/i386/kernel/traps.c 2007-01-23 13:45:33.000000000 +0100 @@ -53,6 +53,7 @@ #include #include +#include #include "mach_traps.h" @@ -252,8 +253,9 @@ void show_registers(struct pt_regs *regs regs->esi, regs->edi, regs->ebp, esp); printk(KERN_EMERG "ds: %04x es: %04x ss: %04x\n", regs->xds & 0xffff, regs->xes & 0xffff, ss); - printk(KERN_EMERG "Process %s (pid: %d, threadinfo=%p task=%p)", - current->comm, current->pid, current_thread_info(), current); + printk(KERN_EMERG "Process %s (pid: %d[#%u], threadinfo=%p task=%p)", + current->comm, current->pid, current->xid, + current_thread_info(), current); /* * When in-kernel, we also print out the stack and code at the * time of the fault.. @@ -333,6 +335,8 @@ void die(const char * str, struct pt_reg static int die_counter; unsigned long flags; + vxh_throw_oops(); + if (die.lock_owner != raw_smp_processor_id()) { console_verbose(); spin_lock_irqsave(&die.lock, flags); @@ -365,8 +369,9 @@ void die(const char * str, struct pt_reg #endif if (nl) printk("\n"); - notify_die(DIE_OOPS, (char *)str, regs, err, 255, SIGSEGV); + notify_die(DIE_OOPS, (char *)str, regs, err, 255, SIGSEGV); show_registers(regs); + vxh_dump_history(); } else printk(KERN_EMERG "Recursive die() failure, output suppressed\n"); diff -Nurp linux-2.6.16.38/arch/ia64/ia32/binfmt_elf32.c linux-2.6.16.38-vs2.0.3-rc1/arch/ia64/ia32/binfmt_elf32.c --- linux-2.6.16.38/arch/ia64/ia32/binfmt_elf32.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/ia64/ia32/binfmt_elf32.c 2007-01-23 13:45:33.000000000 +0100 @@ -236,7 +236,8 @@ ia32_setup_arg_pages (struct linux_binpr kmem_cache_free(vm_area_cachep, mpnt); return ret; } - current->mm->stack_vm = current->mm->total_vm = vma_pages(mpnt); + vx_vmpages_sub(current->mm, current->mm->total_vm - vma_pages(mpnt)); + current->mm->stack_vm = current->mm->total_vm; } for (i = 0 ; i < MAX_ARG_PAGES ; i++) { diff -Nurp linux-2.6.16.38/arch/ia64/ia32/ia32_entry.S linux-2.6.16.38-vs2.0.3-rc1/arch/ia64/ia32/ia32_entry.S --- linux-2.6.16.38/arch/ia64/ia32/ia32_entry.S 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/ia64/ia32/ia32_entry.S 2007-01-23 13:45:33.000000000 +0100 @@ -483,7 +483,7 @@ ia32_syscall_table: data8 sys_tgkill /* 270 */ data8 compat_sys_utimes data8 sys32_fadvise64_64 - data8 sys_ni_syscall + data8 sys32_vserver data8 sys_ni_syscall data8 sys_ni_syscall /* 275 */ data8 sys_ni_syscall diff -Nurp linux-2.6.16.38/arch/ia64/Kconfig linux-2.6.16.38-vs2.0.3-rc1/arch/ia64/Kconfig --- linux-2.6.16.38/arch/ia64/Kconfig 2007-01-23 13:44:16.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/ia64/Kconfig 2007-01-23 13:45:33.000000000 +0100 @@ -467,6 +467,8 @@ endmenu source "arch/ia64/Kconfig.debug" +source "kernel/vserver/Kconfig" + source "security/Kconfig" source "crypto/Kconfig" diff -Nurp linux-2.6.16.38/arch/ia64/kernel/entry.S linux-2.6.16.38-vs2.0.3-rc1/arch/ia64/kernel/entry.S --- linux-2.6.16.38/arch/ia64/kernel/entry.S 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/ia64/kernel/entry.S 2007-01-23 13:45:33.000000000 +0100 @@ -1591,7 +1591,7 @@ sys_call_table: data8 sys_mq_notify data8 sys_mq_getsetattr data8 sys_ni_syscall // reserved for kexec_load - data8 sys_ni_syscall // reserved for vserver + data8 sys_vserver data8 sys_waitid // 1270 data8 sys_add_key data8 sys_request_key diff -Nurp linux-2.6.16.38/arch/ia64/kernel/perfmon.c linux-2.6.16.38-vs2.0.3-rc1/arch/ia64/kernel/perfmon.c --- linux-2.6.16.38/arch/ia64/kernel/perfmon.c 2007-01-23 13:44:22.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/ia64/kernel/perfmon.c 2007-01-23 13:45:33.000000000 +0100 @@ -41,6 +41,8 @@ #include #include #include +#include +#include #include #include @@ -2355,7 +2357,7 @@ pfm_smpl_buffer_alloc(struct task_struct */ insert_vm_struct(mm, vma); - mm->total_vm += size >> PAGE_SHIFT; + vx_vmpages_add(mm, size >> PAGE_SHIFT); vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file, vma_pages(vma)); up_write(&task->mm->mmap_sem); diff -Nurp linux-2.6.16.38/arch/ia64/kernel/ptrace.c linux-2.6.16.38-vs2.0.3-rc1/arch/ia64/kernel/ptrace.c --- linux-2.6.16.38/arch/ia64/kernel/ptrace.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/ia64/kernel/ptrace.c 2007-01-23 13:45:33.000000000 +0100 @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -1443,6 +1444,9 @@ sys_ptrace (long request, pid_t pid, uns read_unlock(&tasklist_lock); if (!child) goto out; + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT)) + goto out_tsk; + ret = -EPERM; if (pid == 1) /* no messing around with init! */ goto out_tsk; diff -Nurp linux-2.6.16.38/arch/ia64/kernel/signal.c linux-2.6.16.38-vs2.0.3-rc1/arch/ia64/kernel/signal.c --- linux-2.6.16.38/arch/ia64/kernel/signal.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/ia64/kernel/signal.c 2007-01-23 13:45:33.000000000 +0100 @@ -21,6 +21,7 @@ #include #include #include +#include #include #include diff -Nurp linux-2.6.16.38/arch/ia64/mm/fault.c linux-2.6.16.38-vs2.0.3-rc1/arch/ia64/mm/fault.c --- linux-2.6.16.38/arch/ia64/mm/fault.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/ia64/mm/fault.c 2007-01-23 13:45:33.000000000 +0100 @@ -10,6 +10,7 @@ #include #include #include +#include #include #include diff -Nurp linux-2.6.16.38/arch/ia64/sn/kernel/xpc_main.c linux-2.6.16.38-vs2.0.3-rc1/arch/ia64/sn/kernel/xpc_main.c --- linux-2.6.16.38/arch/ia64/sn/kernel/xpc_main.c 2007-01-23 13:44:18.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/ia64/sn/kernel/xpc_main.c 2007-01-23 13:45:33.000000000 +0100 @@ -109,6 +109,7 @@ static ctl_table xpc_sys_xpc_hb_dir[] = 0644, NULL, &proc_dointvec_minmax, + NULL, &sysctl_intvec, NULL, &xpc_hb_min_interval, @@ -122,6 +123,7 @@ static ctl_table xpc_sys_xpc_hb_dir[] = 0644, NULL, &proc_dointvec_minmax, + NULL, &sysctl_intvec, NULL, &xpc_hb_check_min_interval, @@ -146,6 +148,7 @@ static ctl_table xpc_sys_xpc_dir[] = { 0644, NULL, &proc_dointvec_minmax, + NULL, &sysctl_intvec, NULL, &xpc_disengage_request_min_timelimit, diff -Nurp linux-2.6.16.38/arch/m32r/kernel/sys_m32r.c linux-2.6.16.38-vs2.0.3-rc1/arch/m32r/kernel/sys_m32r.c --- linux-2.6.16.38/arch/m32r/kernel/sys_m32r.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/m32r/kernel/sys_m32r.c 2007-01-23 13:45:33.000000000 +0100 @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -206,7 +207,7 @@ asmlinkage int sys_uname(struct old_utsn if (!name) return -EFAULT; down_read(&uts_sem); - err=copy_to_user(name, &system_utsname, sizeof (*name)); + err=copy_to_user(name, vx_new_utsname(), sizeof (*name)); up_read(&uts_sem); return err?-EFAULT:0; } diff -Nurp linux-2.6.16.38/arch/m68k/Kconfig linux-2.6.16.38-vs2.0.3-rc1/arch/m68k/Kconfig --- linux-2.6.16.38/arch/m68k/Kconfig 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/m68k/Kconfig 2007-01-23 13:45:33.000000000 +0100 @@ -650,6 +650,8 @@ source "fs/Kconfig" source "arch/m68k/Kconfig.debug" +source "kernel/vserver/Kconfig" + source "security/Kconfig" source "crypto/Kconfig" diff -Nurp linux-2.6.16.38/arch/m68k/kernel/ptrace.c linux-2.6.16.38-vs2.0.3-rc1/arch/m68k/kernel/ptrace.c --- linux-2.6.16.38/arch/m68k/kernel/ptrace.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/m68k/kernel/ptrace.c 2007-01-23 13:45:33.000000000 +0100 @@ -280,6 +280,8 @@ long arch_ptrace(struct task_struct *chi ret = ptrace_request(child, request, addr, data); break; } + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT)) + goto out_tsk; return ret; out_eio: diff -Nurp linux-2.6.16.38/arch/m68knommu/Kconfig linux-2.6.16.38-vs2.0.3-rc1/arch/m68knommu/Kconfig --- linux-2.6.16.38/arch/m68knommu/Kconfig 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/m68knommu/Kconfig 2007-01-23 13:45:33.000000000 +0100 @@ -646,6 +646,8 @@ source "fs/Kconfig" source "arch/m68knommu/Kconfig.debug" +source "kernel/vserver/Kconfig" + source "security/Kconfig" source "crypto/Kconfig" diff -Nurp linux-2.6.16.38/arch/mips/Kconfig linux-2.6.16.38-vs2.0.3-rc1/arch/mips/Kconfig --- linux-2.6.16.38/arch/mips/Kconfig 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/mips/Kconfig 2007-01-23 13:45:33.000000000 +0100 @@ -1814,6 +1814,8 @@ source "arch/mips/oprofile/Kconfig" source "arch/mips/Kconfig.debug" +source "kernel/vserver/Kconfig" + source "security/Kconfig" source "crypto/Kconfig" diff -Nurp linux-2.6.16.38/arch/mips/kernel/linux32.c linux-2.6.16.38-vs2.0.3-rc1/arch/mips/kernel/linux32.c --- linux-2.6.16.38/arch/mips/kernel/linux32.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/mips/kernel/linux32.c 2007-01-23 13:45:33.000000000 +0100 @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -1099,7 +1100,7 @@ asmlinkage long sys32_newuname(struct ne int ret = 0; down_read(&uts_sem); - if (copy_to_user(name,&system_utsname,sizeof *name)) + if (copy_to_user(name, vx_new_utsname(), sizeof *name)) ret = -EFAULT; up_read(&uts_sem); diff -Nurp linux-2.6.16.38/arch/mips/kernel/ptrace.c linux-2.6.16.38-vs2.0.3-rc1/arch/mips/kernel/ptrace.c --- linux-2.6.16.38/arch/mips/kernel/ptrace.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/mips/kernel/ptrace.c 2007-01-23 13:45:33.000000000 +0100 @@ -476,6 +476,8 @@ asmlinkage void do_syscall_trace(struct goto out; if (!test_thread_flag(TIF_SYSCALL_TRACE)) goto out; + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT)) + goto out_tsk; /* The 0x80 provides a way for the tracing parent to distinguish between a syscall stop and SIGTRAP delivery */ diff -Nurp linux-2.6.16.38/arch/mips/kernel/scall32-o32.S linux-2.6.16.38-vs2.0.3-rc1/arch/mips/kernel/scall32-o32.S --- linux-2.6.16.38/arch/mips/kernel/scall32-o32.S 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/mips/kernel/scall32-o32.S 2007-01-23 13:45:33.000000000 +0100 @@ -607,7 +607,7 @@ einval: li v0, -EINVAL sys sys_mq_timedreceive 5 sys sys_mq_notify 2 /* 4275 */ sys sys_mq_getsetattr 3 - sys sys_ni_syscall 0 /* sys_vserver */ + sys sys_vserver 3 sys sys_waitid 5 sys sys_ni_syscall 0 /* available, was setaltroot */ sys sys_add_key 5 /* 4280 */ diff -Nurp linux-2.6.16.38/arch/mips/kernel/scall64-64.S linux-2.6.16.38-vs2.0.3-rc1/arch/mips/kernel/scall64-64.S --- linux-2.6.16.38/arch/mips/kernel/scall64-64.S 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/mips/kernel/scall64-64.S 2007-01-23 13:45:33.000000000 +0100 @@ -433,7 +433,7 @@ sys_call_table: PTR sys_mq_timedreceive PTR sys_mq_notify PTR sys_mq_getsetattr /* 5235 */ - PTR sys_ni_syscall /* sys_vserver */ + PTR sys_vserver PTR sys_waitid PTR sys_ni_syscall /* available, was setaltroot */ PTR sys_add_key diff -Nurp linux-2.6.16.38/arch/mips/kernel/scall64-n32.S linux-2.6.16.38-vs2.0.3-rc1/arch/mips/kernel/scall64-n32.S --- linux-2.6.16.38/arch/mips/kernel/scall64-n32.S 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/mips/kernel/scall64-n32.S 2007-01-23 13:45:33.000000000 +0100 @@ -359,7 +359,7 @@ EXPORT(sysn32_call_table) PTR compat_sys_mq_timedreceive PTR compat_sys_mq_notify PTR compat_sys_mq_getsetattr - PTR sys_ni_syscall /* 6240, sys_vserver */ + PTR sys32_vserver /* 6240 */ PTR sysn32_waitid PTR sys_ni_syscall /* available, was setaltroot */ PTR sys_add_key diff -Nurp linux-2.6.16.38/arch/mips/kernel/scall64-o32.S linux-2.6.16.38-vs2.0.3-rc1/arch/mips/kernel/scall64-o32.S --- linux-2.6.16.38/arch/mips/kernel/scall64-o32.S 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/mips/kernel/scall64-o32.S 2007-01-23 13:45:34.000000000 +0100 @@ -481,7 +481,7 @@ sys_call_table: PTR compat_sys_mq_timedreceive PTR compat_sys_mq_notify /* 4275 */ PTR compat_sys_mq_getsetattr - PTR sys_ni_syscall /* sys_vserver */ + PTR sys32_vserver PTR sys32_waitid PTR sys_ni_syscall /* available, was setaltroot */ PTR sys_add_key /* 4280 */ diff -Nurp linux-2.6.16.38/arch/mips/kernel/syscall.c linux-2.6.16.38-vs2.0.3-rc1/arch/mips/kernel/syscall.c --- linux-2.6.16.38/arch/mips/kernel/syscall.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/mips/kernel/syscall.c 2007-01-23 13:45:34.000000000 +0100 @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -229,7 +230,7 @@ out: */ asmlinkage int sys_uname(struct old_utsname __user * name) { - if (name && !copy_to_user(name, &system_utsname, sizeof (*name))) + if (name && !copy_to_user(name, vx_new_utsname(), sizeof (*name))) return 0; return -EFAULT; } @@ -240,21 +241,23 @@ asmlinkage int sys_uname(struct old_utsn asmlinkage int sys_olduname(struct oldold_utsname __user * name) { int error; + struct new_utsname *ptr; if (!name) return -EFAULT; if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname))) return -EFAULT; - error = __copy_to_user(&name->sysname,&system_utsname.sysname,__OLD_UTS_LEN); + ptr = vx_new_utsname(); + error = __copy_to_user(&name->sysname,ptr->sysname,__OLD_UTS_LEN); error -= __put_user(0,name->sysname+__OLD_UTS_LEN); - error -= __copy_to_user(&name->nodename,&system_utsname.nodename,__OLD_UTS_LEN); + error -= __copy_to_user(&name->nodename,ptr->nodename,__OLD_UTS_LEN); error -= __put_user(0,name->nodename+__OLD_UTS_LEN); - error -= __copy_to_user(&name->release,&system_utsname.release,__OLD_UTS_LEN); + error -= __copy_to_user(&name->release,ptr->release,__OLD_UTS_LEN); error -= __put_user(0,name->release+__OLD_UTS_LEN); - error -= __copy_to_user(&name->version,&system_utsname.version,__OLD_UTS_LEN); + error -= __copy_to_user(&name->version,ptr->version,__OLD_UTS_LEN); error -= __put_user(0,name->version+__OLD_UTS_LEN); - error -= __copy_to_user(&name->machine,&system_utsname.machine,__OLD_UTS_LEN); + error -= __copy_to_user(&name->machine,ptr->machine,__OLD_UTS_LEN); error = __put_user(0,name->machine+__OLD_UTS_LEN); error = error ? -EFAULT : 0; @@ -290,10 +293,10 @@ asmlinkage int _sys_sysmips(int cmd, lon return -EFAULT; down_write(&uts_sem); - strncpy(system_utsname.nodename, nodename, len); + strncpy(vx_new_uts(nodename), nodename, len); nodename[__NEW_UTS_LEN] = '\0'; - strlcpy(system_utsname.nodename, nodename, - sizeof(system_utsname.nodename)); + strlcpy(vx_new_uts(nodename), nodename, + sizeof(vx_new_uts(nodename))); up_write(&uts_sem); return 0; } diff -Nurp linux-2.6.16.38/arch/mips/kernel/sysirix.c linux-2.6.16.38-vs2.0.3-rc1/arch/mips/kernel/sysirix.c --- linux-2.6.16.38/arch/mips/kernel/sysirix.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/mips/kernel/sysirix.c 2007-01-23 13:45:34.000000000 +0100 @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -904,7 +905,7 @@ asmlinkage int irix_getdomainname(char _ down_read(&uts_sem); if (len > __NEW_UTS_LEN) len = __NEW_UTS_LEN; - err = copy_to_user(name, system_utsname.domainname, len) ? -EFAULT : 0; + err = copy_to_user(name, vx_new_uts(domainname), len) ? -EFAULT : 0; up_read(&uts_sem); return err; @@ -1147,11 +1148,11 @@ struct iuname { asmlinkage int irix_uname(struct iuname __user *buf) { down_read(&uts_sem); - if (copy_from_user(system_utsname.sysname, buf->sysname, 65) - || copy_from_user(system_utsname.nodename, buf->nodename, 65) - || copy_from_user(system_utsname.release, buf->release, 65) - || copy_from_user(system_utsname.version, buf->version, 65) - || copy_from_user(system_utsname.machine, buf->machine, 65)) { + if (copy_from_user(vx_new_uts(sysname), buf->sysname, 65) + || copy_from_user(vx_new_uts(nodename), buf->nodename, 65) + || copy_from_user(vx_new_uts(release), buf->release, 65) + || copy_from_user(vx_new_uts(version), buf->version, 65) + || copy_from_user(vx_new_uts(machine), buf->machine, 65)) { return -EFAULT; } up_read(&uts_sem); diff -Nurp linux-2.6.16.38/arch/parisc/hpux/sys_hpux.c linux-2.6.16.38-vs2.0.3-rc1/arch/parisc/hpux/sys_hpux.c --- linux-2.6.16.38/arch/parisc/hpux/sys_hpux.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/parisc/hpux/sys_hpux.c 2007-01-23 13:45:34.000000000 +0100 @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -266,15 +267,15 @@ static int hpux_uname(struct hpux_utsnam down_read(&uts_sem); - error = __copy_to_user(&name->sysname,&system_utsname.sysname,HPUX_UTSLEN-1); + error = __copy_to_user(&name->sysname,vx_new_uts(sysname),HPUX_UTSLEN-1); error |= __put_user(0,name->sysname+HPUX_UTSLEN-1); - error |= __copy_to_user(&name->nodename,&system_utsname.nodename,HPUX_UTSLEN-1); + error |= __copy_to_user(&name->nodename,vx_new_uts(nodename),HPUX_UTSLEN-1); error |= __put_user(0,name->nodename+HPUX_UTSLEN-1); - error |= __copy_to_user(&name->release,&system_utsname.release,HPUX_UTSLEN-1); + error |= __copy_to_user(&name->release,vx_new_uts(release),HPUX_UTSLEN-1); error |= __put_user(0,name->release+HPUX_UTSLEN-1); - error |= __copy_to_user(&name->version,&system_utsname.version,HPUX_UTSLEN-1); + error |= __copy_to_user(&name->version,vx_new_uts(version),HPUX_UTSLEN-1); error |= __put_user(0,name->version+HPUX_UTSLEN-1); - error |= __copy_to_user(&name->machine,&system_utsname.machine,HPUX_UTSLEN-1); + error |= __copy_to_user(&name->machine,vx_new_uts(machine),HPUX_UTSLEN-1); error |= __put_user(0,name->machine+HPUX_UTSLEN-1); up_read(&uts_sem); @@ -373,8 +374,8 @@ int hpux_utssys(char *ubuf, int n, int t /* TODO: print a warning about using this? */ down_write(&uts_sem); error = -EFAULT; - if (!copy_from_user(system_utsname.sysname, ubuf, len)) { - system_utsname.sysname[len] = 0; + if (!copy_from_user(vx_new_uts(sysname), ubuf, len)) { + vx_new_uts(sysname)[len] = 0; error = 0; } up_write(&uts_sem); @@ -400,8 +401,8 @@ int hpux_utssys(char *ubuf, int n, int t /* TODO: print a warning about this? */ down_write(&uts_sem); error = -EFAULT; - if (!copy_from_user(system_utsname.release, ubuf, len)) { - system_utsname.release[len] = 0; + if (!copy_from_user(vx_new_uts(release), ubuf, len)) { + vx_new_uts(release)[len] = 0; error = 0; } up_write(&uts_sem); @@ -422,13 +423,13 @@ int hpux_getdomainname(char *name, int l down_read(&uts_sem); - nlen = strlen(system_utsname.domainname) + 1; + nlen = strlen(vx_new_uts(domainname)) + 1; if (nlen < len) len = nlen; if(len > __NEW_UTS_LEN) goto done; - if(copy_to_user(name, system_utsname.domainname, len)) + if(copy_to_user(name, vx_new_uts(domainname), len)) goto done; err = 0; done: diff -Nurp linux-2.6.16.38/arch/parisc/Kconfig linux-2.6.16.38-vs2.0.3-rc1/arch/parisc/Kconfig --- linux-2.6.16.38/arch/parisc/Kconfig 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/parisc/Kconfig 2007-01-23 13:45:34.000000000 +0100 @@ -213,6 +213,8 @@ source "arch/parisc/oprofile/Kconfig" source "arch/parisc/Kconfig.debug" +source "kernel/vserver/Kconfig" + source "security/Kconfig" source "crypto/Kconfig" diff -Nurp linux-2.6.16.38/arch/parisc/kernel/syscall_table.S linux-2.6.16.38-vs2.0.3-rc1/arch/parisc/kernel/syscall_table.S --- linux-2.6.16.38/arch/parisc/kernel/syscall_table.S 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/parisc/kernel/syscall_table.S 2007-01-23 13:45:34.000000000 +0100 @@ -368,7 +368,7 @@ ENTRY_COMP(mbind) /* 260 */ ENTRY_COMP(get_mempolicy) ENTRY_COMP(set_mempolicy) - ENTRY_SAME(ni_syscall) /* 263: reserved for vserver */ + ENTRY_DIFF(vserver) ENTRY_SAME(add_key) ENTRY_SAME(request_key) /* 265 */ ENTRY_SAME(keyctl) diff -Nurp linux-2.6.16.38/arch/parisc/kernel/sys_parisc32.c linux-2.6.16.38-vs2.0.3-rc1/arch/parisc/kernel/sys_parisc32.c --- linux-2.6.16.38/arch/parisc/kernel/sys_parisc32.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/parisc/kernel/sys_parisc32.c 2007-01-23 13:45:34.000000000 +0100 @@ -657,6 +657,7 @@ asmlinkage int sys32_sysinfo(struct sysi do { seq = read_seqbegin(&xtime_lock); + /* FIXME: requires vx virtualization */ val.uptime = jiffies / HZ; val.loads[0] = avenrun[0] << (SI_LOAD_SHIFT - FSHIFT); diff -Nurp linux-2.6.16.38/arch/powerpc/Kconfig linux-2.6.16.38-vs2.0.3-rc1/arch/powerpc/Kconfig --- linux-2.6.16.38/arch/powerpc/Kconfig 2007-01-23 13:44:16.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/powerpc/Kconfig 2007-01-23 13:45:34.000000000 +0100 @@ -977,6 +977,8 @@ endmenu source "arch/powerpc/Kconfig.debug" +source "kernel/vserver/Kconfig" + source "security/Kconfig" config KEYS_COMPAT diff -Nurp linux-2.6.16.38/arch/powerpc/kernel/process.c linux-2.6.16.38-vs2.0.3-rc1/arch/powerpc/kernel/process.c --- linux-2.6.16.38/arch/powerpc/kernel/process.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/powerpc/kernel/process.c 2007-01-23 13:45:34.000000000 +0100 @@ -425,8 +425,9 @@ void show_regs(struct pt_regs * regs) trap = TRAP(regs); if (trap == 0x300 || trap == 0x600) printk("DAR: "REG", DSISR: "REG"\n", regs->dar, regs->dsisr); - printk("TASK = %p[%d] '%s' THREAD: %p", - current, current->pid, current->comm, task_thread_info(current)); + printk("TASK = %p[%d,#%u] '%s' THREAD: %p", + current, current->pid, current->xid, + current->comm, task_thread_info(current)); #ifdef CONFIG_SMP printk(" CPU: %d", smp_processor_id()); diff -Nurp linux-2.6.16.38/arch/powerpc/kernel/syscalls.c linux-2.6.16.38-vs2.0.3-rc1/arch/powerpc/kernel/syscalls.c --- linux-2.6.16.38/arch/powerpc/kernel/syscalls.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/powerpc/kernel/syscalls.c 2007-01-23 13:45:34.000000000 +0100 @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -259,7 +260,7 @@ long ppc_newuname(struct new_utsname __u int err = 0; down_read(&uts_sem); - if (copy_to_user(name, &system_utsname, sizeof(*name))) + if (copy_to_user(name, vx_new_utsname(), sizeof(*name))) err = -EFAULT; up_read(&uts_sem); if (!err) @@ -272,7 +273,7 @@ int sys_uname(struct old_utsname __user int err = 0; down_read(&uts_sem); - if (copy_to_user(name, &system_utsname, sizeof(*name))) + if (copy_to_user(name, vx_new_utsname(), sizeof(*name))) err = -EFAULT; up_read(&uts_sem); if (!err) @@ -283,25 +284,22 @@ int sys_uname(struct old_utsname __user int sys_olduname(struct oldold_utsname __user *name) { int error; + struct new_utsname *ptr; if (!access_ok(VERIFY_WRITE, name, sizeof(struct oldold_utsname))) return -EFAULT; down_read(&uts_sem); - error = __copy_to_user(&name->sysname, &system_utsname.sysname, - __OLD_UTS_LEN); + ptr = vx_new_utsname(); + error = __copy_to_user(&name->sysname, ptr->sysname, __OLD_UTS_LEN); error |= __put_user(0, name->sysname + __OLD_UTS_LEN); - error |= __copy_to_user(&name->nodename, &system_utsname.nodename, - __OLD_UTS_LEN); + error |= __copy_to_user(&name->nodename, ptr->nodename, __OLD_UTS_LEN); error |= __put_user(0, name->nodename + __OLD_UTS_LEN); - error |= __copy_to_user(&name->release, &system_utsname.release, - __OLD_UTS_LEN); + error |= __copy_to_user(&name->release, ptr->release, __OLD_UTS_LEN); error |= __put_user(0, name->release + __OLD_UTS_LEN); - error |= __copy_to_user(&name->version, &system_utsname.version, - __OLD_UTS_LEN); + error |= __copy_to_user(&name->version, ptr->version, __OLD_UTS_LEN); error |= __put_user(0, name->version + __OLD_UTS_LEN); - error |= __copy_to_user(&name->machine, &system_utsname.machine, - __OLD_UTS_LEN); + error |= __copy_to_user(&name->machine, ptr->machine, __OLD_UTS_LEN); error |= override_machine(name->machine); up_read(&uts_sem); diff -Nurp linux-2.6.16.38/arch/powerpc/kernel/systbl.S linux-2.6.16.38-vs2.0.3-rc1/arch/powerpc/kernel/systbl.S --- linux-2.6.16.38/arch/powerpc/kernel/systbl.S 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/powerpc/kernel/systbl.S 2007-01-23 13:45:34.000000000 +0100 @@ -296,7 +296,7 @@ COMPAT_SYS(fstatfs64) SYSX(sys_ni_syscall, ppc_fadvise64_64, ppc_fadvise64_64) PPC_SYS(rtas) OLDSYS(debug_setcontext) -SYSCALL(ni_syscall) +SYSX(sys_vserver, sys32_vserver, sys_vserver) SYSCALL(ni_syscall) COMPAT_SYS(mbind) COMPAT_SYS(get_mempolicy) diff -Nurp linux-2.6.16.38/arch/powerpc/kernel/vdso.c linux-2.6.16.38-vs2.0.3-rc1/arch/powerpc/kernel/vdso.c --- linux-2.6.16.38/arch/powerpc/kernel/vdso.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/powerpc/kernel/vdso.c 2007-01-23 13:45:34.000000000 +0100 @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -294,7 +295,7 @@ int arch_setup_additional_pages(struct l kmem_cache_free(vm_area_cachep, vma); return -ENOMEM; } - mm->total_vm += (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; + vx_vmpages_add(mm, (vma->vm_end - vma->vm_start) >> PAGE_SHIFT); up_write(&mm->mmap_sem); return 0; diff -Nurp linux-2.6.16.38/arch/ppc/Kconfig linux-2.6.16.38-vs2.0.3-rc1/arch/ppc/Kconfig --- linux-2.6.16.38/arch/ppc/Kconfig 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/ppc/Kconfig 2007-01-23 13:45:34.000000000 +0100 @@ -1394,6 +1394,8 @@ source "arch/powerpc/oprofile/Kconfig" source "arch/ppc/Kconfig.debug" +source "kernel/vserver/Kconfig" + source "security/Kconfig" source "crypto/Kconfig" diff -Nurp linux-2.6.16.38/arch/s390/Kconfig linux-2.6.16.38-vs2.0.3-rc1/arch/s390/Kconfig --- linux-2.6.16.38/arch/s390/Kconfig 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/s390/Kconfig 2007-01-23 13:45:34.000000000 +0100 @@ -472,6 +472,8 @@ source "arch/s390/oprofile/Kconfig" source "arch/s390/Kconfig.debug" +source "kernel/vserver/Kconfig" + source "security/Kconfig" source "crypto/Kconfig" diff -Nurp linux-2.6.16.38/arch/s390/kernel/process.c linux-2.6.16.38-vs2.0.3-rc1/arch/s390/kernel/process.c --- linux-2.6.16.38/arch/s390/kernel/process.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/s390/kernel/process.c 2007-01-23 13:45:34.000000000 +0100 @@ -164,9 +164,9 @@ void show_regs(struct pt_regs *regs) struct task_struct *tsk = current; printk("CPU: %d %s\n", task_thread_info(tsk)->cpu, print_tainted()); - printk("Process %s (pid: %d, task: %p, ksp: %p)\n", - current->comm, current->pid, (void *) tsk, - (void *) tsk->thread.ksp); + printk("Process %s (pid: %d[#%u], task: %p, ksp: %p)\n", + current->comm, current->pid, current->xid, + (void *) tsk, (void *) tsk->thread.ksp); show_registers(regs); /* Show stack backtrace if pt_regs is from kernel mode */ diff -Nurp linux-2.6.16.38/arch/s390/kernel/ptrace.c linux-2.6.16.38-vs2.0.3-rc1/arch/s390/kernel/ptrace.c --- linux-2.6.16.38/arch/s390/kernel/ptrace.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/s390/kernel/ptrace.c 2007-01-23 13:45:34.000000000 +0100 @@ -723,7 +723,13 @@ sys_ptrace(long request, long pid, long goto out; } + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT)) { + ret = -EPERM; + goto out_tsk; + } + ret = do_ptrace(child, request, addr, data); +out_tsk: put_task_struct(child); out: unlock_kernel(); diff -Nurp linux-2.6.16.38/arch/s390/kernel/syscalls.S linux-2.6.16.38-vs2.0.3-rc1/arch/s390/kernel/syscalls.S --- linux-2.6.16.38/arch/s390/kernel/syscalls.S 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/s390/kernel/syscalls.S 2007-01-23 13:45:34.000000000 +0100 @@ -271,7 +271,7 @@ SYSCALL(sys_clock_settime,sys_clock_sett SYSCALL(sys_clock_gettime,sys_clock_gettime,sys32_clock_gettime_wrapper) /* 260 */ SYSCALL(sys_clock_getres,sys_clock_getres,sys32_clock_getres_wrapper) SYSCALL(sys_clock_nanosleep,sys_clock_nanosleep,sys32_clock_nanosleep_wrapper) -NI_SYSCALL /* reserved for vserver */ +SYSCALL(sys_vserver,sys_vserver,sys32_vserver) SYSCALL(s390_fadvise64_64,sys_ni_syscall,sys32_fadvise64_64_wrapper) SYSCALL(sys_statfs64,sys_statfs64,compat_sys_statfs64_wrapper) SYSCALL(sys_fstatfs64,sys_fstatfs64,compat_sys_fstatfs64_wrapper) diff -Nurp linux-2.6.16.38/arch/sh/Kconfig linux-2.6.16.38-vs2.0.3-rc1/arch/sh/Kconfig --- linux-2.6.16.38/arch/sh/Kconfig 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/sh/Kconfig 2007-01-23 13:45:34.000000000 +0100 @@ -633,6 +633,8 @@ source "arch/sh/oprofile/Kconfig" source "arch/sh/Kconfig.debug" +source "kernel/vserver/Kconfig" + source "security/Kconfig" source "crypto/Kconfig" diff -Nurp linux-2.6.16.38/arch/sh/kernel/kgdb_stub.c linux-2.6.16.38-vs2.0.3-rc1/arch/sh/kernel/kgdb_stub.c --- linux-2.6.16.38/arch/sh/kernel/kgdb_stub.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/sh/kernel/kgdb_stub.c 2007-01-23 13:45:34.000000000 +0100 @@ -412,7 +412,7 @@ static struct task_struct *get_thread(in if (pid == PID_MAX) pid = 0; /* First check via PID */ - thread = find_task_by_pid(pid); + thread = find_task_by_real_pid(pid); if (thread) return thread; diff -Nurp linux-2.6.16.38/arch/sh/kernel/setup.c linux-2.6.16.38-vs2.0.3-rc1/arch/sh/kernel/setup.c --- linux-2.6.16.38/arch/sh/kernel/setup.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/sh/kernel/setup.c 2007-01-23 13:45:34.000000000 +0100 @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -485,7 +486,7 @@ static int show_cpuinfo(struct seq_file seq_printf(m, "machine\t\t: %s\n", get_system_type()); seq_printf(m, "processor\t: %d\n", cpu); - seq_printf(m, "cpu family\t: %s\n", system_utsname.machine); + seq_printf(m, "cpu family\t: %s\n", vx_new_uts(machine)); seq_printf(m, "cpu type\t: %s\n", get_cpu_subtype()); show_cpuflags(m); diff -Nurp linux-2.6.16.38/arch/sh/kernel/sys_sh.c linux-2.6.16.38-vs2.0.3-rc1/arch/sh/kernel/sys_sh.c --- linux-2.6.16.38/arch/sh/kernel/sys_sh.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/sh/kernel/sys_sh.c 2007-01-23 13:45:34.000000000 +0100 @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -267,7 +268,7 @@ asmlinkage int sys_uname(struct old_utsn if (!name) return -EFAULT; down_read(&uts_sem); - err=copy_to_user(name, &system_utsname, sizeof (*name)); + err=copy_to_user(name, vx_new_utsname(), sizeof (*name)); up_read(&uts_sem); return err?-EFAULT:0; } diff -Nurp linux-2.6.16.38/arch/sh64/kernel/sys_sh64.c linux-2.6.16.38-vs2.0.3-rc1/arch/sh64/kernel/sys_sh64.c --- linux-2.6.16.38/arch/sh64/kernel/sys_sh64.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/sh64/kernel/sys_sh64.c 2007-01-23 13:45:34.000000000 +0100 @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -279,7 +280,7 @@ asmlinkage int sys_uname(struct old_utsn if (!name) return -EFAULT; down_read(&uts_sem); - err=copy_to_user(name, &system_utsname, sizeof (*name)); + err=copy_to_user(name, vx_new_utsname(), sizeof (*name)); up_read(&uts_sem); return err?-EFAULT:0; } diff -Nurp linux-2.6.16.38/arch/sparc/Kconfig linux-2.6.16.38-vs2.0.3-rc1/arch/sparc/Kconfig --- linux-2.6.16.38/arch/sparc/Kconfig 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/sparc/Kconfig 2007-01-23 13:45:34.000000000 +0100 @@ -284,6 +284,8 @@ source "fs/Kconfig" source "arch/sparc/Kconfig.debug" +source "kernel/vserver/Kconfig" + source "security/Kconfig" source "crypto/Kconfig" diff -Nurp linux-2.6.16.38/arch/sparc/kernel/ptrace.c linux-2.6.16.38-vs2.0.3-rc1/arch/sparc/kernel/ptrace.c --- linux-2.6.16.38/arch/sparc/kernel/ptrace.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/sparc/kernel/ptrace.c 2007-01-23 13:45:34.000000000 +0100 @@ -299,6 +299,10 @@ asmlinkage void do_ptrace(struct pt_regs pt_error_return(regs, -ret); goto out; } + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT)) { + pt_error_return(regs, ESRCH); + goto out_tsk; + } if ((current->personality == PER_SUNOS && request == PTRACE_SUNATTACH) || (current->personality != PER_SUNOS && request == PTRACE_ATTACH)) { diff -Nurp linux-2.6.16.38/arch/sparc/kernel/sys_sparc.c linux-2.6.16.38-vs2.0.3-rc1/arch/sparc/kernel/sys_sparc.c --- linux-2.6.16.38/arch/sparc/kernel/sys_sparc.c 2007-01-23 13:44:27.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/sparc/kernel/sys_sparc.c 2007-01-23 13:45:34.000000000 +0100 @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -473,13 +474,13 @@ asmlinkage int sys_getdomainname(char __ down_read(&uts_sem); - nlen = strlen(system_utsname.domainname) + 1; + nlen = strlen(vx_new_uts(domainname)) + 1; if (nlen < len) len = nlen; if (len > __NEW_UTS_LEN) goto done; - if (copy_to_user(name, system_utsname.domainname, len)) + if (copy_to_user(name, vx_new_uts(domainname), len)) goto done; err = 0; done: diff -Nurp linux-2.6.16.38/arch/sparc/kernel/sys_sunos.c linux-2.6.16.38-vs2.0.3-rc1/arch/sparc/kernel/sys_sunos.c --- linux-2.6.16.38/arch/sparc/kernel/sys_sunos.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/sparc/kernel/sys_sunos.c 2007-01-23 13:45:34.000000000 +0100 @@ -35,6 +35,7 @@ #include #include #include +#include #include @@ -482,14 +483,16 @@ struct sunos_utsname { asmlinkage int sunos_uname(struct sunos_utsname __user *name) { int ret; + struct new_utsname *ptr; down_read(&uts_sem); - ret = copy_to_user(&name->sname[0], &system_utsname.sysname[0], sizeof(name->sname) - 1); + ptr = vx_new_utsname(); + ret = copy_to_user(&name->sname[0], ptr->sysname, sizeof(name->sname) - 1); if (!ret) { - ret |= __copy_to_user(&name->nname[0], &system_utsname.nodename[0], sizeof(name->nname) - 1); + ret |= __copy_to_user(&name->nname[0], ptr->nodename, sizeof(name->nname) - 1); ret |= __put_user('\0', &name->nname[8]); - ret |= __copy_to_user(&name->rel[0], &system_utsname.release[0], sizeof(name->rel) - 1); - ret |= __copy_to_user(&name->ver[0], &system_utsname.version[0], sizeof(name->ver) - 1); - ret |= __copy_to_user(&name->mach[0], &system_utsname.machine[0], sizeof(name->mach) - 1); + ret |= __copy_to_user(&name->rel[0], ptr->release, sizeof(name->rel) - 1); + ret |= __copy_to_user(&name->ver[0], ptr->version, sizeof(name->ver) - 1); + ret |= __copy_to_user(&name->mach[0], ptr->machine, sizeof(name->mach) - 1); } up_read(&uts_sem); return ret ? -EFAULT : 0; diff -Nurp linux-2.6.16.38/arch/sparc/kernel/systbls.S linux-2.6.16.38-vs2.0.3-rc1/arch/sparc/kernel/systbls.S --- linux-2.6.16.38/arch/sparc/kernel/systbls.S 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/sparc/kernel/systbls.S 2007-01-23 13:45:34.000000000 +0100 @@ -72,7 +72,7 @@ sys_call_table: /*250*/ .long sparc_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl /*255*/ .long sys_nis_syscall, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep /*260*/ .long sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun -/*265*/ .long sys_timer_delete, sys_timer_create, sys_nis_syscall, sys_io_setup, sys_io_destroy +/*265*/ .long sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy /*270*/ .long sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink /*275*/ .long sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid /*280*/ .long sys_ni_syscall, sys_add_key, sys_request_key, sys_keyctl, sys_openat diff -Nurp linux-2.6.16.38/arch/sparc64/Kconfig linux-2.6.16.38-vs2.0.3-rc1/arch/sparc64/Kconfig --- linux-2.6.16.38/arch/sparc64/Kconfig 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/sparc64/Kconfig 2007-01-23 13:45:34.000000000 +0100 @@ -394,6 +394,8 @@ endmenu source "arch/sparc64/Kconfig.debug" +source "kernel/vserver/Kconfig" + source "security/Kconfig" source "crypto/Kconfig" diff -Nurp linux-2.6.16.38/arch/sparc64/kernel/binfmt_aout32.c linux-2.6.16.38-vs2.0.3-rc1/arch/sparc64/kernel/binfmt_aout32.c --- linux-2.6.16.38/arch/sparc64/kernel/binfmt_aout32.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/sparc64/kernel/binfmt_aout32.c 2007-01-23 13:45:34.000000000 +0100 @@ -27,6 +27,7 @@ #include #include #include +#include #include #include diff -Nurp linux-2.6.16.38/arch/sparc64/kernel/ptrace.c linux-2.6.16.38-vs2.0.3-rc1/arch/sparc64/kernel/ptrace.c --- linux-2.6.16.38/arch/sparc64/kernel/ptrace.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/sparc64/kernel/ptrace.c 2007-01-23 13:45:35.000000000 +0100 @@ -209,6 +209,10 @@ asmlinkage void do_ptrace(struct pt_regs pt_error_return(regs, -ret); goto out; } + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT)) { + pt_error_return(regs, ESRCH); + goto out_tsk; + } if ((current->personality == PER_SUNOS && request == PTRACE_SUNATTACH) || (current->personality != PER_SUNOS && request == PTRACE_ATTACH)) { diff -Nurp linux-2.6.16.38/arch/sparc64/kernel/sys_sparc.c linux-2.6.16.38-vs2.0.3-rc1/arch/sparc64/kernel/sys_sparc.c --- linux-2.6.16.38/arch/sparc64/kernel/sys_sparc.c 2007-01-23 13:44:27.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/sparc64/kernel/sys_sparc.c 2007-01-23 13:45:35.000000000 +0100 @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -480,13 +481,13 @@ asmlinkage long sys_getdomainname(char _ down_read(&uts_sem); - nlen = strlen(system_utsname.domainname) + 1; + nlen = strlen(vx_new_uts(domainname)) + 1; if (nlen < len) len = nlen; if (len > __NEW_UTS_LEN) goto done; - if (copy_to_user(name, system_utsname.domainname, len)) + if (copy_to_user(name, vx_new_uts(domainname), len)) goto done; err = 0; done: diff -Nurp linux-2.6.16.38/arch/sparc64/kernel/sys_sunos32.c linux-2.6.16.38-vs2.0.3-rc1/arch/sparc64/kernel/sys_sunos32.c --- linux-2.6.16.38/arch/sparc64/kernel/sys_sunos32.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/sparc64/kernel/sys_sunos32.c 2007-01-23 13:45:35.000000000 +0100 @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -437,18 +438,20 @@ struct sunos_utsname { asmlinkage int sunos_uname(struct sunos_utsname __user *name) { int ret; + struct new_utsname *ptr; down_read(&uts_sem); - ret = copy_to_user(&name->sname[0], &system_utsname.sysname[0], + ptr = vx_new_utsname(); + ret = copy_to_user(&name->sname[0], ptr->sysname, sizeof(name->sname) - 1); - ret |= copy_to_user(&name->nname[0], &system_utsname.nodename[0], + ret |= copy_to_user(&name->nname[0], ptr->nodename, sizeof(name->nname) - 1); ret |= put_user('\0', &name->nname[8]); - ret |= copy_to_user(&name->rel[0], &system_utsname.release[0], + ret |= copy_to_user(&name->rel[0], ptr->release, sizeof(name->rel) - 1); - ret |= copy_to_user(&name->ver[0], &system_utsname.version[0], + ret |= copy_to_user(&name->ver[0], ptr->version, sizeof(name->ver) - 1); - ret |= copy_to_user(&name->mach[0], &system_utsname.machine[0], + ret |= copy_to_user(&name->mach[0], ptr->machine, sizeof(name->mach) - 1); up_read(&uts_sem); return (ret ? -EFAULT : 0); diff -Nurp linux-2.6.16.38/arch/sparc64/kernel/systbls.S linux-2.6.16.38-vs2.0.3-rc1/arch/sparc64/kernel/systbls.S --- linux-2.6.16.38/arch/sparc64/kernel/systbls.S 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/sparc64/kernel/systbls.S 2007-01-23 13:45:35.000000000 +0100 @@ -73,7 +73,7 @@ sys_call_table32: /*250*/ .word sys32_mremap, sys32_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl .word sys_ni_syscall, compat_sys_clock_settime, compat_sys_clock_gettime, compat_sys_clock_getres, sys32_clock_nanosleep /*260*/ .word compat_sys_sched_getaffinity, compat_sys_sched_setaffinity, sys32_timer_settime, compat_sys_timer_gettime, sys_timer_getoverrun - .word sys_timer_delete, compat_sys_timer_create, sys_ni_syscall, compat_sys_io_setup, sys_io_destroy + .word sys_timer_delete, compat_sys_timer_create, sys32_vserver, compat_sys_io_setup, sys_io_destroy /*270*/ .word sys32_io_submit, sys_io_cancel, compat_sys_io_getevents, sys32_mq_open, sys_mq_unlink .word compat_sys_mq_timedsend, compat_sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, compat_sys_waitid /*280*/ .word sys_ni_syscall, sys_add_key, sys_request_key, sys_keyctl, compat_sys_openat @@ -142,7 +142,7 @@ sys_call_table: /*250*/ .word sys64_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl .word sys_ni_syscall, sys_clock_settime, sys_clock_gettime, sys_clock_getres, sys_clock_nanosleep /*260*/ .word sys_sched_getaffinity, sys_sched_setaffinity, sys_timer_settime, sys_timer_gettime, sys_timer_getoverrun - .word sys_timer_delete, sys_timer_create, sys_ni_syscall, sys_io_setup, sys_io_destroy + .word sys_timer_delete, sys_timer_create, sys_vserver, sys_io_setup, sys_io_destroy /*270*/ .word sys_io_submit, sys_io_cancel, sys_io_getevents, sys_mq_open, sys_mq_unlink .word sys_mq_timedsend, sys_mq_timedreceive, sys_mq_notify, sys_mq_getsetattr, sys_waitid /*280*/ .word sys_nis_syscall, sys_add_key, sys_request_key, sys_keyctl, sys_openat diff -Nurp linux-2.6.16.38/arch/sparc64/solaris/fs.c linux-2.6.16.38-vs2.0.3-rc1/arch/sparc64/solaris/fs.c --- linux-2.6.16.38/arch/sparc64/solaris/fs.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/sparc64/solaris/fs.c 2007-01-23 13:45:35.000000000 +0100 @@ -363,7 +363,7 @@ static int report_statvfs(struct vfsmoun int j = strlen (p); if (j > 15) j = 15; - if (IS_RDONLY(inode)) i = 1; + if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt)) i = 1; if (mnt->mnt_flags & MNT_NOSUID) i |= 2; if (!sysv_valid_dev(inode->i_sb->s_dev)) return -EOVERFLOW; @@ -399,7 +399,7 @@ static int report_statvfs64(struct vfsmo int j = strlen (p); if (j > 15) j = 15; - if (IS_RDONLY(inode)) i = 1; + if (IS_RDONLY(inode) || MNT_IS_RDONLY(mnt)) i = 1; if (mnt->mnt_flags & MNT_NOSUID) i |= 2; if (!sysv_valid_dev(inode->i_sb->s_dev)) return -EOVERFLOW; diff -Nurp linux-2.6.16.38/arch/sparc64/solaris/misc.c linux-2.6.16.38-vs2.0.3-rc1/arch/sparc64/solaris/misc.c --- linux-2.6.16.38/arch/sparc64/solaris/misc.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/sparc64/solaris/misc.c 2007-01-23 13:45:35.000000000 +0100 @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -239,7 +240,7 @@ asmlinkage int solaris_utssys(u32 buf, u /* Let's cheat */ err = set_utsfield(v->sysname, "SunOS", 1, 0); down_read(&uts_sem); - err |= set_utsfield(v->nodename, system_utsname.nodename, + err |= set_utsfield(v->nodename, vx_new_uts(nodename), 1, 1); up_read(&uts_sem); err |= set_utsfield(v->release, "2.6", 0, 0); @@ -263,7 +264,7 @@ asmlinkage int solaris_utsname(u32 buf) /* Why should we not lie a bit? */ down_read(&uts_sem); err = set_utsfield(v->sysname, "SunOS", 0, 0); - err |= set_utsfield(v->nodename, system_utsname.nodename, 1, 1); + err |= set_utsfield(v->nodename, vx_new_uts(nodename), 1, 1); err |= set_utsfield(v->release, "5.6", 0, 0); err |= set_utsfield(v->version, "Generic", 0, 0); err |= set_utsfield(v->machine, machine(), 0, 0); @@ -295,7 +296,7 @@ asmlinkage int solaris_sysinfo(int cmd, case SI_HOSTNAME: r = buffer + 256; down_read(&uts_sem); - for (p = system_utsname.nodename, q = buffer; + for (p = vx_new_uts(nodename), q = buffer; q < r && *p && *p != '.'; *q++ = *p++); up_read(&uts_sem); *q = 0; diff -Nurp linux-2.6.16.38/arch/um/drivers/mconsole_kern.c linux-2.6.16.38-vs2.0.3-rc1/arch/um/drivers/mconsole_kern.c --- linux-2.6.16.38/arch/um/drivers/mconsole_kern.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/um/drivers/mconsole_kern.c 2007-01-23 13:45:35.000000000 +0100 @@ -21,6 +21,7 @@ #include "linux/proc_fs.h" #include "linux/syscalls.h" #include "linux/console.h" +#include "linux/vs_cvirt.h" #include "asm/irq.h" #include "asm/uaccess.h" #include "user_util.h" diff -Nurp linux-2.6.16.38/arch/um/Kconfig linux-2.6.16.38-vs2.0.3-rc1/arch/um/Kconfig --- linux-2.6.16.38/arch/um/Kconfig 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/um/Kconfig 2007-01-23 13:45:35.000000000 +0100 @@ -290,6 +290,8 @@ source "drivers/connector/Kconfig" source "fs/Kconfig" +source "kernel/vserver/Kconfig" + source "security/Kconfig" source "crypto/Kconfig" diff -Nurp linux-2.6.16.38/arch/um/kernel/syscall_kern.c linux-2.6.16.38-vs2.0.3-rc1/arch/um/kernel/syscall_kern.c --- linux-2.6.16.38/arch/um/kernel/syscall_kern.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/um/kernel/syscall_kern.c 2007-01-23 13:45:35.000000000 +0100 @@ -15,6 +15,8 @@ #include "linux/unistd.h" #include "linux/slab.h" #include "linux/utime.h" +#include + #include "asm/mman.h" #include "asm/uaccess.h" #include "kern_util.h" @@ -110,7 +112,7 @@ long sys_uname(struct old_utsname * name if (!name) return -EFAULT; down_read(&uts_sem); - err=copy_to_user(name, &system_utsname, sizeof (*name)); + err=copy_to_user(name, vx_new_utsname(), sizeof (*name)); up_read(&uts_sem); return err?-EFAULT:0; } @@ -118,6 +120,7 @@ long sys_uname(struct old_utsname * name long sys_olduname(struct oldold_utsname * name) { long error; + struct new_utsname *ptr; if (!name) return -EFAULT; @@ -126,19 +129,20 @@ long sys_olduname(struct oldold_utsname down_read(&uts_sem); - error = __copy_to_user(&name->sysname,&system_utsname.sysname, + ptr = vx_new_utsname(); + error = __copy_to_user(&name->sysname,ptr->sysname, __OLD_UTS_LEN); error |= __put_user(0,name->sysname+__OLD_UTS_LEN); - error |= __copy_to_user(&name->nodename,&system_utsname.nodename, + error |= __copy_to_user(&name->nodename,ptr->nodename, __OLD_UTS_LEN); error |= __put_user(0,name->nodename+__OLD_UTS_LEN); - error |= __copy_to_user(&name->release,&system_utsname.release, + error |= __copy_to_user(&name->release,ptr->release, __OLD_UTS_LEN); error |= __put_user(0,name->release+__OLD_UTS_LEN); - error |= __copy_to_user(&name->version,&system_utsname.version, + error |= __copy_to_user(&name->version,ptr->version, __OLD_UTS_LEN); error |= __put_user(0,name->version+__OLD_UTS_LEN); - error |= __copy_to_user(&name->machine,&system_utsname.machine, + error |= __copy_to_user(&name->machine,ptr->machine, __OLD_UTS_LEN); error |= __put_user(0,name->machine+__OLD_UTS_LEN); diff -Nurp linux-2.6.16.38/arch/um/sys-x86_64/syscalls.c linux-2.6.16.38-vs2.0.3-rc1/arch/um/sys-x86_64/syscalls.c --- linux-2.6.16.38/arch/um/sys-x86_64/syscalls.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/um/sys-x86_64/syscalls.c 2007-01-23 13:45:35.000000000 +0100 @@ -9,6 +9,7 @@ #include "linux/shm.h" #include "linux/utsname.h" #include "linux/personality.h" +#include "linux/vs_cvirt.h" #include "asm/uaccess.h" #define __FRAME_OFFSETS #include "asm/ptrace.h" @@ -21,7 +22,7 @@ asmlinkage long sys_uname64(struct new_u { int err; down_read(&uts_sem); - err = copy_to_user(name, &system_utsname, sizeof (*name)); + err = copy_to_user(name, vx_new_utsname(), sizeof (*name)); up_read(&uts_sem); if (personality(current->personality) == PER_LINUX32) err |= copy_to_user(&name->machine, "i686", 5); diff -Nurp linux-2.6.16.38/arch/v850/Kconfig linux-2.6.16.38-vs2.0.3-rc1/arch/v850/Kconfig --- linux-2.6.16.38/arch/v850/Kconfig 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/v850/Kconfig 2007-01-23 13:45:35.000000000 +0100 @@ -320,6 +320,8 @@ source "drivers/usb/Kconfig" source "arch/v850/Kconfig.debug" +source "kernel/vserver/Kconfig" + source "security/Kconfig" source "crypto/Kconfig" diff -Nurp linux-2.6.16.38/arch/v850/kernel/ptrace.c linux-2.6.16.38-vs2.0.3-rc1/arch/v850/kernel/ptrace.c --- linux-2.6.16.38/arch/v850/kernel/ptrace.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/v850/kernel/ptrace.c 2007-01-23 14:12:07.000000000 +0100 @@ -117,6 +117,9 @@ long arch_ptrace(struct task_struct *chi { int rval; + if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT)) + goto out; + switch (request) { unsigned long val, copied; diff -Nurp linux-2.6.16.38/arch/x86_64/ia32/ia32_aout.c linux-2.6.16.38-vs2.0.3-rc1/arch/x86_64/ia32/ia32_aout.c --- linux-2.6.16.38/arch/x86_64/ia32/ia32_aout.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/x86_64/ia32/ia32_aout.c 2007-01-23 13:45:35.000000000 +0100 @@ -25,6 +25,7 @@ #include #include #include +#include #include #include diff -Nurp linux-2.6.16.38/arch/x86_64/ia32/ia32_binfmt.c linux-2.6.16.38-vs2.0.3-rc1/arch/x86_64/ia32/ia32_binfmt.c --- linux-2.6.16.38/arch/x86_64/ia32/ia32_binfmt.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/x86_64/ia32/ia32_binfmt.c 2007-01-23 13:45:35.000000000 +0100 @@ -371,7 +371,8 @@ int ia32_setup_arg_pages(struct linux_bi kmem_cache_free(vm_area_cachep, mpnt); return ret; } - mm->stack_vm = mm->total_vm = vma_pages(mpnt); + vx_vmpages_sub(mm, mm->total_vm - vma_pages(mpnt)); + mm->stack_vm = mm->total_vm; } for (i = 0 ; i < MAX_ARG_PAGES ; i++) { diff -Nurp linux-2.6.16.38/arch/x86_64/ia32/ia32entry.S linux-2.6.16.38-vs2.0.3-rc1/arch/x86_64/ia32/ia32entry.S --- linux-2.6.16.38/arch/x86_64/ia32/ia32entry.S 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/x86_64/ia32/ia32entry.S 2007-01-23 13:45:35.000000000 +0100 @@ -650,7 +650,7 @@ ia32_sys_call_table: .quad sys_tgkill /* 270 */ .quad compat_sys_utimes .quad sys32_fadvise64_64 - .quad quiet_ni_syscall /* sys_vserver */ + .quad sys32_vserver .quad sys_mbind .quad compat_sys_get_mempolicy /* 275 */ .quad sys_set_mempolicy diff -Nurp linux-2.6.16.38/arch/x86_64/ia32/syscall32.c linux-2.6.16.38-vs2.0.3-rc1/arch/x86_64/ia32/syscall32.c --- linux-2.6.16.38/arch/x86_64/ia32/syscall32.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/x86_64/ia32/syscall32.c 2007-01-23 13:45:35.000000000 +0100 @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -70,7 +71,7 @@ int syscall32_setup_pages(struct linux_b kmem_cache_free(vm_area_cachep, vma); return ret; } - mm->total_vm += npages; + vx_vmpages_add(mm, npages); up_write(&mm->mmap_sem); return 0; } diff -Nurp linux-2.6.16.38/arch/x86_64/ia32/sys_ia32.c linux-2.6.16.38-vs2.0.3-rc1/arch/x86_64/ia32/sys_ia32.c --- linux-2.6.16.38/arch/x86_64/ia32/sys_ia32.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/x86_64/ia32/sys_ia32.c 2007-01-23 13:45:35.000000000 +0100 @@ -62,6 +62,7 @@ #include #include #include +#include #include #include #include @@ -882,6 +883,7 @@ asmlinkage long sys32_mmap2(unsigned lon asmlinkage long sys32_olduname(struct oldold_utsname __user * name) { int error; + struct new_utsname *ptr; if (!name) return -EFAULT; @@ -890,13 +892,14 @@ asmlinkage long sys32_olduname(struct ol down_read(&uts_sem); - error = __copy_to_user(&name->sysname,&system_utsname.sysname,__OLD_UTS_LEN); + ptr = vx_new_utsname(); + error = __copy_to_user(&name->sysname,ptr->sysname,__OLD_UTS_LEN); __put_user(0,name->sysname+__OLD_UTS_LEN); - __copy_to_user(&name->nodename,&system_utsname.nodename,__OLD_UTS_LEN); + __copy_to_user(&name->nodename,ptr->nodename,__OLD_UTS_LEN); __put_user(0,name->nodename+__OLD_UTS_LEN); - __copy_to_user(&name->release,&system_utsname.release,__OLD_UTS_LEN); + __copy_to_user(&name->release,ptr->release,__OLD_UTS_LEN); __put_user(0,name->release+__OLD_UTS_LEN); - __copy_to_user(&name->version,&system_utsname.version,__OLD_UTS_LEN); + __copy_to_user(&name->version,ptr->version,__OLD_UTS_LEN); __put_user(0,name->version+__OLD_UTS_LEN); { char *arch = "x86_64"; @@ -919,7 +922,7 @@ long sys32_uname(struct old_utsname __us if (!name) return -EFAULT; down_read(&uts_sem); - err=copy_to_user(name, &system_utsname, sizeof (*name)); + err=copy_to_user(name, vx_new_utsname(), sizeof (*name)); up_read(&uts_sem); if (personality(current->personality) == PER_LINUX32) err |= copy_to_user(&name->machine, "i686", 5); diff -Nurp linux-2.6.16.38/arch/x86_64/Kconfig linux-2.6.16.38-vs2.0.3-rc1/arch/x86_64/Kconfig --- linux-2.6.16.38/arch/x86_64/Kconfig 2007-01-23 13:44:16.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/x86_64/Kconfig 2007-01-23 13:45:35.000000000 +0100 @@ -590,6 +590,8 @@ endmenu source "arch/x86_64/Kconfig.debug" +source "kernel/vserver/Kconfig" + source "security/Kconfig" source "crypto/Kconfig" diff -Nurp linux-2.6.16.38/arch/x86_64/kernel/sys_x86_64.c linux-2.6.16.38-vs2.0.3-rc1/arch/x86_64/kernel/sys_x86_64.c --- linux-2.6.16.38/arch/x86_64/kernel/sys_x86_64.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/x86_64/kernel/sys_x86_64.c 2007-01-23 13:45:35.000000000 +0100 @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -148,7 +149,7 @@ asmlinkage long sys_uname(struct new_uts { int err; down_read(&uts_sem); - err = copy_to_user(name, &system_utsname, sizeof (*name)); + err = copy_to_user(name, vx_new_utsname(), sizeof (*name)); up_read(&uts_sem); if (personality(current->personality) == PER_LINUX32) err |= copy_to_user(&name->machine, "i686", 5); diff -Nurp linux-2.6.16.38/arch/x86_64/kernel/traps.c linux-2.6.16.38-vs2.0.3-rc1/arch/x86_64/kernel/traps.c --- linux-2.6.16.38/arch/x86_64/kernel/traps.c 2006-06-09 15:25:50.000000000 +0200 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/x86_64/kernel/traps.c 2007-01-23 13:45:35.000000000 +0100 @@ -322,8 +322,9 @@ void show_registers(struct pt_regs *regs printk("CPU %d ", cpu); __show_regs(regs); - printk("Process %s (pid: %d, threadinfo %p, task %p)\n", - cur->comm, cur->pid, task_thread_info(cur), cur); + printk("Process %s (pid: %d[#%u], threadinfo %p, task %p)\n", + cur->comm, cur->pid, cur->xid, + task_thread_info(cur), cur); /* * When in-kernel, we also print out the stack and code at the diff -Nurp linux-2.6.16.38/arch/xtensa/kernel/syscalls.c linux-2.6.16.38-vs2.0.3-rc1/arch/xtensa/kernel/syscalls.c --- linux-2.6.16.38/arch/xtensa/kernel/syscalls.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/arch/xtensa/kernel/syscalls.c 2007-01-23 13:45:35.000000000 +0100 @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -129,7 +130,7 @@ out: int sys_uname(struct old_utsname * name) { - if (name && !copy_to_user(name, &system_utsname, sizeof (*name))) + if (name && !copy_to_user(name, vx_new_utsname(), sizeof (*name))) return 0; return -EFAULT; } diff -Nurp linux-2.6.16.38/drivers/block/Kconfig linux-2.6.16.38-vs2.0.3-rc1/drivers/block/Kconfig --- linux-2.6.16.38/drivers/block/Kconfig 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/drivers/block/Kconfig 2007-01-23 13:45:35.000000000 +0100 @@ -315,6 +315,13 @@ config BLK_DEV_CRYPTOLOOP instead, which can be configured to be on-disk compatible with the cryptoloop device. +config BLK_DEV_VROOT + tristate "Virtual Root device support" + depends on QUOTACTL + ---help--- + Saying Y here will allow you to use quota/fs ioctls on a shared + partition within a virtual server without compromising security. + config BLK_DEV_NBD tristate "Network block device support" depends on NET diff -Nurp linux-2.6.16.38/drivers/block/Makefile linux-2.6.16.38-vs2.0.3-rc1/drivers/block/Makefile --- linux-2.6.16.38/drivers/block/Makefile 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/drivers/block/Makefile 2007-01-23 13:45:35.000000000 +0100 @@ -30,4 +30,5 @@ obj-$(CONFIG_BLK_DEV_CRYPTOLOOP) += cryp obj-$(CONFIG_VIODASD) += viodasd.o obj-$(CONFIG_BLK_DEV_SX8) += sx8.o obj-$(CONFIG_BLK_DEV_UB) += ub.o +obj-$(CONFIG_BLK_DEV_VROOT) += vroot.o diff -Nurp linux-2.6.16.38/drivers/block/vroot.c linux-2.6.16.38-vs2.0.3-rc1/drivers/block/vroot.c --- linux-2.6.16.38/drivers/block/vroot.c 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/drivers/block/vroot.c 2007-01-23 13:45:35.000000000 +0100 @@ -0,0 +1,288 @@ +/* + * linux/drivers/block/vroot.c + * + * written by Herbert Pötzl, 9/11/2002 + * ported to 2.6.10 by Herbert Pötzl, 30/12/2004 + * + * based on the loop.c code by Theodore Ts'o. + * + * Copyright (C) 2002-2005 by Herbert Pötzl. + * Redistribution of this file is permitted under the + * GNU General Public License. + * + */ + +#include +#include +#include +#include +#include +#include + +#include +#include + + +static int max_vroot = 8; + +static struct vroot_device *vroot_dev; +static struct gendisk **disks; + + +static int vroot_set_dev( + struct vroot_device *vr, + struct file *vr_file, + struct block_device *bdev, + unsigned int arg) +{ + struct block_device *real_bdev; + struct file *file; + struct inode *inode; + int error; + + error = -EBUSY; + if (vr->vr_state != Vr_unbound) + goto out; + + error = -EBADF; + file = fget(arg); + if (!file) + goto out; + + error = -EINVAL; + inode = file->f_dentry->d_inode; + + + if (S_ISBLK(inode->i_mode)) { + real_bdev = inode->i_bdev; + vr->vr_device = real_bdev; + __iget(real_bdev->bd_inode); + } else + goto out_fput; + + vxdprintk(VXD_CBIT(misc, 0), + "vroot[%d]_set_dev: dev=" VXF_DEV, + vr->vr_number, VXD_DEV(real_bdev)); + + vr->vr_state = Vr_bound; + error = 0; + + out_fput: + fput(file); + out: + return error; +} + +static int vroot_clr_dev( + struct vroot_device *vr, + struct file *vr_file, + struct block_device *bdev) +{ + struct block_device *real_bdev; + + if (vr->vr_state != Vr_bound) + return -ENXIO; + if (vr->vr_refcnt > 1) /* we needed one fd for the ioctl */ + return -EBUSY; + + real_bdev = vr->vr_device; + + vxdprintk(VXD_CBIT(misc, 0), + "vroot[%d]_clr_dev: dev=" VXF_DEV, + vr->vr_number, VXD_DEV(real_bdev)); + + bdput(real_bdev); + vr->vr_state = Vr_unbound; + vr->vr_device = NULL; + return 0; +} + + +static int vr_ioctl(struct inode * inode, struct file * file, + unsigned int cmd, unsigned long arg) +{ + struct vroot_device *vr = inode->i_bdev->bd_disk->private_data; + int err; + + down(&vr->vr_ctl_mutex); + switch (cmd) { + case VROOT_SET_DEV: + err = vroot_set_dev(vr, file, inode->i_bdev, arg); + break; + case VROOT_CLR_DEV: + err = vroot_clr_dev(vr, file, inode->i_bdev); + break; + default: + err = -EINVAL; + break; + } + up(&vr->vr_ctl_mutex); + return err; +} + +static int vr_open(struct inode *inode, struct file *file) +{ + struct vroot_device *vr = inode->i_bdev->bd_disk->private_data; + + down(&vr->vr_ctl_mutex); + vr->vr_refcnt++; + up(&vr->vr_ctl_mutex); + return 0; +} + +static int vr_release(struct inode *inode, struct file *file) +{ + struct vroot_device *vr = inode->i_bdev->bd_disk->private_data; + + down(&vr->vr_ctl_mutex); + --vr->vr_refcnt; + up(&vr->vr_ctl_mutex); + return 0; +} + +static struct block_device_operations vr_fops = { + .owner = THIS_MODULE, + .open = vr_open, + .release = vr_release, + .ioctl = vr_ioctl, +}; + +struct block_device *__vroot_get_real_bdev(struct block_device *bdev) +{ + struct inode *inode = bdev->bd_inode; + struct vroot_device *vr; + struct block_device *real_bdev; + int minor = iminor(inode); + + vr = &vroot_dev[minor]; + real_bdev = vr->vr_device; + + vxdprintk(VXD_CBIT(misc, 0), + "vroot[%d]_get_real_bdev: dev=" VXF_DEV, + vr->vr_number, VXD_DEV(real_bdev)); + + if (vr->vr_state != Vr_bound) + return ERR_PTR(-ENXIO); + + __iget(real_bdev->bd_inode); + return real_bdev; +} + +/* + * And now the modules code and kernel interface. + */ + +module_param(max_vroot, int, 0); + +MODULE_PARM_DESC(max_vroot, "Maximum number of vroot devices (1-256)"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS_BLOCKDEV_MAJOR(VROOT_MAJOR); + +MODULE_AUTHOR ("Herbert Pötzl"); +MODULE_DESCRIPTION ("Virtual Root Device Mapper"); + + +int __init vroot_init(void) +{ + int err, i; + + if (max_vroot < 1 || max_vroot > 256) { + max_vroot = MAX_VROOT_DEFAULT; + printk(KERN_WARNING "vroot: invalid max_vroot " + "(must be between 1 and 256), " + "using default (%d)\n", max_vroot); + } + + if (register_blkdev(VROOT_MAJOR, "vroot")) + return -EIO; + + err = -ENOMEM; + vroot_dev = kmalloc(max_vroot * sizeof(struct vroot_device), GFP_KERNEL); + if (!vroot_dev) + goto out_mem1; + memset(vroot_dev, 0, max_vroot * sizeof(struct vroot_device)); + + disks = kmalloc(max_vroot * sizeof(struct gendisk *), GFP_KERNEL); + if (!disks) + goto out_mem2; + + for (i = 0; i < max_vroot; i++) { + disks[i] = alloc_disk(1); + if (!disks[i]) + goto out_mem3; + } + + devfs_mk_dir("vroot"); + + for (i = 0; i < max_vroot; i++) { + struct vroot_device *vr = &vroot_dev[i]; + struct gendisk *disk = disks[i]; + + memset(vr, 0, sizeof(*vr)); + init_MUTEX(&vr->vr_ctl_mutex); + vr->vr_number = i; + disk->major = VROOT_MAJOR; + disk->first_minor = i; + disk->fops = &vr_fops; + sprintf(disk->disk_name, "vroot%d", i); + sprintf(disk->devfs_name, "vroot/%d", i); + disk->private_data = vr; + } + + err = register_vroot_grb(&__vroot_get_real_bdev); + if (err) + goto out_reg; + + for (i = 0; i < max_vroot; i++) + add_disk(disks[i]); + printk(KERN_INFO "vroot: loaded (max %d devices)\n", max_vroot); + return 0; + +out_reg: + devfs_remove("vroot"); +out_mem3: + while (i--) + put_disk(disks[i]); + kfree(disks); +out_mem2: + kfree(vroot_dev); +out_mem1: + unregister_blkdev(VROOT_MAJOR, "vroot"); + printk(KERN_ERR "vroot: ran out of memory\n"); + return err; +} + +void vroot_exit(void) +{ + int i; + + if (unregister_vroot_grb(&__vroot_get_real_bdev)) + printk(KERN_WARNING "vroot: cannot unregister grb\n"); + + for (i = 0; i < max_vroot; i++) { + del_gendisk(disks[i]); + put_disk(disks[i]); + } + devfs_remove("vroot"); + if (unregister_blkdev(VROOT_MAJOR, "vroot")) + printk(KERN_WARNING "vroot: cannot unregister blkdev\n"); + + kfree(disks); + kfree(vroot_dev); +} + +module_init(vroot_init); +module_exit(vroot_exit); + +#ifndef MODULE + +static int __init max_vroot_setup(char *str) +{ + max_vroot = simple_strtol(str, NULL, 0); + return 1; +} + +__setup("max_vroot=", max_vroot_setup); + +#endif + diff -Nurp linux-2.6.16.38/drivers/char/random.c linux-2.6.16.38-vs2.0.3-rc1/drivers/char/random.c --- linux-2.6.16.38/drivers/char/random.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/drivers/char/random.c 2007-01-23 13:45:35.000000000 +0100 @@ -1174,7 +1174,7 @@ static char sysctl_bootid[16]; static int proc_do_uuid(ctl_table *table, int write, struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos) { - ctl_table fake_table; + ctl_table fake_table = {0}; unsigned char buf[64], tmp_uuid[16], *uuid; uuid = table->data; diff -Nurp linux-2.6.16.38/drivers/char/tty_io.c linux-2.6.16.38-vs2.0.3-rc1/drivers/char/tty_io.c --- linux-2.6.16.38/drivers/char/tty_io.c 2007-01-23 13:44:18.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/drivers/char/tty_io.c 2007-01-23 13:45:35.000000000 +0100 @@ -103,6 +103,7 @@ #include #include #include +#include #include @@ -2381,13 +2382,16 @@ static int tiocsctty(struct tty_struct * static int tiocgpgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p) { + pid_t pgrp; /* * (tty == real_tty) is a cheap way of * testing if the tty is NOT a master pty. */ if (tty == real_tty && current->signal->tty != real_tty) return -ENOTTY; - return put_user(real_tty->pgrp, p); + + pgrp = vx_map_pid(real_tty->pgrp); + return put_user(pgrp, p); } static int tiocspgrp(struct tty_struct *tty, struct tty_struct *real_tty, pid_t __user *p) @@ -2405,6 +2409,8 @@ static int tiocspgrp(struct tty_struct * return -ENOTTY; if (get_user(pgrp, p)) return -EFAULT; + + pgrp = vx_rmap_pid(pgrp); if (pgrp < 0) return -EINVAL; if (session_of_pgrp(pgrp) != current->signal->session) diff -Nurp linux-2.6.16.38/drivers/infiniband/core/uverbs_mem.c linux-2.6.16.38-vs2.0.3-rc1/drivers/infiniband/core/uverbs_mem.c --- linux-2.6.16.38/drivers/infiniband/core/uverbs_mem.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/drivers/infiniband/core/uverbs_mem.c 2007-01-23 13:45:35.000000000 +0100 @@ -36,6 +36,7 @@ #include #include +#include #include "uverbs.h" @@ -161,7 +162,7 @@ out: if (ret < 0) __ib_umem_release(dev, mem, 0); else - current->mm->locked_vm = locked; + vx_vmlocked_sub(current->mm, current->mm->locked_vm - locked); up_write(¤t->mm->mmap_sem); free_page((unsigned long) page_list); @@ -174,8 +175,8 @@ void ib_umem_release(struct ib_device *d __ib_umem_release(dev, umem, 1); down_write(¤t->mm->mmap_sem); - current->mm->locked_vm -= - PAGE_ALIGN(umem->length + umem->offset) >> PAGE_SHIFT; + vx_vmlocked_sub(current->mm, + PAGE_ALIGN(umem->length + umem->offset) >> PAGE_SHIFT); up_write(¤t->mm->mmap_sem); } @@ -184,7 +185,7 @@ static void ib_umem_account(void *work_p struct ib_umem_account_work *work = work_ptr; down_write(&work->mm->mmap_sem); - work->mm->locked_vm -= work->diff; + vx_vmlocked_sub(work->mm, work->diff); up_write(&work->mm->mmap_sem); mmput(work->mm); kfree(work); diff -Nurp linux-2.6.16.38/fs/attr.c linux-2.6.16.38-vs2.0.3-rc1/fs/attr.c --- linux-2.6.16.38/fs/attr.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/attr.c 2007-01-23 13:45:36.000000000 +0100 @@ -15,6 +15,9 @@ #include #include #include +#include +#include +#include /* Taken over from the old code... */ @@ -56,6 +59,28 @@ int inode_change_ok(struct inode *inode, if (current->fsuid != inode->i_uid && !capable(CAP_FOWNER)) goto error; } + + /* Check for evil vserver activity */ + if (vx_check(0, VX_ADMIN)) + goto fine; + + if (IS_BARRIER(inode)) { + vxwprintk(1, "xid=%d messing with the barrier.", + vx_current_xid()); + goto error; + } + switch (inode->i_sb->s_magic) { + case PROC_SUPER_MAGIC: + vxwprintk(1, "xid=%d messing with the procfs.", + vx_current_xid()); + goto error; + case DEVPTS_SUPER_MAGIC: + if (vx_check(inode->i_xid, VX_IDENT)) + goto fine; + vxwprintk(1, "xid=%d messing with the devpts.", + vx_current_xid()); + goto error; + } fine: retval = 0; error: @@ -79,6 +104,8 @@ int inode_setattr(struct inode * inode, inode->i_uid = attr->ia_uid; if (ia_valid & ATTR_GID) inode->i_gid = attr->ia_gid; + if ((ia_valid & ATTR_XID) && IS_TAGXID(inode)) + inode->i_xid = attr->ia_xid; if (ia_valid & ATTR_ATIME) inode->i_atime = timespec_trunc(attr->ia_atime, inode->i_sb->s_time_gran); @@ -153,7 +180,8 @@ int notify_change(struct dentry * dentry error = security_inode_setattr(dentry, attr); if (!error) { if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) || - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) || + (ia_valid & ATTR_XID && attr->ia_xid != inode->i_xid)) error = DQUOT_TRANSFER(inode, attr) ? -EDQUOT : 0; if (!error) error = inode_setattr(inode, attr); diff -Nurp linux-2.6.16.38/fs/binfmt_aout.c linux-2.6.16.38-vs2.0.3-rc1/fs/binfmt_aout.c --- linux-2.6.16.38/fs/binfmt_aout.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/binfmt_aout.c 2007-01-23 13:45:36.000000000 +0100 @@ -24,6 +24,7 @@ #include #include #include +#include #include #include diff -Nurp linux-2.6.16.38/fs/binfmt_elf.c linux-2.6.16.38-vs2.0.3-rc1/fs/binfmt_elf.c --- linux-2.6.16.38/fs/binfmt_elf.c 2007-01-23 13:44:36.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/binfmt_elf.c 2007-01-23 13:45:36.000000000 +0100 @@ -38,6 +38,8 @@ #include #include #include +#include +#include #include #include diff -Nurp linux-2.6.16.38/fs/binfmt_elf_fdpic.c linux-2.6.16.38-vs2.0.3-rc1/fs/binfmt_elf_fdpic.c --- linux-2.6.16.38/fs/binfmt_elf_fdpic.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/binfmt_elf_fdpic.c 2007-01-23 13:45:36.000000000 +0100 @@ -32,6 +32,7 @@ #include #include #include +#include #include #include diff -Nurp linux-2.6.16.38/fs/binfmt_flat.c linux-2.6.16.38-vs2.0.3-rc1/fs/binfmt_flat.c --- linux-2.6.16.38/fs/binfmt_flat.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/binfmt_flat.c 2007-01-23 13:45:36.000000000 +0100 @@ -36,6 +36,7 @@ #include #include #include +#include #include #include diff -Nurp linux-2.6.16.38/fs/binfmt_som.c linux-2.6.16.38-vs2.0.3-rc1/fs/binfmt_som.c --- linux-2.6.16.38/fs/binfmt_som.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/binfmt_som.c 2007-01-23 13:45:36.000000000 +0100 @@ -28,6 +28,7 @@ #include #include #include +#include #include #include diff -Nurp linux-2.6.16.38/fs/devpts/inode.c linux-2.6.16.38-vs2.0.3-rc1/fs/devpts/inode.c --- linux-2.6.16.38/fs/devpts/inode.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/devpts/inode.c 2007-01-23 13:45:36.000000000 +0100 @@ -19,7 +19,19 @@ #include #include -#define DEVPTS_SUPER_MAGIC 0x1cd1 + +static int devpts_permission(struct inode *inode, int mask, struct nameidata *nd) +{ + int ret = -EACCES; + + if (vx_check(inode->i_xid, VX_IDENT)) + ret = generic_permission(inode, mask, NULL); + return ret; +} + +static struct inode_operations devpts_file_inode_operations = { + .permission = devpts_permission, +}; static struct vfsmount *devpts_mnt; static struct dentry *devpts_root; @@ -69,6 +81,24 @@ static int devpts_remount(struct super_b return 0; } +static int devpts_filter(struct dentry *de) +{ + return vx_check(de->d_inode->i_xid, VX_IDENT); +} + +static int devpts_readdir(struct file * filp, void * dirent, filldir_t filldir) +{ + return dcache_readdir_filter(filp, dirent, filldir, devpts_filter); +} + +static struct file_operations devpts_dir_operations = { + .open = dcache_dir_open, + .release = dcache_dir_close, + .llseek = dcache_dir_lseek, + .read = generic_read_dir, + .readdir = devpts_readdir, +}; + static struct super_operations devpts_sops = { .statfs = simple_statfs, .remount_fs = devpts_remount, @@ -95,8 +125,9 @@ devpts_fill_super(struct super_block *s, inode->i_uid = inode->i_gid = 0; inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR; inode->i_op = &simple_dir_inode_operations; - inode->i_fop = &simple_dir_operations; + inode->i_fop = &devpts_dir_operations; inode->i_nlink = 2; + inode->i_xid = vx_current_xid(); devpts_root = s->s_root = d_alloc_root(inode); if (s->s_root) @@ -155,6 +186,8 @@ int devpts_pty_new(struct tty_struct *tt inode->i_gid = config.setgid ? config.gid : current->fsgid; inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; init_special_inode(inode, S_IFCHR|config.mode, device); + inode->i_xid = vx_current_xid(); + inode->i_op = &devpts_file_inode_operations; inode->u.generic_ip = tty; dentry = get_node(number); diff -Nurp linux-2.6.16.38/fs/exec.c linux-2.6.16.38-vs2.0.3-rc1/fs/exec.c --- linux-2.6.16.38/fs/exec.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/exec.c 2007-01-23 13:45:36.000000000 +0100 @@ -49,6 +49,8 @@ #include #include #include +#include +#include #include #include @@ -436,7 +438,8 @@ int setup_arg_pages(struct linux_binprm kmem_cache_free(vm_area_cachep, mpnt); return ret; } - mm->stack_vm = mm->total_vm = vma_pages(mpnt); + vx_vmpages_sub(mm, mm->total_vm - vma_pages(mpnt)); + mm->stack_vm = mm->total_vm; } for (i = 0 ; i < MAX_ARG_PAGES ; i++) { @@ -1332,7 +1335,7 @@ static void format_corename(char *corena case 'h': down_read(&uts_sem); rc = snprintf(out_ptr, out_end - out_ptr, - "%s", system_utsname.nodename); + "%s", vx_new_uts(nodename)); up_read(&uts_sem); if (rc > out_end - out_ptr) goto out; diff -Nurp linux-2.6.16.38/fs/ext2/balloc.c linux-2.6.16.38-vs2.0.3-rc1/fs/ext2/balloc.c --- linux-2.6.16.38/fs/ext2/balloc.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/ext2/balloc.c 2007-01-23 13:45:36.000000000 +0100 @@ -17,6 +17,7 @@ #include #include #include +#include /* * balloc.c contains the blocks allocation and deallocation routines @@ -109,6 +110,8 @@ static int reserve_blocks(struct super_b free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter); root_blocks = le32_to_cpu(es->s_r_blocks_count); + DLIMIT_ADJUST_BLOCK(sb, vx_current_xid(), &free_blocks, &root_blocks); + if (free_blocks < count) count = free_blocks; @@ -259,6 +262,7 @@ do_more: } error_return: brelse(bitmap_bh); + DLIMIT_FREE_BLOCK(inode, freed); release_blocks(sb, freed); DQUOT_FREE_BLOCK(inode, freed); } @@ -362,6 +366,10 @@ int ext2_new_block(struct inode *inode, *err = -ENOSPC; goto out_dquot; } + if (DLIMIT_ALLOC_BLOCK(inode, es_alloc)) { + *err = -ENOSPC; + goto out_dlimit; + } ext2_debug ("goal=%lu.\n", goal); @@ -509,6 +517,8 @@ got_block: *err = 0; out_release: group_release_blocks(sb, group_no, desc, gdp_bh, group_alloc); + DLIMIT_FREE_BLOCK(inode, es_alloc); +out_dlimit: release_blocks(sb, es_alloc); out_dquot: DQUOT_FREE_BLOCK(inode, dq_alloc); diff -Nurp linux-2.6.16.38/fs/ext2/ext2.h linux-2.6.16.38-vs2.0.3-rc1/fs/ext2/ext2.h --- linux-2.6.16.38/fs/ext2/ext2.h 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/ext2/ext2.h 2007-01-23 13:45:36.000000000 +0100 @@ -162,6 +162,7 @@ extern struct file_operations ext2_xip_f extern struct address_space_operations ext2_aops; extern struct address_space_operations ext2_aops_xip; extern struct address_space_operations ext2_nobh_aops; +extern int ext2_sync_flags(struct inode *inode); /* namei.c */ extern struct inode_operations ext2_dir_inode_operations; diff -Nurp linux-2.6.16.38/fs/ext2/file.c linux-2.6.16.38-vs2.0.3-rc1/fs/ext2/file.c --- linux-2.6.16.38/fs/ext2/file.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/ext2/file.c 2007-01-23 13:45:36.000000000 +0100 @@ -79,4 +79,5 @@ struct inode_operations ext2_file_inode_ #endif .setattr = ext2_setattr, .permission = ext2_permission, + .sync_flags = ext2_sync_flags, }; diff -Nurp linux-2.6.16.38/fs/ext2/ialloc.c linux-2.6.16.38-vs2.0.3-rc1/fs/ext2/ialloc.c --- linux-2.6.16.38/fs/ext2/ialloc.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/ext2/ialloc.c 2007-01-23 13:45:36.000000000 +0100 @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include "ext2.h" #include "xattr.h" #include "acl.h" @@ -126,6 +128,7 @@ void ext2_free_inode (struct inode * ino ext2_xattr_delete_inode(inode); DQUOT_FREE_INODE(inode); DQUOT_DROP(inode); + DLIMIT_FREE_INODE(inode); } es = EXT2_SB(sb)->s_es; @@ -465,6 +468,11 @@ struct inode *ext2_new_inode(struct inod if (!inode) return ERR_PTR(-ENOMEM); + inode->i_xid = vx_current_fsxid(sb); + if (DLIMIT_ALLOC_INODE(inode)) { + err = -ENOSPC; + goto fail_dlim; + } ei = EXT2_I(inode); sbi = EXT2_SB(sb); es = sbi->s_es; @@ -579,7 +587,8 @@ got: inode->i_blocks = 0; inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC; memset(ei->i_data, 0, sizeof(ei->i_data)); - ei->i_flags = EXT2_I(dir)->i_flags & ~EXT2_BTREE_FL; + ei->i_flags = EXT2_I(dir)->i_flags & + ~(EXT2_BTREE_FL|EXT2_IUNLINK_FL|EXT2_BARRIER_FL); if (S_ISLNK(mode)) ei->i_flags &= ~(EXT2_IMMUTABLE_FL|EXT2_APPEND_FL); /* dirsync is only applied to directories */ @@ -627,12 +636,15 @@ fail_free_drop: fail_drop: DQUOT_DROP(inode); + DLIMIT_FREE_INODE(inode); inode->i_flags |= S_NOQUOTA; inode->i_nlink = 0; iput(inode); return ERR_PTR(err); fail: + DLIMIT_FREE_INODE(inode); +fail_dlim: make_bad_inode(inode); iput(inode); return ERR_PTR(err); diff -Nurp linux-2.6.16.38/fs/ext2/inode.c linux-2.6.16.38-vs2.0.3-rc1/fs/ext2/inode.c --- linux-2.6.16.38/fs/ext2/inode.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/ext2/inode.c 2007-01-26 01:40:24.000000000 +0100 @@ -31,6 +31,7 @@ #include #include #include +#include #include "ext2.h" #include "acl.h" #include "xip.h" @@ -925,7 +926,7 @@ void ext2_truncate (struct inode * inode return; if (ext2_inode_is_fast_symlink(inode)) return; - if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) + if (IS_APPEND(inode) || IS_IXORUNLINK(inode)) return; ext2_discard_prealloc(inode); @@ -1054,25 +1055,70 @@ void ext2_set_inode_flags(struct inode * { unsigned int flags = EXT2_I(inode)->i_flags; - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC); + inode->i_flags &= ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER | + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC); + + if (flags & EXT2_IMMUTABLE_FL) + inode->i_flags |= S_IMMUTABLE; + if (flags & EXT2_IUNLINK_FL) + inode->i_flags |= S_IUNLINK; + if (flags & EXT2_BARRIER_FL) + inode->i_flags |= S_BARRIER; + if (flags & EXT2_SYNC_FL) inode->i_flags |= S_SYNC; if (flags & EXT2_APPEND_FL) inode->i_flags |= S_APPEND; - if (flags & EXT2_IMMUTABLE_FL) - inode->i_flags |= S_IMMUTABLE; if (flags & EXT2_NOATIME_FL) inode->i_flags |= S_NOATIME; if (flags & EXT2_DIRSYNC_FL) inode->i_flags |= S_DIRSYNC; } +int ext2_sync_flags(struct inode *inode) +{ + unsigned int oldflags, newflags; + + oldflags = EXT2_I(inode)->i_flags; + newflags = oldflags & ~(EXT2_APPEND_FL | + EXT2_IMMUTABLE_FL | EXT2_IUNLINK_FL | + EXT2_BARRIER_FL | EXT2_NOATIME_FL | + EXT2_SYNC_FL | EXT2_DIRSYNC_FL); + + if (IS_APPEND(inode)) + newflags |= EXT2_APPEND_FL; + if (IS_IMMUTABLE(inode)) + newflags |= EXT2_IMMUTABLE_FL; + if (IS_IUNLINK(inode)) + newflags |= EXT2_IUNLINK_FL; + if (IS_BARRIER(inode)) + newflags |= EXT2_BARRIER_FL; + + /* we do not want to copy superblock flags */ + if (inode->i_flags & S_NOATIME) + newflags |= EXT2_NOATIME_FL; + if (inode->i_flags & S_SYNC) + newflags |= EXT2_SYNC_FL; + if (inode->i_flags & S_DIRSYNC) + newflags |= EXT2_DIRSYNC_FL; + + if (oldflags ^ newflags) { + EXT2_I(inode)->i_flags = newflags; + inode->i_ctime = CURRENT_TIME; + mark_inode_dirty(inode); + } + + return 0; +} + void ext2_read_inode (struct inode * inode) { struct ext2_inode_info *ei = EXT2_I(inode); ino_t ino = inode->i_ino; struct buffer_head * bh; struct ext2_inode * raw_inode = ext2_get_inode(inode->i_sb, ino, &bh); + uid_t uid; + gid_t gid; int n; #ifdef CONFIG_EXT2_FS_POSIX_ACL @@ -1083,12 +1129,17 @@ void ext2_read_inode (struct inode * ino goto bad_inode; inode->i_mode = le16_to_cpu(raw_inode->i_mode); - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low); - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low); + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low); + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low); if (!(test_opt (inode->i_sb, NO_UID32))) { - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16; - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16; + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16; + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16; } + inode->i_uid = INOXID_UID(XID_TAG(inode), uid, gid); + inode->i_gid = INOXID_GID(XID_TAG(inode), uid, gid); + inode->i_xid = INOXID_XID(XID_TAG(inode), uid, gid, + le16_to_cpu(raw_inode->i_raw_xid)); + inode->i_nlink = le16_to_cpu(raw_inode->i_links_count); inode->i_size = le32_to_cpu(raw_inode->i_size); inode->i_atime.tv_sec = le32_to_cpu(raw_inode->i_atime); @@ -1186,8 +1237,8 @@ static int ext2_update_inode(struct inod struct ext2_inode_info *ei = EXT2_I(inode); struct super_block *sb = inode->i_sb; ino_t ino = inode->i_ino; - uid_t uid = inode->i_uid; - gid_t gid = inode->i_gid; + uid_t uid = XIDINO_UID(XID_TAG(inode), inode->i_uid, inode->i_xid); + gid_t gid = XIDINO_GID(XID_TAG(inode), inode->i_gid, inode->i_xid); struct buffer_head * bh; struct ext2_inode * raw_inode = ext2_get_inode(sb, ino, &bh); int n; @@ -1222,6 +1273,9 @@ static int ext2_update_inode(struct inod raw_inode->i_uid_high = 0; raw_inode->i_gid_high = 0; } +#ifdef CONFIG_INOXID_INTERN + raw_inode->i_raw_xid = cpu_to_le16(inode->i_xid); +#endif raw_inode->i_links_count = cpu_to_le16(inode->i_nlink); raw_inode->i_size = cpu_to_le32(inode->i_size); raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec); @@ -1308,7 +1362,8 @@ int ext2_setattr(struct dentry *dentry, if (error) return error; if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) || - (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) { + (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid) || + (iattr->ia_valid & ATTR_XID && iattr->ia_xid != inode->i_xid)) { error = DQUOT_TRANSFER(inode, iattr) ? -EDQUOT : 0; if (error) return error; diff -Nurp linux-2.6.16.38/fs/ext2/ioctl.c linux-2.6.16.38-vs2.0.3-rc1/fs/ext2/ioctl.c --- linux-2.6.16.38/fs/ext2/ioctl.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/ext2/ioctl.c 2007-01-23 13:45:36.000000000 +0100 @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -30,7 +31,8 @@ int ext2_ioctl (struct inode * inode, st case EXT2_IOC_SETFLAGS: { unsigned int oldflags; - if (IS_RDONLY(inode)) + if (IS_RDONLY(inode) || + (filp && MNT_IS_RDONLY(filp->f_vfsmnt))) return -EROFS; if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER)) @@ -50,7 +52,9 @@ int ext2_ioctl (struct inode * inode, st * * This test looks nicer. Thanks to Pauline Middelink */ - if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) { + if ((oldflags & EXT2_IMMUTABLE_FL) || + ((flags ^ oldflags) & (EXT2_APPEND_FL | + EXT2_IMMUTABLE_FL | EXT2_IUNLINK_FL))) { if (!capable(CAP_LINUX_IMMUTABLE)) return -EPERM; } @@ -69,7 +73,8 @@ int ext2_ioctl (struct inode * inode, st case EXT2_IOC_SETVERSION: if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER)) return -EPERM; - if (IS_RDONLY(inode)) + if (IS_RDONLY(inode) || + (filp && MNT_IS_RDONLY(filp->f_vfsmnt))) return -EROFS; if (get_user(inode->i_generation, (int __user *) arg)) return -EFAULT; diff -Nurp linux-2.6.16.38/fs/ext2/namei.c linux-2.6.16.38-vs2.0.3-rc1/fs/ext2/namei.c --- linux-2.6.16.38/fs/ext2/namei.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/ext2/namei.c 2007-01-23 13:45:36.000000000 +0100 @@ -31,6 +31,7 @@ */ #include +#include #include "ext2.h" #include "xattr.h" #include "acl.h" @@ -82,6 +83,7 @@ static struct dentry *ext2_lookup(struct inode = iget(dir->i_sb, ino); if (!inode) return ERR_PTR(-EACCES); + vx_propagate_xid(nd, inode); } return d_splice_alias(inode, dentry); } @@ -407,6 +409,7 @@ struct inode_operations ext2_dir_inode_o #endif .setattr = ext2_setattr, .permission = ext2_permission, + .sync_flags = ext2_sync_flags, }; struct inode_operations ext2_special_inode_operations = { @@ -418,4 +421,5 @@ struct inode_operations ext2_special_ino #endif .setattr = ext2_setattr, .permission = ext2_permission, + .sync_flags = ext2_sync_flags, }; diff -Nurp linux-2.6.16.38/fs/ext2/super.c linux-2.6.16.38-vs2.0.3-rc1/fs/ext2/super.c --- linux-2.6.16.38/fs/ext2/super.c 2007-01-23 13:44:19.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/ext2/super.c 2007-01-23 13:45:36.000000000 +0100 @@ -330,7 +330,7 @@ enum { Opt_err_ro, Opt_nouid32, Opt_nocheck, Opt_debug, Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl, Opt_xip, Opt_ignore, Opt_err, Opt_quota, - Opt_usrquota, Opt_grpquota + Opt_usrquota, Opt_grpquota, Opt_tagxid }; static match_table_t tokens = { @@ -358,6 +358,7 @@ static match_table_t tokens = { {Opt_acl, "acl"}, {Opt_noacl, "noacl"}, {Opt_xip, "xip"}, + {Opt_tagxid, "tagxid"}, {Opt_grpquota, "grpquota"}, {Opt_ignore, "noquota"}, {Opt_quota, "quota"}, @@ -421,6 +422,11 @@ static int parse_options (char * options case Opt_nouid32: set_opt (sbi->s_mount_opt, NO_UID32); break; +#ifndef CONFIG_INOXID_NONE + case Opt_tagxid: + set_opt (sbi->s_mount_opt, TAGXID); + break; +#endif case Opt_nocheck: clear_opt (sbi->s_mount_opt, CHECK); break; @@ -722,6 +728,8 @@ static int ext2_fill_super(struct super_ if (!parse_options ((char *) data, sbi)) goto failed_mount; + if (EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_TAGXID) + sb->s_flags |= MS_TAGXID; sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | ((EXT2_SB(sb)->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0); @@ -1031,6 +1039,13 @@ static int ext2_remount (struct super_bl goto restore_opts; } + if ((sbi->s_mount_opt & EXT2_MOUNT_TAGXID) && + !(sb->s_flags & MS_TAGXID)) { + printk("EXT2-fs: %s: tagxid not permitted on remount.\n", + sb->s_id); + return -EINVAL; + } + sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | ((sbi->s_mount_opt & EXT2_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0); diff -Nurp linux-2.6.16.38/fs/ext2/symlink.c linux-2.6.16.38-vs2.0.3-rc1/fs/ext2/symlink.c --- linux-2.6.16.38/fs/ext2/symlink.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/ext2/symlink.c 2007-01-23 13:45:36.000000000 +0100 @@ -38,6 +38,7 @@ struct inode_operations ext2_symlink_ino .listxattr = ext2_listxattr, .removexattr = generic_removexattr, #endif + .sync_flags = ext2_sync_flags, }; struct inode_operations ext2_fast_symlink_inode_operations = { @@ -49,4 +50,5 @@ struct inode_operations ext2_fast_symlin .listxattr = ext2_listxattr, .removexattr = generic_removexattr, #endif + .sync_flags = ext2_sync_flags, }; diff -Nurp linux-2.6.16.38/fs/ext2/xattr.c linux-2.6.16.38-vs2.0.3-rc1/fs/ext2/xattr.c --- linux-2.6.16.38/fs/ext2/xattr.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/ext2/xattr.c 2007-01-23 13:45:36.000000000 +0100 @@ -60,6 +60,7 @@ #include #include #include +#include #include "ext2.h" #include "xattr.h" #include "acl.h" @@ -645,8 +646,12 @@ ext2_xattr_set2(struct inode *inode, str the inode. */ ea_bdebug(new_bh, "reusing block"); + error = -ENOSPC; + if (DLIMIT_ALLOC_BLOCK(inode, 1)) + goto cleanup; error = -EDQUOT; if (DQUOT_ALLOC_BLOCK(inode, 1)) { + DLIMIT_FREE_BLOCK(inode, 1); unlock_buffer(new_bh); goto cleanup; } @@ -740,6 +745,7 @@ ext2_xattr_set2(struct inode *inode, str le32_to_cpu(HDR(old_bh)->h_refcount) - 1); if (ce) mb_cache_entry_release(ce); + DLIMIT_FREE_BLOCK(inode, 1); DQUOT_FREE_BLOCK(inode, 1); mark_buffer_dirty(old_bh); ea_bdebug(old_bh, "refcount now=%d", @@ -804,6 +810,7 @@ ext2_xattr_delete_inode(struct inode *in mark_buffer_dirty(bh); if (IS_SYNC(inode)) sync_dirty_buffer(bh); + DLIMIT_FREE_BLOCK(inode, 1); DQUOT_FREE_BLOCK(inode, 1); } EXT2_I(inode)->i_file_acl = 0; diff -Nurp linux-2.6.16.38/fs/ext3/balloc.c linux-2.6.16.38-vs2.0.3-rc1/fs/ext3/balloc.c --- linux-2.6.16.38/fs/ext3/balloc.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/ext3/balloc.c 2007-01-23 13:45:36.000000000 +0100 @@ -20,6 +20,7 @@ #include #include #include +#include /* * balloc.c contains the blocks allocation and deallocation routines @@ -504,8 +505,10 @@ void ext3_free_blocks(handle_t *handle, return; } ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks); - if (dquot_freed_blocks) + if (dquot_freed_blocks) { + DLIMIT_FREE_BLOCK(inode, dquot_freed_blocks); DQUOT_FREE_BLOCK(inode, dquot_freed_blocks); + } return; } @@ -1116,18 +1119,32 @@ out: return ret; } -static int ext3_has_free_blocks(struct ext3_sb_info *sbi) +static int ext3_has_free_blocks(struct super_block *sb) { - int free_blocks, root_blocks; + struct ext3_sb_info *sbi = EXT3_SB(sb); + int free_blocks, root_blocks, cond; free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter); root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count); - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) && + + vxdprintk(VXD_CBIT(dlim, 3), + "ext3_has_free_blocks(%p): free=%u, root=%u", + sb, free_blocks, root_blocks); + + DLIMIT_ADJUST_BLOCK(sb, vx_current_xid(), &free_blocks, &root_blocks); + + cond = (free_blocks < root_blocks + 1 && + !capable(CAP_SYS_RESOURCE) && sbi->s_resuid != current->fsuid && - (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))) { - return 0; - } - return 1; + (sbi->s_resgid == 0 || !in_group_p (sbi->s_resgid))); + + vxdprintk(VXD_CBIT(dlim, 3), + "ext3_has_free_blocks(%p): %u<%u+1, %c, %u!=%u r=%d", + sb, free_blocks, root_blocks, + !capable(CAP_SYS_RESOURCE)?'1':'0', + sbi->s_resuid, current->fsuid, cond?0:1); + + return (cond ? 0 : 1); } /* @@ -1138,7 +1155,7 @@ static int ext3_has_free_blocks(struct e */ int ext3_should_retry_alloc(struct super_block *sb, int *retries) { - if (!ext3_has_free_blocks(EXT3_SB(sb)) || (*retries)++ > 3) + if (!ext3_has_free_blocks(sb) || (*retries)++ > 3) return 0; jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id); @@ -1193,6 +1210,8 @@ int ext3_new_block(handle_t *handle, str *errp = -EDQUOT; return 0; } + if (DLIMIT_ALLOC_BLOCK(inode, 1)) + goto out_dlimit; sbi = EXT3_SB(sb); es = EXT3_SB(sb)->s_es; @@ -1209,7 +1228,7 @@ int ext3_new_block(handle_t *handle, str if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) > 0)) my_rsv = &block_i->rsv_window_node; - if (!ext3_has_free_blocks(sbi)) { + if (!ext3_has_free_blocks(sb)) { *errp = -ENOSPC; goto out; } @@ -1393,6 +1412,9 @@ allocated: io_error: *errp = -EIO; out: + if (!performed_allocation) + DLIMIT_FREE_BLOCK(inode, 1); +out_dlimit: if (fatal) { *errp = fatal; ext3_std_error(sb, fatal); diff -Nurp linux-2.6.16.38/fs/ext3/file.c linux-2.6.16.38-vs2.0.3-rc1/fs/ext3/file.c --- linux-2.6.16.38/fs/ext3/file.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/ext3/file.c 2007-01-23 13:45:36.000000000 +0100 @@ -131,5 +131,6 @@ struct inode_operations ext3_file_inode_ .removexattr = generic_removexattr, #endif .permission = ext3_permission, + .sync_flags = ext3_sync_flags, }; diff -Nurp linux-2.6.16.38/fs/ext3/ialloc.c linux-2.6.16.38-vs2.0.3-rc1/fs/ext3/ialloc.c --- linux-2.6.16.38/fs/ext3/ialloc.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/ext3/ialloc.c 2007-01-23 13:45:36.000000000 +0100 @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include @@ -127,6 +129,7 @@ void ext3_free_inode (handle_t *handle, ext3_xattr_delete_inode(handle, inode); DQUOT_FREE_INODE(inode); DQUOT_DROP(inode); + DLIMIT_FREE_INODE(inode); is_directory = S_ISDIR(inode->i_mode); @@ -443,6 +446,12 @@ struct inode *ext3_new_inode(handle_t *h inode = new_inode(sb); if (!inode) return ERR_PTR(-ENOMEM); + + inode->i_xid = vx_current_fsxid(sb); + if (DLIMIT_ALLOC_INODE(inode)) { + err = -ENOSPC; + goto out_dlimit; + } ei = EXT3_I(inode); sbi = EXT3_SB(sb); @@ -565,7 +574,8 @@ got: ei->i_dir_start_lookup = 0; ei->i_disksize = 0; - ei->i_flags = EXT3_I(dir)->i_flags & ~EXT3_INDEX_FL; + ei->i_flags = EXT3_I(dir)->i_flags & + ~(EXT3_INDEX_FL|EXT3_IUNLINK_FL|EXT3_BARRIER_FL); if (S_ISLNK(mode)) ei->i_flags &= ~(EXT3_IMMUTABLE_FL|EXT3_APPEND_FL); /* dirsync only applies to directories */ @@ -620,6 +630,8 @@ got: fail: ext3_std_error(sb, err); out: + DLIMIT_FREE_INODE(inode); +out_dlimit: iput(inode); ret = ERR_PTR(err); really_out: @@ -631,6 +643,7 @@ fail_free_drop: fail_drop: DQUOT_DROP(inode); + DLIMIT_FREE_INODE(inode); inode->i_flags |= S_NOQUOTA; inode->i_nlink = 0; iput(inode); diff -Nurp linux-2.6.16.38/fs/ext3/inode.c linux-2.6.16.38-vs2.0.3-rc1/fs/ext3/inode.c --- linux-2.6.16.38/fs/ext3/inode.c 2007-01-23 13:44:30.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/ext3/inode.c 2007-01-26 01:40:47.000000000 +0100 @@ -36,6 +36,7 @@ #include #include #include +#include #include "xattr.h" #include "acl.h" @@ -2098,7 +2099,7 @@ void ext3_truncate(struct inode * inode) return; if (ext3_inode_is_fast_symlink(inode)) return; - if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) + if (IS_APPEND(inode) || IS_IXORUNLINK(inode)) return; /* @@ -2421,19 +2422,77 @@ void ext3_set_inode_flags(struct inode * { unsigned int flags = EXT3_I(inode)->i_flags; - inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC); + inode->i_flags &= ~(S_IMMUTABLE | S_IUNLINK | S_BARRIER | + S_SYNC | S_APPEND | S_NOATIME | S_DIRSYNC); + + if (flags & EXT3_IMMUTABLE_FL) + inode->i_flags |= S_IMMUTABLE; + if (flags & EXT3_IUNLINK_FL) + inode->i_flags |= S_IUNLINK; + if (flags & EXT3_BARRIER_FL) + inode->i_flags |= S_BARRIER; + if (flags & EXT3_SYNC_FL) inode->i_flags |= S_SYNC; if (flags & EXT3_APPEND_FL) inode->i_flags |= S_APPEND; - if (flags & EXT3_IMMUTABLE_FL) - inode->i_flags |= S_IMMUTABLE; if (flags & EXT3_NOATIME_FL) inode->i_flags |= S_NOATIME; if (flags & EXT3_DIRSYNC_FL) inode->i_flags |= S_DIRSYNC; } +int ext3_sync_flags(struct inode *inode) +{ + unsigned int oldflags, newflags; + int err = 0; + + oldflags = EXT3_I(inode)->i_flags; + newflags = oldflags & ~(EXT3_APPEND_FL | + EXT3_IMMUTABLE_FL | EXT3_IUNLINK_FL | + EXT3_BARRIER_FL | EXT3_NOATIME_FL | + EXT3_SYNC_FL | EXT3_DIRSYNC_FL); + + if (IS_APPEND(inode)) + newflags |= EXT3_APPEND_FL; + if (IS_IMMUTABLE(inode)) + newflags |= EXT3_IMMUTABLE_FL; + if (IS_IUNLINK(inode)) + newflags |= EXT3_IUNLINK_FL; + if (IS_BARRIER(inode)) + newflags |= EXT3_BARRIER_FL; + + /* we do not want to copy superblock flags */ + if (inode->i_flags & S_NOATIME) + newflags |= EXT3_NOATIME_FL; + if (inode->i_flags & S_SYNC) + newflags |= EXT3_SYNC_FL; + if (inode->i_flags & S_DIRSYNC) + newflags |= EXT3_DIRSYNC_FL; + + if (oldflags ^ newflags) { + handle_t *handle; + struct ext3_iloc iloc; + + handle = ext3_journal_start(inode, 1); + if (IS_ERR(handle)) + return PTR_ERR(handle); + if (IS_SYNC(inode)) + handle->h_sync = 1; + err = ext3_reserve_inode_write(handle, inode, &iloc); + if (err) + goto flags_err; + + EXT3_I(inode)->i_flags = newflags; + inode->i_ctime = CURRENT_TIME; + + err = ext3_mark_iloc_dirty(handle, inode, &iloc); + flags_err: + ext3_journal_stop(handle); + } + return err; +} + void ext3_read_inode(struct inode * inode) { struct ext3_iloc iloc; @@ -2441,6 +2500,8 @@ void ext3_read_inode(struct inode * inod struct ext3_inode_info *ei = EXT3_I(inode); struct buffer_head *bh; int block; + uid_t uid; + gid_t gid; #ifdef CONFIG_EXT3_FS_POSIX_ACL ei->i_acl = EXT3_ACL_NOT_CACHED; @@ -2453,12 +2514,17 @@ void ext3_read_inode(struct inode * inod bh = iloc.bh; raw_inode = ext3_raw_inode(&iloc); inode->i_mode = le16_to_cpu(raw_inode->i_mode); - inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low); - inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low); + uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low); + gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low); if(!(test_opt (inode->i_sb, NO_UID32))) { - inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16; - inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16; + uid |= le16_to_cpu(raw_inode->i_uid_high) << 16; + gid |= le16_to_cpu(raw_inode->i_gid_high) << 16; } + inode->i_uid = INOXID_UID(XID_TAG(inode), uid, gid); + inode->i_gid = INOXID_GID(XID_TAG(inode), uid, gid); + inode->i_xid = INOXID_XID(XID_TAG(inode), uid, gid, + le16_to_cpu(raw_inode->i_raw_xid)); + inode->i_nlink = le16_to_cpu(raw_inode->i_links_count); inode->i_size = le32_to_cpu(raw_inode->i_size); inode->i_atime.tv_sec = le32_to_cpu(raw_inode->i_atime); @@ -2585,6 +2651,8 @@ static int ext3_do_update_inode(handle_t struct ext3_inode *raw_inode = ext3_raw_inode(iloc); struct ext3_inode_info *ei = EXT3_I(inode); struct buffer_head *bh = iloc->bh; + uid_t uid = XIDINO_UID(XID_TAG(inode), inode->i_uid, inode->i_xid); + gid_t gid = XIDINO_GID(XID_TAG(inode), inode->i_gid, inode->i_xid); int err = 0, rc, block; /* For fields not not tracking in the in-memory inode, @@ -2594,29 +2662,32 @@ static int ext3_do_update_inode(handle_t raw_inode->i_mode = cpu_to_le16(inode->i_mode); if(!(test_opt(inode->i_sb, NO_UID32))) { - raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid)); - raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid)); + raw_inode->i_uid_low = cpu_to_le16(low_16_bits(uid)); + raw_inode->i_gid_low = cpu_to_le16(low_16_bits(gid)); /* * Fix up interoperability with old kernels. Otherwise, old inodes get * re-used with the upper 16 bits of the uid/gid intact */ if(!ei->i_dtime) { raw_inode->i_uid_high = - cpu_to_le16(high_16_bits(inode->i_uid)); + cpu_to_le16(high_16_bits(uid)); raw_inode->i_gid_high = - cpu_to_le16(high_16_bits(inode->i_gid)); + cpu_to_le16(high_16_bits(gid)); } else { raw_inode->i_uid_high = 0; raw_inode->i_gid_high = 0; } } else { raw_inode->i_uid_low = - cpu_to_le16(fs_high2lowuid(inode->i_uid)); + cpu_to_le16(fs_high2lowuid(uid)); raw_inode->i_gid_low = - cpu_to_le16(fs_high2lowgid(inode->i_gid)); + cpu_to_le16(fs_high2lowgid(gid)); raw_inode->i_uid_high = 0; raw_inode->i_gid_high = 0; } +#ifdef CONFIG_INOXID_INTERN + raw_inode->i_raw_xid = cpu_to_le16(inode->i_xid); +#endif raw_inode->i_links_count = cpu_to_le16(inode->i_nlink); raw_inode->i_size = cpu_to_le32(ei->i_disksize); raw_inode->i_atime = cpu_to_le32(inode->i_atime.tv_sec); @@ -2769,7 +2840,8 @@ int ext3_setattr(struct dentry *dentry, return error; if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) || - (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) { + (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid) || + (ia_valid & ATTR_XID && attr->ia_xid != inode->i_xid)) { handle_t *handle; /* (user+group)*(old+new) structure, inode write (sb, @@ -2791,6 +2863,8 @@ int ext3_setattr(struct dentry *dentry, inode->i_uid = attr->ia_uid; if (attr->ia_valid & ATTR_GID) inode->i_gid = attr->ia_gid; + if ((attr->ia_valid & ATTR_XID) && IS_TAGXID(inode)) + inode->i_xid = attr->ia_xid; error = ext3_mark_inode_dirty(handle, inode); ext3_journal_stop(handle); } diff -Nurp linux-2.6.16.38/fs/ext3/ioctl.c linux-2.6.16.38-vs2.0.3-rc1/fs/ext3/ioctl.c --- linux-2.6.16.38/fs/ext3/ioctl.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/ext3/ioctl.c 2007-01-23 13:45:36.000000000 +0100 @@ -8,11 +8,13 @@ */ #include +#include #include #include #include #include #include +#include #include @@ -36,7 +38,8 @@ int ext3_ioctl (struct inode * inode, st unsigned int oldflags; unsigned int jflag; - if (IS_RDONLY(inode)) + if (IS_RDONLY(inode) || + (filp && MNT_IS_RDONLY(filp->f_vfsmnt))) return -EROFS; if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER)) @@ -59,7 +62,9 @@ int ext3_ioctl (struct inode * inode, st * * This test looks nicer. Thanks to Pauline Middelink */ - if ((flags ^ oldflags) & (EXT3_APPEND_FL | EXT3_IMMUTABLE_FL)) { + if ((oldflags & EXT3_IMMUTABLE_FL) || + ((flags ^ oldflags) & (EXT3_APPEND_FL | + EXT3_IMMUTABLE_FL | EXT3_IUNLINK_FL))) { if (!capable(CAP_LINUX_IMMUTABLE)) return -EPERM; } @@ -112,7 +117,8 @@ flags_err: if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER)) return -EPERM; - if (IS_RDONLY(inode)) + if (IS_RDONLY(inode) || + (filp && MNT_IS_RDONLY(filp->f_vfsmnt))) return -EROFS; if (get_user(generation, (int __user *) arg)) return -EFAULT; @@ -166,7 +172,8 @@ flags_err: if (!test_opt(inode->i_sb, RESERVATION) ||!S_ISREG(inode->i_mode)) return -ENOTTY; - if (IS_RDONLY(inode)) + if (IS_RDONLY(inode) || + (filp && MNT_IS_RDONLY(filp->f_vfsmnt))) return -EROFS; if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER)) @@ -201,7 +208,8 @@ flags_err: if (!capable(CAP_SYS_RESOURCE)) return -EPERM; - if (IS_RDONLY(inode)) + if (IS_RDONLY(inode) || + (filp && MNT_IS_RDONLY(filp->f_vfsmnt))) return -EROFS; if (get_user(n_blocks_count, (__u32 __user *)arg)) @@ -222,7 +230,8 @@ flags_err: if (!capable(CAP_SYS_RESOURCE)) return -EPERM; - if (IS_RDONLY(inode)) + if (IS_RDONLY(inode) || + (filp && MNT_IS_RDONLY(filp->f_vfsmnt))) return -EROFS; if (copy_from_user(&input, (struct ext3_new_group_input __user *)arg, @@ -237,6 +246,38 @@ flags_err: return err; } +#if defined(CONFIG_VSERVER_LEGACY) && !defined(CONFIG_INOXID_NONE) + case EXT3_IOC_SETXID: { + handle_t *handle; + struct ext3_iloc iloc; + int xid; + int err; + + /* fixme: if stealth, return -ENOTTY */ + if (!capable(CAP_CONTEXT)) + return -EPERM; + if (IS_RDONLY(inode)) + return -EROFS; + if (!(inode->i_sb->s_flags & MS_TAGXID)) + return -ENOSYS; + if (get_user(xid, (int __user *) arg)) + return -EFAULT; + + handle = ext3_journal_start(inode, 1); + if (IS_ERR(handle)) + return PTR_ERR(handle); + err = ext3_reserve_inode_write(handle, inode, &iloc); + if (err) + return err; + + inode->i_xid = (xid & 0xFFFF); + inode->i_ctime = CURRENT_TIME; + + err = ext3_mark_iloc_dirty(handle, inode, &iloc); + ext3_journal_stop(handle); + return err; + } +#endif default: return -ENOTTY; diff -Nurp linux-2.6.16.38/fs/ext3/namei.c linux-2.6.16.38-vs2.0.3-rc1/fs/ext3/namei.c --- linux-2.6.16.38/fs/ext3/namei.c 2007-01-29 13:43:30.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/ext3/namei.c 2007-01-29 13:44:46.000000000 +0100 @@ -36,6 +36,7 @@ #include #include #include +#include #include "namei.h" #include "xattr.h" @@ -1018,6 +1019,7 @@ static struct dentry *ext3_lookup(struct if (!inode) return ERR_PTR(-EACCES); + vx_propagate_xid(nd, inode); } return d_splice_alias(inode, dentry); } @@ -2393,6 +2395,7 @@ struct inode_operations ext3_dir_inode_o .removexattr = generic_removexattr, #endif .permission = ext3_permission, + .sync_flags = ext3_sync_flags, }; struct inode_operations ext3_special_inode_operations = { @@ -2404,4 +2407,5 @@ struct inode_operations ext3_special_ino .removexattr = generic_removexattr, #endif .permission = ext3_permission, + .sync_flags = ext3_sync_flags, }; diff -Nurp linux-2.6.16.38/fs/ext3/super.c linux-2.6.16.38-vs2.0.3-rc1/fs/ext3/super.c --- linux-2.6.16.38/fs/ext3/super.c 2007-01-23 13:44:19.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/ext3/super.c 2007-01-23 13:45:36.000000000 +0100 @@ -674,7 +674,7 @@ enum { Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota, Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_quota, Opt_noquota, Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_usrquota, - Opt_grpquota + Opt_grpquota, Opt_tagxid }; static match_table_t tokens = { @@ -723,6 +723,7 @@ static match_table_t tokens = { {Opt_quota, "quota"}, {Opt_usrquota, "usrquota"}, {Opt_barrier, "barrier=%u"}, + {Opt_tagxid, "tagxid"}, {Opt_err, NULL}, {Opt_resize, "resize"}, }; @@ -815,6 +816,11 @@ static int parse_options (char *options, case Opt_nouid32: set_opt (sbi->s_mount_opt, NO_UID32); break; +#ifndef CONFIG_INOXID_NONE + case Opt_tagxid: + set_opt (sbi->s_mount_opt, TAGXID); + break; +#endif case Opt_nocheck: clear_opt (sbi->s_mount_opt, CHECK); break; @@ -1469,6 +1475,9 @@ static int ext3_fill_super (struct super NULL, 0)) goto failed_mount; + if (EXT3_SB(sb)->s_mount_opt & EXT3_MOUNT_TAGXID) + sb->s_flags |= MS_TAGXID; + sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0); @@ -2278,6 +2287,12 @@ static int ext3_remount (struct super_bl if (sbi->s_mount_opt & EXT3_MOUNT_ABORT) ext3_abort(sb, __FUNCTION__, "Abort forced by user"); + if ((sbi->s_mount_opt & EXT3_MOUNT_TAGXID) && + !(sb->s_flags & MS_TAGXID)) { + printk("EXT3-fs: %s: tagxid not permitted on remount.\n", + sb->s_id); + return -EINVAL; + } sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0); diff -Nurp linux-2.6.16.38/fs/ext3/symlink.c linux-2.6.16.38-vs2.0.3-rc1/fs/ext3/symlink.c --- linux-2.6.16.38/fs/ext3/symlink.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/ext3/symlink.c 2007-01-23 13:45:36.000000000 +0100 @@ -40,6 +40,7 @@ struct inode_operations ext3_symlink_ino .listxattr = ext3_listxattr, .removexattr = generic_removexattr, #endif + .sync_flags = ext3_sync_flags, }; struct inode_operations ext3_fast_symlink_inode_operations = { @@ -51,4 +52,5 @@ struct inode_operations ext3_fast_symlin .listxattr = ext3_listxattr, .removexattr = generic_removexattr, #endif + .sync_flags = ext3_sync_flags, }; diff -Nurp linux-2.6.16.38/fs/ext3/xattr.c linux-2.6.16.38-vs2.0.3-rc1/fs/ext3/xattr.c --- linux-2.6.16.38/fs/ext3/xattr.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/ext3/xattr.c 2007-01-23 13:45:36.000000000 +0100 @@ -58,6 +58,7 @@ #include #include #include +#include #include "xattr.h" #include "acl.h" @@ -495,6 +496,7 @@ ext3_xattr_release_block(handle_t *handl ext3_journal_dirty_metadata(handle, bh); if (IS_SYNC(inode)) handle->h_sync = 1; + DLIMIT_FREE_BLOCK(inode, 1); DQUOT_FREE_BLOCK(inode, 1); unlock_buffer(bh); ea_bdebug(bh, "refcount now=%d; releasing", @@ -763,11 +765,14 @@ inserted: if (new_bh == bs->bh) ea_bdebug(new_bh, "keeping"); else { + error = -ENOSPC; + if (DLIMIT_ALLOC_BLOCK(inode, 1)) + goto cleanup; /* The old block is released after updating the inode. */ error = -EDQUOT; if (DQUOT_ALLOC_BLOCK(inode, 1)) - goto cleanup; + goto cleanup_dlimit; error = ext3_journal_get_write_access(handle, new_bh); if (error) @@ -843,6 +848,8 @@ cleanup: cleanup_dquot: DQUOT_FREE_BLOCK(inode, 1); +cleanup_dlimit: + DLIMIT_FREE_BLOCK(inode, 1); goto cleanup; bad_block: diff -Nurp linux-2.6.16.38/fs/fcntl.c linux-2.6.16.38-vs2.0.3-rc1/fs/fcntl.c --- linux-2.6.16.38/fs/fcntl.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/fcntl.c 2007-01-23 13:45:36.000000000 +0100 @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -85,6 +86,8 @@ repeat: error = -EMFILE; if (newfd >= current->signal->rlim[RLIMIT_NOFILE].rlim_cur) goto out; + if (!vx_files_avail(1)) + goto out; error = expand_files(files, newfd); if (error < 0) @@ -126,6 +129,7 @@ static int dupfd(struct file *file, unsi FD_SET(fd, fdt->open_fds); FD_CLR(fd, fdt->close_on_exec); spin_unlock(&files->file_lock); + vx_openfd_inc(fd); fd_install(fd, file); } else { spin_unlock(&files->file_lock); @@ -178,6 +182,9 @@ asmlinkage long sys_dup2(unsigned int ol if (tofree) filp_close(tofree, files); + else + vx_openfd_inc(newfd); /* fd was unused */ + err = newfd; out: return err; @@ -481,7 +488,7 @@ void send_sigio(struct fown_struct *fown read_lock(&tasklist_lock); if (pid > 0) { - p = find_task_by_pid(pid); + p = find_task_by_real_pid(pid); if (p) { send_sigio_to_task(p, fown, fd, band); } @@ -516,7 +523,7 @@ int send_sigurg(struct fown_struct *fown read_lock(&tasklist_lock); if (pid > 0) { - p = find_task_by_pid(pid); + p = find_task_by_real_pid(pid); if (p) { send_sigurg_to_task(p, fown); } diff -Nurp linux-2.6.16.38/fs/file_table.c linux-2.6.16.38-vs2.0.3-rc1/fs/file_table.c --- linux-2.6.16.38/fs/file_table.c 2006-03-20 06:53:29.000000000 +0100 +++ linux-2.6.16.38-vs2.0.3-rc1/fs/file_table.c 2007-01-23 13:45:36.000000000 +0100 @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include @@ -119,6 +121,8 @@ struct file *get_empty_filp(void) rwlock_init(&f->f_owner.lock); /* f->f_version: 0 */ INIT_LIST_HEAD(&f->f_u.fu_list); + f->f_xid = vx_current_xid(); + vx_files_inc(f); return f; over: @@ -173,6 +177,8 @@ void fastcall __fput(struct file *file) fops_put(file->f_op); if (file->f_mode & FMODE_WRITE) put_write_access(inode); + vx_files_dec(file); + file->f_xid = 0; file_kill(f