Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>To catch incorrect memory accesses, <a href="https://www.kernel.org/doc/Documentation/kasan.txt" rel="nofollow noreferrer">KAsan</a> or <a href="http://www.mjmwired.net/kernel/Documentation/kmemcheck.txt" rel="nofollow noreferrer">kmemcheck</a> could probably be more useful. Note that Kmemcheck, however, is known to incur a significant which may sometimes be unacceptable, so it is up to you to decide. KASan should be much faster.</p> <p>1. Concerning kmemleak, its operation is described in detail in the <a href="http://www.mjmwired.net/kernel/Documentation/kmemleak.txt" rel="nofollow noreferrer">kernel docs</a>.</p> <p>In short, it is more reliable to execute </p> <pre><code>echo scan &gt; /sys/kernel/debug/kmemleak </code></pre> <p>as root to trigger memory analysis immediately before you read <code>/sys/kernel/debug/kmemleak</code>. Sometimes, I found even more reliable to execute the above command twice before reading kmemleak's report.</p> <p>To "reset" the data collected by kmemleak, you can execute</p> <pre><code>echo clear /sys/kernel/debug/kmemleak </code></pre> <p>The output you have posted means that kmemleak thinks that a memory area 2Kb in size at address <code>0xc625e000</code> has not been freed at the time the tool has last analyzed memory. The backtrace specifies where the memory was allocated. "swapper" is the name of the process that has allocated that memory area.</p> <p>2. As far as setting memory read-only is concerned, this technique is indeed used in some places of the kernel, e.g. to protect the code of the kernel proper and the modules. I cannot give you exact instructions here but the implementation of <a href="http://lxr.free-electrons.com/ident?i=set_page_attributes" rel="nofollow noreferrer">set_page_attributes() function</a> is a good place to start digging in.</p> <p>Note that kmemcheck I mentioned above uses a somewhat similar technique to track memory accesses: makes pages "look" like they do not exist so that each access to them causes a page fault, etc. The details are in the <a href="http://www.mjmwired.net/kernel/Documentation/kmemcheck.txt" rel="nofollow noreferrer">kernel docs</a>, as usual.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload