diff -u linux-2.6.16-ve026test002/drivers/net/loopback.c ./drivers/net/loopback.c
--- linux-2.6.16-ve026test002/drivers/net/loopback.c	2006-03-15 18:28:33.000000000 +0300
+++ ./drivers/net/loopback.c	2006-03-20 18:42:07.000000000 +0300
@@ -222,6 +222,10 @@
 				  |NETIF_F_LLTX|NETIF_F_VIRTUAL,
 };
 
+#ifdef loopback_dev
+#undef loopback_dev
+#endif
+
 struct net_device loopback_dev = {
 	.name	 		= "lo",
 	.mtu			= (16 * 1024) + 20 + 20 + 12,
@@ -257,7 +261,9 @@
 		loopback_dev.get_stats = &get_stats;
 		loopback_dev.destructor = &loopback_destructor;
 	}
-	
+#if defined(CONFIG_VE_NETDEV) || defined(CONFIG_VE_NETDEV_MODULE)
+	get_ve0()->_loopback_dev = &loopback_dev;
+#endif
 	return register_netdev(&loopback_dev);
 };
 
diff -u linux-2.6.16-ve026test002/fs/binfmt_elf.c ./fs/binfmt_elf.c
--- linux-2.6.16-ve026test002/fs/binfmt_elf.c	2006-03-15 18:28:33.000000000 +0300
+++ ./fs/binfmt_elf.c	2006-03-20 18:42:07.000000000 +0300
@@ -669,7 +669,7 @@
 			 */
 			SET_PERSONALITY(loc->elf_ex, ibcs2_interpreter);
 
-			interpreter = open_exec(elf_interpreter);
+			interpreter = open_exec(elf_interpreter, NULL);
 			retval = PTR_ERR(interpreter);
 			if (IS_ERR(interpreter))
 				goto out_free_interp;
diff -u linux-2.6.16-ve026test002/fs/exec.c ./fs/exec.c
--- linux-2.6.16-ve026test002/fs/exec.c	2006-03-15 18:28:33.000000000 +0300
+++ ./fs/exec.c	2006-03-20 18:42:07.000000000 +0300
@@ -137,7 +137,7 @@
 	if (!S_ISREG(nd.dentry->d_inode->i_mode))
 		goto exit;
 
-	error = vfs_permission(&nd, MAY_READ | MAY_EXEC);
+	error = vfs_permission(&nd, MAY_READ | MAY_EXEC, NULL);
 	if (error)
 		goto exit;
 
@@ -492,7 +492,7 @@
 
 #endif /* CONFIG_MMU */
 
-struct file *open_exec(const char *name)
+struct file *open_exec(const char *name, struct linux_binprm *bprm)
 {
 	struct nameidata nd;
 	int err;
@@ -506,9 +506,16 @@
 		file = ERR_PTR(-EACCES);
 		if (!(nd.mnt->mnt_flags & MNT_NOEXEC) &&
 		    S_ISREG(inode->i_mode)) {
-			int err = vfs_permission(&nd, MAY_EXEC);
-			if (!err && !(inode->i_mode & 0111))
-				err = -EACCES;
+			int err;
+			struct exec_perm *perm;
+
+			if (bprm != NULL) {
+				perm = &bprm->perm;
+				perm->set = 0;
+			} else
+				perm = NULL;
+
+			err = vfs_permission(&nd, MAY_EXEC, perm);
 			file = ERR_PTR(err);
 			if (!err) {
 				file = nameidata_to_filp(&nd, O_RDONLY);
@@ -949,13 +956,6 @@
 	struct inode * inode = bprm->file->f_dentry->d_inode;
 	int retval;
 
-	mode = inode->i_mode;
-	/*
-	 * Check execute perms again - if the caller has CAP_DAC_OVERRIDE,
-	 * generic_permission lets a non-executable through
-	 */
-	if (!(mode & 0111))	/* with at least _one_ execute bit set */
-		return -EACCES;
 	if (bprm->file->f_op == NULL)
 		return -EACCES;
 
@@ -963,10 +963,24 @@
 	bprm->e_gid = current->egid;
 
 	if(!(bprm->file->f_vfsmnt->mnt_flags & MNT_NOSUID)) {
+		if (!bprm->perm.set) {
+			/*
+			 * This piece of code creates a time window between
+			 * MAY_EXEC permission check and setuid/setgid
+			 * operations and may be considered as a security hole.
+			 * This code is here for compatibility reasons,
+			 * if the filesystem is unable to return info now.
+			 */
+			bprm->perm.mode = inode->i_mode;
+			bprm->perm.uid = inode->i_uid;
+			bprm->perm.gid = inode->i_gid;
+		}
+		mode = bprm->perm.mode;
+
 		/* Set-uid? */
 		if (mode & S_ISUID) {
 			current->personality &= ~PER_CLEAR_ON_SETID;
-			bprm->e_uid = inode->i_uid;
+			bprm->e_uid = bprm->perm.uid;
 		}
 
 		/* Set-gid? */
@@ -977,7 +991,7 @@
 		 */
 		if ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) {
 			current->personality &= ~PER_CLEAR_ON_SETID;
-			bprm->e_gid = inode->i_gid;
+			bprm->e_gid = bprm->perm.gid;
 		}
 	}
 
@@ -1076,7 +1090,7 @@
 
 	        loader = PAGE_SIZE*MAX_ARG_PAGES-sizeof(void *);
 
-		file = open_exec("/sbin/loader");
+		file = open_exec("/sbin/loader", bprm);
 		retval = PTR_ERR(file);
 		if (IS_ERR(file))
 			return retval;
@@ -1170,7 +1184,7 @@
 		goto out_ret;
 	memset(bprm, 0, sizeof(*bprm));
 
-	file = open_exec(filename);
+	file = open_exec(filename, bprm);
 	retval = PTR_ERR(file);
 	if (IS_ERR(file))
 		goto out_kfree;
diff -u linux-2.6.16-ve026test002/fs/ioprio.c ./fs/ioprio.c
--- linux-2.6.16-ve026test002/fs/ioprio.c	2006-03-15 18:28:33.000000000 +0300
+++ ./fs/ioprio.c	2006-03-20 18:42:07.000000000 +0300
@@ -53,6 +53,9 @@
 	struct user_struct *user;
 	int ret;
 
+	if (!ve_is_super(get_exec_env()))
+		return -EPERM;
+
 	switch (class) {
 		case IOPRIO_CLASS_RT:
 			if (!capable(CAP_SYS_ADMIN))
@@ -154,14 +157,14 @@
 			if (!user)
 				break;
 
-			do_each_thread_all(g, p) {
+			do_each_thread_ve(g, p) {
 				if (p->uid != user->uid)
 					continue;
 				if (ret == -ESRCH)
 					ret = p->ioprio;
 				else
 					ret = ioprio_best(ret, p->ioprio);
-			} while_each_thread_all(g, p);
+			} while_each_thread_ve(g, p);
 
 			if (who)
 				free_uid(user);
diff -u linux-2.6.16-ve026test002/fs/namei.c ./fs/namei.c
--- linux-2.6.16-ve026test002/fs/namei.c	2006-03-15 18:28:33.000000000 +0300
+++ ./fs/namei.c	2006-03-20 18:42:07.000000000 +0300
@@ -179,7 +179,7 @@
  * for filesystem access without changing the "normal" uids which
  * are used for other things..
  */
-int generic_permission(struct inode *inode, int mask,
+static int __generic_permission(struct inode *inode, int mask,
 		int (*check_acl)(struct inode *inode, int mask))
 {
 	umode_t			mode = inode->i_mode;
@@ -225,7 +225,26 @@
 	return -EACCES;
 }
 
-int permission(struct inode *inode, int mask, struct nameidata *nd)
+int generic_permission(struct inode *inode, int mask,
+		int (*check_acl)(struct inode *inode, int mask),
+		struct exec_perm *perm)
+{
+	int ret;
+
+	if (perm == NULL)
+		return __generic_permission(inode, mask, check_acl);
+
+	mutex_lock(&inode->i_mutex);
+	ret = __generic_permission(inode, mask, check_acl);
+	if (!ret)
+		set_exec_perm(perm, inode);
+	mutex_unlock(&inode->i_mutex);
+	return ret;
+}
+
+
+int permission(struct inode *inode, int mask, struct nameidata *nd,
+		struct exec_perm *perm)
 {
 	int retval, submask;
 
@@ -250,9 +269,9 @@
 	/* Ordinary permission routines do not understand MAY_APPEND. */
 	submask = mask & ~MAY_APPEND;
 	if (inode->i_op && inode->i_op->permission)
-		retval = inode->i_op->permission(inode, submask, nd);
+		retval = inode->i_op->permission(inode, submask, nd, perm);
 	else
-		retval = generic_permission(inode, submask, NULL);
+		retval = generic_permission(inode, submask, NULL, perm);
 	if (retval)
 		return retval;
 
@@ -269,9 +288,9 @@
  * for filesystem access without changing the "normal" uids which
  * are used for other things.
  */
-int vfs_permission(struct nameidata *nd, int mask)
+int vfs_permission(struct nameidata *nd, int mask, struct exec_perm *perm)
 {
-	return permission(nd->dentry->d_inode, mask, nd);
+	return permission(nd->dentry->d_inode, mask, nd, perm);
 }
 
 /**
@@ -288,7 +307,7 @@
  */
 int file_permission(struct file *file, int mask)
 {
-	return permission(file->f_dentry->d_inode, mask, NULL);
+	return permission(file->f_dentry->d_inode, mask, NULL, NULL);
 }
 
 /*
@@ -812,7 +831,7 @@
 		nd->flags |= LOOKUP_CONTINUE;
 		err = exec_permission_lite(inode, nd);
 		if (err == -EAGAIN)
-			err = vfs_permission(nd, MAY_EXEC);
+			err = vfs_permission(nd, MAY_EXEC, NULL);
  		if (err)
 			break;
 
@@ -1239,7 +1258,7 @@
 	int err;
 
 	inode = base->d_inode;
-	err = permission(inode, MAY_EXEC, nd);
+	err = permission(inode, MAY_EXEC, nd, NULL);
 	dentry = ERR_PTR(err);
 	if (err)
 		goto out;
@@ -1374,7 +1393,7 @@
 
 	BUG_ON(victim->d_parent->d_inode != dir);
 
-	error = permission(dir,MAY_WRITE | MAY_EXEC, NULL);
+	error = permission(dir,MAY_WRITE | MAY_EXEC, NULL, NULL);
 	if (error)
 		return error;
 	if (IS_APPEND(dir))
@@ -1411,7 +1430,7 @@
 		return -EEXIST;
 	if (IS_DEADDIR(dir))
 		return -ENOENT;
-	return permission(dir,MAY_WRITE | MAY_EXEC, nd);
+	return permission(dir,MAY_WRITE | MAY_EXEC, nd, NULL);
 }
 
 /* 
@@ -1511,7 +1530,7 @@
 	if (S_ISDIR(inode->i_mode) && (flag & FMODE_WRITE))
 		return -EISDIR;
 
-	error = vfs_permission(nd, acc_mode);
+	error = vfs_permission(nd, acc_mode, NULL);
 	if (error)
 		return error;
 
@@ -2333,7 +2352,7 @@
 	 * we'll need to flip '..'.
 	 */
 	if (new_dir != old_dir) {
-		error = permission(old_dentry->d_inode, MAY_WRITE, NULL);
+		error = permission(old_dentry->d_inode, MAY_WRITE, NULL, NULL);
 		if (error)
 			return error;
 	}
diff -u linux-2.6.16-ve026test002/fs/namespace.c ./fs/namespace.c
--- linux-2.6.16-ve026test002/fs/namespace.c	2006-03-15 18:28:33.000000000 +0300
+++ ./fs/namespace.c	2006-03-20 18:42:07.000000000 +0300
@@ -668,7 +668,7 @@
 		if (current->uid != nd->dentry->d_inode->i_uid)
 			return -EPERM;
 	}
-	if (vfs_permission(nd, MAY_WRITE))
+	if (vfs_permission(nd, MAY_WRITE, NULL))
 		return -EPERM;
 	return 0;
 #endif
diff -u linux-2.6.16-ve026test002/fs/open.c ./fs/open.c
--- linux-2.6.16-ve026test002/fs/open.c	2006-03-15 18:28:33.000000000 +0300
+++ ./fs/open.c	2006-03-20 18:42:07.000000000 +0300
@@ -280,7 +280,7 @@
 	if (!S_ISREG(inode->i_mode))
 		goto dput_and_out;
 
-	error = vfs_permission(&nd, MAY_WRITE);
+	error = vfs_permission(&nd, MAY_WRITE, NULL);
 	if (error)
 		goto dput_and_out;
 
@@ -434,7 +434,7 @@
                         goto dput_and_out;
 
 		if (current->fsuid != inode->i_uid &&
-		    (error = vfs_permission(&nd, MAY_WRITE)) != 0)
+		    (error = vfs_permission(&nd, MAY_WRITE, NULL)) != 0)
 			goto dput_and_out;
 	}
 	mutex_lock(&inode->i_mutex);
@@ -487,7 +487,7 @@
                         goto dput_and_out;
 
 		if (current->fsuid != inode->i_uid &&
-		    (error = vfs_permission(&nd, MAY_WRITE)) != 0)
+		    (error = vfs_permission(&nd, MAY_WRITE, NULL)) != 0)
 			goto dput_and_out;
 	}
 	mutex_lock(&inode->i_mutex);
