diff options
Diffstat (limited to 'fs/coda')
-rw-r--r-- | fs/coda/cache.c | 4 | ||||
-rw-r--r-- | fs/coda/coda_fs_i.h | 2 | ||||
-rw-r--r-- | fs/coda/coda_linux.c | 8 | ||||
-rw-r--r-- | fs/coda/inode.c | 6 | ||||
-rw-r--r-- | fs/coda/psdev.c | 7 | ||||
-rw-r--r-- | fs/coda/upcall.c | 10 |
6 files changed, 24 insertions, 13 deletions
diff --git a/fs/coda/cache.c b/fs/coda/cache.c index 958ae0e0ff8c..1da168c61d35 100644 --- a/fs/coda/cache.c +++ b/fs/coda/cache.c | |||
@@ -33,7 +33,7 @@ void coda_cache_enter(struct inode *inode, int mask) | |||
33 | 33 | ||
34 | spin_lock(&cii->c_lock); | 34 | spin_lock(&cii->c_lock); |
35 | cii->c_cached_epoch = atomic_read(&permission_epoch); | 35 | cii->c_cached_epoch = atomic_read(&permission_epoch); |
36 | if (cii->c_uid != current_fsuid()) { | 36 | if (!uid_eq(cii->c_uid, current_fsuid())) { |
37 | cii->c_uid = current_fsuid(); | 37 | cii->c_uid = current_fsuid(); |
38 | cii->c_cached_perm = mask; | 38 | cii->c_cached_perm = mask; |
39 | } else | 39 | } else |
@@ -65,7 +65,7 @@ int coda_cache_check(struct inode *inode, int mask) | |||
65 | 65 | ||
66 | spin_lock(&cii->c_lock); | 66 | spin_lock(&cii->c_lock); |
67 | hit = (mask & cii->c_cached_perm) == mask && | 67 | hit = (mask & cii->c_cached_perm) == mask && |
68 | cii->c_uid == current_fsuid() && | 68 | uid_eq(cii->c_uid, current_fsuid()) && |
69 | cii->c_cached_epoch == atomic_read(&permission_epoch); | 69 | cii->c_cached_epoch == atomic_read(&permission_epoch); |
70 | spin_unlock(&cii->c_lock); | 70 | spin_unlock(&cii->c_lock); |
71 | 71 | ||
diff --git a/fs/coda/coda_fs_i.h b/fs/coda/coda_fs_i.h index b24fdfd8a3f0..c64075213218 100644 --- a/fs/coda/coda_fs_i.h +++ b/fs/coda/coda_fs_i.h | |||
@@ -25,7 +25,7 @@ struct coda_inode_info { | |||
25 | u_short c_flags; /* flags (see below) */ | 25 | u_short c_flags; /* flags (see below) */ |
26 | unsigned int c_mapcount; /* nr of times this inode is mapped */ | 26 | unsigned int c_mapcount; /* nr of times this inode is mapped */ |
27 | unsigned int c_cached_epoch; /* epoch for cached permissions */ | 27 | unsigned int c_cached_epoch; /* epoch for cached permissions */ |
28 | vuid_t c_uid; /* fsuid for cached permissions */ | 28 | kuid_t c_uid; /* fsuid for cached permissions */ |
29 | unsigned int c_cached_perm; /* cached access permissions */ | 29 | unsigned int c_cached_perm; /* cached access permissions */ |
30 | spinlock_t c_lock; | 30 | spinlock_t c_lock; |
31 | struct inode vfs_inode; | 31 | struct inode vfs_inode; |
diff --git a/fs/coda/coda_linux.c b/fs/coda/coda_linux.c index 854ace712685..2849f41e72a2 100644 --- a/fs/coda/coda_linux.c +++ b/fs/coda/coda_linux.c | |||
@@ -100,9 +100,9 @@ void coda_vattr_to_iattr(struct inode *inode, struct coda_vattr *attr) | |||
100 | if (attr->va_mode != (u_short) -1) | 100 | if (attr->va_mode != (u_short) -1) |
101 | inode->i_mode = attr->va_mode | inode_type; | 101 | inode->i_mode = attr->va_mode | inode_type; |
102 | if (attr->va_uid != -1) | 102 | if (attr->va_uid != -1) |
103 | inode->i_uid = (uid_t) attr->va_uid; | 103 | inode->i_uid = make_kuid(&init_user_ns, (uid_t) attr->va_uid); |
104 | if (attr->va_gid != -1) | 104 | if (attr->va_gid != -1) |
105 | inode->i_gid = (gid_t) attr->va_gid; | 105 | inode->i_gid = make_kgid(&init_user_ns, (gid_t) attr->va_gid); |
106 | if (attr->va_nlink != -1) | 106 | if (attr->va_nlink != -1) |
107 | set_nlink(inode, attr->va_nlink); | 107 | set_nlink(inode, attr->va_nlink); |
108 | if (attr->va_size != -1) | 108 | if (attr->va_size != -1) |
@@ -171,10 +171,10 @@ void coda_iattr_to_vattr(struct iattr *iattr, struct coda_vattr *vattr) | |||
171 | vattr->va_mode = iattr->ia_mode; | 171 | vattr->va_mode = iattr->ia_mode; |
172 | } | 172 | } |
173 | if ( valid & ATTR_UID ) { | 173 | if ( valid & ATTR_UID ) { |
174 | vattr->va_uid = (vuid_t) iattr->ia_uid; | 174 | vattr->va_uid = (vuid_t) from_kuid(&init_user_ns, iattr->ia_uid); |
175 | } | 175 | } |
176 | if ( valid & ATTR_GID ) { | 176 | if ( valid & ATTR_GID ) { |
177 | vattr->va_gid = (vgid_t) iattr->ia_gid; | 177 | vattr->va_gid = (vgid_t) from_kgid(&init_user_ns, iattr->ia_gid); |
178 | } | 178 | } |
179 | if ( valid & ATTR_SIZE ) { | 179 | if ( valid & ATTR_SIZE ) { |
180 | vattr->va_size = iattr->ia_size; | 180 | vattr->va_size = iattr->ia_size; |
diff --git a/fs/coda/inode.c b/fs/coda/inode.c index be2aa4909487..cf674e9179a3 100644 --- a/fs/coda/inode.c +++ b/fs/coda/inode.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/file.h> | 20 | #include <linux/file.h> |
21 | #include <linux/vfs.h> | 21 | #include <linux/vfs.h> |
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
23 | #include <linux/pid_namespace.h> | ||
23 | 24 | ||
24 | #include <asm/uaccess.h> | 25 | #include <asm/uaccess.h> |
25 | 26 | ||
@@ -48,7 +49,7 @@ static struct inode *coda_alloc_inode(struct super_block *sb) | |||
48 | return NULL; | 49 | return NULL; |
49 | memset(&ei->c_fid, 0, sizeof(struct CodaFid)); | 50 | memset(&ei->c_fid, 0, sizeof(struct CodaFid)); |
50 | ei->c_flags = 0; | 51 | ei->c_flags = 0; |
51 | ei->c_uid = 0; | 52 | ei->c_uid = GLOBAL_ROOT_UID; |
52 | ei->c_cached_perm = 0; | 53 | ei->c_cached_perm = 0; |
53 | spin_lock_init(&ei->c_lock); | 54 | spin_lock_init(&ei->c_lock); |
54 | return &ei->vfs_inode; | 55 | return &ei->vfs_inode; |
@@ -157,6 +158,9 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent) | |||
157 | int error; | 158 | int error; |
158 | int idx; | 159 | int idx; |
159 | 160 | ||
161 | if (task_active_pid_ns(current) != &init_pid_ns) | ||
162 | return -EINVAL; | ||
163 | |||
160 | idx = get_device_index((struct coda_mount_data *) data); | 164 | idx = get_device_index((struct coda_mount_data *) data); |
161 | 165 | ||
162 | /* Ignore errors in data, for backward compatibility */ | 166 | /* Ignore errors in data, for backward compatibility */ |
diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c index 761d5b31b18d..ebc2bae6c289 100644 --- a/fs/coda/psdev.c +++ b/fs/coda/psdev.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/list.h> | 37 | #include <linux/list.h> |
38 | #include <linux/mutex.h> | 38 | #include <linux/mutex.h> |
39 | #include <linux/device.h> | 39 | #include <linux/device.h> |
40 | #include <linux/pid_namespace.h> | ||
40 | #include <asm/io.h> | 41 | #include <asm/io.h> |
41 | #include <asm/poll.h> | 42 | #include <asm/poll.h> |
42 | #include <asm/uaccess.h> | 43 | #include <asm/uaccess.h> |
@@ -266,6 +267,12 @@ static int coda_psdev_open(struct inode * inode, struct file * file) | |||
266 | struct venus_comm *vcp; | 267 | struct venus_comm *vcp; |
267 | int idx, err; | 268 | int idx, err; |
268 | 269 | ||
270 | if (task_active_pid_ns(current) != &init_pid_ns) | ||
271 | return -EINVAL; | ||
272 | |||
273 | if (current_user_ns() != &init_user_ns) | ||
274 | return -EINVAL; | ||
275 | |||
269 | idx = iminor(inode); | 276 | idx = iminor(inode); |
270 | if (idx < 0 || idx >= MAX_CODADEVS) | 277 | if (idx < 0 || idx >= MAX_CODADEVS) |
271 | return -ENODEV; | 278 | return -ENODEV; |
diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c index 0c68fd31fbf2..3a731976dc5e 100644 --- a/fs/coda/upcall.c +++ b/fs/coda/upcall.c | |||
@@ -50,9 +50,9 @@ static void *alloc_upcall(int opcode, int size) | |||
50 | return ERR_PTR(-ENOMEM); | 50 | return ERR_PTR(-ENOMEM); |
51 | 51 | ||
52 | inp->ih.opcode = opcode; | 52 | inp->ih.opcode = opcode; |
53 | inp->ih.pid = current->pid; | 53 | inp->ih.pid = task_pid_nr_ns(current, &init_pid_ns); |
54 | inp->ih.pgid = task_pgrp_nr(current); | 54 | inp->ih.pgid = task_pgrp_nr_ns(current, &init_pid_ns); |
55 | inp->ih.uid = current_fsuid(); | 55 | inp->ih.uid = from_kuid(&init_user_ns, current_fsuid()); |
56 | 56 | ||
57 | return (void*)inp; | 57 | return (void*)inp; |
58 | } | 58 | } |
@@ -157,7 +157,7 @@ int venus_lookup(struct super_block *sb, struct CodaFid *fid, | |||
157 | } | 157 | } |
158 | 158 | ||
159 | int venus_close(struct super_block *sb, struct CodaFid *fid, int flags, | 159 | int venus_close(struct super_block *sb, struct CodaFid *fid, int flags, |
160 | vuid_t uid) | 160 | kuid_t uid) |
161 | { | 161 | { |
162 | union inputArgs *inp; | 162 | union inputArgs *inp; |
163 | union outputArgs *outp; | 163 | union outputArgs *outp; |
@@ -166,7 +166,7 @@ int venus_close(struct super_block *sb, struct CodaFid *fid, int flags, | |||
166 | insize = SIZE(release); | 166 | insize = SIZE(release); |
167 | UPARG(CODA_CLOSE); | 167 | UPARG(CODA_CLOSE); |
168 | 168 | ||
169 | inp->ih.uid = uid; | 169 | inp->ih.uid = from_kuid(&init_user_ns, uid); |
170 | inp->coda_close.VFid = *fid; | 170 | inp->coda_close.VFid = *fid; |
171 | inp->coda_close.flags = flags; | 171 | inp->coda_close.flags = flags; |
172 | 172 | ||