arch/ia64/ia32/binfmt_elf32.c: elf32_map() broken ia64 build _and_ boot

arch/ia64/ia32/binfmt_elf32.c: elf32_map() broken ia64 build _and_ boot

Post by Paul Jacks » Sun, 02 May 2004 17:40:08


It's worse than I realized when I started this lkml thread (now adding
linux-ia64 to cc list because I likely need ia64 maintainers assistance).

Not only don't the bssprot patches in Andrew's 2.6.6-rc2-mm2 not build,
they don't boot on SGI's SN2 ia64 with sn2_defconfig. If I remove these
4 bssprot patches, then 2.6.6-rc2-mm2 builds (with the easy build fixes
already understood earlier this week) and boots on SN2 ia64 with
sn2_defconfig.

The 4 patches in question are named in Andrews 2.6.6-rc2-mm2 series file:

bssprot.patch
bssprot-sparc-fix.patch
bssprot-cleanup.patch
bssprot-more-fixes.patch

If I apply the cheap bssprot fix, changing the signature of the function
elf32_map() in arch/ia64/ia32/binfmt_elf32.c as noted earlier in this
lkml thread, then yes I can build it, including these patches, for
sn2_defconfig.

But trying to boot the resulting kernel on an SGI SN2 system fails. The
boot successfully prints out:

Freeing unused kernel memory: 336kB freed

but freezes prior to displaying the next line expected:

INIT: version 2.85 booting

I have to reset instead at this point.

On this system the program /sbin/init is the following type:

/sbin/init: ELF 64-bit LSB executable, IA-64, version 1 (SYSV),
for GNU/Linux 2.4.0, dynamically linked (uses shared libs), stripped

JFReiser posted a few days ago on this lkml thread a partial analysis of
what would be required to complete this bssprot patch for ia64.

