Skip to content

Commit 4ed0c30

Browse files
AstralBobAndreas Gruenbacher
authored andcommitted
gfs2: move privileged user check to gfs2_quota_lock_check
Before this patch, function gfs2_quota_lock checked if it was called from a privileged user, and if so, it bypassed the quota check: superuser can operate outside the quotas. That's the wrong place for the check because the lock/unlock functions are separate from the lock_check function, and you can do lock and unlock without actually checking the quotas. This patch moves the check to gfs2_quota_lock_check. Signed-off-by: Bob Peterson <[email protected]> Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent e6ce26e commit 4ed0c30

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

fs/gfs2/quota.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,8 +1051,7 @@ int gfs2_quota_lock(struct gfs2_inode *ip, kuid_t uid, kgid_t gid)
10511051
u32 x;
10521052
int error = 0;
10531053

1054-
if (capable(CAP_SYS_RESOURCE) ||
1055-
sdp->sd_args.ar_quota != GFS2_QUOTA_ON)
1054+
if (sdp->sd_args.ar_quota != GFS2_QUOTA_ON)
10561055
return 0;
10571056

10581057
error = gfs2_quota_hold(ip, uid, gid);

fs/gfs2/quota.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ static inline int gfs2_quota_lock_check(struct gfs2_inode *ip,
4444
int ret;
4545

4646
ap->allowed = UINT_MAX; /* Assume we are permitted a whole lot */
47-
if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF)
47+
if (capable(CAP_SYS_RESOURCE) ||
48+
sdp->sd_args.ar_quota == GFS2_QUOTA_OFF)
4849
return 0;
4950
ret = gfs2_quota_lock(ip, NO_UID_QUOTA_CHANGE, NO_GID_QUOTA_CHANGE);
5051
if (ret)

0 commit comments

Comments
 (0)