Skip to content
systemcoding.dev
Kernels

Declare module metadata with MODULE_LICENSE and MODULE_AUTHOR

Set MODULE_LICENSE, MODULE_AUTHOR and MODULE_DESCRIPTION in a Linux 6.12 module, and see how the license decides which symbols you may use.

1 min read
Summarize in AI

Every module should say who wrote it, what it does and under which license. The license is not decoration: the loader compares it with the kernel's GPL-only exports and taints the kernel when it does not recognize a free license.

demo.cc
#include <linux/module.h>

static int __init demo_init(void) { return 0; }
static void __exit demo_exit(void) { }
module_init(demo_init);
module_exit(demo_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Ada Example <[email protected]>");
MODULE_DESCRIPTION("Demo module that does nothing");
Shell
modinfo -F license demo.ko
Text
GPL

A module that declares "Proprietary" or omits the macro cannot link against symbols exported with EXPORT_SYMBOL_GPL, and loading it sets taint flag P (and G stays off), which makes bug reports from that kernel unwelcome. The accepted strings are listed in include/linux/module.h and the module documentation. Use "Dual MIT/GPL" or "Dual BSD/GPL" if the code is also offered under another license; the kernel treats those as GPL-compatible. Recent modpost versions warn about a missing MODULE_DESCRIPTION, so add it from the start.

Share

More snippets

Systems Programming

Get the page size with sysconf(_SC_PAGESIZE)

Read the memory page size at run time with sysconf(_SC_PAGESIZE) instead of hard-coding 4096, which is wrong on arm64 kernels built with 16K or 64K pages.

1 min read

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.