Now the job is a little bigger - not only complete the patch (required
to fix some bss protections that matter at least to Wine, but also get
it to boot again, on SN2 hardware, probably on white box ia64 hardware
as well.

This is not something I can do in a reasonable time, and I do not
have the liberty of taking an unreasonable time for this.

... seeking asistance ... who might be able to assist further here?

--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson < XXXX@XXXXX.COM > 1.650.933.1373
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to XXXX@XXXXX.COM
More majordomo info at http://www.yqcomputer.com/
Please read the FAQ at http://www.yqcomputer.com/
 
 
 

arch/ia64/ia32/binfmt_elf32.c: elf32_map() broken ia64 build _and_ boot

Post by John Reise » Tue, 04 May 2004 23:20:13


[snip]

This indicates a problem with the very first execve() and/or its shared
libraries. It is likely that printk() of the arguments and results
to elf_map() and load_elf_interp(), both in fs/binfmt_elf.c,
will aid in finding the problem. This I would do, if I had hardware.

Are there any reports, either success or failure, for any other 64-bit
architecture?

--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to XXXX@XXXXX.COM
More majordomo info at http://www.yqcomputer.com/
Please read the FAQ at http://www.yqcomputer.com/

 
 
 

arch/ia64/ia32/binfmt_elf32.c: elf32_map() broken ia64 build _and_ boot

Post by Andrew Mor » Wed, 05 May 2004 03:10:25

ohn Reiser < XXXX@XXXXX.COM > wrote:

It worked OK on ppc64 but I also was having ia64 problems so I dropped the
patch. The final version is below.

It could do with a rethink. Is there not some simpler way of doing this?




From: John Reiser < XXXX@XXXXX.COM >

The problem:

Mike Hearn < XXXX@XXXXX.COM > reports:

Ihere is a problem in fs/binfmt_elf.c, around line 700.

When mapping a nobits PT_LOAD segment with a memsize > filesize, the kernel
calls set_brk (which in turns calls do_brk) to map and clear the area, but
this discards access permissons on the mapping leading to rwx protection.
This causes a load failure on systems where the VM cannot reserve swap space
for the segment, unless overcommit is active (on many systems it's not on by
default).

It seems that this discarding of access permissions on the unlikely codepath
is incorrect.

The ability to define a new (large) ELF section which isn't backed by swap
space nor disk space and that will be mapped to a specific VMA range is needed
by Wine to reserve the PE load area.

Currently the fact that the section is always mapped rwx despite being marked
read-only in the binary prevents us from using this as a solution to the
problems caused by exec-shield/prelink, meaning the only solution is to
bootstrap the ELF interpreter ourselves from a statically linked binary.
Clearly we'd rather not do that.

Thanks to XXXX@XXXXX.COM for bringing the matter to my attention.

[1] http://bugzilla.kernel.org/show_bug.cgi?id=2255


The patch:

- do_brk(): new parameter vm_inhibit turns off permissions from
VM_DATA_DEFAULT_FLAGS; default to 0. defined in mm/mmap.c, mm/nommu.c;
header include/linux/mm.h; used in fs/binfmt_aout.c, fs/binfmt_elf.c.
Propagate through set_brk() in fs/binfmt_aout.c and fs/binfmt_elf.c.

- total_mapping_size(): new routine computes length of minimal single
interval that covers all the PT_LOAD, for ease and safety in placement when
there are holes between PT_LOAD. Defined in fs/binfmt_elf.c; used there and
arch/x86_64/ia32/ia32_binfmt.c, arch/s390/kernel/binfmt_elf32.c. Copied or
derived from Fedora Core 2 kernel-2.6.5-1.308.src.rpm and later, whose
license is GPLv2 or later.

- do_bss_pages(): do not set current->mm->brk, to allow for use by multiple
.bss (local to each PT_LOAD), and by both main ELF program and ELF program
interpreter; in fs/binfmt_elf.c.

- padzero(): return number of bytes that were written; in fs/binfmt_elf.c.

- calc_bss_inhibit(): new routine computes VM_* bits for .bss; fs/binfmt_elf.c.

- elf_map(): new parameter total_size allows for holes between PT_LOAD; in
fs/binfmt_elf.c, arch/x86_64/ia32/ia32_binfmt.c, arch/s390/kernel/
binfmt_elf32.c.

- load_elf_binary(): create a local .bss for each PT_LOAD when .p_memsz >
.p_filesz, and honor the protection in .p_flags, using new parameter to
do_brk(). Set current->mm->brk. In fs/binfmt_elf.c.

- load_elf_interp(): handle local .bss similar to load_elf_binary(). In
fs/binfmt_elf.c.


---

25-akpm/arch/ia64/ia32/binfmt_elf32.c | 3
25-akpm/arch/ia64/kernel/sys_ia64.c | 2
25-akpm/arch/mips/kernel/irixelf.c | 8 -
25-akpm/arch/mips/kernel/sysirix.c | 2
25-akpm/arch/s390/kernel/binfmt_elf32.c | 21 ++
25-akpm/arch/sparc/kernel/sys_sunos.c | 2
25-akpm/arch/sparc64/kernel/binfm
 
 
 

arch/ia64/ia32/binfmt_elf32.c: elf32_map() broken ia64 build _and_ boot

Post by Paul Jacks » Wed, 05 May 2004 06:10:16

> This indicates a problem with the very first execve() and/or its shared

Since I see Andrew dropped the patch for the moment, I'm thinking that
the ball is back in you guys court. If you end up with some patch to a
well-known base (Linus rc or Andrew mm, say) that you'd like me to try
out, let me know. You might want to include the printk's of
args/results that you describe above, right in the patch, so I can
provide more rapid and useful feedback, should whatever be this
execve/sharedlib problem still persist.

Yes - I have the hardware - but I must ration my time on this patch.

Will this work for you?

--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson < XXXX@XXXXX.COM > 1.650.933.1373
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to XXXX@XXXXX.COM
More majordomo info at http://www.yqcomputer.com/
Please read the FAQ at http://www.yqcomputer.com/
 
 
 

arch/ia64/ia32/binfmt_elf32.c: elf32_map() broken ia64 build _and_ boot

Post by Paul Jacks » Wed, 05 May 2004 07:20:15

> It would be nice to get the bssprot patch in though, ...

Once you've digested Andrew's query as to whether there is a simpler way
to do this, and know whether it's this patch or some other that you want
to push, then if you send me a patch, ideally including the printk's in
fs/binfmt_elf.c that Reiser thought might facilitate debugging, then I'd
be willing to apply the patch and try booting it on my ia64 SN2 hardware.

--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson < XXXX@XXXXX.COM > 1.650.933.1373
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to XXXX@XXXXX.COM
More majordomo info at http://www.yqcomputer.com/
Please read the FAQ at http://www.yqcomputer.com/
 
 
 

arch/ia64/ia32/binfmt_elf32.c: elf32_map() broken ia64 build _and_ boot

Post by Paul Jacks » Wed, 05 May 2004 07:30:29

> so if you have higher priorities don't worry about Wine.

Excellent - I think I can easily follow your suggestion ;).

--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson < XXXX@XXXXX.COM > 1.650.933.1373
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to XXXX@XXXXX.COM
More majordomo info at http://www.yqcomputer.com/
Please read the FAQ at http://www.yqcomputer.com/