diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2013-02-02 09:53:11 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2013-02-13 09:16:09 -0500 |
commit | 6fab877900030ba3ae11928efb6087589f1e514c (patch) | |
tree | a57cd5cef8ec66709e73558d4876130892df2fe2 /fs/nfsd/vfs.c | |
parent | 4c1e1b34d5c800ad3ac9a7e2805b0bea70ad2278 (diff) |
nfsd: Properly compare and initialize kuids and kgids
Use uid_eq(uid, GLOBAL_ROOT_UID) instead of !uid.
Use gid_eq(gid, GLOBAL_ROOT_GID) instead of !gid.
Use uid_eq(uid, INVALID_UID) instead of uid == -1
Use gid_eq(uid, INVALID_GID) instead of gid == -1
Use uid = GLOBAL_ROOT_UID instead of uid = 0;
Use gid = GLOBAL_ROOT_GID instead of gid = 0;
Use !uid_eq(uid1, uid2) instead of uid1 != uid2.
Use !gid_eq(gid1, gid2) instead of gid1 != gid2.
Use uid_eq(uid1, uid2) instead of uid1 == uid2.
Cc: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'fs/nfsd/vfs.c')
-rw-r--r-- | fs/nfsd/vfs.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index d586117fa94a..31ff1d642e31 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c | |||
@@ -401,8 +401,8 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap, | |||
401 | 401 | ||
402 | /* Revoke setuid/setgid on chown */ | 402 | /* Revoke setuid/setgid on chown */ |
403 | if (!S_ISDIR(inode->i_mode) && | 403 | if (!S_ISDIR(inode->i_mode) && |
404 | (((iap->ia_valid & ATTR_UID) && iap->ia_uid != inode->i_uid) || | 404 | (((iap->ia_valid & ATTR_UID) && !uid_eq(iap->ia_uid, inode->i_uid)) || |
405 | ((iap->ia_valid & ATTR_GID) && iap->ia_gid != inode->i_gid))) { | 405 | ((iap->ia_valid & ATTR_GID) && !gid_eq(iap->ia_gid, inode->i_gid)))) { |
406 | iap->ia_valid |= ATTR_KILL_PRIV; | 406 | iap->ia_valid |= ATTR_KILL_PRIV; |
407 | if (iap->ia_valid & ATTR_MODE) { | 407 | if (iap->ia_valid & ATTR_MODE) { |
408 | /* we're setting mode too, just clear the s*id bits */ | 408 | /* we're setting mode too, just clear the s*id bits */ |
@@ -1205,7 +1205,7 @@ nfsd_create_setattr(struct svc_rqst *rqstp, struct svc_fh *resfhp, | |||
1205 | * send along the gid on create when it tries to implement | 1205 | * send along the gid on create when it tries to implement |
1206 | * setgid directories via NFS: | 1206 | * setgid directories via NFS: |
1207 | */ | 1207 | */ |
1208 | if (current_fsuid() != 0) | 1208 | if (!uid_eq(current_fsuid(), GLOBAL_ROOT_UID)) |
1209 | iap->ia_valid &= ~(ATTR_UID|ATTR_GID); | 1209 | iap->ia_valid &= ~(ATTR_UID|ATTR_GID); |
1210 | if (iap->ia_valid) | 1210 | if (iap->ia_valid) |
1211 | return nfsd_setattr(rqstp, resfhp, iap, 0, (time_t)0); | 1211 | return nfsd_setattr(rqstp, resfhp, iap, 0, (time_t)0); |
@@ -2150,7 +2150,7 @@ nfsd_permission(struct svc_rqst *rqstp, struct svc_export *exp, | |||
2150 | * with NFSv3. | 2150 | * with NFSv3. |
2151 | */ | 2151 | */ |
2152 | if ((acc & NFSD_MAY_OWNER_OVERRIDE) && | 2152 | if ((acc & NFSD_MAY_OWNER_OVERRIDE) && |
2153 | inode->i_uid == current_fsuid()) | 2153 | uid_eq(inode->i_uid, current_fsuid())) |
2154 | return 0; | 2154 | return 0; |
2155 | 2155 | ||
2156 | /* This assumes NFSD_MAY_{READ,WRITE,EXEC} == MAY_{READ,WRITE,EXEC} */ | 2156 | /* This assumes NFSD_MAY_{READ,WRITE,EXEC} == MAY_{READ,WRITE,EXEC} */ |