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 9ACE0C433F5 for ; Fri, 14 Jan 2022 07:45:20 +0000 (UTC) Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94.2) (envelope-from ) id 1n8HGp-000534-4o; Fri, 14 Jan 2022 02:45:11 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1n8HGl-00052y-D3 for kernelnewbies@kernelnewbies.org; Fri, 14 Jan 2022 02:45:07 -0500 Received: by mail-wm1-x32a.google.com with SMTP id d18-20020a05600c251200b0034974323cfaso6783810wma.4 for ; Thu, 13 Jan 2022 23:45:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hifiphile-com.20210112.gappssmtp.com; s=20210112; h=in-reply-to:references:thread-topic:user-agent:mime-version :content-transfer-encoding:subject:from:date:to:cc:message-id; bh=6UxnzDouMZ9g0kZkq8uhk3XKBoaTv3pS8VLx/inV8BQ=; b=WYAl3+7YhTRn3sB0eBQK4Ri6LAUmljwNM7PSfG0C9hEg7yhYA4LrtFnF7cSzmb00eu p7q1xH/MJ8h6rFEtK09hJ1SvsaOBo9YN23IExOUG9L4CHZnp9vyv5dt9QicdXYSjWiBy i2EclRTvlLSYjv/WqFHbiqgL+cHo7nohy4K/FiPUMBo5af4UnItV/RsonjM9Rch8kfYf Y3TvyuSGdAjEcAOmjfr4YPdGEIbNkThwogXOFAwg2x21DMM8g7potRxhkUKcrPU/5H57 77xfuFdHwiXcNJLcNih/LR/8QRl7JRlTF0SDvFSVQoBs39oAx6BLexRzw2xx8k+AfnFI 0B2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:in-reply-to:references:thread-topic:user-agent :mime-version:content-transfer-encoding:subject:from:date:to:cc :message-id; bh=6UxnzDouMZ9g0kZkq8uhk3XKBoaTv3pS8VLx/inV8BQ=; b=BnlYAwGNRKaKdVgd9mYEh0zX/4B5os4tZy9Tgp/ATx0/9oiIqZiVIakZPmYue6a1kn C9D7MN+47F9kYBzpG1o4UIfb8z/+J+GzsqiNRnYvHaWlayG8HKq2Ezbvh++vAS5iIdbC d1PIF4qT4BgZkICjlYWN5sCdP17lnLbasdMYd+jOqblGpHR7D6xsqAfjM+sazib2Z6ha G1/6Y17uctnAP8ERryFxyAUpgMSVefxL58BaCTMjcEfFQqWwEsiw8dJU0iVHY/WFs8yO NZMDbsiBbS0Ga0Ir74sO4+gfxOjnLyPUgvfXzvj2nJzMwII5qlspIHi7p/AIE2u5C/AW CNNQ== X-Gm-Message-State: AOAM530VpqhFwl88OWqhZyTfpE8ZM5mD3zHmDaHb0L5LpdH5b5yHPLtG D7huv98U3v8/kneofYAcluJkZQ== X-Google-Smtp-Source: ABdhPJx4ZRLa60QWXPQPa3s2ZI/eBQ/tnpESc4b9eRkjhZCnT5Axmxe77o2M0M5+0Wbu7qBOIoGDRw== X-Received: by 2002:a1c:f310:: with SMTP id q16mr7132123wmq.148.1642146306207; Thu, 13 Jan 2022 23:45:06 -0800 (PST) Received: from ?IPV6:2a01:e34:ec1a:b010:2425:ce29:e778:70f4? ([2a01:e34:ec1a:b010:2425:ce29:e778:70f4]) by smtp.gmail.com with ESMTPSA id bi24sm9657999wmb.9.2022.01.13.23.45.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 Jan 2022 23:45:05 -0800 (PST) In-Reply-To: <026301d808de$be9a3a10$3bceae30$@etri.re.kr> References: <026301d808de$be9a3a10$3bceae30$@etri.re.kr> X-Referenced-Uid: 4299 Thread-Topic: RE: How to disable address randomization ? User-Agent: Android X-Is-Generated-Message-Id: true MIME-Version: 1.0 X-Local-Message-Id: Subject: RE: How to disable address randomization ? From: admin LI Date: Fri, 14 Jan 2022 08:14:25 +0100 To: Chan Kim Message-ID: Cc: kernelnewbies 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="===============8774848306694681667==" Errors-To: kernelnewbies-bounces@kernelnewbies.org --===============8774848306694681667== Content-Type: multipart/alternative; boundary="----STZ8THEJ825MZA2QLG2X3YBP8SZ03R" Content-Transfer-Encoding: 7bit ------STZ8THEJ825MZA2QLG2X3YBP8SZ03R Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Hi Chan, Thank you for pointing me to the right direction=2E Pointer Typ= es =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Pointers printed without a speci= fier extension (i=2Ee unadorned %p) are hashed to give a unique identifier = without leaking kernel addresses to user space=2E On 64 bit machines the fi= rst 32 bits are zeroed=2E If you _really_ want the address see %px below=2E= =E2=81=A3Get BlueMail for Android =E2=80=8B On Jan 14, 2022, 01:36, at 0= 1:36, Chan Kim wrote: >Hi, > >To print kernel virtual= address, you should use %px instead of %p in >the printk=2E > >Probably th= at=E2=80=99s why you couldn=E2=80=99t see the pointer values correctly=2E >= >Chan > > > >From: admin LI >Sent: Friday, Janua= ry 14, 2022 6:02 AM >To: kernelnewbies@kernelnewbies=2Eorg >Subject: How to= disable address randomization ? > > > >Hi, > >I'm developing a kernel mod= ule for an ARM machine, while debugging I >found addresses >printed are al= l randomized and useless for debugging=2E > >To prove I was not crazy I wro= te this small program: > >--------------------------------- >#include >#include >#include >#inc= lude > >MODULE_LICENSE("GPL"); >MODULE_AUTHOR("Somebody");= >MODULE_DESCRIPTION("A simple example Linux module=2E"); >MODULE_VERSION("= 0=2E01"); > >static int __init example_init(void) { > uint32_t a; > u= int32_t b; > uint32_t c; > uint8_t d[10]; > uint8_t *e; > > pri= ntk(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_KERN= EL); > 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 exa= mple_exit(void) { > printk(KERN_INFO "Goodbye, World!\n"); >} > >module_ini= t(example_init); >module_exit(example_exit); >-----------------------------= ---- >And it gave me this output: > >Hello, World! >&a b3f9fa31 >&b 27e1c68= a >&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 t= he same kind of >randomized addresses=2E > >When I search randomization the= only thing I found is KASLR which I >don't think is the same thing=2E ------STZ8THEJ825MZA2QLG2X3YBP8SZ03R Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Hi Chan,
=
Thank you for pointing me to the right directi= on=2E

