From: John Reiser <jreiser@BitWagon.com>
To: Paul Jackson <pj@sgi.com>
Cc: Andrew Morton <akpm@osdl.org>,
mike@navi.cx, pageexec@freemail.hu, linux-kernel@vger.kernel.org
Subject: Re: arch/ia64/ia32/binfmt_elf32.c: elf32_map() broken ia64 build
Date: Mon, 26 Apr 2004 22:17:52 -0700 [thread overview]
Message-ID: <408DED00.6070402@BitWagon.com> (raw)
In-Reply-To: <20040426185633.7969ca0d.pj@sgi.com>
Paul Jackson wrote:
> Not sure how (no lkml thread that I can see), but it seems from Andrew's
> broken out patch "bssprot.patch" in 2.6.6-rc2-mm2 that John Reiser
> and/or others on the To list above conspired to break the build of
> arch/ia64/ia32/binfmt_elf32.c: elf32_map().
There was no conspiracy. The patch was compiled and linked on three archs,
and ia64 was not one of them. The #define of elf32_map contributed to
the obfuscation.
> Would someone care to recommend a proper fix?
A proper fix might require help from an ia64 maintainer to define macros
IA32_ELF_PAGESTART, IA32_ELF_PAGEALIGN, IA32_ELF_PAGEOFFSET
and will require ia32_do_munmap(). Below is partial progress,
"completing the parallelogram" from fs/binfmt_elf.c via
arch/x86_64/ia32/ia32_binfmt.c and arch/s390/kernel/binfmt_elf32.c.
This patch requires an ia32_do_munmap(). Until then, Paul's change
is sufficient, and loses no functionality except when PT_LOADs from the
same file designate non-adjacent regions, which was part of the reason
for the bssprot* patch(es) anyway.
When applied after 2.6.6-rc2-mm2, this compiles with warning (no prototype
for ia32_do_munmap), does not link (ia32_do_munmap is undefined), and
has not been executed.
--- ./arch/ia64/ia32/binfmt_elf32.c.orig 2004-04-26 19:17:14.000000000 -0700
+++ ./arch/ia64/ia32/binfmt_elf32.c 2004-04-26 19:57:19.000000000 -0700
@@ -220,10 +220,33 @@
}
static unsigned long
-elf32_map (struct file *filep, unsigned long addr, struct elf_phdr *eppnt, int prot, int type)
+elf32_map (struct file *filep, unsigned long addr, struct elf_phdr const *eppnt,
+ int prot, int type, unsigned long total_size)
{
- unsigned long pgoff = (eppnt->p_vaddr) & ~IA32_PAGE_MASK;
+ /* IA32_ELF_PAGEOFFSET ? */
+ unsigned long const pgoff = eppnt->p_vaddr & ~IA32_PAGE_MASK;
- return ia32_do_mmap(filep, (addr & IA32_PAGE_MASK), eppnt->p_filesz + pgoff, prot, type,
- eppnt->p_offset - pgoff);
+ unsigned long size = eppnt->p_filesz + pgoff;
+ unsigned long off = eppnt->p_offset - pgoff;
+
+ addr = addr & IA32_PAGE_MASK; /* IA32_ELF_PAGESTART ? */
+ size = IA32_PAGE_ALIGN(size); /* IA32_ELF_PAGEALIGN ? */
+
+ /*
+ * total_size is the size of the ELF (interpreter) image.
+ * The _first_ mmap needs to know the full size, otherwise
+ * randomization might put this image into an overlapping
+ * position with the ELF binary image. (since size < total_size)
+ * So we first map the 'big' image - and unmap the remainder at
+ * the end. (which unmap is needed for ELF images with holes.)
+ */
+ if (total_size) {
+ unsigned long map_addr;
+ total_size = IA32_PAGE_ALIGN(total_size); /* IA32_ELF_PAGEALIGN ? */
+ map_addr = ia32_do_mmap(filep, addr, total_size, prot, type, off);
+ if (!BAD_ADDR(map_addr))
+ ia32_do_munmap(current->mm, map_addr+size, total_size-size);
+ return map_addr;
+ } else
+ return ia32_do_mmap(filep, addr, size, prot, type, off);
}
--
next prev parent reply other threads:[~2004-04-27 5:18 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-27 1:56 arch/ia64/ia32/binfmt_elf32.c: elf32_map() broken ia64 build Paul Jackson
2004-04-27 5:17 ` John Reiser [this message]
2004-04-27 5:27 ` Paul Jackson
2004-05-01 8:33 ` Paul Jackson
2004-05-01 8:33 ` arch/ia64/ia32/binfmt_elf32.c: elf32_map() broken ia64 build _and_ boot Paul Jackson
2004-05-03 14:08 ` arch/ia64/ia32/binfmt_elf32.c: elf32_map() broken ia64 build John Reiser
2004-05-03 14:08 ` arch/ia64/ia32/binfmt_elf32.c: elf32_map() broken ia64 build _and_ boot John Reiser
2004-05-03 17:57 ` arch/ia64/ia32/binfmt_elf32.c: elf32_map() broken ia64 build Andrew Morton
2004-05-03 17:57 ` arch/ia64/ia32/binfmt_elf32.c: elf32_map() broken ia64 build _and_ boot Andrew Morton
2004-05-03 21:04 ` arch/ia64/ia32/binfmt_elf32.c: elf32_map() broken ia64 build Paul Jackson
2004-05-03 21:04 ` arch/ia64/ia32/binfmt_elf32.c: elf32_map() broken ia64 build _and_ boot Paul Jackson
2004-05-03 21:29 ` arch/ia64/ia32/binfmt_elf32.c: elf32_map() broken ia64 build Mike Hearn
2004-05-03 21:29 ` arch/ia64/ia32/binfmt_elf32.c: elf32_map() broken ia64 build _and_ boot Mike Hearn
2004-05-03 22:10 ` arch/ia64/ia32/binfmt_elf32.c: elf32_map() broken ia64 build Paul Jackson
2004-05-03 22:10 ` arch/ia64/ia32/binfmt_elf32.c: elf32_map() broken ia64 build _and_ boot Paul Jackson
2004-05-03 22:20 ` arch/ia64/ia32/binfmt_elf32.c: elf32_map() broken ia64 build Mike Hearn
2004-05-03 22:20 ` arch/ia64/ia32/binfmt_elf32.c: elf32_map() broken ia64 build _and_ boot Mike Hearn
2004-05-03 22:26 ` arch/ia64/ia32/binfmt_elf32.c: elf32_map() broken ia64 build Paul Jackson
2004-05-03 22:26 ` arch/ia64/ia32/binfmt_elf32.c: elf32_map() broken ia64 build _and_ boot Paul Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=408DED00.6070402@BitWagon.com \
--to=jreiser@bitwagon.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mike@navi.cx \
--cc=pageexec@freemail.hu \
--cc=pj@sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.