aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hpfs
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2012-02-07 19:27:53 -0500
committerEric W. Biederman <ebiederm@xmission.com>2012-09-21 06:13:32 -0400
commit0e1a43c71612cd0b6b50da03040c85fbf3d24211 (patch)
tree3287a4782caa59dbcb6e922835d056724759b9ff /fs/hpfs
parent2f2f43d3c7b1da8dba56716dd1be196b6f57bf9b (diff)
userns: Convert hpfs to use kuid and kgid where appropriate
Cc: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz> Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'fs/hpfs')
-rw-r--r--fs/hpfs/hpfs_fn.h4
-rw-r--r--fs/hpfs/inode.c19
-rw-r--r--fs/hpfs/namei.c8
-rw-r--r--fs/hpfs/super.c18
4 files changed, 28 insertions, 21 deletions
diff --git a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h
index ac1ead194db..7102aaecc24 100644
--- a/fs/hpfs/hpfs_fn.h
+++ b/fs/hpfs/hpfs_fn.h
@@ -63,8 +63,8 @@ struct hpfs_sb_info {
63 unsigned sb_dmap; /* sector number of dnode bit map */ 63 unsigned sb_dmap; /* sector number of dnode bit map */
64 unsigned sb_n_free; /* free blocks for statfs, or -1 */ 64 unsigned sb_n_free; /* free blocks for statfs, or -1 */
65 unsigned sb_n_free_dnodes; /* free dnodes for statfs, or -1 */ 65 unsigned sb_n_free_dnodes; /* free dnodes for statfs, or -1 */
66 uid_t sb_uid; /* uid from mount options */ 66 kuid_t sb_uid; /* uid from mount options */
67 gid_t sb_gid; /* gid from mount options */ 67 kgid_t sb_gid; /* gid from mount options */
68 umode_t sb_mode; /* mode from mount options */ 68 umode_t sb_mode; /* mode from mount options */
69 unsigned sb_eas : 2; /* eas: 0-ignore, 1-ro, 2-rw */ 69 unsigned sb_eas : 2; /* eas: 0-ignore, 1-ro, 2-rw */
70 unsigned sb_err : 2; /* on errs: 0-cont, 1-ro, 2-panic */ 70 unsigned sb_err : 2; /* on errs: 0-cont, 1-ro, 2-panic */
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c
index ed671e0ea78..804a9a842cb 100644
--- a/fs/hpfs/inode.c
+++ b/fs/hpfs/inode.c
@@ -7,6 +7,7 @@
7 */ 7 */
8 8
9#include <linux/slab.h> 9#include <linux/slab.h>
10#include <linux/user_namespace.h>
10#include "hpfs_fn.h" 11#include "hpfs_fn.h"
11 12
12void hpfs_init_inode(struct inode *i) 13void hpfs_init_inode(struct inode *i)
@@ -60,14 +61,14 @@ void hpfs_read_inode(struct inode *i)
60 if (hpfs_sb(i->i_sb)->sb_eas) { 61 if (hpfs_sb(i->i_sb)->sb_eas) {
61 if ((ea = hpfs_get_ea(i->i_sb, fnode, "UID", &ea_size))) { 62 if ((ea = hpfs_get_ea(i->i_sb, fnode, "UID", &ea_size))) {
62 if (ea_size == 2) { 63 if (ea_size == 2) {
63 i->i_uid = le16_to_cpu(*(__le16*)ea); 64 i_uid_write(i, le16_to_cpu(*(__le16*)ea));
64 hpfs_inode->i_ea_uid = 1; 65 hpfs_inode->i_ea_uid = 1;
65 } 66 }
66 kfree(ea); 67 kfree(ea);
67 } 68 }
68 if ((ea = hpfs_get_ea(i->i_sb, fnode, "GID", &ea_size))) { 69 if ((ea = hpfs_get_ea(i->i_sb, fnode, "GID", &ea_size))) {
69 if (ea_size == 2) { 70 if (ea_size == 2) {
70 i->i_gid = le16_to_cpu(*(__le16*)ea); 71 i_gid_write(i, le16_to_cpu(*(__le16*)ea));
71 hpfs_inode->i_ea_gid = 1; 72 hpfs_inode->i_ea_gid = 1;
72 } 73 }
73 kfree(ea); 74 kfree(ea);
@@ -149,13 +150,13 @@ static void hpfs_write_inode_ea(struct inode *i, struct fnode *fnode)
149 hpfs_error(i->i_sb, "fnode %08x has some unknown HPFS386 stuctures", i->i_ino); 150 hpfs_error(i->i_sb, "fnode %08x has some unknown HPFS386 stuctures", i->i_ino);
150 } else*/ if (hpfs_sb(i->i_sb)->sb_eas >= 2) { 151 } else*/ if (hpfs_sb(i->i_sb)->sb_eas >= 2) {
151 __le32 ea; 152 __le32 ea;
152 if ((i->i_uid != hpfs_sb(i->i_sb)->sb_uid) || hpfs_inode->i_ea_uid) { 153 if (!uid_eq(i->i_uid, hpfs_sb(i->i_sb)->sb_uid) || hpfs_inode->i_ea_uid) {
153 ea = cpu_to_le32(i->i_uid); 154 ea = cpu_to_le32(i_uid_read(i));
154 hpfs_set_ea(i, fnode, "UID", (char*)&ea, 2); 155 hpfs_set_ea(i, fnode, "UID", (char*)&ea, 2);
155 hpfs_inode->i_ea_uid = 1; 156 hpfs_inode->i_ea_uid = 1;
156 } 157 }
157 if ((i->i_gid != hpfs_sb(i->i_sb)->sb_gid) || hpfs_inode->i_ea_gid) { 158 if (!gid_eq(i->i_gid, hpfs_sb(i->i_sb)->sb_gid) || hpfs_inode->i_ea_gid) {
158 ea = cpu_to_le32(i->i_gid); 159 ea = cpu_to_le32(i_gid_read(i));
159 hpfs_set_ea(i, fnode, "GID", (char *)&ea, 2); 160 hpfs_set_ea(i, fnode, "GID", (char *)&ea, 2);
160 hpfs_inode->i_ea_gid = 1; 161 hpfs_inode->i_ea_gid = 1;
161 } 162 }
@@ -261,9 +262,11 @@ int hpfs_setattr(struct dentry *dentry, struct iattr *attr)
261 hpfs_lock(inode->i_sb); 262 hpfs_lock(inode->i_sb);
262 if (inode->i_ino == hpfs_sb(inode->i_sb)->sb_root) 263 if (inode->i_ino == hpfs_sb(inode->i_sb)->sb_root)
263 goto out_unlock; 264 goto out_unlock;
264 if ((attr->ia_valid & ATTR_UID) && attr->ia_uid >= 0x10000) 265 if ((attr->ia_valid & ATTR_UID) &&
266 from_kuid(&init_user_ns, attr->ia_uid) >= 0x10000)
265 goto out_unlock; 267 goto out_unlock;
266 if ((attr->ia_valid & ATTR_GID) && attr->ia_gid >= 0x10000) 268 if ((attr->ia_valid & ATTR_GID) &&
269 from_kgid(&init_user_ns, attr->ia_gid) >= 0x10000)
267 goto out_unlock; 270 goto out_unlock;
268 if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size) 271 if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size)
269 goto out_unlock; 272 goto out_unlock;
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index bc9082482f6..345713d2f8f 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -91,8 +91,8 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
91 inc_nlink(dir); 91 inc_nlink(dir);
92 insert_inode_hash(result); 92 insert_inode_hash(result);
93 93
94 if (result->i_uid != current_fsuid() || 94 if (!uid_eq(result->i_uid, current_fsuid()) ||
95 result->i_gid != current_fsgid() || 95 !gid_eq(result->i_gid, current_fsgid()) ||
96 result->i_mode != (mode | S_IFDIR)) { 96 result->i_mode != (mode | S_IFDIR)) {
97 result->i_uid = current_fsuid(); 97 result->i_uid = current_fsuid();
98 result->i_gid = current_fsgid(); 98 result->i_gid = current_fsgid();
@@ -179,8 +179,8 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, b
179 179
180 insert_inode_hash(result); 180 insert_inode_hash(result);
181 181
182 if (result->i_uid != current_fsuid() || 182 if (!uid_eq(result->i_uid, current_fsuid()) ||
183 result->i_gid != current_fsgid() || 183 !gid_eq(result->i_gid, current_fsgid()) ||
184 result->i_mode != (mode | S_IFREG)) { 184 result->i_mode != (mode | S_IFREG)) {
185 result->i_uid = current_fsuid(); 185 result->i_uid = current_fsuid();
186 result->i_gid = current_fsgid(); 186 result->i_gid = current_fsgid();
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
index 706a12c083e..a152783602d 100644
--- a/fs/hpfs/super.c
+++ b/fs/hpfs/super.c
@@ -251,7 +251,7 @@ static const match_table_t tokens = {
251 {Opt_err, NULL}, 251 {Opt_err, NULL},
252}; 252};
253 253
254static int parse_opts(char *opts, uid_t *uid, gid_t *gid, umode_t *umask, 254static int parse_opts(char *opts, kuid_t *uid, kgid_t *gid, umode_t *umask,
255 int *lowercase, int *eas, int *chk, int *errs, 255 int *lowercase, int *eas, int *chk, int *errs,
256 int *chkdsk, int *timeshift) 256 int *chkdsk, int *timeshift)
257{ 257{
@@ -276,12 +276,16 @@ static int parse_opts(char *opts, uid_t *uid, gid_t *gid, umode_t *umask,
276 case Opt_uid: 276 case Opt_uid:
277 if (match_int(args, &option)) 277 if (match_int(args, &option))
278 return 0; 278 return 0;
279 *uid = option; 279 *uid = make_kuid(current_user_ns(), option);
280 if (!uid_valid(*uid))
281 return 0;
280 break; 282 break;
281 case Opt_gid: 283 case Opt_gid:
282 if (match_int(args, &option)) 284 if (match_int(args, &option))
283 return 0; 285 return 0;
284 *gid = option; 286 *gid = make_kgid(current_user_ns(), option);
287 if (!gid_valid(*gid))
288 return 0;
285 break; 289 break;
286 case Opt_umask: 290 case Opt_umask:
287 if (match_octal(args, &option)) 291 if (match_octal(args, &option))
@@ -378,8 +382,8 @@ HPFS filesystem options:\n\
378 382
379static int hpfs_remount_fs(struct super_block *s, int *flags, char *data) 383static int hpfs_remount_fs(struct super_block *s, int *flags, char *data)
380{ 384{
381 uid_t uid; 385 kuid_t uid;
382 gid_t gid; 386 kgid_t gid;
383 umode_t umask; 387 umode_t umask;
384 int lowercase, eas, chk, errs, chkdsk, timeshift; 388 int lowercase, eas, chk, errs, chkdsk, timeshift;
385 int o; 389 int o;
@@ -455,8 +459,8 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
455 struct hpfs_sb_info *sbi; 459 struct hpfs_sb_info *sbi;
456 struct inode *root; 460 struct inode *root;
457 461
458 uid_t uid; 462 kuid_t uid;
459 gid_t gid; 463 kgid_t gid;
460 umode_t umask; 464 umode_t umask;
461 int lowercase, eas, chk, errs, chkdsk, timeshift; 465 int lowercase, eas, chk, errs, chkdsk, timeshift;
462 466