From 541ce2e21b2a729b46a95ed394ba759c4ce749b4 Mon Sep 17 00:00:00 2001 From: Mark Huang Date: Sun, 19 Dec 2004 04:27:18 +0000 Subject: [PATCH] put Proper patches back in since they are probably not the cause of the kernel crashes --- Makefile | 2 +- fs/ioctl.c | 13 +++++++++++++ fs/namei.c | 16 ---------------- include/linux/vserver/inode.h | 7 +++++++ kernel/vserver/inode.c | 31 +++++++++++++++++++++++++++++++ scripts/kernel-2.6-planetlab.spec | 2 +- 6 files changed, 53 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index f43c73662..4d94580e0 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ VERSION = 2 PATCHLEVEL = 6 SUBLEVEL = 8 -EXTRAVERSION = -1.521.2.4.planetlab +EXTRAVERSION = -1.521.2.5.planetlab NAME=Zonked Quokka # *DOCUMENTATION* diff --git a/fs/ioctl.c b/fs/ioctl.c index 96a1b601e..6404b0c10 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c @@ -173,6 +173,19 @@ asmlinkage long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) error = vx_proc_ioctl(filp->f_dentry->d_inode, filp, cmd, arg); break; #endif + case FIOC_SETIATTR: + case FIOC_GETIATTR: + /* + * Verify that this filp is a file object, + * not (say) a socket. + */ + error = -ENOTTY; + if (S_ISREG(filp->f_dentry->d_inode->i_mode) || + S_ISDIR(filp->f_dentry->d_inode->i_mode)) + error = vc_iattr_ioctl(filp->f_dentry, + cmd, arg); + break; + default: error = -ENOTTY; if (S_ISREG(filp->f_dentry->d_inode->i_mode)) diff --git a/fs/namei.c b/fs/namei.c index 4b3e1ca08..656430d6b 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -214,20 +214,6 @@ int vfs_permission(struct inode * inode, int mask) return -EACCES; } -static inline int xid_permission(struct inode *inode, int mask, struct nameidata *nd) -{ - if (inode->i_xid == 0) - return 0; - if (vx_check(inode->i_xid, VX_ADMIN|VX_WATCH|VX_IDENT)) - return 0; -/* - printk("VSW: xid=%d denied access to %p[#%d,%lu] »%*s«.\n", - vx_current_xid(), inode, inode->i_xid, inode->i_ino, - nd->dentry->d_name.len, nd->dentry->d_name.name); -*/ - return -EACCES; -} - int permission(struct inode * inode,int mask, struct nameidata *nd) { int retval; @@ -241,8 +227,6 @@ int permission(struct inode * inode,int mask, struct nameidata *nd) (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode))) return -EROFS; - if ((retval = xid_permission(inode, mask, nd))) - return retval; if (inode->i_op && inode->i_op->permission) retval = inode->i_op->permission(inode, submask, nd); else diff --git a/include/linux/vserver/inode.h b/include/linux/vserver/inode.h index fc49aba6d..e19632d08 100644 --- a/include/linux/vserver/inode.h +++ b/include/linux/vserver/inode.h @@ -57,6 +57,10 @@ extern int vc_set_iattr_v0(uint32_t, void __user *); extern int vc_get_iattr(uint32_t, void __user *); extern int vc_set_iattr(uint32_t, void __user *); +extern int vc_iattr_ioctl(struct dentry *de, + unsigned int cmd, + unsigned long arg); + #endif /* __KERNEL__ */ /* inode ioctls */ @@ -64,4 +68,7 @@ extern int vc_set_iattr(uint32_t, void __user *); #define FIOC_GETXFLG _IOR('x', 5, long) #define FIOC_SETXFLG _IOW('x', 6, long) +#define FIOC_GETIATTR _IOR('x', 7, long) +#define FIOC_SETIATTR _IOR('x', 8, long) + #endif /* _VX_INODE_H */ diff --git a/kernel/vserver/inode.c b/kernel/vserver/inode.c index dda881895..3e8120bd3 100644 --- a/kernel/vserver/inode.c +++ b/kernel/vserver/inode.c @@ -170,6 +170,37 @@ int vc_set_iattr(uint32_t id, void __user *data) return ret; } +int vc_iattr_ioctl(struct dentry *de, unsigned int cmd, unsigned long arg) +{ + void __user *data = (void __user *)arg; + struct vcmd_ctx_iattr_v1 vc_data; + int ret; + + /* + * I don't think we need any dget/dput pairs in here as long as + * this function is always called from sys_ioctl i.e., de is + * a field of a struct file that is guaranteed not to be freed. + */ + if (cmd == FIOC_SETIATTR) { + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_LINUX_IMMUTABLE)) + return -EPERM; + if (copy_from_user (&vc_data, data, sizeof(vc_data))) + return -EFAULT; + ret = __vc_set_iattr(de, + &vc_data.xid, &vc_data.flags, &vc_data.mask); + } + else { + if (!vx_check(0, VX_ADMIN)) + return -ENOSYS; + ret = __vc_get_iattr(de->d_inode, + &vc_data.xid, &vc_data.flags, &vc_data.mask); + } + + if (!ret && copy_to_user (data, &vc_data, sizeof(vc_data))) + ret = -EFAULT; + return ret; +} + #ifdef CONFIG_VSERVER_LEGACY #include diff --git a/scripts/kernel-2.6-planetlab.spec b/scripts/kernel-2.6-planetlab.spec index f961ec1a7..72d0603b7 100644 --- a/scripts/kernel-2.6-planetlab.spec +++ b/scripts/kernel-2.6-planetlab.spec @@ -22,7 +22,7 @@ Summary: The Linux kernel (the core of the Linux operating system) %define kversion 2.6.%{sublevel} %define rpmversion 2.6.%{sublevel} %define rhbsys %([ -r /etc/beehive-root ] && echo || echo .`whoami`) -%define release 1.521.2.4.planetlab%{?date:.%{date}} +%define release 1.521.2.5.planetlab%{?date:.%{date}} %define signmodules 0 %define KVERREL %{PACKAGE_VERSION}-%{PACKAGE_RELEASE} -- 2.47.0