diff -NurpP --minimal DEVEL/linux-2.4.22-vs1.1.3/Makefile DEVEL/linux-2.4.22-vs1.1.4/Makefile --- DEVEL/linux-2.4.22-vs1.1.3/Makefile Mon Dec 1 16:29:18 2003 +++ DEVEL/linux-2.4.22-vs1.1.4/Makefile Mon Dec 1 16:29:23 2003 @@ -1,7 +1,7 @@ VERSION = 2 PATCHLEVEL = 4 SUBLEVEL = 22 -EXTRAVERSION = -vs1.1.3 +EXTRAVERSION = -vs1.1.4 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) diff -NurpP --minimal DEVEL/linux-2.4.22-vs1.1.3/drivers/block/vroot.c DEVEL/linux-2.4.22-vs1.1.4/drivers/block/vroot.c --- DEVEL/linux-2.4.22-vs1.1.3/drivers/block/vroot.c Mon Dec 1 16:29:18 2003 +++ DEVEL/linux-2.4.22-vs1.1.4/drivers/block/vroot.c Mon Dec 1 16:29:24 2003 @@ -35,7 +35,7 @@ #include "vroot.h" -static int max_vroot = 8; +static int max_vroot = MAX_VROOT_DEFAULT; static struct vroot_device *vroot_dev; static devfs_handle_t devfs_handle; /* For the directory */ @@ -261,8 +261,9 @@ int __init vroot_init(void) if ((max_vroot < 1) || (max_vroot > 256)) { printk(KERN_WARNING "vroot: invalid max_vroot (must be between" - " 1 and 256), using default (4)\n"); - max_vroot = 4; + " 1 and 256), using default (" + ##MAX_VROOT_DEFAULT ")\n"); + max_vroot = MAX_VROOT_DEFAULT; } if (devfs_register_blkdev(MAJOR_NR, "vroot", &vr_fops)) { diff -NurpP --minimal DEVEL/linux-2.4.22-vs1.1.3/drivers/block/vroot.h DEVEL/linux-2.4.22-vs1.1.4/drivers/block/vroot.h --- DEVEL/linux-2.4.22-vs1.1.3/drivers/block/vroot.h Mon Dec 1 16:29:18 2003 +++ DEVEL/linux-2.4.22-vs1.1.4/drivers/block/vroot.h Mon Dec 1 16:29:24 2003 @@ -34,6 +34,8 @@ struct vroot_device { #endif /* __KERNEL__ */ +#define MAX_VROOT_DEFAULT 8 + /* * IOCTL commands --- we will commandeer 0x56 ('V') */ diff -NurpP --minimal DEVEL/linux-2.4.22-vs1.1.3/fs/devpts/root.c DEVEL/linux-2.4.22-vs1.1.4/fs/devpts/root.c --- DEVEL/linux-2.4.22-vs1.1.3/fs/devpts/root.c Mon Dec 1 16:29:18 2003 +++ DEVEL/linux-2.4.22-vs1.1.4/fs/devpts/root.c Mon Dec 1 16:29:24 2003 @@ -66,7 +66,8 @@ static int devpts_root_readdir(struct fi while ( nr - 2 < sbi->max_ptys ) { int ptynr = nr - 2; struct inode *inode = sbi->inodes[ptynr]; - if (inode && vx_check(inode->u.devpts_i.vx_id, VX_WATCH|VX_IDENT)) { + if (inode && vx_check(inode->u.devpts_i.vx_id, + VX_WATCH|VX_IDENT)) { genptsname(numbuf, ptynr); if ( filldir(dirent, numbuf, strlen(numbuf), nr, nr, DT_CHR) < 0 ) return 0; diff -NurpP --minimal DEVEL/linux-2.4.22-vs1.1.3/fs/ext2/inode.c DEVEL/linux-2.4.22-vs1.1.4/fs/ext2/inode.c --- DEVEL/linux-2.4.22-vs1.1.3/fs/ext2/inode.c Mon Dec 1 16:29:18 2003 +++ DEVEL/linux-2.4.22-vs1.1.4/fs/ext2/inode.c Mon Dec 1 16:29:24 2003 @@ -64,7 +64,7 @@ void ext2_delete_inode (struct inode * i ext2_update_inode(inode, IS_SYNC(inode)); inode->i_size = 0; if (inode->i_blocks) - ext2_truncate_nocheck (inode); + ext2_truncate_nocheck(inode); ext2_free_inode (inode); unlock_kernel(); @@ -788,7 +788,7 @@ static void ext2_free_branches(struct in ext2_free_data(inode, p, q); } -static void ext2_truncate_nocheck (struct inode * inode) +static void ext2_truncate_nocheck(struct inode * inode) { u32 *i_data = inode->u.ext2_i.i_data; int addr_per_block = EXT2_ADDR_PER_BLOCK(inode->i_sb); @@ -881,7 +881,7 @@ void ext2_truncate (struct inode * inode { if (IS_APPEND(inode) || IS_IMMUTABLE_FILE(inode)) return; - ext2_truncate_nocheck (inode); + ext2_truncate_nocheck(inode); } void ext2_set_inode_flags(struct inode *inode) diff -NurpP --minimal DEVEL/linux-2.4.22-vs1.1.3/fs/ext3/inode.c DEVEL/linux-2.4.22-vs1.1.4/fs/ext3/inode.c --- DEVEL/linux-2.4.22-vs1.1.3/fs/ext3/inode.c Mon Dec 1 16:29:18 2003 +++ DEVEL/linux-2.4.22-vs1.1.4/fs/ext3/inode.c Mon Dec 1 16:29:24 2003 @@ -2004,7 +2004,7 @@ void ext3_truncate(struct inode * inode) { if (IS_APPEND(inode) || IS_IMMUTABLE_FILE(inode)) return; - ext3_truncate_nocheck (inode); + ext3_truncate_nocheck(inode); } /* diff -NurpP --minimal DEVEL/linux-2.4.22-vs1.1.3/fs/proc/array.c DEVEL/linux-2.4.22-vs1.1.4/fs/proc/array.c --- DEVEL/linux-2.4.22-vs1.1.3/fs/proc/array.c Mon Dec 1 16:29:18 2003 +++ DEVEL/linux-2.4.22-vs1.1.4/fs/proc/array.c Mon Dec 1 16:29:24 2003 @@ -301,6 +301,7 @@ int proc_pid_status(struct task_struct * buffer = task_cap(task, buffer); if (task->s_info) { int i; + buffer += sprintf (buffer,"s_context: %d [", task->vx_id); for (i=0; is_info->vx_id[i]; @@ -325,6 +326,7 @@ int proc_pid_status(struct task_struct * } if (task->ip_info) { int i; + buffer += sprintf (buffer,"ipv4root:"); for (i=0; iip_info->nbipv4; i++){ buffer += sprintf (buffer," %08x/%08x" diff -NurpP --minimal DEVEL/linux-2.4.22-vs1.1.3/include/linux/ext2_fs.h DEVEL/linux-2.4.22-vs1.1.4/include/linux/ext2_fs.h --- DEVEL/linux-2.4.22-vs1.1.3/include/linux/ext2_fs.h Mon Dec 1 16:29:18 2003 +++ DEVEL/linux-2.4.22-vs1.1.4/include/linux/ext2_fs.h Mon Dec 1 16:29:24 2003 @@ -198,7 +198,7 @@ struct ext2_group_desc #define EXT2_ECOMPR_FL 0x00000800 /* Compression error */ /* End compression flags --- maybe not all used */ #define EXT2_BTREE_FL 0x00001000 /* btree format dir */ -#define EXT2_IMMUTABLE_LINK_FL 0x00008000 /* Immutable link */ +#define EXT2_IMMUTABLE_LINK_FL 0x00008000 /* Immutable link */ #define EXT2_RESERVED_FL 0x80000000 /* reserved for ext2 lib */ #define EXT2_FL_USER_VISIBLE 0x00009FFF /* User visible flags */ diff -NurpP --minimal DEVEL/linux-2.4.22-vs1.1.3/include/linux/vswitch.h DEVEL/linux-2.4.22-vs1.1.4/include/linux/vswitch.h --- DEVEL/linux-2.4.22-vs1.1.3/include/linux/vswitch.h Mon Dec 1 16:29:18 2003 +++ DEVEL/linux-2.4.22-vs1.1.4/include/linux/vswitch.h Mon Dec 1 16:29:24 2003 @@ -57,7 +57,7 @@ /* interface version */ -#define VCI_VERSION 0x00010002 +#define VCI_VERSION 0x00010003 diff -NurpP --minimal DEVEL/linux-2.4.22-vs1.1.3/include/net/route.h DEVEL/linux-2.4.22-vs1.1.4/include/net/route.h --- DEVEL/linux-2.4.22-vs1.1.3/include/net/route.h Mon Dec 1 16:29:18 2003 +++ DEVEL/linux-2.4.22-vs1.1.4/include/net/route.h Mon Dec 1 16:29:24 2003 @@ -171,7 +171,7 @@ static inline int ip_route_connect(struc if (ip_info != NULL) { __u32 ipv4root = ip_info->ipv4[0]; if (ipv4root != 0) { - int n=ip_info->nbipv4; + int n = ip_info->nbipv4; if (src == 0) { if (n > 1) { u32 foundsrc; @@ -198,7 +198,7 @@ static inline int ip_route_connect(struc for (i=0; iipv4[i] == src) break; } - if (i==n) + if (i == n) return -EPERM; } if (dst == 0x0100007f && !vx_check(0, VX_ADMIN)) diff -NurpP --minimal DEVEL/linux-2.4.22-vs1.1.3/kernel/exit.c DEVEL/linux-2.4.22-vs1.1.4/kernel/exit.c --- DEVEL/linux-2.4.22-vs1.1.3/kernel/exit.c Mon Dec 1 16:29:18 2003 +++ DEVEL/linux-2.4.22-vs1.1.4/kernel/exit.c Mon Dec 1 16:29:24 2003 @@ -169,6 +169,7 @@ static inline void forget_original_paren pid_t initpid = father->s_info->initpid; if ((initpid != 0) && (father->pid != initpid)) { struct task_struct *r = find_task_by_pid(initpid); + if (r != NULL) vchild_reaper = r; } diff -NurpP --minimal DEVEL/linux-2.4.22-vs1.1.3/kernel/sched.c DEVEL/linux-2.4.22-vs1.1.4/kernel/sched.c --- DEVEL/linux-2.4.22-vs1.1.3/kernel/sched.c Mon Dec 1 16:29:18 2003 +++ DEVEL/linux-2.4.22-vs1.1.4/kernel/sched.c Mon Dec 1 16:29:24 2003 @@ -166,14 +166,12 @@ static inline int goodness(struct task_s * Don't do any other calculations if the time slice is * over.. */ - if (p->s_info != NULL - && (p->s_info->flags & VX_INFO_SCHED)) { + if (p->s_info && (p->s_info->flags & VX_INFO_SCHED)) { weight = atomic_read(&p->s_info->ticks) / atomic_read(&p->s_info->refcount); - weight = (weight+p->counter)>>1; - } else { + weight = (weight+p->counter) >> 1; + } else weight = p->counter; - } if (!weight) goto out; @@ -631,15 +629,13 @@ repeat_schedule: member processes p->counter */ for_each_task(p) { - if (p->s_info != NULL - && (p->s_info->flags & VX_INFO_SCHED)) - atomic_set (&p->s_info->ticks,0); + if (p->s_info && (p->s_info->flags & VX_INFO_SCHED)) + atomic_set(&p->s_info->ticks, 0); } for_each_task(p) { p->counter = (p->counter >> 1) + NICE_TO_TICKS(p->nice); - if (p->s_info != NULL - && (p->s_info->flags & VX_INFO_SCHED)) - atomic_add (p->counter,&p->s_info->ticks); + if (p->s_info && (p->s_info->flags & VX_INFO_SCHED)) + atomic_add(p->counter, &p->s_info->ticks); } read_unlock(&tasklist_lock); spin_lock_irq(&runqueue_lock); diff -NurpP --minimal DEVEL/linux-2.4.22-vs1.1.3/kernel/signal.c DEVEL/linux-2.4.22-vs1.1.4/kernel/signal.c --- DEVEL/linux-2.4.22-vs1.1.3/kernel/signal.c Mon Dec 1 16:29:18 2003 +++ DEVEL/linux-2.4.22-vs1.1.4/kernel/signal.c Mon Dec 1 16:29:24 2003 @@ -622,9 +622,9 @@ kill_pg_info(int sig, struct siginfo *in retval = -ESRCH; read_lock(&tasklist_lock); for_each_task(p) { - if (p->pgrp == pgrp && thread_group_leader(p) - && ((long)info==1 - || vx_check(p->vx_id, VX_IDENT))) { + if (p->pgrp == pgrp && thread_group_leader(p) && + ((long)info == 1 || + vx_check(p->vx_id, VX_IDENT))) { int err = send_sig_info(sig, info, p); if (retval) retval = err; @@ -715,8 +715,9 @@ static int kill_something_info(int sig, read_lock(&tasklist_lock); for_each_task(p) { - if (p->pid > 1 && p != current && thread_group_leader(p) - && vx_check(p->vx_id, VX_IDENT)) { + if (p->pid > 1 && p != current && + thread_group_leader(p) && + vx_check(p->vx_id, VX_IDENT)) { int err = send_sig_info(sig, info, p); ++count; if (err != -EPERM) diff -NurpP --minimal DEVEL/linux-2.4.22-vs1.1.3/kernel/sys.c DEVEL/linux-2.4.22-vs1.1.4/kernel/sys.c --- DEVEL/linux-2.4.22-vs1.1.3/kernel/sys.c Mon Dec 1 16:29:18 2003 +++ DEVEL/linux-2.4.22-vs1.1.4/kernel/sys.c Mon Dec 1 16:29:24 2003 @@ -281,9 +281,9 @@ asmlinkage long sys_getpriority(int whic } /* - * hotplug path is set via /proc/sys - * invoked by hotplug-aware bus drivers, - * with exec_usermodehelper and some thread-spawner + * vshelper path is set via /proc/sys + * invoked by vserver sys_reboot(), with + * the following arguments * * argv [0] = vshelper_path; * argv [1] = context identifier @@ -364,7 +364,7 @@ asmlinkage long sys_reboot(int magic1, i magic2 != LINUX_REBOOT_MAGIC2B)) return -EINVAL; - if (!vx_check(0, VX_ADMIN|VX_WATCH)) + if (!vx_check(0, VX_ADMIN | VX_WATCH)) return vs_reboot(cmd, arg); lock_kernel(); @@ -1180,7 +1180,8 @@ asmlinkage long sys_setdomainname(char * down_write(&uts_sem); domainname = system_utsname.domainname; - if (current->s_info) domainname = current->s_info->domainname; + if (current->s_info) + domainname = current->s_info->domainname; errno = -EFAULT; if (!copy_from_user(tmp, name, len)) { memcpy(domainname, tmp, len); diff -NurpP --minimal DEVEL/linux-2.4.22-vs1.1.3/kernel/sysctl.c DEVEL/linux-2.4.22-vs1.1.4/kernel/sysctl.c --- DEVEL/linux-2.4.22-vs1.1.3/kernel/sysctl.c Mon Dec 1 16:29:18 2003 +++ DEVEL/linux-2.4.22-vs1.1.4/kernel/sysctl.c Mon Dec 1 16:29:24 2003 @@ -819,6 +819,7 @@ static int proc_doutsstring(ctl_table *t if (current->s_info) { tmp = *table; table = &tmp; + if (table->data == (void*)&system_utsname.nodename) tmp.data = ¤t->s_info->nodename; else if (table->data == (void*)&system_utsname.domainname) diff -NurpP --minimal DEVEL/linux-2.4.22-vs1.1.3/kernel/vcontext.c DEVEL/linux-2.4.22-vs1.1.4/kernel/vcontext.c --- DEVEL/linux-2.4.22-vs1.1.3/kernel/vcontext.c Mon Dec 1 16:29:18 2003 +++ DEVEL/linux-2.4.22-vs1.1.4/kernel/vcontext.c Mon Dec 1 16:29:24 2003 @@ -156,14 +156,9 @@ void vx_assign_ip_info (struct iproot_in */ void vx_release_ip_info (struct iproot_info *ip_info) { - if (ip_info) { - if (atomic_dec_and_test(&ip_info->refcount)) { - if (ip_info->mark != 0xdeadbeef) - printk("vx_release_ip_info: broken signature %08lx\n", ip_info->mark); - else - vfree(ip_info); - } - } + if (ip_info) + if (atomic_dec_and_test(&ip_info->refcount)) + vfree(ip_info); } @@ -182,7 +177,8 @@ static int vx_switch_user_struct(int new atomic_dec(&old_user->processes); current->user = new_user; free_uid(old_user); - } + } else + free_uid(new_user); return 0; } @@ -211,9 +207,8 @@ int vc_new_s_context(uint32_t ctx, void { int ret = -EPERM; struct vcmd_new_s_context_v1 vc_data; - #define MAX_S_CONTEXT 65535 /* Arbitrary limit */ - if (copy_from_user (&vc_data, data, sizeof(vc_data))) + if (copy_from_user(&vc_data, data, sizeof(vc_data))) return -EFAULT; if (ctx == -1) { if (current->s_info == NULL @@ -222,10 +217,12 @@ int vc_new_s_context(uint32_t ctx, void /* it. Wrap around possible, so we loop */ static int alloc_ctx = MIN_D_CONTEXT; static spinlock_t alloc_ctx_lock = SPIN_LOCK_UNLOCKED; + spin_lock(&alloc_ctx_lock); while (1) { int found = 0; struct task_struct *p; + alloc_ctx++; /* The vx_id 1 is special. It sess all processes */ if (alloc_ctx == 1) @@ -278,6 +275,7 @@ int vc_new_s_context(uint32_t ctx, void /* The root context can become any context it wants */ int found = 0; struct task_struct *p; + /* Check if in use so we reuse the same context_info */ read_lock(&tasklist_lock); ret = ctx; @@ -320,8 +318,8 @@ int vc_set_ipv4root(uint32_t nbip, void struct vcmd_set_ipv4root_v3 vc_data; struct iproot_info *ip_info = current->ip_info; - if (copy_from_user (&vc_data, data, sizeof(vc_data))) - return -EFAULT; + if (copy_from_user (&vc_data, data, sizeof(vc_data))) + return -EFAULT; if (nbip < 0 || nbip > NB_IPV4ROOT) ret = -EINVAL; @@ -361,5 +359,3 @@ int vc_set_ipv4root(uint32_t nbip, void } return ret; } - - diff -NurpP --minimal DEVEL/linux-2.4.22-vs1.1.3/net/ipv4/devinet.c DEVEL/linux-2.4.22-vs1.1.4/net/ipv4/devinet.c --- DEVEL/linux-2.4.22-vs1.1.3/net/ipv4/devinet.c Mon Dec 1 16:29:18 2003 +++ DEVEL/linux-2.4.22-vs1.1.4/net/ipv4/devinet.c Mon Dec 1 16:29:24 2003 @@ -466,13 +466,14 @@ static int devinet_notiproot (struct in_ { int ret = 0; struct iproot_info *info = current->ip_info; + if (info && !vx_check(0, VX_ADMIN)) { int i; int nbip = info->nbipv4; __u32 addr = ifa->ifa_local; ret = 1; for (i=0; iipv4[i] == addr) { + if(info->ipv4[i] == addr) { ret = 0; break; } @@ -584,8 +585,7 @@ int devinet_ioctl(unsigned int cmd, void ret = -EADDRNOTAVAIL; goto done; } - if (ifa != NULL - && devinet_notiproot(ifa)) { + if (ifa != NULL && devinet_notiproot(ifa)) { ret = -EADDRNOTAVAIL; goto done; } diff -NurpP --minimal DEVEL/linux-2.4.22-vs1.1.3/net/ipv4/tcp_ipv4.c DEVEL/linux-2.4.22-vs1.1.4/net/ipv4/tcp_ipv4.c --- DEVEL/linux-2.4.22-vs1.1.3/net/ipv4/tcp_ipv4.c Mon Dec 1 16:29:18 2003 +++ DEVEL/linux-2.4.22-vs1.1.4/net/ipv4/tcp_ipv4.c Mon Dec 1 16:29:24 2003 @@ -191,6 +191,7 @@ static inline int tcp_in_list (struct so if (ip_info) { int n = ip_info->nbipv4; int i; + for (i=0; iipv4[i] == addr) return 1; @@ -206,19 +207,20 @@ static inline int tcp_in_list (struct so int tcp_ipv4_addr_conflict (struct sock *sk1, struct sock *sk2) { int ret = 0; - if (sk1->rcv_saddr) + + if (sk1->rcv_saddr) { /* Bind to one address only */ ret = tcp_in_list (sk2,sk1->rcv_saddr); - else if (sk1->ip_info) { + } else if (sk1->ip_info) { /* A restricted bind(any) */ struct iproot_info *ip_info = sk1->ip_info; int n = ip_info->nbipv4; int i; + for (i=0; iipv4[i])) return 1; - } - else /* A bind(any) do not allow other bind on the same port */ + } else /* A bind(any) do not allow other bind on the same port */ return 1; return 0; } @@ -466,15 +468,17 @@ static inline int tcp_addr_in_list ( if (rcv_saddr == daddr) return 1; else if (rcv_saddr == 0) { - /* Accept any address or only the one in the list */ - if (ip_info) { + /* Accept any address or check the list */ + if (!ip_info) + return 1; + else { int n = ip_info->nbipv4; int i; + for (i=0; iipv4[i] == daddr) return 1; } - else return 1; } return 0; } diff -NurpP --minimal DEVEL/linux-2.4.22-vs1.1.3/net/ipv4/udp.c DEVEL/linux-2.4.22-vs1.1.4/net/ipv4/udp.c --- DEVEL/linux-2.4.22-vs1.1.3/net/ipv4/udp.c Mon Dec 1 16:29:18 2003 +++ DEVEL/linux-2.4.22-vs1.1.4/net/ipv4/udp.c Mon Dec 1 16:29:24 2003 @@ -213,16 +213,13 @@ static void udp_v4_unhash(struct sock *s static int udp_in_list (struct iproot_info *ip_info, u32 addr) { - int ret = 0; int n = ip_info->nbipv4; int i; - for (i=0; iipv4[i] == addr) { - ret = 1; - break; - } - } - return ret; + + for (i=0; iipv4[i] == addr) + return 1; + return 0; } /* UDP is nearly always wildcards out the wazoo, it makes no sense to try @@ -553,10 +550,12 @@ int udp_sendmsg(struct sock *sk, struct if (rt == NULL) { struct iproot_info *ip_info = current->ip_info; + if (ip_info != NULL) { __u32 ipv4root = ip_info->ipv4[0]; if (ipv4root) { - if (daddr == 0x0100007f && !vx_check(0, VX_ADMIN)) + if (daddr == 0x0100007f && + !vx_check(0, VX_ADMIN)) daddr = ipv4root; if (ufh.saddr == 0) ufh.saddr = ipv4root;