Linux Security Modules development
 help / color / mirror / Atom feed
* [RFC PATCH 0/4] Introduce capable_noaudit
@ 2026-06-26 11:45 cem
  2026-06-26 11:45 ` [RFC PATCH 1/4] capabily: Add new capable_noaudit cem
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: cem @ 2026-06-26 11:45 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: jack, djwong, hch, serge, linux-security-module, linux-kernel,
	linux-xfs, Carlos Maiolino

From: Carlos Maiolino <cem@kernel.org>

In some cases - filesystems quota specifically here - we'd like to check
for effective capabilities without issuing spurious audit messages and
without the need to specify a namespace for that.

This series introduce capable_noaudit() which has the same goal as
capable() but without firing audit messages.

Also, this updates both generic quota and xfs quota code to use that.

The last patch unexports has_capability_noaudit() which was originally
exported to be used in xfs but turns out it does not meet our needs.

Note this is based on top of a current series I have to remove
has_capability_noaudit() calls from xfs so the xfs patch won't
apply cleanly without that series.

If adding this helper is acceptable, I'll turn this into a non-rfc
series with the required changes to apply properly.

Comments? Flames?
Cheers

Carlos Maiolino (4):
  capabily: Add new capable_noaudit
  quota: Don't issue audit messages on quota enforcing
  xfs: replace ns_capable_noaudit()
  capability: unexport has_capability_noaudit

 fs/quota/dquot.c           |  2 +-
 fs/xfs/xfs_trans_dquot.c   |  2 +-
 include/linux/capability.h |  5 +++++
 kernel/capability.c        | 18 +++++++++++++++++-
 4 files changed, 24 insertions(+), 3 deletions(-)

-- 
2.54.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [RFC PATCH 1/4] capabily: Add new capable_noaudit
  2026-06-26 11:45 [RFC PATCH 0/4] Introduce capable_noaudit cem
@ 2026-06-26 11:45 ` cem
  2026-06-26 11:45 ` [RFC PATCH 2/4] quota: Don't issue audit messages on quota enforcing cem
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: cem @ 2026-06-26 11:45 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: jack, djwong, hch, serge, linux-security-module, linux-kernel,
	linux-xfs, Carlos Maiolino

From: Carlos Maiolino <cem@kernel.org>

In some situations (quota enforcement bypass in this case) we'd like to
check for a specific capability without triggering spurious audit
messages from security modules like selinux.

Add a new helper so we don't need to use ns_capable_noaudit() directly.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
 include/linux/capability.h |  5 +++++
 kernel/capability.c        | 17 +++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/include/linux/capability.h b/include/linux/capability.h
index 37db92b3d6f8..873416ba884c 100644
--- a/include/linux/capability.h
+++ b/include/linux/capability.h
@@ -145,6 +145,7 @@ extern bool has_capability_noaudit(struct task_struct *t, int cap);
 extern bool has_ns_capability_noaudit(struct task_struct *t,
 				      struct user_namespace *ns, int cap);
 extern bool capable(int cap);
+extern bool capable_noaudit(int cap);
 extern bool ns_capable(struct user_namespace *ns, int cap);
 extern bool ns_capable_noaudit(struct user_namespace *ns, int cap);
 extern bool ns_capable_setid(struct user_namespace *ns, int cap);
@@ -167,6 +168,10 @@ static inline bool capable(int cap)
 {
 	return true;
 }
+static inline bool capable_noaudit(int cap)
+{
+	return true;
+}
 static inline bool ns_capable(struct user_namespace *ns, int cap)
 {
 	return true;
diff --git a/kernel/capability.c b/kernel/capability.c
index 829f49ae07b9..2c2d1e8300bd 100644
--- a/kernel/capability.c
+++ b/kernel/capability.c
@@ -416,6 +416,23 @@ bool capable(int cap)
 	return ns_capable(&init_user_ns, cap);
 }
 EXPORT_SYMBOL(capable);
+
+/**
+ * capable_noaudit - Determine if the current task has a superior
+ * capability in effect (unaudited).
+ * @cap: The capability to be tested for
+ *
+ * This is the same as capable(), except it uses CAP_OPT_NOAUDIT as to prevent
+ * issuing spurious audit messages.
+ *
+ * This sets PF_SUPERPRIV on the task if the capability is available on the
+ * assumption that it's about to be used.
+ */
+bool capable_noaudit(int cap)
+{
+	return ns_capable_noaudit(&init_user_ns, cap);
+}
+EXPORT_SYMBOL(capable_noaudit);
 #endif /* CONFIG_MULTIUSER */
 
 /**
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [RFC PATCH 2/4] quota: Don't issue audit messages on quota enforcing
  2026-06-26 11:45 [RFC PATCH 0/4] Introduce capable_noaudit cem
  2026-06-26 11:45 ` [RFC PATCH 1/4] capabily: Add new capable_noaudit cem