@@ -551,7 +551,7 @@
 
 	res = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW|LOOKUP_ACCESS, &nd);
 	if (!res) {
-		res = vfs_permission(&nd, mode);
+		res = vfs_permission(&nd, mode, NULL);
 		/* SuS v2 requires we report a read only fs too */
 		if(!res && (mode & S_IWOTH) && IS_RDONLY(nd.dentry->d_inode)
 		   && !special_file(nd.dentry->d_inode->i_mode))
@@ -580,7 +580,7 @@
 	if (error)
 		goto out;
 
-	error = vfs_permission(&nd, MAY_EXEC);
+	error = vfs_permission(&nd, MAY_EXEC, NULL);
 	if (error)
 		goto dput_and_out;
 
@@ -631,7 +631,7 @@
 	if (error)
 		goto out;
 
-	error = vfs_permission(&nd, MAY_EXEC);
+	error = vfs_permission(&nd, MAY_EXEC, NULL);
 	if (error)
 		goto dput_and_out;
 
diff -u linux-2.6.16-ve026test002/fs/proc/base.c ./fs/proc/base.c
--- linux-2.6.16-ve026test002/fs/proc/base.c	2006-03-15 18:28:33.000000000 +0300
+++ ./fs/proc/base.c	2006-03-20 18:42:07.000000000 +0300
@@ -584,19 +584,21 @@
 	return proc_check_chroot(root, vfsmnt);
 }
 
-static int proc_permission(struct inode *inode, int mask, struct nameidata *nd)
+static int proc_permission(struct inode *inode, int mask, struct nameidata *nd,
+		struct exec_perm *perm)
 {
-	if (generic_permission(inode, mask, NULL) != 0)
+	if (generic_permission(inode, mask, NULL, perm) != 0)
 		return -EACCES;
 	return proc_check_root(inode);
 }
 
-static int proc_task_permission(struct inode *inode, int mask, struct nameidata *nd)
+static int proc_task_permission(struct inode *inode, int mask, struct nameidata *nd,
+		struct exec_perm *perm)
 {
 	struct dentry *root;
 	struct vfsmount *vfsmnt;
 
-	if (generic_permission(inode, mask, NULL) != 0)
+	if (generic_permission(inode, mask, NULL, perm) != 0)
 		return -EACCES;
 
 	if (proc_task_root_link(inode, &root, &vfsmnt))
diff -u linux-2.6.16-ve026test002/include/linux/fs.h ./include/linux/fs.h
--- linux-2.6.16-ve026test002/include/linux/fs.h	2006-03-15 18:28:33.000000000 +0300
+++ ./include/linux/fs.h	2006-03-20 18:42:07.000000000 +0300
@@ -599,6 +599,20 @@
 
 extern struct block_device *I_BDEV(struct inode *inode);
 
+struct exec_perm {
+	umode_t mode;
+	uid_t uid, gid;
+	int set;
+};
+
+static inline void set_exec_perm(struct exec_perm *perm, struct inode *ino)
+{
+	perm->set = 1;
+	perm->mode = ino->i_mode;
+	perm->uid = ino->i_uid;
+	perm->gid = ino->i_gid;
+}
+
 struct fown_struct {
 	rwlock_t lock;          /* protects pid, uid, euid fields */
 	int pid;		/* pid or -pgrp where SIGIO should be sent */
@@ -920,7 +934,7 @@
 /*
  * VFS helper functions..
  */
-extern int vfs_permission(struct nameidata *, int);
+extern int vfs_permission(struct nameidata *, int, struct exec_perm *);
 extern int vfs_create(struct inode *, struct dentry *, int, struct nameidata *);
 extern int vfs_mkdir(struct inode *, struct dentry *, int);
 extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t);
@@ -1059,7 +1073,8 @@
 	void * (*follow_link) (struct dentry *, struct nameidata *);
 	void (*put_link) (struct dentry *, struct nameidata *, void *);
 	void (*truncate) (struct inode *);
-	int (*permission) (struct inode *, int, struct nameidata *);
+	int (*permission) (struct inode *, int, struct nameidata *,
+			struct exec_perm *);
 	int (*setattr) (struct dentry *, struct iattr *);
 	int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
 	int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
@@ -1490,9 +1505,10 @@
 			 void *data, int force);
 extern sector_t bmap(struct inode *, sector_t);
 extern int notify_change(struct dentry *, struct iattr *);
