[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a0293b2d-7a43-49b7-8146-c20fd4be262f@westnet.com.au>
Date: Tue, 13 Aug 2024 14:53:07 +1000
From: Greg Ungerer <gregungerer@...tnet.com.au>
To: Max Filippov <jcmvbkbc@...il.com>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org,
linux-fsdevel@...r.kernel.org, Eric Biederman <ebiederm@...ssion.com>,
Kees Cook <keescook@...omium.org>, Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>
Subject: Re: [PATCH] binfmt_elf_fdpic: fix /proc/<pid>/auxv
Hi Max,
On 13/8/24 04:02, Max Filippov wrote:
> Hi Greg,
>
> On Sun, Aug 11, 2024 at 7:26 PM Greg Ungerer <gregungerer@...tnet.com.au> wrote:
>> On 23/3/24 05:54, Max Filippov wrote:
>>> Althought FDPIC linux kernel provides /proc/<pid>/auxv files they are
>>> empty because there's no code that initializes mm->saved_auxv in the
>>> FDPIC ELF loader.
>>>
>>> Synchronize FDPIC ELF aux vector setup with ELF. Replace entry-by-entry
>>> aux vector copying to userspace with initialization of mm->saved_auxv
>>> first and then copying it to userspace as a whole.
>>>
>>> Signed-off-by: Max Filippov <jcmvbkbc@...il.com>
>>
>> This is breaking ARM nommu builds supporting fdpic and elf binaries for me.
>>
>> Tests I have for m68k and riscv nommu setups running elf binaries
>> don't show any problems - I am only seeing this on ARM.
>>
>>
>> ...
>> Freeing unused kernel image (initmem) memory: 472K
>> This architecture does not have kernel memory protection.
>> Run /init as init process
>> Internal error: Oops - undefined instruction: 0 [#1] ARM
>> Modules linked in:
>> CPU: 0 PID: 1 Comm: init Not tainted 6.10.0 #1
>> Hardware name: ARM-Versatile (Device Tree Support)
>> PC is at load_elf_fdpic_binary+0xb34/0xb80
>> LR is at 0x0
>> pc : [<00109ce8>] lr : [<00000000>] psr: 80000153
>> sp : 00823e40 ip : 00000000 fp : 00b8fee4
>> r10: 009c9b80 r9 : 00b8ff80 r8 : 009ee800
>> r7 : 00000000 r6 : 009f7e80 r5 : 00b8fedc r4 : 00b87000
>> r3 : 00b8fed8 r2 : 00b8fee0 r1 : 00b87128 r0 : 00b8fef0
>> Flags: Nzcv IRQs on FIQs off Mode SVC_32 ISA ARM Segment none
>> Control: 00091176 Table: 00000000 DAC: 00000000
>> Register r0 information: non-slab/vmalloc memory
>> Register r1 information: slab/vmalloc mm_struct start 00b87000 pointer offset 296 size 428
>> Register r2 information: non-slab/vmalloc memory
>> Register r3 information: non-slab/vmalloc memory
>> Register r4 information: slab/vmalloc mm_struct start 00b87000 pointer offset 0 size 428
>> Register r5 information: non-slab/vmalloc memory
>> Register r6 information: slab/vmalloc kmalloc-32 start 009f7e80 pointer offset 0 size 32
>> Register r7 information: non-slab/vmalloc memory
>> Register r8 information: slab/vmalloc kmalloc-512 start 009ee800 pointer offset 0 size 512
>> Register r9 information: non-slab/vmalloc memory
>> Register r10 information: slab/vmalloc kmalloc-128 start 009c9b80 pointer offset 0 size 128
>> Register r11 information: non-slab/vmalloc memory
>> Register r12 information: non-slab/vmalloc memory
>> Process init (pid: 1, stack limit = 0x(ptrval))
>> Stack: (0x00823e40 to 0x00824000)
>> 3e40: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
>> 3e60: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
>> 3e80: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
>> 3ea0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
>> 3ec0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
>> 3ee0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
>> 3f00: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
>> 3f20: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
>> 3f40: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
>> 3f60: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
>> 3f80: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
>> 3fa0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
>> 3fc0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
>> 3fe0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
>> Call trace:
>> load_elf_fdpic_binary from bprm_execve+0x1b4/0x488
>> bprm_execve from kernel_execve+0x154/0x1e4
>> kernel_execve from kernel_init+0x4c/0x108
>> kernel_init from ret_from_fork+0x14/0x38
>> Exception stack(0x00823fb0 to 0x00823ff8)
>> 3fa0: ???????? ???????? ???????? ????????
>> 3fc0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
>> 3fe0: ???????? ???????? ???????? ???????? ???????? ????????
>> Code: bad PC value
>> ---[ end trace 0000000000000000 ]---
>> note: init[1] exited with irqs disabled
>> Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
>> ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b ]---
>>
>>
>> The code around that PC is:
>>
>> 109cd0: e2833ff1 add r3, r3, #964 @ 0x3c4
>> 109cd4: e5933000 ldr r3, [r3]
>> 109cd8: e5933328 ldr r3, [r3, #808] @ 0x328
>> 109cdc: e5933084 ldr r3, [r3, #132] @ 0x84
>> 109ce0: e5843034 str r3, [r4, #52] @ 0x34
>> 109ce4: eafffdbc b 1093dc <load_elf_fdpic_binary+0x228>
>> 109ce8: e7f001f2 .word 0xe7f001f2
>> 109cec: eb09471d bl 35b968 <__stack_chk_fail>
>> 109cf0: e59f0038 ldr r0, [pc, #56] @ 109d30 <load_elf_fdpic_binary+0xb7c>
>> 109cf4: eb092f03 bl 355908 <_printk>
>> 109cf8: eafffdb7 b 1093dc <load_elf_fdpic_binary+0x228>
>>
>>
>> Reverting just this change gets it working again.
>>
>> Any idea what might be going on?
>
> Other than that the layout of the aux vector has slightly changed I don't
> see anything. I can take a look at what's going on if you can share the
> reproducer.
I build the test binary using a simple script:
https://github.com/gregungerer/simple-linux/blob/master/build-armnommu-linux-uclibc-fdpic.sh
Run the resulting vmlinux and devicetree under qemu as per comments at top of that script.
Note that that script has a revert of this change (at line 191), so you would need
to take that out to reproduce the problem. This script will look for a couple of
configs and a versatile patch:
https://github.com/gregungerer/simple-linux/blob/master/configs/linux-6.10-armnommu-versatile.config
https://github.com/gregungerer/simple-linux/blob/master/configs/uClibc-ng-1.0.49-armnommu-fdpic.config
https://github.com/gregungerer/simple-linux/blob/master/configs/busybox-1.36.1.config
https://github.com/gregungerer/simple-linux/blob/master/configs/rootfs.dev
https://github.com/gregungerer/simple-linux/blob/master/patches/linux-6.10-armnommu-versatile.patch
https://github.com/gregungerer/simple-linux/blob/master/patches/linux-6.10-binfmt_elf_fdpic-fix-proc-pid-auxv.patch
Or you could just clone the whole small set in one step from:
https://github.com/gregungerer/simple-linux.git
If you need to me to run something I can do that easily too.
Regards
Greg
Powered by blists - more mailing lists