linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] module.h: allow #define strings to work with MODULE_IMPORT_NS
@ 2022-01-08 14:06 Greg Kroah-Hartman
  2022-01-10 17:39 ` Matthias Maennich
  2022-01-12  3:13 ` Luis Chamberlain
  0 siblings, 2 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2022-01-08 14:06 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, Luis Chamberlain, Jessica Yu, Matthias Maennich

The MODULE_IMPORT_NS() macro does not allow defined strings to work
properly with it, so add a layer of indirection to allow this to happen.

Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Jessica Yu <jeyu@kernel.org>
Cc: Matthias Maennich <maennich@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
Note, there is no in-kernel user of this, I wrote this to help deal with
some module namespace issues that Android kernels were having where we
wanted to put the namespace name in a build #define to make things
easier over time when combined with the change at:
	https://lore.kernel.org/all/20220108140415.3360088-1-gregkh@linuxfoundation.org/

I can also see this be used in ways to make namespace names up "on the
fly at build time" when combined with the above-referenced change to
create a different namespace for every time the kernel is built to do a
poor-man's symbol mangling to make life harder for out-of-tree modules.
Not that I would ever suggest such a thing :)

 include/linux/module.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/module.h b/include/linux/module.h
index c9f1200b2312..f4338235ed2c 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -290,7 +290,8 @@ extern typeof(name) __mod_##type##__##name##_device_table		\
  * files require multiple MODULE_FIRMWARE() specifiers */
 #define MODULE_FIRMWARE(_firmware) MODULE_INFO(firmware, _firmware)
 
-#define MODULE_IMPORT_NS(ns) MODULE_INFO(import_ns, #ns)
+#define _MODULE_IMPORT_NS(ns)	MODULE_INFO(import_ns, #ns)
+#define MODULE_IMPORT_NS(ns)	_MODULE_IMPORT_NS(ns)
 
 struct notifier_block;
 
-- 
2.34.1


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

* Re: [PATCH] module.h: allow #define strings to work with MODULE_IMPORT_NS
  2022-01-08 14:06 [PATCH] module.h: allow #define strings to work with MODULE_IMPORT_NS Greg Kroah-Hartman
@ 2022-01-10 17:39 ` Matthias Maennich
  2022-01-12  3:13 ` Luis Chamberlain
  1 sibling, 0 replies; 3+ messages in thread
From: Matthias Maennich @ 2022-01-10 17:39 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, Luis Chamberlain, Jessica Yu

On Sat, Jan 08, 2022 at 03:06:57PM +0100, Greg Kroah-Hartman wrote:
>The MODULE_IMPORT_NS() macro does not allow defined strings to work
>properly with it, so add a layer of indirection to allow this to happen.
>
>Cc: Luis Chamberlain <mcgrof@kernel.org>
>Cc: Jessica Yu <jeyu@kernel.org>
>Cc: Matthias Maennich <maennich@google.com>
>Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Reviewed-by: Matthias Maennich <maennich@google.com>

Cheers,
Matthias

>---
>Note, there is no in-kernel user of this, I wrote this to help deal with
>some module namespace issues that Android kernels were having where we
>wanted to put the namespace name in a build #define to make things
>easier over time when combined with the change at:
>	https://lore.kernel.org/all/20220108140415.3360088-1-gregkh@linuxfoundation.org/
>
>I can also see this be used in ways to make namespace names up "on the
>fly at build time" when combined with the above-referenced change to
>create a different namespace for every time the kernel is built to do a
>poor-man's symbol mangling to make life harder for out-of-tree modules.
>Not that I would ever suggest such a thing :)
>
> include/linux/module.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
>diff --git a/include/linux/module.h b/include/linux/module.h
>index c9f1200b2312..f4338235ed2c 100644
>--- a/include/linux/module.h
>+++ b/include/linux/module.h
>@@ -290,7 +290,8 @@ extern typeof(name) __mod_##type##__##name##_device_table		\
>  * files require multiple MODULE_FIRMWARE() specifiers */
> #define MODULE_FIRMWARE(_firmware) MODULE_INFO(firmware, _firmware)
>
>-#define MODULE_IMPORT_NS(ns) MODULE_INFO(import_ns, #ns)
>+#define _MODULE_IMPORT_NS(ns)	MODULE_INFO(import_ns, #ns)
>+#define MODULE_IMPORT_NS(ns)	_MODULE_IMPORT_NS(ns)
>
> struct notifier_block;
>
>-- 
>2.34.1
>

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

* Re: [PATCH] module.h: allow #define strings to work with MODULE_IMPORT_NS
  2022-01-08 14:06 [PATCH] module.h: allow #define strings to work with MODULE_IMPORT_NS Greg Kroah-Hartman
  2022-01-10 17:39 ` Matthias Maennich
@ 2022-01-12  3:13 ` Luis Chamberlain
  1 sibling, 0 replies; 3+ messages in thread
From: Luis Chamberlain @ 2022-01-12  3:13 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Jessica Yu, Matthias Maennich, linux-modules

On Sat, Jan 08, 2022 at 03:06:57PM +0100, Greg Kroah-Hartman wrote:
> The MODULE_IMPORT_NS() macro does not allow defined strings to work
> properly with it, so add a layer of indirection to allow this to happen.
> 
> Cc: Luis Chamberlain <mcgrof@kernel.org>
> Cc: Jessica Yu <jeyu@kernel.org>
> Cc: Matthias Maennich <maennich@google.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Thanks, queued onto modulex-next [0].

[0] https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git/log/?h=modules-next

  Luis

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

end of thread, other threads:[~2022-01-12  3:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-08 14:06 [PATCH] module.h: allow #define strings to work with MODULE_IMPORT_NS Greg Kroah-Hartman
2022-01-10 17:39 ` Matthias Maennich
2022-01-12  3:13 ` Luis Chamberlain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).