-extern int permission(struct inode *, int, struct nameidata *);
+extern int permission(struct inode *, int, struct nameidata *,
+		struct exec_perm *);
 extern int generic_permission(struct inode *, int,
-		int (*check_acl)(struct inode *, int));
+		int (*check_acl)(struct inode *, int), struct exec_perm *);
 
 extern int get_write_access(struct inode *);
 extern int deny_write_access(struct file *);
@@ -1511,7 +1527,9 @@
 extern int may_open(struct nameidata *, int, int);
 
 extern int kernel_read(struct file *, unsigned long, char *, unsigned long);
-extern struct file * open_exec(const char *);
+
+struct linux_binprm;
+extern struct file * open_exec(const char *, struct linux_binprm *);
  
 /* fs/dcache.c -- generic fs support functions */
 extern int is_subdir(struct dentry *, struct dentry *);
diff -u linux-2.6.16-ve026test002/include/linux/netdevice.h ./include/linux/netdevice.h
--- linux-2.6.16-ve026test002/include/linux/netdevice.h	2006-03-15 18:28:33.000000000 +0300
+++ ./include/linux/netdevice.h	2006-03-20 18:42:07.000000000 +0300
@@ -555,13 +555,14 @@
 
 extern struct net_device		loopback_dev;		/* The loopback */
 #if defined(CONFIG_VE_NETDEV) || defined(CONFIG_VE_NETDEV_MODULE)
-#define visible_loopback_dev	(*get_exec_env()->_loopback_dev)
+#define loopback_dev	(*get_exec_env()->_loopback_dev)
+#define ve0_loopback	(*get_ve0()->_loopback_dev)
 #define dev_base	(get_exec_env()->_net_dev_base)
 #define visible_dev_head(x)	(&(x)->_net_dev_head)
 #define visible_dev_index_head(x) (&(x)->_net_dev_index_head)
 #else
-#define visible_loopback_dev	loopback_dev
 extern struct net_device		*dev_base;		/* All devices */
+#define ve0_loopback	loopback_dev
 #define visible_dev_head(x)	NULL
 #define visible_dev_index_head(x) NULL
 #endif
diff -u linux-2.6.16-ve026test002/include/linux/netfilter_ipv4/ip_conntrack.h ./include/linux/netfilter_ipv4/ip_conntrack.h
--- linux-2.6.16-ve026test002/include/linux/netfilter_ipv4/ip_conntrack.h	2006-03-15 18:28:33.000000000 +0300
+++ ./include/linux/netfilter_ipv4/ip_conntrack.h	2006-03-20 18:42:07.000000000 +0300
@@ -373,7 +373,7 @@
 static inline void ip_conntrack_event(enum ip_conntrack_events event,
 				      struct ip_conntrack *ct)
 {
-	if (is_confirmed(ct) && !is_dying(ct))
+	if (is_confirmed(ct) && !is_dying(ct) && ve_is_super(get_exec_env()))
 		notifier_call_chain(&ip_conntrack_chain, event, ct);
 }
 
@@ -381,7 +381,8 @@
 ip_conntrack_expect_event(enum ip_conntrack_expect_events event,
 			  struct ip_conntrack_expect *exp)
 {
-	notifier_call_chain(&ip_conntrack_expect_chain, event, exp);
+	if (ve_is_super(get_exec_env()))
+		notifier_call_chain(&ip_conntrack_expect_chain, event, exp);
 }
 #else /* CONFIG_IP_NF_CONNTRACK_EVENTS */
 static inline void ip_conntrack_event_cache(enum ip_conntrack_events event, 
diff -u linux-2.6.16-ve026test002/include/linux/nfcalls.h ./include/linux/nfcalls.h
--- linux-2.6.16-ve026test002/include/linux/nfcalls.h	2006-03-15 18:28:33.000000000 +0300
+++ ./include/linux/nfcalls.h	2006-03-20 18:42:07.000000000 +0300
@@ -144,6 +144,7 @@
 DECL_KSYM_MODULE(iptable_nat);
 DECL_KSYM_MODULE(ip_nat_ftp);
 DECL_KSYM_MODULE(ip_nat_irc);
+DECL_KSYM_MODULE(ipt_REDIRECT);
 
 struct sk_buff;
 
@@ -172,6 +173,7 @@
 DECL_KSYM_CALL(int, init_iptable_nat, (void));
 DECL_KSYM_CALL(int, init_iptable_nat_ftp, (void));
 DECL_KSYM_CALL(int, init_iptable_nat_irc, (void));
+DECL_KSYM_CALL(int, init_iptable_REDIRECT, (void));
 DECL_KSYM_CALL(void, fini_iptable_nat_irc, (void));
 DECL_KSYM_CALL(void, fini_iptable_nat_ftp, (void));
 DECL_KSYM_CALL(void, fini_iptable_nat, (void));
@@ -197,6 +199,7 @@
 DECL_KSYM_CALL(void, fini_iptables, (void));
 DECL_KSYM_CALL(void, fini_xtables, (void));
 DECL_KSYM_CALL(void, fini_netfilter, (void));
+DECL_KSYM_CALL(void, fini_iptable_REDIRECT, (void));
 
 DECL_KSYM_CALL(void, ipt_flush_table, (struct xt_table *table));
 #endif /* CONFIG_VE_IPTABLES */
diff -u linux-2.6.16-ve026test002/include/linux/vzcalluser.h ./include/linux/vzcalluser.h
--- linux-2.6.16-ve026test002/include/linux/vzcalluser.h	2006-03-15 18:28:32.000000000 +0300
+++ ./include/linux/vzcalluser.h	2006-03-20 18:42:07.000000000 +0300
@@ -80,6 +80,7 @@
 #define VE_IP_NAT_MOD			(1U<<20)
 #define VE_IP_NAT_FTP_MOD		(1U<<21)
 #define VE_IP_NAT_IRC_MOD		(1U<<22)
+#define VE_IP_TARGET_REDIRECT_MOD	(1U<<23)
 
 /* these masks represent modules with their dependences */
 #define VE_IP_IPTABLES		(VE_IP_IPTABLES_MOD)
@@ -125,6 +126,8 @@
 					| VE_IP_NAT | VE_IP_CONNTRACK_FTP)
 #define VE_IP_NAT_IRC		(VE_IP_NAT_IRC_MOD		\
 					| VE_IP_NAT | VE_IP_CONNTRACK_IRC)
+#define VE_IP_TARGET_REDIRECT	(VE_IP_TARGET_REDIRECT_MOD	\
+					| VE_IP_NAT)
 
 /* safe iptables mask to be used by default */
 #define VE_IP_DEFAULT					\
diff -u linux-2.6.16-ve026test002/kernel/printk.c ./kernel/printk.c
--- linux-2.6.16-ve026test002/kernel/printk.c	2006-03-15 18:28:33.000000000 +0300
+++ ./kernel/printk.c	2006-03-20 18:42:07.000000000 +0300
@@ -32,6 +32,7 @@
 #include <linux/bootmem.h>
 #include <linux/vzratelimit.h>
 #include <linux/syscalls.h>
+#include <linux/veprintk.h>
 
 #include <asm/uaccess.h>
 
