title: Marking loadable kernel module as in-tree
body: <p><em>This question is about linux kernel 4.10.</em></p>
  
  <p>Loading an out-of-tree LKM causes kernel to print a warning:</p>
  
  <p><code>module: loading out-of-tree module taints kernel.</code></p>
  
  <p>This raises from this check in <a href="http://lxr.free-electrons.com/source/kernel/module.c#L2332" rel="noreferrer">module.c</a>: 
  <code>if (!get_modinfo(info, "intree")) {</code></p>
  
  <p>Reading <code>get_modinfo</code> it seams that "intree" is just a a magic-string livnig inside the <code>.ko</code> file.</p>
  
  <p>Running <code>readelf</code> on a random LKM I found in my system shows this:</p>
  
  <p><code>readelf -a imon.ko | grep intree
     161: 00000000000006c0     9 OBJECT  LOCAL  DEFAULT   13 __UNIQUE_ID_intree1</code></p>
  
  <p>While looking for <code>intree</code> in a simple, custom hello_world LKM returns no results.</p>
  
  <p>Is this actually the case?</p>
  
  <p>How are some modules marked as being in-tree? Is it done by adding a macro to the module (like MODULE_LICENCE), or by building the module in a specific way or something else?</p>