Linux kbuild/kconfig development
 help / color / mirror / Atom feed
From: Luis Chamberlain <mcgrof@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: x86@kernel.org, hpa@zytor.com, petr.pavlu@suse.com,
	samitolvanen@google.com, da.gomez@samsung.com,
	masahiroy@kernel.org, nathan@kernel.org, nicolas@fjasle.eu,
	linux-kernel@vger.kernel.org, linux-modules@vger.kernel.org,
	linux-kbuild@vger.kernel.org, hch@infradead.org,
	gregkh@linuxfoundation.org
Subject: Re: [RFC] module: Strict per-modname namespaces
Date: Wed, 6 Nov 2024 15:42:03 -0800	[thread overview]
Message-ID: <Zyv-yxClglfwvmUa@bombadil.infradead.org> (raw)
In-Reply-To: <20241106190240.GR10375@noisy.programming.kicks-ass.net>

On Wed, Nov 06, 2024 at 08:02:40PM +0100, Peter Zijlstra wrote:
> Hi,
> 
> I've been wanting $topic for a while, and having just stumbled into the
> whole namespace thing by accident, I figured I'd give it a go, most if
> the hard parts seem to have already been done.

Neat, hch suggested something similar a while back

https://lore.kernel.org/all/ZCIiBHyrzDoTJPXT@bombadil.infradead.org/

> It reserves and disallows imports on any "MODULE_${name}" namespace,
> while it implicitly adds the same namespace to every module.

That's simple enough, I like it.

> This allows exports targeted at specific modules and no others -- one
> random example included. I've hated the various kvm exports we've had
> for a while, and strictly limiting them to the kvm module helps
> alleviate some abuse potential.

Yeah we also want:

EXPORT_SYMBOL_NS_GPL(bdev_disk_changed, MODULE_loop);
EXPORT_SYMBOL_NS_GPL(bdev_disk_changed, MODULE_dasd_kmod);

But we might as well have EXPORT_SYMBOL_GPL_FOR() with the implied
module list. We could then add just:


EXPORT_SYMBOL_GPL_FOR(bdev_disk_changed, loop);

But it would be nice to just also support this as well:

EXPORT_SYMBOL_GPL_FOR(bdev_disk_changed, loop, dasd_kmod);

That's possible perhaps something grotesque like this:

#define _EXPORT_SYMBOL_GPL_FOR_EACH(name, module) EXPORT_SYMBOL_NS_GPL(name, MODULE_##module);

#define _GET_MACRO(_1, _2, _3, _4, _5, NAME, ...) NAME

#define _EXPORT_SYMBOL_GPL_FOR1(name, a) \
    _EXPORT_SYMBOL_GPL_FOR_EACH(name, a)

#define _EXPORT_SYMBOL_GPL_FOR2(name, a, b) \
    _EXPORT_SYMBOL_GPL_FOR_EACH(name, a) \
    _EXPORT_SYMBOL_GPL_FOR_EACH(name, b)

#define _EXPORT_SYMBOL_GPL_FOR3(name, a, b, c) \
    _EXPORT_SYMBOL_GPL_FOR_EACH(name, a) \
    _EXPORT_SYMBOL_GPL_FOR_EACH(name, b) \
    _EXPORT_SYMBOL_GPL_FOR_EACH(name, c)

#define _EXPORT_SYMBOL_GPL_FOR4(name, a, b, c, d) \
    _EXPORT_SYMBOL_GPL_FOR_EACH(name, a) \
    _EXPORT_SYMBOL_GPL_FOR_EACH(name, b) \
    _EXPORT_SYMBOL_GPL_FOR_EACH(name, c) \
    _EXPORT_SYMBOL_GPL_FOR_EACH(name, d)

#define _EXPORT_SYMBOL_GPL_FOR5(name, a, b, c, d, e) \
    _EXPORT_SYMBOL_GPL_FOR_EACH(name, a) \
    _EXPORT_SYMBOL_GPL_FOR_EACH(name, b) \
    _EXPORT_SYMBOL_GPL_FOR_EACH(name, c) \
    _EXPORT_SYMBOL_GPL_FOR_EACH(name, d) \
    _EXPORT_SYMBOL_GPL_FOR_EACH(name, e)

#define EXPORT_SYMBOL_GPL_FOR(name, ...) \
    _GET_MACRO(__VA_ARGS__, \
               _EXPORT_SYMBOL_GPL_FOR5, \
               _EXPORT_SYMBOL_GPL_FOR4, \
               _EXPORT_SYMBOL_GPL_FOR3, \
               _EXPORT_SYMBOL_GPL_FOR2, \
               _EXPORT_SYMBOL_GPL_FOR1)(name, __VA_ARGS__)

  Luis

  reply	other threads:[~2024-11-06 23:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-06 19:02 [RFC] module: Strict per-modname namespaces Peter Zijlstra
2024-11-06 23:42 ` Luis Chamberlain [this message]
2024-11-07  5:46   ` Christoph Hellwig
2024-11-07  8:12     ` Masahiro Yamada
2024-11-07 12:50       ` Peter Zijlstra
2024-11-07  5:39 ` Christoph Hellwig
2024-11-08  8:08   ` Geert Uytterhoeven
2024-11-07  6:12 ` Greg KH
2024-11-07  7:55 ` Masahiro Yamada
2024-11-07 11:58   ` Peter Zijlstra
2024-11-07 15:27     ` Peter Zijlstra
2024-11-08 15:28 ` H. Peter Anvin
2024-11-08 15:35   ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zyv-yxClglfwvmUa@bombadil.infradead.org \
    --to=mcgrof@kernel.org \
    --cc=da.gomez@samsung.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@infradead.org \
    --cc=hpa@zytor.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=nicolas@fjasle.eu \
    --cc=peterz@infradead.org \
    --cc=petr.pavlu@suse.com \
    --cc=samitolvanen@google.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox