All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeffrey Walton <noloader@gmail.com>
To: admin LI <admin@hifiphile.com>
Cc: kernelnewbies <kernelnewbies@kernelnewbies.org>
Subject: Re: How to disable address randomization ?
Date: Thu, 13 Jan 2022 17:44:47 -0500	[thread overview]
Message-ID: <CAH8yC8kU7D9+d04F0NgxLtyguJ1PoLH+SJKdGRcScMMjs9rsMA@mail.gmail.com> (raw)
In-Reply-To: <CA+GyqeZpd+x7VG_1aO5ogCsQ_=hMoDFSN16dE6739cjU_nR2dw@mail.gmail.com>

On Thu, Jan 13, 2022 at 4:04 PM admin LI <admin@hifiphile.com> wrote:
>
> I'm developing a kernel module for an ARM machine, while debugging I found addresses
> printed are all randomized and useless for debugging.
>
> To prove I was not crazy I wrote this small program:
>
> ---------------------------------
> #include <linux/init.h>
> #include <linux/module.h>
> #include <linux/kernel.h>
> #include <linux/slab.h>
>
> MODULE_LICENSE("GPL");
> MODULE_AUTHOR("Somebody");
> MODULE_DESCRIPTION("A simple example Linux module.");
> MODULE_VERSION("0.01");
>
> static int __init example_init(void) {
>     uint32_t a;
>     uint32_t b;
>     uint32_t c;
>     uint8_t d[10];
>     uint8_t *e;
>
>     printk(KERN_INFO "Hello, World!\n");
>     printk(KERN_INFO "&a %p\n",&a);
>     printk(KERN_INFO "&b %p\n",&b);
>     printk(KERN_INFO "&c %p\n",&c);
>     printk(KERN_INFO "&d %p\n",d);
>     printk(KERN_INFO "&d[0] %p\n",&d[0]);
>     printk(KERN_INFO "&d[1] %p\n",&d[1]);
>
>     e = kmalloc(10, GFP_KERNEL);
>     printk(KERN_INFO "&e[0] %p\n",&e[0]);
>     printk(KERN_INFO "&e[1] %p\n",&e[1]);
>
>     kfree(e);
>
>  return 0;
> }
>
> static void __exit example_exit(void) {
>  printk(KERN_INFO "Goodbye, World!\n");
> }
>
> module_init(example_init);
> module_exit(example_exit);
> ---------------------------------
> And it gave me this output:
>
> Hello, World!
> &a b3f9fa31
> &b 27e1c68a
> &c da50d287
> &d 9f9aec2b
> &d[0] 9f9aec2b
> &d[1] cc627580
> &e[0] 98b8c9eb
> &e[1] 45f248f8
>
> Then I tested on my debian host machine which gave me the same kind of randomized addresses.
>
> When I search randomization the only thing I found is KASLR which I don't think is the same thing.

I think something else may be going on, but I'll toss this out there
in case it helps.

In the past randomization was disabled by writing 0 to
/proc/sys/kernel/randomize_va_space. Something like:

    sysctl -w kernel.randomize_va_space=0

To make it permanent, change it in /etc/sysctl.conf.

Jeff

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

  parent reply	other threads:[~2022-01-13 22:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-13 21:01 How to disable address randomization ? admin LI
2022-01-13 21:40 ` Valentin Vidić
2022-01-13 22:44 ` Jeffrey Walton [this message]
2022-01-13 23:54   ` Aruna Hewapathirane
2022-01-14  7:11     ` admin LI
2022-01-14  7:12   ` admin LI
2022-01-14  0:36 ` Chan Kim
2022-01-14  7:14   ` admin LI

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAH8yC8kU7D9+d04F0NgxLtyguJ1PoLH+SJKdGRcScMMjs9rsMA@mail.gmail.com \
    --to=noloader@gmail.com \
    --cc=admin@hifiphile.com \
    --cc=kernelnewbies@kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.