Re: [PATCH -v2 5/7] module: Extend the MODULE_ namespace parsing

From: Peter Zijlstra
Date: Fri May 02 2025 - 09:22:18 EST


On Fri, Feb 07, 2025 at 05:41:54PM +0900, Masahiro Yamada wrote:

> > +static bool verify_module_namespace(const char *namespace, const char *modname)
> > +{
> > + size_t len, modlen = strlen(modname);
> > + const char *sep;
> > + bool glob;
> > +
> > + if (strncmp(namespace, "MODULE_", 7) != 0)
> > + return false;
> > +
> > + for (namespace += 7; *namespace; namespace = sep) {
> > + sep = strchrnul(namespace, ',');
> > + len = sep - namespace;
> > +
> > + glob = false;
> > + if (sep[-1] == '*') {
> > + len--;
> > + glob = true;
> > + }
>
>
> Why only limited to the trailing wildcard?

Because its simple and easy.

> Did you consider using glob_match()?

I had not, because I didn't know we had that in-kernel. Looking at that,
using it is a bit of a pain, since it needs the pattern as a C string,
which means I need to strdup() the thing because I can't modify the
original.

That in turn means we need to deal with malloc failure.

Is that all worth it?