@@ -123,31 +124,6 @@
 static int log_buf_len = __LOG_BUF_LEN;
 static unsigned long logged_chars; /* Number of chars produced since last read+clear operation */
 
-#ifdef CONFIG_VE
-
-#define ve_log_wait		(*(get_exec_env()->_log_wait))
-#define ve_log_start		(*(get_exec_env()->_log_start))
-#define ve_log_end		(*(get_exec_env()->_log_end))
-#define ve_logged_chars		(*(get_exec_env()->_logged_chars))
-#define ve_log_buf		(get_exec_env()->log_buf)
-#define ve_log_buf_len		(ve_is_super(get_exec_env()) ? \
-				log_buf_len : VE_DEFAULT_LOG_BUF_LEN)
-#define VE_LOG_BUF_MASK		(ve_log_buf_len - 1)
-#define VE_LOG_BUF(idx)		(ve_log_buf[(idx) & VE_LOG_BUF_MASK])
-
-#else
-
-#define ve_log_wait		log_wait
-#define ve_log_start		log_start
-#define ve_log_end		log_end
-#define ve_logged_chars		logged_chars
-#define ve_log_buf		log_buf
-#define ve_log_buf_len		log_buf_len
-#define VE_LOG_BUF_MASK		LOG_BUF_MASK
-#define VE_LOG_BUF(idx)		LOG_BUF(idx)
-
-#endif /* CONFIG_VE */
-
 /*
  *	Setup a list of consoles. Called from init/main.c
  */
diff -u linux-2.6.16-ve026test002/kernel/ve.c ./kernel/ve.c
--- linux-2.6.16-ve026test002/kernel/ve.c	2006-03-15 18:28:33.000000000 +0300
+++ ./kernel/ve.c	2006-03-20 18:42:07.000000000 +0300
@@ -76,6 +76,7 @@
 INIT_KSYM_MODULE(iptable_nat);
 INIT_KSYM_MODULE(ip_nat_ftp);
 INIT_KSYM_MODULE(ip_nat_irc);
+INIT_KSYM_MODULE(ipt_REDIRECT);
 
 INIT_KSYM_CALL(int, init_netfilter, (void));
 INIT_KSYM_CALL(int, init_xtables, (void));
@@ -102,6 +103,7 @@
 INIT_KSYM_CALL(int, init_iptable_nat, (void));
 INIT_KSYM_CALL(int, init_iptable_nat_ftp, (void));
 INIT_KSYM_CALL(int, init_iptable_nat_irc, (void));
+INIT_KSYM_CALL(int, init_iptable_REDIRECT, (void));
 INIT_KSYM_CALL(void, fini_iptable_nat_irc, (void));
 INIT_KSYM_CALL(void, fini_iptable_nat_ftp, (void));
 INIT_KSYM_CALL(void, fini_iptable_nat, (void));
@@ -127,6 +129,7 @@
 INIT_KSYM_CALL(void, fini_iptables, (void));
 INIT_KSYM_CALL(void, fini_xtables, (void));
 INIT_KSYM_CALL(void, fini_netfilter, (void));
+INIT_KSYM_CALL(void, fini_iptable_REDIRECT, (void));
 
 INIT_KSYM_CALL(void, ipt_flush_table, (struct xt_table *table));
 #endif
diff -u linux-2.6.16-ve026test002/kernel/vecalls.c ./kernel/vecalls.c
--- linux-2.6.16-ve026test002/kernel/vecalls.c	2006-03-15 18:28:33.000000000 +0300
+++ ./kernel/vecalls.c	2006-03-20 18:42:07.000000000 +0300
@@ -1607,11 +1607,24 @@
 	if (err < 0)
 		goto err_xt_length;
 #endif
+#if defined(CONFIG_IP_NF_TARGET_REDIRECT) || \
+    defined(CONFIG_IP_NF_TARGET_REDIRECT_MODULE)
+	err = KSYMIPTINIT(init_mask, ve, VE_IP_TARGET_REDIRECT,
+			ipt_REDIRECT, init_iptable_REDIRECT, ());
+	if (err < 0)
+		goto err_iptable_REDIRECT;
+#endif
 	return 0;
 
 /* ------------------------------------------------------------------------- */
 
 cleanup:
+#if defined(CONFIG_IP_NF_TARGET_REDIRECT) || \
+    defined(CONFIG_IP_NF_TARGET_REDIRECT_MODULE)
+	KSYMIPTFINI(ve->_iptables_modules, VE_IP_TARGET_REDIRECT,
+			ipt_REDIRECT, fini_iptable_REDIRECT, ());
+err_iptable_REDIRECT:
+#endif
 #if defined(CONFIG_NETFILTER_XT_MATCH_LENGTH) || \
     defined(CONFIG_NETFILTER_XT_MATCH_LENGTH_MODULE)
 	KSYMIPTFINI(ve->_iptables_modules, VE_IP_MATCH_LENGTH,
diff -u linux-2.6.16-ve026test002/kernel/veowner.c ./kernel/veowner.c
--- linux-2.6.16-ve026test002/kernel/veowner.c	2006-03-15 18:28:32.000000000 +0300
+++ ./kernel/veowner.c	2006-03-20 18:42:07.000000000 +0300
@@ -100,6 +100,7 @@
 		"cmdline",
 		"vmstat",
 		"modules",
+		"kmsg",
 		NULL,
 	};
 	char **p;
diff -u linux-2.6.16-ve026test002/net/core/dst.c ./net/core/dst.c
--- linux-2.6.16-ve026test002/net/core/dst.c	2006-03-15 18:28:33.000000000 +0300
+++ ./net/core/dst.c	2006-03-20 18:42:07.000000000 +0300
@@ -241,13 +241,13 @@
 		dst->input = dst_discard_in;
 		dst->output = dst_discard_out;
 	} else {
-		dst->dev = &visible_loopback_dev;
-		dev_hold(&visible_loopback_dev);
+		dst->dev = &loopback_dev;
+		dev_hold(&loopback_dev);
 		dev_put(dev);
 		if (dst->neighbour && dst->neighbour->dev == dev) {
-			dst->neighbour->dev = &visible_loopback_dev;
+			dst->neighbour->dev = &loopback_dev;
 			dev_put(dev);
-			dev_hold(&visible_loopback_dev);
+			dev_hold(&loopback_dev);
 		}
 	}
 }
diff -u linux-2.6.16-ve026test002/net/ipv4/devinet.c ./net/ipv4/devinet.c
--- linux-2.6.16-ve026test002/net/ipv4/devinet.c	2006-03-15 18:28:33.000000000 +0300
+++ ./net/ipv4/devinet.c	2006-03-20 18:42:07.000000000 +0300
@@ -196,7 +196,7 @@
 	ASSERT_RTNL();
 
 	dev = in_dev->dev;
-	if (dev == &loopback_dev)
+	if (dev == &ve0_loopback)
 		return;
 
 	in_dev->dead = 1;
@@ -1009,7 +1009,7 @@
 	case NETDEV_UP:
 		if (dev->mtu < 68)
 			break;