Pointer Types
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
= Pointers printed without a specifier extension (i=2Ee unadorned %p) are has= hed to give a unique identifier without leaking kernel addresses to user sp= ace=2E On 64 bit machines the first 32 bits are zeroed=2E If you _really_ w= ant the address see %px below=2E

On Ja= n 14, 2022, at 01:36, Chan Kim <ckim@etri=2Ere=2Ekr> wrote:

Hi,

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

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

=

Chan

 

<= div>

From:= admin LI <admin@hifiphile=2Ecom>
Sent: Friday, January 14, 2022 6:02 AM
To: kernelnewbies@ker= nelnewbies=2Eorg
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 rand= omized and useless for debugging=2E

To prove I was not crazy I wrote= this small program:

---------------------------------
#include &= lt;linux/init=2Eh>
#include <linux/module=2Eh>
#include <= linux/kernel=2Eh>
#include <linux/slab=2Eh>

MODULE_LICEN= SE("GPL");
MODULE_AUTHOR("Somebody");
MODULE_DESCRIPTION("A simple ex= ample Linux module=2E");
MODULE_VERSION("0=2E01");

static int __i= nit example_init(void) {
    uint32_t a;
    uint= 32_t b;
    uint32_t c;
    uint8_t d[10];
&nb= sp;   uint8_t *e;

    printk(KERN_INFO "Hello, World!= \n");
    printk(KERN_INFO "&a %p\n",&a);
  &n= bsp; printk(KERN_INFO "&b %p\n",&b);
    printk(KERN_I= NFO "&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;
}

s= tatic void __exit example_exit(void) {
 printk(KERN_INFO "Goodbye, = World!\n");
}

module_init(example_init);
module_exit(example_e= xit);
---------------------------------
And it gave me this output:
Hello, World!
&a b3f9fa31
&b 27e1c68a
&c da50d28= 7
&d 9f9aec2b
&d[0] 9f9aec2b
&d[1] cc627580
&e[= 0] 98b8c9eb
&e[1] 45f248f8

Then I tested on my debian host ma= chine which gave me the same kind of randomized addresses=2E

When I = search randomization the only thing I found is KASLR which I don't think is= the same thing=2E

------STZ8THEJ825MZA2QLG2X3YBP8SZ03R-- --===============8774848306694681667== 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 --===============8774848306694681667==--