* [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; 10+ 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] 10+ 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 15:16 ` Darrick J. Wong
2026-06-26 15:31 ` Paul Moore
2026-06-26 11:45 ` [RFC PATCH 2/4] quota: Don't issue audit messages on quota enforcing cem
` (2 subsequent siblings)
3 siblings, 2 replies; 10+ 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] 10+ 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 15:18 ` Darrick J. Wong
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, 1 reply; 10+ 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] 10+ 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 15:19 ` Darrick J. Wong
2026-06-26 11:45 ` [RFC PATCH 4/4] capability: unexport has_capability_noaudit cem
3 siblings, 1 reply; 10+ 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] 10+ 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; 10+ 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] 10+ messages in thread
* Re: [RFC PATCH 1/4] capabily: Add new capable_noaudit
2026-06-26 11:45 ` [RFC PATCH 1/4] capabily: Add new capable_noaudit cem
@ 2026-06-26 15:16 ` Darrick J. Wong
2026-06-26 15:31 ` Paul Moore
1 sibling, 0 replies; 10+ messages in thread
From: Darrick J. Wong @ 2026-06-26 15:16 UTC (permalink / raw)
To: cem
Cc: linux-fsdevel, jack, hch, serge, linux-security-module,
linux-kernel, linux-xfs
s/capabily/capability/ in the subject even if the typo actually makes it
easier to find the thread.
On Fri, Jun 26, 2026 at 01:45:20PM +0200, cem@kernel.org wrote:
> 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.
Can you mention that this checks the current process' effective
capabilities (as opposed to the real ones)? So that nobody else has to
suffer the confusion I pointed out in [1] which was the source of the
security bugs in the first place?
(I do like the wrapper though)
--D
[1] https://lore.kernel.org/linux-xfs/20260625160317.GY6078@frogsfrogsfrogs/
> + */
> +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 [flat|nested] 10+ messages in thread
* Re: [RFC PATCH 2/4] quota: Don't issue audit messages on quota enforcing
2026-06-26 11:45 ` [RFC PATCH 2/4] quota: Don't issue audit messages on quota enforcing cem
@ 2026-06-26 15:18 ` Darrick J. Wong
0 siblings, 0 replies; 10+ messages in thread
From: Darrick J. Wong @ 2026-06-26 15:18 UTC (permalink / raw)
To: cem
Cc: linux-fsdevel, jack, hch, serge, linux-security-module,
linux-kernel, linux-xfs
On Fri, Jun 26, 2026 at 01:45:21PM +0200, cem@kernel.org wrote:
> 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) &&
Yeah, we're just checking if we're going to enforce hardlimits, not
actually denying something based on lack of capability. For all we know
the user is well under their disk quota limit.
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> (info->dqi_format->qf_fmt_id != QFMT_VFS_OLD ||
> !(info->dqi_flags & DQF_ROOT_SQUASH));
> }
> --
> 2.54.0
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH 3/4] xfs: replace ns_capable_noaudit()
2026-06-26 11:45 ` [RFC PATCH 3/4] xfs: replace ns_capable_noaudit() cem
@ 2026-06-26 15:19 ` Darrick J. Wong
0 siblings, 0 replies; 10+ messages in thread
From: Darrick J. Wong @ 2026-06-26 15:19 UTC (permalink / raw)
To: cem
Cc: linux-fsdevel, jack, hch, serge, linux-security-module,
linux-kernel, linux-xfs
On Fri, Jun 26, 2026 at 01:45:22PM +0200, cem@kernel.org wrote:
> 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.
Might as well do the one in xfs_fsmap.c too, since it was originally a
capable() call.
--D
> 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 [flat|nested] 10+ messages in thread
* Re: [RFC PATCH 1/4] capabily: Add new capable_noaudit
2026-06-26 11:45 ` [RFC PATCH 1/4] capabily: Add new capable_noaudit cem
2026-06-26 15:16 ` Darrick J. Wong
@ 2026-06-26 15:31 ` Paul Moore
2026-06-26 17:46 ` Serge E. Hallyn
1 sibling, 1 reply; 10+ messages in thread
From: Paul Moore @ 2026-06-26 15:31 UTC (permalink / raw)
To: cem
Cc: linux-fsdevel, jack, djwong, hch, serge, linux-security-module,
linux-kernel, linux-xfs
On Fri, Jun 26, 2026 at 7:49 AM <cem@kernel.org> wrote:
>
> 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(+)
This is Serge's call, not mine, but FWIW, I somewhat prefer to see
code use the ns_capable_XXX() variants directly as I like to think it
means some thought went into ensuring the capability check is being
done in the right namespace. Yes, we all know that capable() just
uses the init namespace, but I like to think that having to type that
out in the parameter list might be a good double check ;)
--
paul-moore.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH 1/4] capabily: Add new capable_noaudit
2026-06-26 15:31 ` Paul Moore
@ 2026-06-26 17:46 ` Serge E. Hallyn
0 siblings, 0 replies; 10+ messages in thread
From: Serge E. Hallyn @ 2026-06-26 17:46 UTC (permalink / raw)
To: Paul Moore
Cc: cem, linux-fsdevel, jack, djwong, hch, serge,
linux-security-module, linux-kernel, linux-xfs
On Fri, Jun 26, 2026 at 11:31:06AM -0400, Paul Moore wrote:
> On Fri, Jun 26, 2026 at 7:49 AM <cem@kernel.org> wrote:
> >
> > 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(+)
>
> This is Serge's call, not mine, but FWIW, I somewhat prefer to see
> code use the ns_capable_XXX() variants directly as I like to think it
> means some thought went into ensuring the capability check is being
> done in the right namespace. Yes, we all know that capable() just
> uses the init namespace, but I like to think that having to type that
> out in the parameter list might be a good double check ;)
Hm, yeah, on he one hand it seems like a nice shortcut, but I still
see people confusing what 'capable' really does, so standardizing on
ns_capable_noaudit(&init_user_ns, x) might be worthwhile.
(and then patch 3 can go)
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-06-26 17:54 UTC | newest]
Thread overview: 10+ 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 15:16 ` Darrick J. Wong
2026-06-26 15:31 ` Paul Moore
2026-06-26 17:46 ` Serge E. Hallyn
2026-06-26 11:45 ` [RFC PATCH 2/4] quota: Don't issue audit messages on quota enforcing cem
2026-06-26 15:18 ` Darrick J. Wong
2026-06-26 11:45 ` [RFC PATCH 3/4] xfs: replace ns_capable_noaudit() cem
2026-06-26 15:19 ` Darrick J. Wong
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