-		if (dev == &visible_loopback_dev) {
+		if (dev == &loopback_dev) {
 			struct in_ifaddr *ifa;
 			if ((ifa = inet_alloc_ifa()) != NULL) {
 				ifa->ifa_local =
diff -u linux-2.6.16-ve026test002/net/ipv4/route.c ./net/ipv4/route.c
--- linux-2.6.16-ve026test002/net/ipv4/route.c	2006-03-15 18:28:33.000000000 +0300
+++ ./net/ipv4/route.c	2006-03-20 18:42:07.000000000 +0300
@@ -1779,7 +1779,7 @@
 #endif
 	rth->rt_iif	=
 	rth->fl.iif	= dev->ifindex;
-	rth->u.dst.dev	= &visible_loopback_dev;
+	rth->u.dst.dev	= &loopback_dev;
 	dev_hold(rth->u.dst.dev);
 	rth->idev	= in_dev_get(rth->u.dst.dev);
 	rth->fl.oif	= 0;
@@ -2103,7 +2103,7 @@
 	if (res.type == RTN_LOCAL) {
 		int result;
 		result = fib_validate_source(saddr, daddr, tos,
-					     visible_loopback_dev.ifindex,
+					     loopback_dev.ifindex,
 					     dev, &spec_dst, &itag);
 		if (result < 0)
 			goto martian_source;
@@ -2175,7 +2175,7 @@
 #endif
 	rth->rt_iif	=
 	rth->fl.iif	= dev->ifindex;
-	rth->u.dst.dev	= &visible_loopback_dev;
+	rth->u.dst.dev	= &loopback_dev;
 	dev_hold(rth->u.dst.dev);
 	rth->idev	= in_dev_get(rth->u.dst.dev);
 	rth->rt_gateway	= daddr;
@@ -2531,7 +2531,7 @@
 					.fwmark = oldflp->fl4_fwmark
 #endif
 				      } },
-			    .iif = visible_loopback_dev.ifindex,
+			    .iif = loopback_dev.ifindex,
 			    .oif = oldflp->oif };
 	struct fib_result res;
 	unsigned flags = 0;
@@ -2634,9 +2634,9 @@
 			fl.fl4_dst = fl.fl4_src = htonl(INADDR_LOOPBACK);
 		if (dev_out)
 			dev_put(dev_out);
-		dev_out = &visible_loopback_dev;
+		dev_out = &loopback_dev;
 		dev_hold(dev_out);
-		fl.oif = visible_loopback_dev.ifindex;
+		fl.oif = loopback_dev.ifindex;
 		res.type = RTN_LOCAL;
 		flags |= RTCF_LOCAL;
 		goto make_route;
@@ -2681,7 +2681,7 @@
 			fl.fl4_src = fl.fl4_dst;
 		if (dev_out)
 			dev_put(dev_out);
-		dev_out = &visible_loopback_dev;
+		dev_out = &loopback_dev;
 		dev_hold(dev_out);
 		fl.oif = dev_out->ifindex;
 		if (res.fi)
diff -u linux-2.6.16-ve026test002/net/unix/af_unix.c ./net/unix/af_unix.c
--- linux-2.6.16-ve026test002/net/unix/af_unix.c	2006-03-15 18:28:33.000000000 +0300
+++ ./net/unix/af_unix.c	2006-03-20 18:42:07.000000000 +0300
@@ -686,7 +686,7 @@
 		err = path_lookup(sunname->sun_path, LOOKUP_FOLLOW, &nd);
 		if (err)
 			goto fail;
-		err = vfs_permission(&nd, MAY_WRITE);
+		err = vfs_permission(&nd, MAY_WRITE, NULL);
 		if (err)
 			goto put_fail;
 
only in patch2:
unchanged:
--- ./arch/mips/kernel/irixelf.c.ve18	2006-03-20 18:38:40.000000000 +0300
+++ ./arch/mips/kernel/irixelf.c	2006-03-20 18:42:06.000000000 +0300
@@ -432,7 +432,7 @@ static inline int look_for_irix_interpre
 		if (retval < 0)
 			goto out;
 
-		file = open_exec(*name);
+		file = open_exec(*name, bprm);
 		if (IS_ERR(file)) {
 			retval = PTR_ERR(file);
 			goto out;
only in patch2:
unchanged:
--- ./fs/binfmt_elf_fdpic.c.ve18	2006-03-20 18:38:40.000000000 +0300
+++ ./fs/binfmt_elf_fdpic.c	2006-03-20 18:42:06.000000000 +0300
@@ -205,7 +205,7 @@ static int load_elf_fdpic_binary(struct 
 			kdebug("Using ELF interpreter %s", interpreter_name);
 
 			/* replace the program with the interpreter */
-			interpreter = open_exec(interpreter_name);
+			interpreter = open_exec(interpreter_name, bprm);
 			retval = PTR_ERR(interpreter);
 			if (IS_ERR(interpreter)) {
 				interpreter = NULL;
only in patch2:
unchanged:
--- ./fs/binfmt_em86.c.ve18	2006-03-20 18:38:40.000000000 +0300
+++ ./fs/binfmt_em86.c	2006-03-20 18:42:06.000000000 +0300
@@ -82,7 +82,7 @@ static int load_em86(struct linux_binprm
 	 * Note that we use open_exec() as the name is now in kernel
 	 * space, and we don't need to copy it.
 	 */
-	file = open_exec(interp);
+	file = open_exec(interp, bprm);
 	if (IS_ERR(file))
 		return PTR_ERR(file);
 
only in patch2:
unchanged:
--- ./fs/binfmt_flat.c.ve18	2006-03-20 18:38:40.000000000 +0300
+++ ./fs/binfmt_flat.c	2006-03-20 18:42:06.000000000 +0300
@@ -774,7 +774,7 @@ static int load_flat_shared_library(int 
 
 	/* Open the file up */
 	bprm.filename = buf;
-	bprm.file = open_exec(bprm.filename);
+	bprm.file = open_exec(bprm.filename, bprm);
 	res = PTR_ERR(bprm.file);
 	if (IS_ERR(bprm.file))
 		return res;
only in patch2:
unchanged:
--- ./fs/binfmt_misc.c.ve18	2006-03-20 18:38:40.000000000 +0300
+++ ./fs/binfmt_misc.c	2006-03-20 18:42:06.000000000 +0300
@@ -179,7 +179,7 @@ static int load_misc_binary(struct linux
 
 	bprm->interp = iname;	/* for binfmt_script */
 
-	interp_file = open_exec (iname);
+	interp_file = open_exec (iname, bprm);
 	retval = PTR_ERR (interp_file);
 	if (IS_ERR (interp_file))
 		goto _error;
only in patch2:
unchanged:
--- ./fs/binfmt_script.c.ve18	2006-03-20 18:38:40.000000000 +0300
+++ ./fs/binfmt_script.c	2006-03-20 18:42:06.000000000 +0300
@@ -85,7 +85,7 @@ static int load_script(struct linux_binp
 	/*
 	 * OK, now restart the process with the interpreter's dentry.
 	 */
-	file = open_exec(interp);
+	file = open_exec(interp, bprm);
 	if (IS_ERR(file))
 		return PTR_ERR(file);
 
only in patch2:
unchanged:
--- ./fs/cifs/cifsfs.c.ve18	2006-03-20 18:38:40.000000000 +0300
+++ ./fs/cifs/cifsfs.c	2006-03-20 18:42:06.000000000 +0300
@@ -220,7 +220,8 @@ cifs_statfs(struct super_block *sb, stru
 				   longer available? */
 }
 
-static int cifs_permission(struct inode * inode, int mask, struct nameidata *nd)
+static int cifs_permission(struct inode * inode, int mask, struct nameidata *nd,
+		struct exec_perm *perm)
 {
 	struct cifs_sb_info *cifs_sb;
 
@@ -232,7 +233,7 @@ static int cifs_permission(struct inode 
 		on the client (above and beyond ACL on servers) for  
 		servers which do not support setting and viewing mode bits,
 		so allowing client to check permissions is useful */ 
-		return generic_permission(inode, mask, NULL);
+		return generic_permission(inode, mask, NULL, perm);
 }
 
 static kmem_cache_t *cifs_inode_cachep;
only in patch2:
unchanged:
--- ./fs/coda/dir.c.ve18	2006-03-20 18:38:40.000000000 +0300
+++ ./fs/coda/dir.c	2006-03-20 18:42:06.000000000 +0300
@@ -151,7 +151,8 @@ exit:
 }
 
 
-int coda_permission(struct inode *inode, int mask, struct nameidata *nd)
+int coda_permission(struct inode *inode, int mask, struct nameidata *nd,
+		struct exec_perm *perm)
 {
         int error = 0;
  
only in patch2:
unchanged:
--- ./fs/coda/pioctl.c.ve18	2006-03-20 18:38:40.000000000 +0300
+++ ./fs/coda/pioctl.c	2006-03-20 18:42:06.000000000 +0300
@@ -25,7 +25,7 @@
 
 /* pioctl ops */
 static int coda_ioctl_permission(struct inode *inode, int mask,
-				 struct nameidata *nd);
+				 struct nameidata *nd, struct exec_perm *perm);
 static int coda_pioctl(struct inode * inode, struct file * filp, 
                        unsigned int cmd, unsigned long user_data);
 
@@ -43,7 +43,7 @@ struct file_operations coda_ioctl_operat
 
 /* the coda pioctl inode ops */
 static int coda_ioctl_permission(struct inode *inode, int mask,
-				 struct nameidata *nd)
+				 struct nameidata *nd, struct exec_perm *perm)
 {
         return 0;
 }
only in patch2:
unchanged:
--- ./fs/compat.c.ve18	2006-03-20 18:38:40.000000000 +0300
+++ ./fs/compat.c	2006-03-20 18:42:06.000000000 +0300
@@ -1479,7 +1479,7 @@ int compat_do_execve(char * filename,
 		goto out_ret;
 	memset(bprm, 0, sizeof(*bprm));
 
-	file = open_exec(filename);
+	file = open_exec(filename, bprm);
 	retval = PTR_ERR(file);
 	if (IS_ERR(file))
 		goto out_kfree;
only in patch2:
unchanged:
--- ./fs/ext2/acl.c.ve18	2006-03-20 18:38:40.000000000 +0300
+++ ./fs/ext2/acl.c	2006-03-20 18:42:06.000000000 +0300
@@ -294,9 +294,10 @@ ext2_check_acl(struct inode *inode, int 
 }
 
 int
-ext2_permission(struct inode *inode, int mask, struct nameidata *nd)
+ext2_permission(struct inode *inode, int mask, struct nameidata *nd,
+		struct exec_perm *perm)
 {
-	return generic_permission(inode, mask, ext2_check_acl);
+	return generic_permission(inode, mask, ext2_check_acl, perm);
 }
 
 /*
only in patch2:
unchanged:
--- ./fs/ext2/acl.h.ve18	2006-03-20 18:38:40.000000000 +0300
+++ ./fs/ext2/acl.h	2006-03-20 18:42:06.000000000 +0300
@@ -58,7 +58,8 @@ static inline int ext2_acl_count(size_t 
 #define EXT2_ACL_NOT_CACHED ((void *)-1)
 
 /* acl.c */
-extern int ext2_permission (struct inode *, int, struct nameidata *);
+extern int ext2_permission (struct inode *, int, struct nameidata *,
+		struct exec_perm *);
 extern int ext2_acl_chmod (struct inode *);
 extern int ext2_init_acl (struct inode *, struct inode *);
 
only in patch2:
unchanged:
--- ./fs/ext3/acl.c.ve18	2006-03-20 18:38:40.000000000 +0300
+++ ./fs/ext3/acl.c	2006-03-20 18:42:06.000000000 +0300
@@ -299,9 +299,10 @@ ext3_check_acl(struct inode *inode, int 
 }
 
 int
-ext3_permission(struct inode *inode, int mask, struct nameidata *nd)
+ext3_permission(struct inode *inode, int mask, struct nameidata *nd,
+		struct exec_perm *perm)
 {
-	return generic_permission(inode, mask, ext3_check_acl);
+	return generic_permission(inode, mask, ext3_check_acl, perm);
 }
 
 /*
only in patch2:
unchanged:
--- ./fs/ext3/acl.h.ve18	2006-03-20 18:38:40.000000000 +0300
+++ ./fs/ext3/acl.h	2006-03-20 18:42:06.000000000 +0300
@@ -58,7 +58,8 @@ static inline int ext3_acl_count(size_t 
 #define EXT3_ACL_NOT_CACHED ((void *)-1)
 
 /* acl.c */
-extern int ext3_permission (struct inode *, int, struct nameidata *);
+extern int ext3_permission (struct inode *, int, struct nameidata *,
+		struct exec_perm *);
 extern int ext3_acl_chmod (struct inode *);
 extern int ext3_init_acl (handle_t *, struct inode *, struct inode *);
 
only in patch2:
unchanged:
--- ./fs/fuse/dir.c.ve18	2006-03-20 18:38:40.000000000 +0300
+++ ./fs/fuse/dir.c	2006-03-20 18:42:06.000000000 +0300
@@ -708,14 +708,15 @@ static int fuse_access(struct inode *ino
  * access request is sent.  Execute permission is still checked
  * locally based on file mode.
  */
-static int fuse_permission(struct inode *inode, int mask, struct nameidata *nd)
+static int fuse_permission(struct inode *inode, int mask, struct nameidata *nd,
+		struct exec_perm *perm)
 {
 	struct fuse_conn *fc = get_fuse_conn(inode);
 
 	if (!fuse_allow_task(fc, current))
 		return -EACCES;
 	else if (fc->flags & FUSE_DEFAULT_PERMISSIONS) {
-		int err = generic_permission(inode, mask, NULL);
+		int err = generic_permission(inode, mask, NULL, perm);
 
 		/* If permission is denied, try to refresh file
 		   attributes.  This is also needed, because the root
@@ -723,7 +724,7 @@ static int fuse_permission(struct inode 
 		if (err == -EACCES) {
 		 	err = fuse_do_getattr(inode);
 			if (!err)
-				err = generic_permission(inode, mask, NULL);
+				err = generic_permission(inode, mask, NULL, perm);
 		}
 
 		/* Note: the opposite of the above test does not
only in patch2:
unchanged:
--- ./fs/hfs/inode.c.ve18	2006-03-20 18:38:40.000000000 +0300
+++ ./fs/hfs/inode.c	2006-03-20 18:42:06.000000000 +0300
@@ -520,11 +520,11 @@ void hfs_clear_inode(struct inode *inode
 }
 
 static int hfs_permission(struct inode *inode, int mask,
-			  struct nameidata *nd)
+			  struct nameidata *nd, struct exec_perm *perm)
 {
 	if (S_ISREG(inode->i_mode) && mask & MAY_EXEC)
 		return 0;
-	return generic_permission(inode, mask, NULL);
+	return generic_permission(inode, mask, NULL, perm);
 }
 
 static int hfs_file_open(struct inode *inode, struct file *file)
only in patch2:
unchanged:
--- ./fs/hfsplus/inode.c.ve18	2006-03-20 18:38:40.000000000 +0300
+++ ./fs/hfsplus/inode.c	2006-03-20 18:42:06.000000000 +0300
@@ -237,7 +237,8 @@ static void hfsplus_set_perms(struct ino
 	perms->dev = cpu_to_be32(HFSPLUS_I(inode).dev);
 }
 
-static int hfsplus_permission(struct inode *inode, int mask, struct nameidata *nd)
+static int hfsplus_permission(struct inode *inode, int mask, struct nameidata *nd,
+		struct exec_perm *perm)
 {
 	/* MAY_EXEC is also used for lookup, if no x bit is set allow lookup,
 	 * open_exec has the same test, so it's still not executable, if a x bit
@@ -245,7 +246,7 @@ static int hfsplus_permission(struct ino
 	 */
 	if (S_ISREG(inode->i_mode) && mask & MAY_EXEC && !(inode->i_mode & 0111))
 		return 0;
-	return generic_permission(inode, mask, NULL);
+	return generic_permission(inode, mask, NULL, perm);
 }
 
 
only in patch2:
unchanged:
--- ./fs/hostfs/hostfs_kern.c.ve18	2006-03-20 18:38:40.000000000 +0300
+++ ./fs/hostfs/hostfs_kern.c	2006-03-20 18:42:06.000000000 +0300
@@ -796,7 +796,8 @@ int hostfs_rename(struct inode *from_ino
 	return(err);
 }
 
-int hostfs_permission(struct inode *ino, int desired, struct nameidata *nd)
+int hostfs_permission(struct inode *ino, int desired, struct nameidata *nd,
+		struct exec_perm *perm)
 {
 	char *name;
 	int r = 0, w = 0, x = 0, err;
@@ -814,7 +815,7 @@ int hostfs_permission(struct inode *ino,
 		err = access_file(name, r, w, x);
 	kfree(name);
 	if(!err)
-		err = generic_permission(ino, desired, NULL);
+		err = generic_permission(ino, desired, NULL, perm);
 	return err;
 }
 
only in patch2:
unchanged:
--- ./fs/hpfs/namei.c.ve18	2006-03-20 18:38:40.000000000 +0300
+++ ./fs/hpfs/namei.c	2006-03-20 18:42:06.000000000 +0300
@@ -415,7 +415,7 @@ again:
 		d_drop(dentry);
 		spin_lock(&dentry->d_lock);
 		if (atomic_read(&dentry->d_count) > 1 ||
-		    permission(inode, MAY_WRITE, NULL) ||
+		    permission(inode, MAY_WRITE, NULL, NULL) ||
 		    !S_ISREG(inode->i_mode) ||
 		    get_write_access(inode)) {
 			spin_unlock(&dentry->d_lock);
only in patch2:
unchanged:
--- ./fs/inotify.c.ve18	2006-03-20 18:38:40.000000000 +0300
+++ ./fs/inotify.c	2006-03-20 18:42:06.000000000 +0300
@@ -374,7 +374,7 @@ static int find_inode(const char __user 
 	if (error)
 		return error;
 	/* you can only watch an inode if you have read permissions on it */
-	error = vfs_permission(nd, MAY_READ);
+	error = vfs_permission(nd, MAY_READ, NULL);
 	if (error) 
 		path_release(nd);
 	return error;
only in patch2:
unchanged:
--- ./fs/jfs/acl.c.ve18	2006-03-20 18:38:40.000000000 +0300
+++ ./fs/jfs/acl.c	2006-03-20 18:42:06.000000000 +0300
@@ -140,9 +140,10 @@ static int jfs_check_acl(struct inode *i
 	return -EAGAIN;
 }
 
-int jfs_permission(struct inode *inode, int mask, struct nameidata *nd)
+int jfs_permission(struct inode *inode, int mask, struct nameidata *nd,
+		struct exec_perm *perm)
 {
-	return generic_permission(inode, mask, jfs_check_acl);
+	return generic_permission(inode, mask, jfs_check_acl, perm);
 }
 
 int jfs_init_acl(tid_t tid, struct inode *inode, struct inode *dir)
only in patch2:
unchanged:
--- ./fs/jfs/jfs_acl.h.ve18	2006-03-20 18:38:40.000000000 +0300
+++ ./fs/jfs/jfs_acl.h	2006-03-20 18:42:06.000000000 +0300
@@ -20,7 +20,7 @@
 
 #ifdef CONFIG_JFS_POSIX_ACL
 
-int jfs_permission(struct inode *, int, struct nameidata *);
+int jfs_permission(struct inode *, int, struct nameidata *, struct exec_perm *);
 int jfs_init_acl(tid_t, struct inode *, struct inode *);
 int jfs_setattr(struct dentry *, struct iattr *);
 
only in patch2:
unchanged:
--- ./fs/nfs/dir.c.ve18	2006-03-20 18:38:40.000000000 +0300
+++ ./fs/nfs/dir.c	2006-03-20 18:42:06.000000000 +0300
@@ -1635,7 +1635,8 @@ out:
 	return -EACCES;
 }
 
-int nfs_permission(struct inode *inode, int mask, struct nameidata *nd)
+int nfs_permission(struct inode *inode, int mask, struct nameidata *nd,
+		struct exec_perm *perm)
 {
 	struct rpc_cred *cred;
 	int res = 0;
@@ -1683,7 +1684,7 @@ out:
 out_notsup:
 	res = nfs_revalidate_inode(NFS_SERVER(inode), inode);
 	if (res == 0)
-		res = generic_permission(inode, mask, NULL);
+		res = generic_permission(inode, mask, NULL, perm);
 	unlock_kernel();
 	return res;
 }
only in patch2:
unchanged:
--- ./fs/nfsd/nfsfh.c.ve18	2006-03-20 18:38:40.000000000 +0300
+++ ./fs/nfsd/nfsfh.c	2006-03-20 18:42:06.000000000 +0300
@@ -56,7 +56,7 @@ static int nfsd_acceptable(void *expv, s
 		/* make sure parents give x permission to user */
 		int err;
 		parent = dget_parent(tdentry);
-		err = permission(parent->d_inode, MAY_EXEC, NULL);
+		err = permission(parent->d_inode, MAY_EXEC, NULL, NULL);
 		if (err < 0) {
 			dput(parent);
 			break;
only in patch2:
unchanged:
--- ./fs/nfsd/vfs.c.ve18	2006-03-20 18:38:40.000000000 +0300
+++ ./fs/nfsd/vfs.c	2006-03-20 18:42:06.000000000 +0300
@@ -1817,12 +1817,13 @@ nfsd_permission(struct svc_export *exp, 
 	    inode->i_uid == current->fsuid)
 		return 0;
 
-	err = permission(inode, acc & (MAY_READ|MAY_WRITE|MAY_EXEC), NULL);
+	err = permission(inode, acc & (MAY_READ|MAY_WRITE|MAY_EXEC),
+			NULL, NULL);
 
 	/* Allow read access to binaries even when mode 111 */
 	if (err == -EACCES && S_ISREG(inode->i_mode) &&
 	    acc == (MAY_READ | MAY_OWNER_OVERRIDE))
-		err = permission(inode, MAY_EXEC, NULL);
+		err = permission(inode, MAY_EXEC, NULL, NULL);
 
 	return err? nfserrno(err) : 0;
 }
only in patch2:
unchanged:
--- ./fs/proc/kmsg.c.ve77	2006-03-20 18:38:41.000000000 +0300
+++ ./fs/proc/kmsg.c	2006-03-20 18:42:07.000000000 +0300
@@ -11,6 +11,7 @@
 #include <linux/kernel.h>
 #include <linux/poll.h>
 #include <linux/fs.h>
+#include <linux/veprintk.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
@@ -40,7 +41,7 @@ static ssize_t kmsg_read(struct file *fi
 
 static unsigned int kmsg_poll(struct file *file, poll_table *wait)
 {
-	poll_wait(file, &log_wait, wait);
+	poll_wait(file, &ve_log_wait, wait);
 	if (do_syslog(9, NULL, 0))
 		return POLLIN | POLLRDNORM;
 	return 0;
only in patch2:
unchanged:
--- ./fs/reiserfs/xattr.c.ve18	2006-03-20 18:38:41.000000000 +0300
+++ ./fs/reiserfs/xattr.c	2006-03-20 18:42:06.000000000 +0300
@@ -1343,7 +1343,8 @@ static int reiserfs_check_acl(struct ino
 	return error;
 }
 
-int reiserfs_permission(struct inode *inode, int mask, struct nameidata *nd)
+int reiserfs_permission(struct inode *inode, int mask, struct nameidata *nd,
+		struct exec_perm *perm)
 {
 	/*
 	 * We don't do permission checks on the internal objects.
@@ -1356,7 +1357,7 @@ int reiserfs_permission(struct inode *in
 	 * Stat data v1 doesn't support ACLs.
 	 */
 	if (get_inode_sd_version(inode) == STAT_DATA_V1)
-		return generic_permission(inode, mask, NULL);
+		return generic_permission(inode, mask, NULL, perm);
 	else
-		return generic_permission(inode, mask, reiserfs_check_acl);
+		return generic_permission(inode, mask, reiserfs_check_acl, perm);
 }
only in patch2:
unchanged:
--- ./fs/smbfs/file.c.ve18	2006-03-20 18:38:41.000000000 +0300
+++ ./fs/smbfs/file.c	2006-03-20 18:42:06.000000000 +0300
@@ -387,7 +387,8 @@ smb_file_release(struct inode *inode, st
  * privileges, so we need our own check for this.
  */
 static int
-smb_file_permission(struct inode *inode, int mask, struct nameidata *nd)
+smb_file_permission(struct inode *inode, int mask, struct nameidata *nd,
+		struct exec_perm *perm)
 {
 	int mode = inode->i_mode;
 	int error = 0;
only in patch2:
unchanged:
--- ./fs/xattr.c.ve18	2006-03-20 18:38:41.000000000 +0300
+++ ./fs/xattr.c	2006-03-20 18:42:06.000000000 +0300
@@ -58,7 +58,7 @@ xattr_permission(struct inode *inode, co
 			return -EPERM;
 	}
 
-	return permission(inode, mask, NULL);
+	return permission(inode, mask, NULL, NULL);
 }
 
 int
only in patch2:
unchanged:
--- ./fs/xfs/linux-2.6/xfs_iops.c.ve18	2006-03-20 18:38:41.000000000 +0300
+++ ./fs/xfs/linux-2.6/xfs_iops.c	2006-03-20 18:42:06.000000000 +0300
@@ -615,7 +615,8 @@ STATIC int
 linvfs_permission(
 	struct inode	*inode,
 	int		mode,
-	struct nameidata *nd)
+	struct nameidata *nd,
+	struct exec_perm *perm)
 {
 	vnode_t		*vp = LINVFS_GET_VP(inode);
 	int		error;
only in patch2:
unchanged:
--- ./include/linux/binfmts.h.ve18	2006-03-20 18:38:41.000000000 +0300
+++ ./include/linux/binfmts.h	2006-03-20 18:42:06.000000000 +0300
@@ -2,6 +2,7 @@
 #define _LINUX_BINFMTS_H
 
 #include <linux/capability.h>
+#include <linux/fs.h>
 
 struct pt_regs;
 
@@ -28,6 +29,7 @@ struct linux_binprm{
 	int sh_bang;
 	struct file * file;
 	int e_uid, e_gid;
+	struct exec_perm perm;
 	kernel_cap_t cap_inheritable, cap_permitted, cap_effective;
 	void *security;
 	int argc, envc;
only in patch2:
unchanged:
--- ./include/linux/coda_linux.h.ve18	2006-03-20 18:38:41.000000000 +0300
+++ ./include/linux/coda_linux.h	2006-03-20 18:42:06.000000000 +0300
@@ -38,7 +38,8 @@ extern struct file_operations coda_ioctl
 int coda_open(struct inode *i, struct file *f);
 int coda_flush(struct file *f);
 int coda_release(struct inode *i, struct file *f);
-int coda_permission(struct inode *inode, int mask, struct nameidata *nd);
+int coda_permission(struct inode *inode, int mask, struct nameidata *nd,
+		struct exec_perm *);
 int coda_revalidate_inode(struct dentry *);
 int coda_getattr(struct vfsmount *, struct dentry *, struct kstat *);
 int coda_setattr(struct dentry *, struct iattr *);
only in patch2:
unchanged:
--- ./include/linux/nfs_fs.h.ve18	2006-03-20 18:38:41.000000000 +0300
+++ ./include/linux/nfs_fs.h	2006-03-20 18:42:06.000000000 +0300
@@ -296,7 +296,7 @@ extern struct inode *nfs_fhget(struct su
 extern int nfs_refresh_inode(struct inode *, struct nfs_fattr *);
 extern int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr);
 extern int nfs_getattr(struct vfsmount *, struct dentry *, struct kstat *);
-extern int nfs_permission(struct inode *, int, struct nameidata *);
+extern int nfs_permission(struct inode *, int, struct nameidata *, struct exec_perm *);
 extern int nfs_access_get_cached(struct inode *, struct rpc_cred *, struct nfs_access_entry *);
 extern void nfs_access_add_cache(struct inode *, struct nfs_access_entry *);
 extern int nfs_open(struct inode *, struct file *);
only in patch2:
unchanged:
--- ./include/linux/reiserfs_xattr.h.ve18	2006-03-20 18:38:41.000000000 +0300
+++ ./include/linux/reiserfs_xattr.h	2006-03-20 18:42:06.000000000 +0300
@@ -42,7 +42,8 @@ int reiserfs_removexattr(struct dentry *
 int reiserfs_delete_xattrs(struct inode *inode);
 int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs);
 int reiserfs_xattr_init(struct super_block *sb, int mount_flags);
-int reiserfs_permission(struct inode *inode, int mask, struct nameidata *nd);
+int reiserfs_permission(struct inode *inode, int mask, struct nameidata *nd,
+		struct exec_perm *);
 
 int reiserfs_xattr_del(struct inode *, const char *);
 int reiserfs_xattr_get(const struct inode *, const char *, void *, size_t);
only in patch2:
unchanged:
--- ./include/linux/veprintk.h.ve77	2006-03-20 18:42:07.000000000 +0300
+++ ./include/linux/veprintk.h	2006-03-20 18:42:07.000000000 +0300
@@ -0,0 +1,38 @@
+/*
+ *  include/linux/veprintk.h
+ *
+ *  Copyright (C) 2006  SWsoft
+ *  All rights reserved.
+ *  
+ *  Licensing governed by "linux/COPYING.SWsoft" file.
+ *
+ */
+
+#ifndef __VE_PRINTK_H__
+#define __VE_PRINTK_H__
+
+#ifdef CONFIG_VE
+
+#define ve_log_wait		(*(get_exec_env()->_log_wait))
+#define ve_log_start		(*(get_exec_env()->_log_start))
+#define ve_log_end		(*(get_exec_env()->_log_end))
+#define ve_logged_chars		(*(get_exec_env()->_logged_chars))
+#define ve_log_buf		(get_exec_env()->log_buf)
+#define ve_log_buf_len		(ve_is_super(get_exec_env()) ? \
+				log_buf_len : VE_DEFAULT_LOG_BUF_LEN)
+#define VE_LOG_BUF_MASK		(ve_log_buf_len - 1)
+#define VE_LOG_BUF(idx)		(ve_log_buf[(idx) & VE_LOG_BUF_MASK])
+
+#else
+
+#define ve_log_wait		log_wait
+#define ve_log_start		log_start
+#define ve_log_end		log_end
+#define ve_logged_chars		logged_chars
+#define ve_log_buf		log_buf
+#define ve_log_buf_len		log_buf_len
+#define VE_LOG_BUF_MASK		LOG_BUF_MASK
+#define VE_LOG_BUF(idx)		LOG_BUF(idx)
+
+#endif /* CONFIG_VE */
+#endif /* __VE_PRINTK_H__ */
only in patch2:
unchanged:
--- ./ipc/mqueue.c.ve18	2006-03-20 18:38:42.000000000 +0300
+++ ./ipc/mqueue.c	2006-03-20 18:42:06.000000000 +0300
@@ -639,7 +639,8 @@ static int oflag2acc[O_ACCMODE] = { MAY_
 		return ERR_PTR(-EINVAL);
 	}
 
-	if (permission(dentry->d_inode, oflag2acc[oflag & O_ACCMODE], NULL)) {
+	if (permission(dentry->d_inode, oflag2acc[oflag & O_ACCMODE],
+			       NULL, NULL)) {
 		dput(dentry);
 		mntput(mqueue_mnt);
 		return ERR_PTR(-EACCES);
only in patch2:
unchanged:
--- ./kernel/audit.c.ve71	2006-03-20 18:38:42.000000000 +0300
+++ ./kernel/audit.c	2006-03-20 18:42:07.000000000 +0300
@@ -372,6 +372,9 @@ static int audit_receive_msg(struct sk_b
 	uid_t			loginuid; /* loginuid of sender */
 	struct audit_sig_info   sig_data;
 
+	if (!ve_is_super(VE_OWNER_SKB(skb)))
+		return -ECONNREFUSED;
+
 	err = audit_netlink_ok(NETLINK_CB(skb).eff_cap, msg_type);
 	if (err)
 		return err;
only in patch2:
unchanged:
--- ./net/ipv4/netfilter/ipt_REDIRECT.c.ve97	2006-03-20 18:38:42.000000000 +0300
+++ ./net/ipv4/netfilter/ipt_REDIRECT.c	2006-03-20 18:42:07.000000000 +0300
@@ -17,6 +17,7 @@
 #include <linux/inetdevice.h>
 #include <net/protocol.h>
 #include <net/checksum.h>
+#include <linux/nfcalls.h>
 #include <linux/netfilter_ipv4.h>
 #include <linux/netfilter_ipv4/ip_nat_rule.h>
 
@@ -25,7 +26,7 @@ MODULE_AUTHOR("Netfilter Core Team <core
 MODULE_DESCRIPTION("iptables REDIRECT target module");
 
 #if 0
-#define DEBUGP printk
+#define DEBUGP ve_printk
 #else
 #define DEBUGP(format, args...)
 #endif
@@ -119,15 +120,37 @@ static struct ipt_target redirect_reg = 
 	.me		= THIS_MODULE,
 };
 
-static int __init init(void)
+int init_iptable_REDIRECT(void)
 {
 	return ipt_register_target(&redirect_reg);
 }
 
-static void __exit fini(void)
+void fini_iptable_REDIRECT(void)
 {
 	ipt_unregister_target(&redirect_reg);
 }
 
+static int __init init(void)
+{
+	int err;
+
+	err = init_iptable_REDIRECT();
+	if (err < 0)
+		return err;
+
+	KSYMRESOLVE(init_iptable_REDIRECT);
+	KSYMRESOLVE(fini_iptable_REDIRECT);
+	KSYMMODRESOLVE(ipt_REDIRECT);
+	return 0;
+}
+
+static void __exit fini(void)
+{
+	KSYMMODUNRESOLVE(ipt_REDIRECT);
+	KSYMUNRESOLVE(init_iptable_REDIRECT);
+	KSYMUNRESOLVE(fini_iptable_REDIRECT);
+	fini_iptable_REDIRECT();
+}
+
 module_init(init);
 module_exit(fini);
