[PATCH 01/13] cred: gather the rules for acting on a task by uid

Josef Bacik josef at toxicpanda.com
Fri Oct 23 13:03:07 UTC 2026


On Fri, Oct 23, 2026 at 07:51:39AM -0500, Serge Hallyn (AMD) wrote:
> Overall I like this, thanks.

Thanks for taking a look.

> > +	default:
> > +		return false;
>
> What do you think about putting a BUG HERE?  It's not actually
> your intent for this ever to be called with 'which' not being
> a valid value, right?

Right, that's never supposed to happen, the callers all pass one of the
three by name. I'd rather not BUG() though. It fails closed as it is, so
the worst a bogus value does is get somebody an EPERM, which isn't worth
taking the box down for.

I agree it shouldn't be silent. I think VFS_WARN_ON_ONCE() fits, it's a
WARN_ON_ONCE() with CONFIG_DEBUG_VFS and compiles away to nothing
without it, so whoever adds a fourth value and forgets the switch hears
about it in testing and nobody else pays for it. It's in use outside of
fs/ already, kernel/nstree.c and kernel/nscommon.c have it.

Christian, if that's fine with you could you fold the below into patch
1? Nothing later in the series touches kernel/cred.c so it shouldn't
conflict with anything. Or I can send a v2, whichever is easier. Thanks,

Josef

diff --git a/kernel/cred.c b/kernel/cred.c
index c067ef72b563..9a3ea6a1b96a 100644
--- a/kernel/cred.c
+++ b/kernel/cred.c
@@ -19,6 +19,7 @@
 #include <linux/binfmts.h>
 #include <linux/cn_proc.h>
 #include <linux/uidgid.h>
+#include <linux/vfsdebug.h>
 
 #if 0
 #define kdebug(FMT, ...)						\
@@ -692,6 +693,7 @@ bool cred_ids_allow_control(const struct cred *subj, enum cred_ids which,
 		gid = subj->fsgid;
 		break;
 	default:
+		VFS_WARN_ON_ONCE(1);
 		return false;
 	}
 



More information about the Linux-security-module-archive mailing list