@ 2026-06-26 11:45 ` cem
  2026-06-26 11:45 ` [RFC PATCH 3/4] xfs: replace ns_capable_noaudit() cem
  2026-06-26 11:45 ` [RFC PATCH 4/4] capability: unexport has_capability_noaudit cem
  3 siblings, 0 replies; 5+ messages in thread
From: cem @ 2026-06-26 11:45 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: jack, djwong, hch, serge, linux-security-module, linux-kernel,
	linux-xfs, Carlos Maiolino

From: Carlos Maiolino <cem@kernel.org>

Calling capable() to determine if we can bypass quota enforcement or not
can trigger spurious audit messages. We don't really require it here so
just use the capable_noaudit() version.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
 fs/quota/dquot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 64cf42721496..1122a29215f7 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -1308,7 +1308,7 @@ static int ignore_hardlimit(struct dquot *dquot)
 {
 	struct mem_dqinfo *info = &sb_dqopt(dquot->dq_sb)->info[dquot->dq_id.type];
 
-	return capable(CAP_SYS_RESOURCE) &&
+	return capable_noaudit(CAP_SYS_RESOURCE) &&
 	       (info->dqi_format->qf_fmt_id != QFMT_VFS_OLD ||
 		!(info->dqi_flags & DQF_ROOT_SQUASH));
 }
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [RFC PATCH 3/4] xfs: replace ns_capable_noaudit()
  2026-06-26 11:45 [RFC PATCH 0/4] Introduce capable_noaudit cem
  2026-06-26 11:45 ` [RFC PATCH 1/4] capabily: Add new capable_noaudit cem
  2026-06-26 11:45 ` [RFC PATCH 2/4] quota: Don't issue audit messages on quota enforcing cem
@ 2026-06-26 11:45 ` cem
  2026-06-26 11:45 ` [RFC PATCH 4/4] capability: unexport has_capability_noaudit cem
  3 siblings, 0 replies; 5+ messages in thread
From: cem @ 2026-06-26 11:45 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: jack, djwong, hch, serge, linux-security-module, linux-kernel,
	linux-xfs, Carlos Maiolino

From: Carlos Maiolino <cem@kernel.org>

We don't need to use ns_capable_noaudit() as all we care is the initial
user namespace, use capable_noaudit() instead.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
 fs/xfs/xfs_trans_dquot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c
index 50e5b323f7f1..30c2f6ec0aac 100644
--- a/fs/xfs/xfs_trans_dquot.c
+++ b/fs/xfs/xfs_trans_dquot.c
@@ -835,7 +835,7 @@ xfs_trans_dqresv(
 	if ((flags & XFS_QMOPT_FORCE_RES) == 0 &&
 	    dqp->q_id &&
 	    xfs_dquot_is_enforced(dqp) &&
-	    !ns_capable_noaudit(&init_user_ns, CAP_SYS_RESOURCE)) {
+	    !capable_noaudit(CAP_SYS_RESOURCE)) {
 		int		quota_nl;
 		bool		fatal;
 
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [RFC PATCH 4/4] capability: unexport has_capability_noaudit
  2026-06-26 11:45 [RFC PATCH 0/4] Introduce capable_noaudit cem
                   ` (2 preceding siblings ...)
  2026-06-26 11:45 ` [RFC PATCH 3/4] xfs: replace ns_capable_noaudit() cem
@ 2026-06-26 11:45 ` cem
  3 siblings, 0 replies; 5+ messages in thread
From: cem @ 2026-06-26 11:45 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: jack, djwong, hch, serge, linux-security-module, linux-kernel,
	linux-xfs, Carlos Maiolino

From: Carlos Maiolino <cem@kernel.org>

This has been originally exported to be used in xfs. Givin we are not
using it anymore, unexport for consistency.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
 kernel/capability.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/kernel/capability.c b/kernel/capability.c
index 2c2d1e8300bd..3d0387fb93a3 100644
--- a/kernel/capability.c
+++ b/kernel/capability.c
@@ -326,7 +326,6 @@ bool has_capability_noaudit(struct task_struct *t, int cap)
 {
 	return has_ns_capability_noaudit(t, &init_user_ns, cap);
 }
-EXPORT_SYMBOL(has_capability_noaudit);
 
 static bool ns_capable_common(struct user_namespace *ns,
 			      int cap,
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-06-26 11:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-26 11:45 [RFC PATCH 0/4] Introduce capable_noaudit cem
2026-06-26 11:45 ` [RFC PATCH 1/4] capabily: Add new capable_noaudit cem
2026-06-26 11:45 ` [RFC PATCH 2/4] quota: Don't issue audit messages on quota enforcing cem
2026-06-26 11:45 ` [RFC PATCH 3/4] xfs: replace ns_capable_noaudit() cem
2026-06-26 11:45 ` [RFC PATCH 4/4] capability: unexport has_capability_noaudit cem

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox