Index: linux-2.6.18/Makefile
===================================================================
--- linux-2.6.18.orig/Makefile
+++ linux-2.6.18/Makefile
@@ -1,7 +1,7 @@
VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 18
-EXTRAVERSION =
+EXTRAVERSION = -vs2.0.3-rc1-gentoo
NAME=Avast! A bilge rat!
# *DOCUMENTATION*
Index: linux-2.6.18/arch/alpha/Kconfig
===================================================================
--- linux-2.6.18.orig/arch/alpha/Kconfig
+++ linux-2.6.18/arch/alpha/Kconfig
@@ -658,6 +658,8 @@ source "arch/alpha/oprofile/Kconfig"
source "arch/alpha/Kconfig.debug"
+source "kernel/vserver/Kconfig"
+
source "security/Kconfig"
source "crypto/Kconfig"
Index: linux-2.6.18/arch/alpha/kernel/entry.S
===================================================================
--- linux-2.6.18.orig/arch/alpha/kernel/entry.S
+++ linux-2.6.18/arch/alpha/kernel/entry.S
@@ -873,24 +873,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
Index: linux-2.6.18/arch/alpha/kernel/osf_sys.c
===================================================================
--- linux-2.6.18.orig/arch/alpha/kernel/osf_sys.c
+++ linux-2.6.18/arch/alpha/kernel/osf_sys.c
@@ -38,6 +38,7 @@
#include <linux/uio.h>
#include <linux/vfs.h>
#include <linux/rcupdate.h>
+#include <linux/vs_cvirt.h>
#include <asm/fpu.h>
#include <asm/io.h>
@@ -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,30 +612,30 @@ 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;
offset = command-1;
- if (offset >= ARRAY_SIZE(sysinfo_table)) {
+ if (offset >= 9) {
/* Digital UNIX has a few unpublished interfaces here */
printk("sysinfo(%d)", command);
goto out;
}
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;
Index: linux-2.6.18/arch/alpha/kernel/ptrace.c
===================================================================
--- linux-2.6.18.orig/arch/alpha/kernel/ptrace.c
+++ linux-2.6.18/arch/alpha/kernel/ptrace.c
@@ -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;
Index: linux-2.6.18/arch/alpha/kernel/systbls.S
===================================================================
--- linux-2.6.18.orig/arch/alpha/kernel/systbls.S
+++ linux-2.6.18/arch/alpha/kernel/systbls.S
@@ -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 */
Index: linux-2.6.18/arch/alpha/mm/init.c
===================================================================
--- linux-2.6.18.orig/arch/alpha/mm/init.c
+++ linux-2.6.18/arch/alpha/mm/init.c
@@ -20,6 +20,7 @@
#include <linux/init.h>
#include <linux/bootmem.h> /* max_low_pfn */
#include <linux/vmalloc.h>
+#include <linux/pagemap.h>
#include <asm/system.h>
#include <asm/uaccess.h>
Index: linux-2.6.18/arch/arm/Kconfig
===================================================================
--- linux-2.6.18.orig/arch/arm/Kconfig
+++ linux-2.6.18/arch/arm/Kconfig
@@ -908,6 +908,8 @@ source "arch/arm/oprofile/Kconfig"
source "arch/arm/Kconfig.debug"
+source "kernel/vserver/Kconfig"
+
source "security/Kconfig"
source "crypto/Kconfig"
Index: linux-2.6.18/arch/arm/kernel/calls.S
===================================================================
--- linux-2.6.18.orig/arch/arm/kernel/calls.S
+++ linux-2.6.18/arch/arm/kernel/calls.S
@@ -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)
Index: linux-2.6.18/arch/arm26/Kconfig
===================================================================
--- linux-2.6.18.orig/arch/arm26/Kconfig
+++ linux-2.6.18/arch/arm26/Kconfig
@@ -234,6 +234,8 @@ source "drivers/usb/Kconfig"
source "arch/arm26/Kconfig.debug"
+source "kernel/vserver/Kconfig"
+
source "security/Kconfig"
source "crypto/Kconfig"
Index: linux-2.6.18/arch/arm26/kernel/calls.S
===================================================================
--- linux-2.6.18.orig/arch/arm26/kernel/calls.S
+++ linux-2.6.18/arch/arm26/kernel/calls.S
@@ -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
Index: linux-2.6.18/arch/arm26/kernel/traps.c
===================================================================
--- linux-2.6.18.orig/arch/arm26/kernel/traps.c
+++ linux-2.6.18/arch/arm26/kernel/traps.c
@@ -185,8 +185,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));
Index: linux-2.6.18/arch/cris/Kconfig
===================================================================
--- linux-2.6.18.orig/arch/cris/Kconfig
+++ linux-2.6.18/arch/cris/Kconfig
@@ -185,6 +185,8 @@ source "drivers/usb/Kconfig"
source "arch/cris/Kconfig.debug"
+source "kernel/vserver/Kconfig"
+
source "security/Kconfig"
source "crypto/Kconfig"
Index: linux-2.6.18/arch/h8300/Kconfig
===================================================================
--- linux-2.6.18.orig/arch/h8300/Kconfig
+++ linux-2.6.18/arch/h8300/Kconfig
@@ -199,6 +199,8 @@ source "fs/Kconfig"
source "arch/h8300/Kconfig.debug"
+source "kernel/vserver/Kconfig"
+
source "security/Kconfig"
source "crypto/Kconfig"
Index: linux-2.6.18/arch/i386/Kconfig
===================================================================
--- linux-2.6.18.orig/arch/i386/Kconfig
+++ linux-2.6.18/arch/i386/Kconfig
@@ -1142,6 +1142,8 @@ endmenu
source "arch/i386/Kconfig.debug"
+source "kernel/vserver/Kconfig"
+
source "security/Kconfig"
source "crypto/Kconfig"
Index: linux-2.6.18/arch/i386/kernel/sys_i386.c
===================================================================
--- linux-2.6.18.orig/arch/i386/kernel/sys_i386.c
+++ linux-2.6.18/arch/i386/kernel/sys_i386.c
@@ -19,6 +19,7 @@
#include <linux/mman.h>
#include <linux/file.h>
#include <linux/utsname.h>
+#include <linux/vs_cvirt.h>
#include <asm/uaccess.h>
#include <asm/ipc.h>
@@ -210,7 +211,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;
}
@@ -218,6 +219,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;
@@ -226,15 +228,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);
Index: linux-2.6.18/arch/i386/kernel/syscall_table.S
===================================================================
--- linux-2.6.18.orig/arch/i386/kernel/syscall_table.S
+++ linux-2.6.18/arch/i386/kernel/syscall_table.S
@@ -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
Index: linux-2.6.18/arch/i386/kernel/sysenter.c
===================================================================
--- linux-2.6.18.orig/arch/i386/kernel/sysenter.c
+++ linux-2.6.18/arch/i386/kernel/sysenter.c
@@ -17,6 +17,7 @@
#include <linux/elf.h>
#include <linux/mm.h>
#include <linux/module.h>
+#include <linux/vs_memory.h>
#include <asm/cpufeature.h>
#include <asm/msr.h>
@@ -156,7 +157,7 @@ int arch_setup_additional_pages(struct l
current->mm->context.vdso = (void *)addr;
current_thread_info()->sysenter_return =
(void *)VDSO_SYM(&SYSENTER_RETURN);
- mm->total_vm++;
+ vx_vmpages_inc(mm);
up_fail:
up_write(&mm->mmap_sem);
return ret;
Index: linux-2.6.18/arch/i386/kernel/traps.c
===================================================================
--- linux-2.6.18.orig/arch/i386/kernel/traps.c
+++ linux-2.6.18/arch/i386/kernel/traps.c
@@ -53,6 +53,7 @@
#include <asm/kdebug.h>
#include <linux/module.h>
+#include <linux/vserver/debug.h>
#include "mach_traps.h"
@@ -304,8 +305,8 @@ 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, ti=%p task=%p task.ti=%p)",
- TASK_COMM_LEN, current->comm, current->pid,
+ printk(KERN_EMERG "Process %.*s (pid: %d[#%u], ti=%p task=%p task.ti=%p)",
+ TASK_COMM_LEN, current->comm, current->pid, current->xid,
current_thread_info(), current, current->thread_info);
/*
* When in-kernel, we also print out the stack and code at the
@@ -388,6 +389,8 @@ void die(const char * str, struct pt_reg
oops_enter();
+ vxh_throw_oops();
+
if (die.lock_owner != raw_smp_processor_id()) {
console_verbose();
spin_lock_irqsave(&die.lock, flags);
@@ -424,9 +427,9 @@ void die(const char * str, struct pt_reg
if (nl)
printk("\n");
if (notify_die(DIE_OOPS, str, regs, err,
- current->thread.trap_no, SIGSEGV) !=
- NOTIFY_STOP) {
+ current->thread.trap_no, SIGSEGV) != NOTIFY_STOP) {
show_registers(regs);
+ vxh_dump_history();
/* Executive summary in case the oops scrolled away */
esp = (unsigned long) (®s->esp);
savesegment(ss, ss);
Index: linux-2.6.18/arch/ia64/Kconfig
===================================================================
--- linux-2.6.18.orig/arch/ia64/Kconfig
+++ linux-2.6.18/arch/ia64/Kconfig
@@ -525,6 +525,8 @@ endmenu
source "arch/ia64/Kconfig.debug"
+source "kernel/vserver/Kconfig"
+
source "security/Kconfig"
source "crypto/Kconfig"
Index: linux-2.6.18/arch/ia64/ia32/binfmt_elf32.c
===================================================================
--- linux-2.6.18.orig/arch/ia64/ia32/binfmt_elf32.c
+++ linux-2.6.18/arch/ia64/ia32/binfmt_elf32.c
@@ -238,7 +238,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++) {
Index: linux-2.6.18/arch/ia64/ia32/ia32_entry.S
===================================================================
--- linux-2.6.18.orig/arch/ia64/ia32/ia32_entry.S
+++ linux-2.6.18/arch/ia64/ia32/ia32_entry.S
@@ -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
Index: linux-2.6.18/arch/ia64/kernel/entry.S
===================================================================
--- linux-2.6.18.orig/arch/ia64/kernel/entry.S
+++ linux-2.6.18/arch/ia64/kernel/entry.S
@@ -1576,7 +1576,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
Index: linux-2.6.18/arch/ia64/kernel/perfmon.c
===================================================================
--- linux-2.6.18.orig/arch/ia64/kernel/perfmon.c
+++ linux-2.6.18/arch/ia64/kernel/perfmon.c
@@ -40,6 +40,7 @@
#include <linux/capability.h>
#include <linux/rcupdate.h>
#include <linux/completion.h>
+#include <linux/vs_memory.h>
#include <asm/errno.h>
#include <asm/intrinsics.h>
@@ -2354,7 +2355,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);
Index: linux-2.6.18/arch/ia64/kernel/ptrace.c
===================================================================
--- linux-2.6.18.orig/arch/ia64/kernel/ptrace.c
+++ linux-2.6.18/arch/ia64/kernel/ptrace.c
@@ -1442,6 +1442,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;
Index: linux-2.6.18/arch/ia64/mm/fault.c
===================================================================
--- linux-2.6.18.orig/arch/ia64/mm/fault.c
+++ linux-2.6.18/arch/ia64/mm/fault.c
@@ -10,6 +10,7 @@
#include <linux/smp_lock.h>
#include <linux/interrupt.h>
#include <linux/kprobes.h>
+#include <linux/vs_memory.h>
#include <asm/pgtable.h>
#include <asm/processor.h>
Index: linux-2.6.18/arch/ia64/sn/kernel/xpc_main.c
===================================================================
--- linux-2.6.18.orig/arch/ia64/sn/kernel/xpc_main.c
+++ linux-2.6.18/arch/ia64/sn/kernel/xpc_main.c
@@ -108,6 +108,7 @@ static ctl_table xpc_sys_xpc_hb_dir[] =
0644,
NULL,
&proc_dointvec_minmax,
+ NULL,
&sysctl_intvec,
NULL,
&xpc_hb_min_interval,
@@ -121,6 +122,7 @@ static ctl_table xpc_sys_xpc_hb_dir[] =
0644,
NULL,
&proc_dointvec_minmax,
+ NULL,
&sysctl_intvec,
NULL,
&xpc_hb_check_min_interval,
@@ -145,6 +147,7 @@ static ctl_table xpc_sys_xpc_dir[] = {
0644,
NULL,
&proc_dointvec_minmax,
+ NULL,
&sysctl_intvec,
NULL,
&xpc_disengage_request_min_timelimit,
Index: linux-2.6.18/arch/m32r/kernel/sys_m32r.c
===================================================================
--- linux-2.6.18.orig/arch/m32r/kernel/sys_m32r.c
+++ linux-2.6.18/arch/m32r/kernel/sys_m32r.c
@@ -20,6 +20,7 @@
#include <linux/mman.h>
#include <linux/file.h>
#include <linux/utsname.h>
+#include <linux/vs_cvirt.h>
#include <asm/uaccess.h>
#include <asm/cachectl.h>
@@ -205,7 +206,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;
}
Index: linux-2.6.18/arch/m68k/Kconfig
===================================================================
--- linux-2.6.18.orig/arch/m68k/Kconfig
+++ linux-2.6.18/arch/m68k/Kconfig
@@ -654,6 +654,8 @@ source "fs/Kconfig"
source "arch/m68k/Kconfig.debug"
+source "kernel/vserver/Kconfig"
+
source "security/Kconfig"
source "crypto/Kconfig"
Index: linux-2.6.18/arch/m68k/kernel/ptrace.c
===================================================================
--- linux-2.6.18.orig/arch/m68k/kernel/ptrace.c
+++ linux-2.6.18/arch/m68k/kernel/ptrace.c
@@ -279,6 +279,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:
Index: linux-2.6.18/arch/m68knommu/Kconfig
===================================================================
--- linux-2.6.18.orig/arch/m68knommu/Kconfig
+++ linux-2.6.18/arch/m68knommu/Kconfig
@@ -663,6 +663,8 @@ source "fs/Kconfig"
source "arch/m68knommu/Kconfig.debug"
+source "kernel/vserver/Kconfig"
+
source "security/Kconfig"
source "crypto/Kconfig"
Index: linux-2.6.18/arch/mips/Kconfig
===================================================================
--- linux-2.6.18.orig/arch/mips/Kconfig
+++ linux-2.6.18/arch/mips/Kconfig
@@ -2057,6 +2057,8 @@ source "arch/mips/oprofile/Kconfig"
source "arch/mips/Kconfig.debug"
+source "kernel/vserver/Kconfig"
+
source "security/Kconfig"
source "crypto/Kconfig"
Index: linux-2.6.18/arch/mips/kernel/linux32.c
===================================================================
--- linux-2.6.18.orig/arch/mips/kernel/linux32.c
+++ linux-2.6.18/arch/mips/kernel/linux32.c
@@ -35,6 +35,7 @@
#include <linux/security.h>
#include <linux/compat.h>
#include <linux/vfs.h>
+#include <linux/vs_cvirt.h>
#include <net/sock.h>
#include <net/scm.h>
@@ -1039,7 +1040,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);
Index: linux-2.6.18/arch/mips/kernel/ptrace.c
===================================================================
--- linux-2.6.18.orig/arch/mips/kernel/ptrace.c
+++ linux-2.6.18/arch/mips/kernel/ptrace.c
@@ -171,6 +171,9 @@ long arch_ptrace(struct task_struct *chi
{
int ret;
+ if (!vx_check(vx_task_xid(child), VX_WATCH|VX_IDENT))
+ goto out;
+
switch (request) {
/* when I and D space are separate, these will need to be fixed. */
case PTRACE_PEEKTEXT: /* read word at location addr. */
Index: linux-2.6.18/arch/mips/kernel/scall32-o32.S
===================================================================
--- linux-2.6.18.orig/arch/mips/kernel/scall32-o32.S
+++ linux-2.6.18/arch/mips/kernel/scall32-o32.S
@@ -630,7 +630,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 */
Index: linux-2.6.18/arch/mips/kernel/scall64-64.S
===================================================================
--- linux-2.6.18.orig/arch/mips/kernel/scall64-64.S
+++ linux-2.6.18/arch/mips/kernel/scall64-64.S
@@ -434,7 +434,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
Index: linux-2.6.18/arch/mips/kernel/scall64-n32.S
===================================================================
--- linux-2.6.18.orig/arch/mips/kernel/scall64-n32.S
+++ linux-2.6.18/arch/mips/kernel/scall64-n32.S
@@ -360,7 +360,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
Index: linux-2.6.18/arch/mips/kernel/scall64-o32.S
===================================================================
--- linux-2.6.18.orig/arch/mips/kernel/scall64-o32.S
+++ linux-2.6.18/arch/mips/kernel/scall64-o32.S
@@ -482,7 +482,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 */
Index: linux-2.6.18/arch/mips/kernel/syscall.c
===================================================================
--- linux-2.6.18.orig/arch/mips/kernel/syscall.c
+++ linux-2.6.18/arch/mips/kernel/syscall.c
@@ -28,6 +28,7 @@
#include <linux/shm.h>
#include <linux/compiler.h>
#include <linux/module.h>
+#include <linux/vs_cvirt.h>
#include <asm/branch.h>
#include <asm/cachectl.h>
@@ -231,7 +232,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;
}
@@ -242,21 +243,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;
Index: linux-2.6.18/arch/mips/kernel/sysirix.c
===================================================================
--- linux-2.6.18.orig/arch/mips/kernel/sysirix.c
+++ linux-2.6.18/arch/mips/kernel/sysirix.c
@@ -32,6 +32,7 @@
#include <linux/security.h>
#include <linux/syscalls.h>
#include <linux/resource.h>
+#include <linux/vs_cvirt.h>
#include <asm/ptrace.h>
#include <asm/page.h>
@@ -884,7 +885,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;
@@ -1127,11 +1128,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);
Index: linux-2.6.18/arch/parisc/Kconfig
===================================================================
--- linux-2.6.18.orig/arch/parisc/Kconfig
+++ linux-2.6.18/arch/parisc/Kconfig
@@ -257,6 +257,8 @@ source "arch/parisc/oprofile/Kconfig"
source "arch/parisc/Kconfig.debug"
+source "kernel/vserver/Kconfig"
+
source "security/Kconfig"
source "crypto/Kconfig"
Index: linux-2.6.18/arch/parisc/hpux/sys_hpux.c
===================================================================
--- linux-2.6.18.orig/arch/parisc/hpux/sys_hpux.c
+++ linux-2.6.18/arch/parisc/hpux/sys_hpux.c
@@ -33,6 +33,7 @@
#include <linux/utsname.h>
#include <linux/vfs.h>
#include <linux/vmalloc.h>
+#include <linux/vs_cvirt.h>
#include <asm/errno.h>
#include <asm/pgalloc.h>
@@ -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:
Index: linux-2.6.18/arch/parisc/kernel/sys_parisc32.c
===================================================================
--- linux-2.6.18.orig/arch/parisc/kernel/sys_parisc32.c
+++ linux-2.6.18/arch/parisc/kernel/sys_parisc32.c
@@ -598,6 +598,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);
Index: linux-2.6.18/arch/parisc/kernel/syscall_table.S
===================================================================
--- linux-2.6.18.orig/arch/parisc/kernel/syscall_table.S
+++ linux-2.6.18/arch/parisc/kernel/syscall_table.S
@@ -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)
Index: linux-2.6.18/arch/powerpc/Kconfig
===================================================================
--- linux-2.6.18.orig/arch/powerpc/Kconfig
+++ linux-2.6.18/arch/powerpc/Kconfig
@@ -1078,6 +1078,8 @@ endmenu
source "arch/powerpc/Kconfig.debug"
+source "kernel/vserver/Kconfig"
+
source "security/Kconfig"
config KEYS_COMPAT
Index: linux-2.6.18/arch/powerpc/kernel/process.c
===================================================================
--- linux-2.6.18.orig/arch/powerpc/kernel/process.c
+++ linux-2.6.18/arch/powerpc/kernel/process.c
@@ -431,8 +431,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());
Index: linux-2.6.18/arch/powerpc/kernel/syscalls.c
===================================================================
--- linux-2.6.18.orig/arch/powerpc/kernel/syscalls.c
+++ linux-2.6.18/arch/powerpc/kernel/syscalls.c
@@ -36,6 +36,7 @@
#include <linux/file.h>
#include <linux/init.h>
#include <linux/personality.h>
+#include <linux/vs_cvirt.h>
#include <asm/uaccess.h>
#include <asm/ipc.h>
@@ -260,7 +261,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)
@@ -273,7 +274,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)
@@ -284,25 +285,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);
Index: linux-2.6.18/arch/powerpc/kernel/vdso.c
===================================================================
--- linux-2.6.18.orig/arch/powerpc/kernel/vdso.c
+++ linux-2.6.18/arch/powerpc/kernel/vdso.c
@@ -22,6 +22,7 @@
#include <linux/elf.h>
#include <linux/security.h>
#include <linux/bootmem.h>
+#include <linux/vs_memory.h>
#include <asm/pgtable.h>
#include <asm/system.h>
@@ -293,7 +294,7 @@ int arch_setup_additional_pages(struct l
/* Put vDSO base into mm struct and account for memory usage */
current->mm->context.vdso_base = vdso_base;
- 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;
Index: linux-2.6.18/arch/ppc/Kconfig
===================================================================
--- linux-2.6.18.orig/arch/ppc/Kconfig
+++ linux-2.6.18/arch/ppc/Kconfig
@@ -1418,6 +1418,8 @@ source "arch/powerpc/oprofile/Kconfig"
source "arch/ppc/Kconfig.debug"
+source "kernel/vserver/Kconfig"
+
source "security/Kconfig"
source "crypto/Kconfig"
Index: linux-2.6.18/arch/s390/Kconfig
===================================================================
--- linux-2.6.18.orig/arch/s390/Kconfig
+++ linux-2.6.18/arch/s390/Kconfig
@@ -495,6 +495,8 @@ source "arch/s390/oprofile/Kconfig"
source "arch/s390/Kconfig.debug"
+source "kernel/vserver/Kconfig"
+
source "security/Kconfig"
source "crypto/Kconfig"
Index: linux-2.6.18/arch/s390/kernel/process.c
===================================================================
--- linux-2.6.18.orig/arch/s390/kernel/process.c
+++ linux-2.6.18/arch/s390/kernel/process.c
@@ -165,9 +165,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 */
Index: linux-2.6.18/arch/s390/kernel/ptrace.c
===================================================================
--- linux-2.6.18.orig/arch/s390/kernel/ptrace.c
+++ linux-2.6.18/arch/s390/kernel/ptrace.c
@@ -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();
Index: linux-2.6.18/arch/s390/kernel/syscalls.S
===================================================================
--- linux-2.6.18.orig/arch/s390/kernel/syscalls.S
+++ linux-2.6.18/arch/s390/kernel/syscalls.S
@@ -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)
Index: linux-2.6.18/arch/sh/Kconfig
===================================================================
--- linux-2.6.18.orig/arch/sh/Kconfig
+++ linux-2.6.18/arch/sh/Kconfig
@@ -646,6 +646,8 @@ source "arch/sh/oprofile/Kconfig"
source "arch/sh/Kconfig.debug"
+source "kernel/vserver/Kconfig"
+
source "security/Kconfig"
source "crypto/Kconfig"
Index: linux-2.6.18/arch/sh/kernel/kgdb_stub.c
===================================================================
--- linux-2.6.18.orig/arch/sh/kernel/kgdb_stub.c
+++ linux-2.6.18/arch/sh/kernel/kgdb_stub.c
@@ -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;
Index: linux-2.6.18/arch/sh/kernel/setup.c
===================================================================
--- linux-2.6.18.orig/arch/sh/kernel/setup.c
+++ linux-2.6.18/arch/sh/kernel/setup.c
@@ -21,6 +21,7 @@
#include <linux/utsname.h>
#include <linux/cpu.h>
#include <linux/pfn.h>
+#include <linux/vs_cvirt.h>
#include <asm/uaccess.h>
#include <asm/io.h>
#include <asm/sections.h>
@@ -481,7 +482,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);
Index: linux-2.6.18/arch/sh/kernel/sys_sh.c
===================================================================
--- linux-2.6.18.orig/arch/sh/kernel/sys_sh.c
+++ linux-2.6.18/arch/sh/kernel/sys_sh.c
@@ -21,6 +21,7 @@
#include <linux/mman.h>
#include <linux/file.h>
#include <linux/utsname.h>
+#include <linux/vs_cvirt.h>
#include <asm/uaccess.h>
#include <asm/ipc.h>
@@ -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;
}
Index: linux-2.6.18/arch/sh64/kernel/sys_sh64.c
===================================================================
--- linux-2.6.18.orig/arch/sh64/kernel/sys_sh64.c
+++ linux-2.6.18/arch/sh64/kernel/sys_sh64.c
@@ -29,6 +29,7 @@
#include <linux/file.h>
#include <linux/utsname.h>
#include <linux/syscalls.h>
+#include <linux/vs_cvirt.h>
#include <asm/uaccess.h>
#include <asm/ipc.h>
#include <asm/ptrace.h>
@@ -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;
}
Index: linux-2.6.18/arch/sparc/Kconfig
===================================================================
--- linux-2.6.18.orig/arch/sparc/Kconfig
+++ linux-2.6.18/arch/sparc/Kconfig
@@ -291,6 +291,8 @@ source "fs/Kconfig"
source "arch/sparc/Kconfig.debug"
+source "kernel/vserver/Kconfig"
+
source "security/Kconfig"
source "crypto/Kconfig"
Index: linux-2.6.18/arch/sparc/kernel/ptrace.c
===================================================================
--- linux-2.6.18.orig/arch/sparc/kernel/ptrace.c
+++ linux-2.6.18/arch/sparc/kernel/ptrace.c
@@ -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)) {
Index: linux-2.6.18/arch/sparc/kernel/sys_sparc.c
===================================================================
--- linux-2.6.18.orig/arch/sparc/kernel/sys_sparc.c
+++ linux-2.6.18/arch/sparc/kernel/sys_sparc.c
@@ -21,6 +21,7 @@
#include <linux/utsname.h>
#include <linux/smp.h>
#include <linux/smp_lock.h>
+#include <linux/vs_cvirt.h>
#include <asm/uaccess.h>
#include <asm/ipc.h>
@@ -475,13 +476,13 @@ asmlinkage int sys_getdomainname(char __
down_read(&uts_sem);
- nlen = strlen(system_utsname.domainname) + 1;
+ nlen = strlen(vx_new_uts(domainname)) + 1;
err = -EINVAL;
if (nlen > len)
goto out;
err = -EFAULT;
- if (!copy_to_user(name, system_utsname.domainname, nlen))
+ if (!copy_to_user(name, vx_new_uts(domainname), nlen))
err = 0;
out:
Index: linux-2.6.18/arch/sparc/kernel/sys_sunos.c
===================================================================
--- linux-2.6.18.orig/arch/sparc/kernel/sys_sunos.c
+++ linux-2.6.18/arch/sparc/kernel/sys_sunos.c
@@ -35,6 +35,7 @@
#include <linux/smp.h>
#include <linux/smp_lock.h>
#include <linux/syscalls.h>
+#include <linux/vs_cvirt.h>
#include <net/sock.h>
@@ -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;
Index: linux-2.6.18/arch/sparc/kernel/systbls.S
===================================================================
--- linux-2.6.18.orig/arch/sparc/kernel/systbls.S
+++ linux-2.6.18/arch/sparc/kernel/systbls.S
@@ -71,7 +71,7 @@ sys_call_table:
/*250*/ .long sparc_mremap, sys_sysctl, sys_getsid, sys_fdatasync, sys_nfsservctl
/*255*/ .long sys_sync_file_range, 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_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
Index: linux-2.6.18/arch/sparc64/Kconfig
===================================================================
--- linux-2.6.18.orig/arch/sparc64/Kconfig
+++ linux-2.6.18/arch/sparc64/Kconfig
@@ -431,6 +431,8 @@ endmenu
source "arch/sparc64/Kconfig.debug"
+source "kernel/vserver/Kconfig"
+
source "security/Kconfig"
source "crypto/Kconfig"
Index: linux-2.6.18/arch/sparc64/kernel/binfmt_aout32.c
===================================================================
--- linux-2.6.18.orig/arch/sparc64/kernel/binfmt_aout32.c
+++ linux-2.6.18/arch/sparc64/kernel/binfmt_aout32.c
@@ -27,6 +27,7 @@
#include <linux/binfmts.h>
#include <linux/personality.h>
#include <linux/init.h>
+#include <linux/vs_memory.h>
#include <asm/system.h>
#include <asm/uaccess.h>
Index: linux-2.6.18/arch/sparc64/kernel/ptrace.c
===================================================================
--- linux-2.6.18.orig/arch/sparc64/kernel/ptrace.c
+++ linux-2.6.18/arch/sparc64/kernel/ptrace.c
@@ -212,6 +212,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)) {
Index: linux-2.6.18/arch/sparc64/kernel/sys_sparc.c
===================================================================
--- linux-2.6.18.orig/arch/sparc64/kernel/sys_sparc.c
+++ linux-2.6.18/arch/sparc64/kernel/sys_sparc.c
@@ -25,6 +25,7 @@
#include <linux/ipc.h>
#include <linux/personality.h>
#include <linux/random.h>
+#include <linux/vs_cvirt.h>
#include <asm/uaccess.h>
#include <asm/ipc.h>
@@ -712,13 +713,13 @@ asmlinkage long sys_getdomainname(char _
down_read(&uts_sem);
- nlen = strlen(system_utsname.domainname) + 1;
+ nlen = strlen(vx_new_uts(domainname)) + 1;
err = -EINVAL;
if (nlen > len)
goto out;
err = -EFAULT;
- if (!copy_to_user(name, system_utsname.domainname, nlen))
+ if (!copy_to_user(name, vx_new_uts(domainname), nlen))
err = 0;
out:
Index: linux-2.6.18/arch/sparc64/kernel/sys_sunos32.c
===================================================================
--- linux-2.6.18.orig/arch/sparc64/kernel/sys_sunos32.c
+++ linux-2.6.18/arch/sparc64/kernel/sys_sunos32.c
@@ -35,6 +35,7 @@
#include <linux/smp.h>
#include <linux/smp_lock.h>
#include <linux/syscalls.h>
+#include <linux/vs_cvirt.h>
#include <asm/uaccess.h>
#include <asm/page.h>
@@ -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);
Index: linux-2.6.18/arch/sparc64/kernel/systbls.S
===================================================================
--- linux-2.6.18.orig/arch/sparc64/kernel/systbls.S
+++ linux-2.6.18/arch/sparc64/kernel/systbls.S
@@ -72,7 +72,7 @@ sys_call_table32:
/*250*/ .word sys32_mremap, sys32_sysctl, sys32_getsid, sys_fdatasync, sys32_nfsservctl
.word sys32_sync_file_range, 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 sys32_tee, 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_sync_file_range, 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_tee, sys_add_key, sys_request_key, sys_keyctl, sys_openat
Index: linux-2.6.18/arch/sparc64/solaris/fs.c
===================================================================
--- linux-2.6.18.orig/arch/sparc64/solaris/fs.c
+++ linux-2.6.18/arch/sparc64/solaris/fs.c
@@ -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;
Index: linux-2.6.18/arch/sparc64/solaris/misc.c
===================================================================
--- linux-2.6.18.orig/arch/sparc64/solaris/misc.c
+++ linux-2.6.18/arch/sparc64/solaris/misc.c
@@ -16,6 +16,7 @@
#include <linux/timex.h>
#include <linux/major.h>
#include <linux/compat.h>
+#include <linux/vs_cvirt.h>
#include <asm/uaccess.h>
#include <asm/string.h>
@@ -248,7 +249,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);
@@ -272,7 +273,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);
@@ -304,7 +305,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;
Index: linux-2.6.18/arch/um/Kconfig
===================================================================
--- linux-2.6.18.orig/arch/um/Kconfig
+++ linux-2.6.18/arch/um/Kconfig
@@ -284,6 +284,8 @@ source "drivers/connector/Kconfig"
source "fs/Kconfig"
+source "kernel/vserver/Kconfig"
+
source "security/Kconfig"
source "crypto/Kconfig"
Index: linux-2.6.18/arch/um/kernel/syscall.c
===================================================================
--- linux-2.6.18.orig/arch/um/kernel/syscall.c
+++ linux-2.6.18/arch/um/kernel/syscall.c
@@ -15,6 +15,8 @@
#include "linux/unistd.h"
#include "linux/slab.h"
#include "linux/utime.h"
+#include <linux/vs_cvirt.h>
+
#include "asm/mman.h"
#include "asm/uaccess.h"
#include "kern_util.h"
@@ -110,7 +112,7 @@ long sys_uname(struct old_utsname __user
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 __user
long sys_olduname(struct oldold_utsname __user * 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);
Index: linux-2.6.18/arch/um/sys-x86_64/syscalls.c
===================================================================
--- linux-2.6.18.orig/arch/um/sys-x86_64/syscalls.c
+++ linux-2.6.18/arch/um/sys-x86_64/syscalls.c
@@ -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);
Index: linux-2.6.18/arch/v850/Kconfig
===================================================================
--- linux-2.6.18.orig/arch/v850/Kconfig
+++ linux-2.6.18/arch/v850/Kconfig
@@ -326,6 +326,8 @@ source "drivers/usb/Kconfig"
source "arch/v850/Kconfig.debug"
+source "kernel/vserver/Kconfig"
+
source "security/Kconfig"
source "crypto/Kconfig"
Index: linux-2.6.18/arch/v850/kernel/ptrace.c
===================================================================
--- linux-2.6.18.orig/arch/v850/kernel/ptrace.c
+++ linux-2.6.18/arch/v850/kernel/ptrace.c
@@ -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;
Index: linux-2.6.18/arch/x86_64/Kconfig
===================================================================
--- linux-2.6.18.orig/arch/x86_64/Kconfig
+++ linux-2.6.18/arch/x86_64/Kconfig
@@ -654,6 +654,8 @@ endmenu
source "arch/x86_64/Kconfig.debug"
+source "kernel/vserver/Kconfig"
+
source "security/Kconfig"
source "crypto/Kconfig"
Index: linux-2.6.18/arch/x86_64/ia32/ia32_aout.c
===================================================================
--- linux-2.6.18.orig/arch/x86_64/ia32/ia32_aout.c
+++ linux-2.6.18/arch/x86_64/ia32/ia32_aout.c
@@ -25,6 +25,7 @@
#include <linux/binfmts.h>
#include <linux/personality.h>
#include <linux/init.h>
+#include <linux/vs_memory.h>
#include <asm/system.h>
#include <asm/uaccess.h>
Index: linux-2.6.18/arch/x86_64/ia32/ia32_binfmt.c
===================================================================
--- linux-2.6.18.orig/arch/x86_64/ia32/ia32_binfmt.c
+++ linux-2.6.18/arch/x86_64/ia32/ia32_binfmt.c
@@ -376,7 +376,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++) {
Index: linux-2.6.18/arch/x86_64/ia32/ia32entry.S
===================================================================
--- linux-2.6.18.orig/arch/x86_64/ia32/ia32entry.S
+++ linux-2.6.18/arch/x86_64/ia32/ia32entry.S
@@ -668,7 +668,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
Index: linux-2.6.18/arch/x86_64/ia32/sys_ia32.c
===================================================================
--- linux-2.6.18.orig/arch/x86_64/ia32/sys_ia32.c
+++ linux-2.6.18/arch/x86_64/ia32/sys_ia32.c
@@ -60,6 +60,7 @@
#include <linux/highuid.h>
#include <linux/vmalloc.h>
#include <linux/fsnotify.h>
+#include <linux/vs_cvirt.h>
#include <asm/mman.h>
#include <asm/types.h>
#include <asm/uaccess.h>
@@ -779,6 +780,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;
@@ -787,13 +789,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";
@@ -816,7 +819,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);
Index: linux-2.6.18/arch/x86_64/ia32/syscall32.c
===================================================================
--- linux-2.6.18.orig/arch/x86_64/ia32/syscall32.c
+++ linux-2.6.18/arch/x86_64/ia32/syscall32.c
@@ -10,6 +10,7 @@
#include <linux/init.h>
#include <linux/stringify.h>
#include <linux/security.h>
+#include <linux/vs_memory.h>
#include <asm/proto.h>
#include <asm/tlbflush.h>
#include <asm/ia32_unistd.h>
@@ -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;
}
Index: linux-2.6.18/arch/x86_64/kernel/sys_x86_64.c
===================================================================
--- linux-2.6.18.orig/arch/x86_64/kernel/sys_x86_64.c
+++ linux-2.6.18/arch/x86_64/kernel/sys_x86_64.c
@@ -16,6 +16,7 @@
#include <linux/file.h>
#include <linux/utsname.h>
#include <linux/personality.h>
+#include <linux/vs_cvirt.h>
#include <asm/uaccess.h>
#include <asm/ia32.h>
@@ -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);
Index: linux-2.6.18/arch/x86_64/kernel/traps.c
===================================================================
--- linux-2.6.18.orig/arch/x86_64/kernel/traps.c
+++ linux-2.6.18/arch/x86_64/kernel/traps.c
@@ -435,8 +435,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
Index: linux-2.6.18/arch/xtensa/kernel/syscalls.c
===================================================================
--- linux-2.6.18.orig/arch/xtensa/kernel/syscalls.c
+++ linux-2.6.18/arch/xtensa/kernel/syscalls.c
@@ -34,6 +34,7 @@
#include <linux/msg.h>
#include <linux/shm.h>
#include <linux/errno.h>
+#include <linux/vs_cvirt.h>
#include <asm/ptrace.h>
#include <asm/signal.h>
#include <asm/uaccess.h>
@@ -128,7 +129,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;
}
Index: linux-2.6.18/block/cfq-iosched.c
===================================================================
--- linux-2.6.18.orig/block/cfq-iosched.c
+++ linux-2.6.18/block/cfq-iosched.c
@@ -326,6 +326,8 @@ static int cfq_queue_empty(request_queue
static inline pid_t cfq_queue_pid(struct task_struct *task, int rw)
{
+ if (task->xid)
+ return task->xid + (1 << 16);
if (rw == READ || rw == WRITE_SYNC)
return task->pid;
Index: linux-2.6.18/drivers/block/Kconfig
===================================================================
--- linux-2.6.18.orig/drivers/block/Kconfig
+++ linux-2.6.18/drivers/block/Kconfig
@@ -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
Index: linux-2.6.18/drivers/block/Makefile
===================================================================
--- linux-2.6.18.orig/drivers/block/Makefile
+++ linux-2.6.18/drivers/block/Makefile
@@ -29,4 +29,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
Index: linux-2.6.18/drivers/block/vroot.c
===================================================================
--- /dev/null
+++ linux-2.6.18/drivers/block/vroot.c
@@ -0,0 +1,281 @@
+/*
+ * 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-2006 by Herbert P�tzl.
+ * Redistribution of this file is permitted under the
+ * GNU General Public License.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/file.h>
+#include <linux/major.h>
+#include <linux/blkdev.h>
+
+#include <linux/vroot.h>
+#include <linux/vserver/debug.h>
+
+
+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;
+ }
+
+ 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);
+ disk->private_data = vr;
+ }
+
+ err = register_vroot_grb(&__vroot_get_real_bdev);
+ if (err)
+ goto out_mem3;
+
+ 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_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]);
+ }
+ 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
+
Index: linux-2.6.18/drivers/char/random.c
===================================================================
--- linux-2.6.18.orig/drivers/char/random.c
+++ linux-2.6.18/drivers/char/random.c
@@ -1173,7 +1173,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;
Index: linux-2.6.18/drivers/char/tty_io.c
===================================================================
--- linux-2.6.18.orig/drivers/char/tty_io.c
+++ linux-2.6.18/drivers/char/tty_io.c
@@ -103,6 +103,7 @@
#include <linux/selection.h>
#include <linux/kmod.h>
+#include <linux/vs_cvirt.h>
#undef TTY_DEBUG_HANGUP
@@ -2940,13 +2941,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);
}
/**
@@ -2978,6 +2982,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)
Index: linux-2.6.18/drivers/infiniband/core/uverbs_mem.c
===================================================================
--- linux-2.6.18.orig/drivers/infiniband/core/uverbs_mem.c
+++ linux-2.6.18/drivers/infiniband/core/uverbs_mem.c
@@ -36,6 +36,7 @@
#include <linux/mm.h>
#include <linux/dma-mapping.h>
+#include <linux/vs_memory.h>
#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);
Index: linux-2.6.18/drivers/infiniband/hw/ipath/ipath_user_pages.c
===================================================================
--- linux-2.6.18.orig/drivers/infiniband/hw/ipath/ipath_user_pages.c
+++ linux-2.6.18/drivers/infiniband/hw/ipath/ipath_user_pages.c
@@ -33,6 +33,7 @@
#include <linux/mm.h>
#include <linux/device.h>
+#include <linux/vs_memory.h>
#include "ipath_kernel.h"
@@ -61,7 +62,8 @@ static int __get_user_pages(unsigned lon
lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >>
PAGE_SHIFT;
- if (num_pages > lock_limit) {
+ if (num_pages > lock_limit ||
+ !vx_vmlocked_avail(current->mm, num_pages)) {
ret = -ENOMEM;
goto bail;
}
@@ -78,7 +80,7 @@ static int __get_user_pages(unsigned lon
goto bail_release;
}
- current->mm->locked_vm += num_pages;
+ vx_vmlocked_add(current->mm, num_pages);
ret = 0;
goto bail;
@@ -147,7 +149,7 @@ void ipath_release_user_pages(struct pag
__ipath_release_user_pages(p, num_pages, 1);
- current->mm->locked_vm -= num_pages;
+ vx_vmlocked_sub(current->mm, num_pages);
up_write(¤t->mm->mmap_sem);
}
@@ -163,7 +165,7 @@ static void user_pages_account(void *ptr
struct ipath_user_pages_work *work = ptr;
down_write(&work->mm->mmap_sem);
- work->mm->locked_vm -= work->num_pages;
+ vx_vmlocked_sub(work->mm, work->num_pages);
up_write(&work->mm->mmap_sem);
mmput(work->mm);
kfree(work);
Index: linux-2.6.18/fs/attr.c
===================================================================
--- linux-2.6.18.orig/fs/attr.c
+++ linux-2.6.18/fs/attr.c
@@ -15,6 +15,9 @@
#include <linux/fcntl.h>
#include <linux/quotaops.h>
#include <linux/security.h>
+#include <linux/proc_fs.h>
+#include <linux/devpts_fs.h>
+#include <linux/vserver/debug.h>
/* 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);
Index: linux-2.6.18/fs/binfmt_aout.c
===================================================================
--- linux-2.6.18.orig/fs/binfmt_aout.c
+++ linux-2.6.18/fs/binfmt_aout.c
@@ -24,6 +24,7 @@
#include <linux/binfmts.h>
#include <linux/personality.h>
#include <linux/init.h>
+#include <linux/vs_memory.h>
#include <asm/system.h>
#include <asm/uaccess.h>
Index: linux-2.6.18/fs/binfmt_elf.c
===================================================================
--- linux-2.6.18.orig/fs/binfmt_elf.c
+++ linux-2.6.18/fs/binfmt_elf.c
@@ -39,6 +39,8 @@
#include <linux/syscalls.h>
#include <linux/random.h>
#include <linux/elf.h>
+#include <linux/vs_memory.h>
+#include <linux/vs_cvirt.h>
#include <asm/uaccess.h>
#include <asm/param.h>
#include <asm/page.h>
Index: linux-2.6.18/fs/binfmt_elf_fdpic.c
===================================================================
--- linux-2.6.18.orig/fs/binfmt_elf_fdpic.c
+++ linux-2.6.18/fs/binfmt_elf_fdpic.c
@@ -34,6 +34,7 @@
#include <linux/elf.h>
#include <linux/elf-fdpic.h>
#include <linux/elfcore.h>
+#include <linux/vs_cvirt.h>
#include <asm/uaccess.h>
#include <asm/param.h>
Index: linux-2.6.18/fs/binfmt_flat.c
===================================================================
--- linux-2.6.18.orig/fs/binfmt_flat.c
+++ linux-2.6.18/fs/binfmt_flat.c
@@ -36,6 +36,7 @@
#include <linux/init.h>
#include <linux/flat.h>
#include <linux/syscalls.h>
+#include <linux/vs_memory.h>
#include <asm/byteorder.h>
#include <asm/system.h>
Index: linux-2.6.18/fs/binfmt_som.c
===================================================================
--- linux-2.6.18.orig/fs/binfmt_som.c
+++ linux-2.6.18/fs/binfmt_som.c
@@ -28,6 +28,7 @@
#include <linux/shm.h>
#include <linux/personality.h>
#include <linux/init.h>
+#include <linux/vs_memory.h>
#include <asm/uaccess.h>
#include <asm/pgtable.h>
Index: linux-2.6.18/fs/devpts/inode.c
===================================================================
--- linux-2.6.18.orig/fs/devpts/inode.c
+++ linux-2.6.18/fs/devpts/inode.c
@@ -20,7 +20,19 @@
#include <linux/devpts_fs.h>
#include <linux/parser.h>
-#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;
@@ -91,6 +103,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,
@@ -117,8 +147,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)
@@ -177,6 +208,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);
Index: linux-2.6.18/fs/exec.c
===================================================================
--- linux-2.6.18.orig/fs/exec.c
+++ linux-2.6.18/fs/exec.c
@@ -49,6 +49,8 @@
#include <linux/acct.h>
#include <linux/cn_proc.h>
#include <linux/audit.h>
+#include <linux/vs_memory.h>
+#include <linux/vs_cvirt.h>
#include <asm/uaccess.h>
#include <asm/mmu_context.h>
@@ -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++) {
@@ -1322,7 +1325,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;
Index: linux-2.6.18/fs/ext2/balloc.c
===================================================================
--- linux-2.6.18.orig/fs/ext2/balloc.c
+++ linux-2.6.18/fs/ext2/balloc.c
@@ -16,6 +16,7 @@
#include <linux/sched.h>
#include <linux/buffer_head.h>
#include <linux/capability.h>
+#include <linux/vs_dlimit.h>
/*
* balloc.c contains the blocks allocation and deallocation routines
@@ -102,12 +103,14 @@ static int reserve_blocks(struct super_b
{
struct ext2_sb_info *sbi = EXT2_SB(sb);
struct ext2_super_block *es = sbi->s_es;
- unsigned free_blocks;
- unsigned root_blocks;
+ unsigned long free_blocks;
+ unsigned long root_blocks;
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;
@@ -258,6 +261,7 @@ do_more:
}
error_return:
brelse(bitmap_bh);
+ DLIMIT_FREE_BLOCK(inode, freed);
release_blocks(sb, freed);
DQUOT_FREE_BLOCK(inode, freed);
}
@@ -361,6 +365,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);
@@ -508,6 +516,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);
Index: linux-2.6.18/fs/ext2/ext2.h
===================================================================
--- linux-2.6.18.orig/fs/ext2/ext2.h
+++ linux-2.6.18/fs/ext2/ext2.h
@@ -165,6 +165,7 @@ extern const struct file_operations ext2
extern const struct address_space_operations ext2_aops;
extern const struct address_space_operations ext2_aops_xip;
extern const 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;
Index: linux-2.6.18/fs/ext2/file.c
===================================================================
--- linux-2.6.18.orig/fs/ext2/file.c
+++ linux-2.6.18/fs/ext2/file.c
@@ -81,4 +81,5 @@ struct inode_operations ext2_file_inode_
#endif
.setattr = ext2_setattr,
.permission = ext2_permission,
+ .sync_flags = ext2_sync_flags,
};
Index: linux-2.6.18/fs/ext2/ialloc.c
===================================================================
--- linux-2.6.18.orig/fs/ext2/ialloc.c
+++ linux-2.6.18/fs/ext2/ialloc.c
@@ -17,6 +17,8 @@
#include <linux/backing-dev.h>
#include <linux/buffer_head.h>
#include <linux/random.h>
+#include <linux/vs_dlimit.h>
+#include <linux/vserver/xid.h>
#include "ext2.h"
#include "xattr.h"
#include "acl.h"
@@ -125,6 +127,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;
@@ -464,6 +467,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;
@@ -578,7 +586,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 */
@@ -626,12 +635,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);
Index: linux-2.6.18/fs/ext2/inode.c
===================================================================
--- linux-2.6.18.orig/fs/ext2/inode.c
+++ linux-2.6.18/fs/ext2/inode.c
@@ -31,6 +31,7 @@
#include <linux/writeback.h>
#include <linux/buffer_head.h>
#include <linux/mpage.h>
+#include <linux/vserver/xid.h>
#include "ext2.h"
#include "acl.h"
#include "xip.h"
@@ -913,7 +914,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);
@@ -1042,25 +1043,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
@@ -1071,12 +1117,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);
@@ -1174,8 +1225,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;
@@ -1210,6 +1261,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);
@@ -1296,7 +1350,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;
Index: linux-2.6.18/fs/ext2/ioctl.c
===================================================================
--- linux-2.6.18.orig/fs/ext2/ioctl.c
+++ linux-2.6.18/fs/ext2/ioctl.c
@@ -11,6 +11,7 @@
#include <linux/capability.h>
#include <linux/time.h>
#include <linux/sched.h>
+#include <linux/mount.h>
#include <asm/current.h>
#include <asm/uaccess.h>
@@ -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;
Index: linux-2.6.18/fs/ext2/namei.c
===================================================================
--- linux-2.6.18.orig/fs/ext2/namei.c
+++ linux-2.6.18/fs/ext2/namei.c
@@ -31,6 +31,7 @@
*/
#include <linux/pagemap.h>
+#include <linux/vserver/xid.h>
#include "ext2.h"
#include "xattr.h"
#include "acl.h"
@@ -66,6 +67,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);
}
@@ -391,6 +393,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 = {
@@ -402,4 +405,5 @@ struct inode_operations ext2_special_ino
#endif
.setattr = ext2_setattr,
.permission = ext2_permission,
+ .sync_flags = ext2_sync_flags,
};
Index: linux-2.6.18/fs/ext2/super.c
===================================================================
--- linux-2.6.18.orig/fs/ext2/super.c
+++ linux-2.6.18/fs/ext2/super.c
@@ -325,7 +325,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 = {
@@ -353,6 +353,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"},
@@ -416,6 +417,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;
@@ -717,6 +723,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);
@@ -1026,6 +1034,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);
Index: linux-2.6.18/fs/ext2/symlink.c
===================================================================
--- linux-2.6.18.orig/fs/ext2/symlink.c
+++ linux-2.6.18/fs/ext2/symlink.c
@@ -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,
};
Index: linux-2.6.18/fs/ext2/xattr.c
===================================================================
--- linux-2.6.18.orig/fs/ext2/xattr.c
+++ linux-2.6.18/fs/ext2/xattr.c
@@ -60,6 +60,7 @@
#include <linux/mbcache.h>
#include <linux/quotaops.h>
#include <linux/rwsem.h>
+#include <linux/vs_dlimit.h>
#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;
Index: linux-2.6.18/fs/ext3/balloc.c
===================================================================
--- linux-2.6.18.orig/fs/ext3/balloc.c
+++ linux-2.6.18/fs/ext3/balloc.c
@@ -19,6 +19,7 @@
#include <linux/ext3_jbd.h>
#include <linux/quotaops.h>
#include <linux/buffer_head.h>
+#include <linux/vs_dlimit.h>
/*
* balloc.c contains the blocks allocation and deallocation routines
@@ -503,8 +504,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;
}
@@ -1161,18 +1164,33 @@ out:
return ret;
}
-static int ext3_has_free_blocks(struct ext3_sb_info *sbi)
+static int ext3_has_free_blocks(struct super_block *sb)
{
+ struct ext3_sb_info *sbi = EXT3_SB(sb);
ext3_fsblk_t free_blocks, root_blocks;
+ int 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=%lu, root=%lu",
+ 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): %lu<%lu+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);
}
/*
@@ -1183,7 +1201,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);
@@ -1240,6 +1258,8 @@ ext3_fsblk_t ext3_new_blocks(handle_t *h
*errp = -EDQUOT;
return 0;