aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2013-02-01 00:56:13 -0500
committerEric W. Biederman <ebiederm@xmission.com>2013-02-13 09:15:10 -0500
commit6b24c0d279eacfb499854d09ea7f2b69d1721a29 (patch)
tree190918f71eb5867fdf755455153fd1e933e8a75a /fs
parent7c06b5d67225dc99ca81a33db3e055e08da857c3 (diff)
gfs2: Use uid_eq and gid_eq where appropriate
Where kuid_t values are compared use uid_eq and where kgid_t values are compared use gid_eq. This is unfortunately necessary because of the type safety that keeps someone from accidentally mixing kuids and kgids with other types. Cc: Steven Whitehouse <swhiteho@redhat.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/gfs2/acl.c2
-rw-r--r--fs/gfs2/inode.c19
-rw-r--r--fs/gfs2/quota.c6
3 files changed, 16 insertions, 11 deletions
diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c
index f850020ad906..f69ac0af5496 100644
--- a/fs/gfs2/acl.c
+++ b/fs/gfs2/acl.c
@@ -237,7 +237,7 @@ static int gfs2_xattr_system_set(struct dentry *dentry, const char *name,
237 return -EINVAL; 237 return -EINVAL;
238 if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode)) 238 if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode))
239 return value ? -EACCES : 0; 239 return value ? -EACCES : 0;
240 if ((current_fsuid() != inode->i_uid) && !capable(CAP_FOWNER)) 240 if (!uid_eq(current_fsuid(), inode->i_uid) && !capable(CAP_FOWNER))
241 return -EPERM; 241 return -EPERM;
242 if (S_ISLNK(inode->i_mode)) 242 if (S_ISLNK(inode->i_mode))
243 return -EOPNOTSUPP; 243 return -EOPNOTSUPP;
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index ce07ce4734f4..bb7c754f46a2 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -368,10 +368,11 @@ static void munge_mode_uid_gid(const struct gfs2_inode *dip,
368 struct inode *inode) 368 struct inode *inode)
369{ 369{
370 if (GFS2_SB(&dip->i_inode)->sd_args.ar_suiddir && 370 if (GFS2_SB(&dip->i_inode)->sd_args.ar_suiddir &&
371 (dip->i_inode.i_mode & S_ISUID) && dip->i_inode.i_uid) { 371 (dip->i_inode.i_mode & S_ISUID) &&
372 !uid_eq(dip->i_inode.i_uid, GLOBAL_ROOT_UID)) {
372 if (S_ISDIR(inode->i_mode)) 373 if (S_ISDIR(inode->i_mode))
373 inode->i_mode |= S_ISUID; 374 inode->i_mode |= S_ISUID;
374 else if (dip->i_inode.i_uid != current_fsuid()) 375 else if (!uid_eq(dip->i_inode.i_uid, current_fsuid()))
375 inode->i_mode &= ~07111; 376 inode->i_mode &= ~07111;
376 inode->i_uid = dip->i_inode.i_uid; 377 inode->i_uid = dip->i_inode.i_uid;
377 } else 378 } else
@@ -978,8 +979,8 @@ static int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name,
978 return -EPERM; 979 return -EPERM;
979 980
980 if ((dip->i_inode.i_mode & S_ISVTX) && 981 if ((dip->i_inode.i_mode & S_ISVTX) &&
981 dip->i_inode.i_uid != current_fsuid() && 982 !uid_eq(dip->i_inode.i_uid, current_fsuid()) &&
982 ip->i_inode.i_uid != current_fsuid() && !capable(CAP_FOWNER)) 983 !uid_eq(ip->i_inode.i_uid, current_fsuid()) && !capable(CAP_FOWNER))
983 return -EPERM; 984 return -EPERM;
984 985
985 if (IS_APPEND(&dip->i_inode)) 986 if (IS_APPEND(&dip->i_inode))
@@ -1589,16 +1590,17 @@ static int setattr_chown(struct inode *inode, struct iattr *attr)
1589 nuid = attr->ia_uid; 1590 nuid = attr->ia_uid;
1590 ngid = attr->ia_gid; 1591 ngid = attr->ia_gid;
1591 1592
1592 if (!(attr->ia_valid & ATTR_UID) || ouid == nuid) 1593 if (!(attr->ia_valid & ATTR_UID) || uid_eq(ouid, nuid))
1593 ouid = nuid = NO_UID_QUOTA_CHANGE; 1594 ouid = nuid = NO_UID_QUOTA_CHANGE;
1594 if (!(attr->ia_valid & ATTR_GID) || ogid == ngid) 1595 if (!(attr->ia_valid & ATTR_GID) || gid_eq(ogid, ngid))
1595 ogid = ngid = NO_GID_QUOTA_CHANGE; 1596 ogid = ngid = NO_GID_QUOTA_CHANGE;
1596 1597
1597 error = gfs2_quota_lock(ip, nuid, ngid); 1598 error = gfs2_quota_lock(ip, nuid, ngid);
1598 if (error) 1599 if (error)
1599 return error; 1600 return error;
1600 1601
1601 if (ouid != NO_UID_QUOTA_CHANGE || ogid != NO_GID_QUOTA_CHANGE) { 1602 if (!uid_eq(ouid, NO_UID_QUOTA_CHANGE) ||
1603 !gid_eq(ogid, NO_GID_QUOTA_CHANGE)) {
1602 error = gfs2_quota_check(ip, nuid, ngid); 1604 error = gfs2_quota_check(ip, nuid, ngid);
1603 if (error) 1605 if (error)
1604 goto out_gunlock_q; 1606 goto out_gunlock_q;
@@ -1612,7 +1614,8 @@ static int setattr_chown(struct inode *inode, struct iattr *attr)
1612 if (error) 1614 if (error)
1613 goto out_end_trans; 1615 goto out_end_trans;
1614 1616
1615 if (ouid != NO_UID_QUOTA_CHANGE || ogid != NO_GID_QUOTA_CHANGE) { 1617 if (!uid_eq(ouid, NO_UID_QUOTA_CHANGE) ||
1618 !gid_eq(ogid, NO_GID_QUOTA_CHANGE)) {
1616 u64 blocks = gfs2_get_inode_blocks(&ip->i_inode); 1619 u64 blocks = gfs2_get_inode_blocks(&ip->i_inode);
1617 gfs2_quota_change(ip, -blocks, ouid, ogid); 1620 gfs2_quota_change(ip, -blocks, ouid, ogid);
1618 gfs2_quota_change(ip, blocks, nuid, ngid); 1621 gfs2_quota_change(ip, blocks, nuid, ngid);
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
index 87f274039c4b..afd2e5d38e5a 100644
--- a/fs/gfs2/quota.c
+++ b/fs/gfs2/quota.c
@@ -525,7 +525,8 @@ int gfs2_quota_hold(struct gfs2_inode *ip, kuid_t uid, kgid_t gid)
525 ip->i_res->rs_qa_qd_num++; 525 ip->i_res->rs_qa_qd_num++;
526 qd++; 526 qd++;
527 527
528 if (uid != NO_UID_QUOTA_CHANGE && uid != ip->i_inode.i_uid) { 528 if (!uid_eq(uid, NO_UID_QUOTA_CHANGE) &&
529 !uid_eq(uid, ip->i_inode.i_uid)) {
529 error = qdsb_get(sdp, make_kqid_uid(uid), qd); 530 error = qdsb_get(sdp, make_kqid_uid(uid), qd);
530 if (error) 531 if (error)
531 goto out; 532 goto out;
@@ -533,7 +534,8 @@ int gfs2_quota_hold(struct gfs2_inode *ip, kuid_t uid, kgid_t gid)
533 qd++; 534 qd++;
534 } 535 }
535 536
536 if (gid != NO_GID_QUOTA_CHANGE && gid != ip->i_inode.i_gid) { 537 if (!gid_eq(gid, NO_GID_QUOTA_CHANGE) &&
538 !gid_eq(gid, ip->i_inode.i_gid)) {
537 error = qdsb_get(sdp, make_kqid_gid(gid), qd); 539 error = qdsb_get(sdp, make_kqid_gid(gid), qd);
538 if (error) 540 if (error)
539 goto out; 541 goto out;