Skip to content

Commit eba0549

Browse files
author
Darrick J. Wong
committed
xfs: don't generate selinux audit messages for capability testing
There are a few places where we test the current process' capability set to decide if we're going to be more or less generous with resource acquisition for a system call. If the process doesn't have the capability, we can continue the call, albeit in a degraded mode. These are /not/ the actual security decisions, so it's not proper to use capable(), which (in certain selinux setups) causes audit messages to get logged. Switch them to has_capability_noaudit. Fixes: 7317a03 ("xfs: refactor inode ownership change transaction/inode/quota allocation idiom") Fixes: ea9a46e ("xfs: only return detailed fsmap info if the caller has CAP_SYS_ADMIN") Signed-off-by: Darrick J. Wong <[email protected]> Cc: Dave Chinner <[email protected]> Reviewed-by: Ondrej Mosnacek <[email protected]> Acked-by: Serge Hallyn <[email protected]> Reviewed-by: Eric Sandeen <[email protected]>
1 parent 1a39ae4 commit eba0549

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

fs/xfs/xfs_fsmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -864,8 +864,8 @@ xfs_getfsmap(
864864
!xfs_getfsmap_is_valid_device(mp, &head->fmh_keys[1]))
865865
return -EINVAL;
866866

867-
use_rmap = capable(CAP_SYS_ADMIN) &&
868-
xfs_has_rmapbt(mp);
867+
use_rmap = xfs_has_rmapbt(mp) &&
868+
has_capability_noaudit(current, CAP_SYS_ADMIN);
869869
head->fmh_entries = 0;
870870

871871
/* Set up our device handlers. */

fs/xfs/xfs_ioctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ xfs_ioctl_setattr_get_trans(
11891189
goto out_error;
11901190

11911191
error = xfs_trans_alloc_ichange(ip, NULL, NULL, pdqp,
1192-
capable(CAP_FOWNER), &tp);
1192+
has_capability_noaudit(current, CAP_FOWNER), &tp);
11931193
if (error)
11941194
goto out_error;
11951195

fs/xfs/xfs_iops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ xfs_setattr_nonsize(
723723
}
724724

725725
error = xfs_trans_alloc_ichange(ip, udqp, gdqp, NULL,
726-
capable(CAP_FOWNER), &tp);
726+
has_capability_noaudit(current, CAP_FOWNER), &tp);
727727
if (error)
728728
goto out_dqrele;
729729

kernel/capability.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ bool has_capability_noaudit(struct task_struct *t, int cap)
360360
{
361361
return has_ns_capability_noaudit(t, &init_user_ns, cap);
362362
}
363+
EXPORT_SYMBOL(has_capability_noaudit);
363364

364365
static bool ns_capable_common(struct user_namespace *ns,
365366
int cap,

0 commit comments

Comments
 (0)