<html><head></head><body style="zoom: 0%;"><div dir="auto">Hi Jeff,<br><br></div>
<div dir="auto">Thanks for your help, finally I found this in kernel document.<br><br></div>
<div dir="auto">Pointer Types <br></div>
<div dir="auto">============= <br></div>
<div dir="auto">Pointers printed without a specifier extension (i.e unadorned %p) are hashed to give a unique identifier without leaking kernel addresses to user space. On 64 bit machines the first 32 bits are zeroed. If you _really_ want the address see %px below.<br><br></div>
<div dir="auto"><!-- tmjah_g_1299s -->Get <!-- tmjah_g_1299e --><a href="https://bluemail.me"><!-- tmjah_g_1299s -->BlueMail for Android<!-- tmjah_g_1299e --></a><!-- tmjah_g_1299s --> <!-- tmjah_g_1299e --></div>
<div class="gmail_quote" >On Jan 13, 2022, at 23:44, Jeffrey Walton <<a href="mailto:noloader@gmail.com" target="_blank">noloader@gmail.com</a>> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="blue">On Thu, Jan 13, 2022 at 4:04 PM admin LI <admin@hifiphile.com> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"><br> I'm developing a kernel module for an ARM machine, while debugging I found addresses<br> printed are all randomized and useless for debugging.<br><br> To prove I was not crazy I wrote this small program:<br><br><hr><br> #include <linux/init.h><br> #include <linux/module.h><br> #include <linux/kernel.h><br> #include <linux/slab.h><br><br> MODULE_LICENSE("GPL");<br> MODULE_AUTHOR("Somebody");<br> MODULE_DESCRIPTION("A simple example Linux module.");<br> MODULE_VERSION("0.01");<br><br> static int __init example_init(void) {<br> uint32_t a;<br> uint32_t b;<br> uint32_t c;<br> uint8_t d[10];<br> uint8_t *e;<br><br> printk(KERN_INFO "Hello, World!\n");<br> printk(KERN_INFO "&a %p\n",&a);<br> printk(KERN_INFO "&b %p\n",&b);<br> printk(KERN_INFO "&c %p\n",&c);<br> printk(KERN_INFO "&d %p\n",d);<br> printk(KERN_INFO "&d[0] %p\n",&d[0]);<br> printk(KERN_INFO "&d[1] %p\n",&d[1]);<br><br> e = kmalloc(10, GFP_KERNEL);<br> printk(KERN_INFO "&e[0] %p\n",&e[0]);<br> printk(KERN_INFO "&e[1] %p\n",&e[1]);<br><br> kfree(e);<br><br> return 0;<br> }<br><br> static void __exit example_exit(void) {<br> printk(KERN_INFO "Goodbye, World!\n");<br> }<br><br> module_init(example_init);<br> module_exit(example_exit);<br><hr><br> And it gave me this output:<br><br> Hello, World!<br> &a b3f9fa31<br> &b 27e1c68a<br> &c da50d287<br> &d 9f9aec2b<br> &d[0] 9f9aec2b<br> &d[1] cc627580<br> &e[0] 98b8c9eb<br> &e[1] 45f248f8<br><br> Then I tested on my debian host machine which gave me the same kind of randomized addresses.<br><br> When I search randomization the only thing I found is KASLR which I don't think is the same thing.<br></blockquote><br>I think something else may be going on, but I'll toss this out there<br>in case it helps.<br><br>In the past randomization was disabled by writing 0 to<br>/proc/sys/kernel/randomize_va_space. Something like:<br><br> sysctl -w kernel.randomize_va_space=0<br><br>To make it permanent, change it in /etc/sysctl.conf.<br><br>Jeff<br></pre></blockquote></div></body></html>