From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 65D54C433EF for ; Fri, 14 Jan 2022 00:36:42 +0000 (UTC) Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94.2) (envelope-from ) id 1n8AZx-0005lF-1B; Thu, 13 Jan 2022 19:36:29 -0500 Received: from mscreen.etri.re.kr ([129.254.9.16]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA (Exim 4.94.2) (envelope-from ) id 1n8AZt-0005l9-Ep for kernelnewbies@kernelnewbies.org; Thu, 13 Jan 2022 19:36:26 -0500 Received: from unknown (HELO send002-relay.gov-dooray.com) (211.180.235.153) by 129.254.9.16 with ESMTP; 14 Jan 2022 09:36:18 +0900 X-Original-SENDERIP: 211.180.235.153 X-Original-MAILFROM: ckim@etri.re.kr X-Original-RCPTTO: kernelnewbies@kernelnewbies.org Received: from [10.162.225.106] (HELO smtp001-imp.gov-dooray.com) ([10.162.225.106]) by send002-relay.gov-dooray.com with SMTP id 107c8be761e0c582; Fri, 14 Jan 2022 09:36:18 +0900 DKIM-Signature: a=rsa-sha256; b=d5pzobmX4Acy2SVr1S1Vt07NDjxWPpAs+U5RdRNkpNVAnJ9uGJ393D1BhWK1n00aiYKBzthnQj qQjUyCfKWEeNdc7vDES6ObEVyRpu81w38RPr5CkjUc0trPu+ALP53x232R2gan4aQTbBQzxn3jU5 1JZsdMlvsxEl0F7SevREm4Hz9KcthWBRdcuu0dYT0Ui8RJgyWpaP9jkSpFRXijw1SfyGbqOvVBuz R3MSRk8mT/4VpvvnZHoiXYfGaQg3UXOJqSM0WUk28z8zmFUJDs60+rsIYMUifGY1Ks8LWVdHkbox p7JNs2o1aQQ0h/Db7XPQvmc7UNAtx4SuXGx/y+Tg==; c=relaxed/relaxed; s=selector; d=dooray.com; v=1; bh=b65JW8G2mP1IkfQNXNSblsZyh3WanHhAVQzNXXoR7Yc=; h=From:To:Subject:Message-ID; Received: from [129.254.132.39] (HELO CHANKIMPC) ([129.254.132.39]) by smtp001-imp.gov-dooray.com with SMTP id ce4a517f61e0c582; Fri, 14 Jan 2022 09:36:18 +0900 From: "Chan Kim" To: "'admin LI'" , References: In-Reply-To: Subject: RE: How to disable address randomization ? Date: Fri, 14 Jan 2022 09:36:17 +0900 Message-ID: <026301d808de$be9a3a10$3bceae30$@etri.re.kr> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQGNqS+OKWnxNHhJhtzpAta8KMOMIKz2agEQ Content-Language: ko X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============9013092258297612276==" Errors-To: kernelnewbies-bounces@kernelnewbies.org This is a multipart message in MIME format. --===============9013092258297612276== Content-Type: multipart/alternative; boundary="----=_NextPart_000_0264_01D8092A.2E827E50" Content-Language: ko This is a multipart message in MIME format. ------=_NextPart_000_0264_01D8092A.2E827E50 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi, To print kernel virtual address, you should use %px instead of %p in the = printk. Probably that=E2=80=99s why you couldn=E2=80=99t see the pointer values = correctly. Chan =20 From: admin LI =20 Sent: Friday, January 14, 2022 6:02 AM To: kernelnewbies@kernelnewbies.org Subject: How to disable address randomization ? =20 Hi, I'm developing a kernel module for an ARM machine, while debugging I = found addresses=20 printed are all randomized and useless for debugging. To prove I was not crazy I wrote this small program: --------------------------------- #include #include #include #include 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 =3D 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. ------=_NextPart_000_0264_01D8092A.2E827E50 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable

Hi,

To print kernel virtual address, you should use %px = instead of %p in the printk.

Probably that=E2=80=99s why you couldn=E2=80=99t = see the pointer values correctly.

Chan

 

From:<= /b> admin LI = <admin@hifiphile.com>
Sent: Friday, January 14, 2022 = 6:02 AM
To: kernelnewbies@kernelnewbies.org
Subject: = How to disable address randomization = ?

 

Hi,

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_AU= THOR("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 =3D 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(ex= ample_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.

------=_NextPart_000_0264_01D8092A.2E827E50-- --===============9013092258297612276== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies --===============9013092258297612276==--