Commit 6b24c0d279eacfb499854d09ea7f2b69d1721a29
1 parent
7c06b5d672
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
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>
Showing 3 changed files with 16 additions and 11 deletions Side-by-side Diff
fs/gfs2/acl.c
... | ... | @@ -237,7 +237,7 @@ |
237 | 237 | return -EINVAL; |
238 | 238 | if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode)) |
239 | 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 | 241 | return -EPERM; |
242 | 242 | if (S_ISLNK(inode->i_mode)) |
243 | 243 | return -EOPNOTSUPP; |
fs/gfs2/inode.c
... | ... | @@ -368,10 +368,11 @@ |
368 | 368 | struct inode *inode) |
369 | 369 | { |
370 | 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 | 373 | if (S_ISDIR(inode->i_mode)) |
373 | 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 | 376 | inode->i_mode &= ~07111; |
376 | 377 | inode->i_uid = dip->i_inode.i_uid; |
377 | 378 | } else |
... | ... | @@ -978,8 +979,8 @@ |
978 | 979 | return -EPERM; |
979 | 980 | |
980 | 981 | if ((dip->i_inode.i_mode & S_ISVTX) && |
981 | - dip->i_inode.i_uid != current_fsuid() && | |
982 | - ip->i_inode.i_uid != current_fsuid() && !capable(CAP_FOWNER)) | |
982 | + !uid_eq(dip->i_inode.i_uid, current_fsuid()) && | |
983 | + !uid_eq(ip->i_inode.i_uid, current_fsuid()) && !capable(CAP_FOWNER)) | |
983 | 984 | return -EPERM; |
984 | 985 | |
985 | 986 | if (IS_APPEND(&dip->i_inode)) |
986 | 987 | |
987 | 988 | |
... | ... | @@ -1589,16 +1590,17 @@ |
1589 | 1590 | nuid = attr->ia_uid; |
1590 | 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 | 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 | 1596 | ogid = ngid = NO_GID_QUOTA_CHANGE; |
1596 | 1597 | |
1597 | 1598 | error = gfs2_quota_lock(ip, nuid, ngid); |
1598 | 1599 | if (error) |
1599 | 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 | 1604 | error = gfs2_quota_check(ip, nuid, ngid); |
1603 | 1605 | if (error) |
1604 | 1606 | goto out_gunlock_q; |
... | ... | @@ -1612,7 +1614,8 @@ |
1612 | 1614 | if (error) |
1613 | 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 | 1619 | u64 blocks = gfs2_get_inode_blocks(&ip->i_inode); |
1617 | 1620 | gfs2_quota_change(ip, -blocks, ouid, ogid); |
1618 | 1621 | gfs2_quota_change(ip, blocks, nuid, ngid); |
fs/gfs2/quota.c
... | ... | @@ -525,7 +525,8 @@ |
525 | 525 | ip->i_res->rs_qa_qd_num++; |
526 | 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 | 530 | error = qdsb_get(sdp, make_kqid_uid(uid), qd); |
530 | 531 | if (error) |
531 | 532 | goto out; |
... | ... | @@ -533,7 +534,8 @@ |
533 | 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 | 539 | error = qdsb_get(sdp, make_kqid_gid(gid), qd); |
538 | 540 | if (error) |
539 | 541 | goto out; |