mirror of
https://github.com/torvalds/linux.git
synced 2026-09-11 20:13:02 +02:00
xfs: fix capability check in xfs
An user reported a bug where he managed to evade group's quota by changing a file's gid to a different group id the same user belonged to, even though quotas were enforced on both gids and the file's size was big enough to exceed the quota's hardlimit. Commiteba0549bc7replaced a capable() call by a has_capability_noaudit() to prevent unnecessary selinux audit messages. Turns out that both calls have slightly different semantics even though their documentation seems similar. Where in a nutshell: capable() - Tests the task's effective credentials has_ns_capability_noaudit() - Tests the task's real credentials This most of the time has no practical difference but in some cases like changing attrs (specifically group id in this case) through a NFS client this will allow the quota code to use XFS_QMOPT_FORCE_RES, effectively bypassing quota accounting checks. Using instead ns_capable_noaudit() should fix this issue and prevent selinux audit messages. This also fix the remaining calls to has_capability_noaudit() Fixes:eba0549bc7("xfs: don't generate selinux audit messages for capability testing") Cc: stable@vger.kernel.org # v5.18 Reported-by: Dr. Thomas Orgis <thomas.orgis@uni-hamburg.de> Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Serge Hallyn <sergeh@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Carlos Maiolino <cem@kernel.org>
This commit is contained in:
parent
885435535b
commit
e2f62a9744
|
|
@ -1175,7 +1175,7 @@ xfs_getfsmap(
|
|||
return -EINVAL;
|
||||
|
||||
use_rmap = xfs_has_rmapbt(mp) &&
|
||||
has_capability_noaudit(current, CAP_SYS_ADMIN);
|
||||
ns_capable_noaudit(&init_user_ns, CAP_SYS_ADMIN);
|
||||
head->fmh_entries = 0;
|
||||
|
||||
/* Set up our device handlers. */
|
||||
|
|
|
|||
|
|
@ -647,7 +647,7 @@ xfs_ioctl_setattr_get_trans(
|
|||
goto out_error;
|
||||
|
||||
error = xfs_trans_alloc_ichange(ip, NULL, NULL, pdqp,
|
||||
has_capability_noaudit(current, CAP_FOWNER), &tp);
|
||||
ns_capable_noaudit(&init_user_ns, CAP_FOWNER), &tp);
|
||||
if (error)
|
||||
goto out_error;
|
||||
|
||||
|
|
|
|||
|
|
@ -834,7 +834,7 @@ xfs_setattr_nonsize(
|
|||
}
|
||||
|
||||
error = xfs_trans_alloc_ichange(ip, udqp, gdqp, NULL,
|
||||
has_capability_noaudit(current, CAP_FOWNER), &tp);
|
||||
ns_capable_noaudit(&init_user_ns, CAP_FOWNER), &tp);
|
||||
if (error)
|
||||
goto out_dqrele;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user