Re: Meet compiled kernel binaray abnormal issue while enabling generic kasan in kernel 6.12 with some default KBUILD_RUSTFLAGS on
From: Alice Ryhl
Date: Wed Jul 16 2025 - 16:08:24 EST
On Wed, Jul 16, 2025 at 8:21 PM Carlos Llamas <cmllamas@xxxxxxxxxx> wrote:
>
> On Wed, Jul 16, 2025 at 07:01:29AM +0000, 刘海燕 (Haiyan Liu) wrote:
> >
> >
> > > -----邮件原件-----
> > > 发件人: Miguel Ojeda <miguel.ojeda.sandonis@xxxxxxxxx>
> > > 发送时间: 2025年7月16日 1:51
> > > 收件人: 刘海燕 (Haiyan Liu) <haiyan.liu@xxxxxxxxxx>
> > > 抄送: Miguel Ojeda <ojeda@xxxxxxxxxx>; 周平 (Ping Zhou/9032) <Ping.Zhou1@xxxxxxxxxx>; 代子为 (Ziwei Dai)
> > > <Ziwei.Dai@xxxxxxxxxx>; 杨丽娜 (Lina Yang) <lina.yang@xxxxxxxxxx>; linux-arm-kernel@xxxxxxxxxxxxxxxxxxx;
> > > linux-kernel@xxxxxxxxxxxxxxx; rust-for-linux@xxxxxxxxxxxxxxx; 王双 (Shuang Wang) <shuang.wang@xxxxxxxxxx>; Andrey Ryabinin
> > > <ryabinin.a.a@xxxxxxxxx>; Alexander Potapenko <glider@xxxxxxxxxx>; Andrey Konovalov <andreyknvl@xxxxxxxxx>; Dmitry Vyukov
> > > <dvyukov@xxxxxxxxxx>; Vincenzo Frascino <vincenzo.frascino@xxxxxxx>; kasan-dev@xxxxxxxxxxxxxxxx; Greg Kroah-Hartman
> > > <gregkh@xxxxxxxxxxxxxxxxxxx>; Arve Hjønnevåg <arve@xxxxxxxxxxx>; Todd Kjos <tkjos@xxxxxxxxxxx>; Martijn Coenen
> > > <maco@xxxxxxxxxxx>; Joel Fernandes <joelagnelf@xxxxxxxxxx>; Christian Brauner <christian@xxxxxxxxxx>; Carlos Llamas
> > > <cmllamas@xxxxxxxxxx>; Suren Baghdasaryan <surenb@xxxxxxxxxx>; Jamie Cunliffe <Jamie.Cunliffe@xxxxxxx>; Catalin Marinas
> > > <catalin.marinas@xxxxxxx>
> > > 主题: Re: Meet compiled kernel binaray abnormal issue while enabling generic kasan in kernel 6.12 with some default KBUILD_RUSTFLAGS
> > > on
> > >
> > >
> > > 注意: 这封邮件来自于外部。除非你确定邮件内容安全,否则不要点击任何链接和附件。
> > > CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender
> > > and know the content is safe.
> > >
> > >
> > >
> > > On Tue, Jul 15, 2025 at 11:41 AM 刘海燕 (Haiyan Liu) <haiyan.liu@xxxxxxxxxx> wrote:
> > > >
> > > > The commit changes the fragment and diff is:
> > >
> > > An Android engineer should know how to handle that, but if you are reporting upstream, it is best to try to reproduce the issue with the
> > > upstream kernels (e.g. arm64 is not in 6.6.y) and provide the full kernel config used.
> > >
> > > > Only two rust-related global variables in fmr.rs and layout.rs have this issue. Their asan.module_ctor complied binaries are wrong.
> > >
> > > I am not sure what you mean by `fmr.rs`. As for `layout.rs`, that is in the `kernel` crate in 6.12.y -- isn't there a single `asan.module_ctor`
> > > per TU? Which object file are you referring to? I get the pair for my `rust/kernel.o`.
> >
> > NSX:FFFFFFC0800A7C94|F800865E asan.module_ctor: str x30,[x18],#0x8 ; x30,[x18],#8
> > NSX:FFFFFFC0800A7C98|F81F0FFE str x30,[sp,#-0x10]! ; x30,[sp,#-16]!
> > NSX:FFFFFFC0800A7C9C|F00240A0 adrp x0,0xFFFFFFC0848BE000
> > NSX:FFFFFFC0800A7CA0|911D8000 add x0,x0,#0x760 ; x0,x0,#1888
> > NSX:FFFFFFC0800A7CA4|52803D61 mov w1,#0x1EB ; w1,#491
> > NSX:FFFFFFC0800A7CA8|94233816 bl 0xFFFFFFC080975D00 ; __asan_register_globals
> > NSX:FFFFFFC0800A7CAC|F84107FE ldr x30,[sp],#0x10 ; x30,[sp],#16
> > NSX:FFFFFFC0800A7CB0|D50323BF autiasp
> > NSX:FFFFFFC0800A7CB4|D65F03C0 ret
> > The first __asan_global struct value is
> > ENAXI:FFFFFFC0848BE760|>FFFFFFC082EDB180 000000000000005F ........_.......
> > ENAXI:FFFFFFC0848BE770| 0000000000000080 FFFFFFC0836DC431 ........1.m.....
> > ENAXI:FFFFFFC0848BE780| FFFFFFC082EEC780 0000000000000000 ................
> > ENAXI:FFFFFFC0848BE790| 0000000000000000 FFFFFFFFFFFFFFFF ................
> > The address of the global is 0xFFFFFFC082EDB180 which value is '/proc/self/cwd/prebuilts/rust/linux-x86/1.82.0/lib/rustlib/src/rust/library/core/src/num/fmt.rs' and its viewinfo is 'vmlinux\Global\__unnamed_357'
> > The original size of the global is 0x5F
> > The name of the global is kmalloc-2k
> > The module name of the global is 'core.27758904ccee4c80-cgu.o'
> >
> > NSX:FFFFFFC0800A7D4C|F800865E asan.mod.:str x30,[x18],#0x8 ; x30,[x18],#8
> > NSX:FFFFFFC0800A7D50|F81F0FFE str x30,[sp,#-0x10]! ; x30,[sp,#-16]!
> > NSX:FFFFFFC0800A7D54|F00240E0 adrp x0,0xFFFFFFC0848C6000
> > NSX:FFFFFFC0800A7D58|912E8000 add x0,x0,#0xBA0 ; x0,x0,#2976
> > NSX:FFFFFFC0800A7D5C|52800961 mov w1,#0x4B ; w1,#75
> > NSX:FFFFFFC0800A7D60|942337E8 bl 0xFFFFFFC080975D00 ; __asan_register_globals
> > NSX:FFFFFFC0800A7D64|F84107FE ldr x30,[sp],#0x10 ; x30,[sp],#16
> > NSX:FFFFFFC0800A7D68|D50323BF autiasp
> > NSX:FFFFFFC0800A7D6C|D65F03C0 ret
> > The second __asan_global struct value is
> > NSD:FFFFFFC0848C6BA0|>FFFFFFC082EECA80 0000000000000020 ........ .......
> > NSD:FFFFFFC0848C6BB0| 0000000000000040 FFFFFFC0836DC431 @.......1.m.....
> > NSD:FFFFFFC0848C6BC0| FFFFFFC082EEDA80 0000000000000000 ................
> > NSD:FFFFFFC0848C6BD0| 0000000000000000 FFFFFFFFFFFFFFFF ................
> > The address of the global is 0xFFFFFFC082EECA80 which value is 0 and its viewinfo is '<&usize_as_core::f..vmlinux\kernel_9a6cb9fd7c8dfd66_cgu\<&usize_as_core::fmt::Debug>::{vtable}'
> > The original size of the global is 0x20
> > The name of the global is kmalloc-2k
> > The module name of the global is 'kernel.9a6cb9fd7c8dfd66-cgu.o'
> >
> > > Cheers,
> > > Miguel
>
> We have KASAN builds with android16-6.12 and haven't seen this issue.
> Can you share your entire config file, so we can try to reproduce?
>
> Cc: Alice Ryhl <aliceryhl@xxxxxxxxxx>
> Cc: Matthew Maurer <mmaurer@xxxxxxxxxx>
>
> Alice, Matthew, have you seen this before?
No, this doesn't ring any bells for me. I guess we need to see a full
config so we can try and reproduce ourselves.
Alice