* is_loadable_phdr
@ 2010-01-28 19:55 Brad Plant
2010-01-28 21:14 ` is_loadable_phdr Keir Fraser
0 siblings, 1 reply; 3+ messages in thread
From: Brad Plant @ 2010-01-28 19:55 UTC (permalink / raw)
To: xen-devel@lists.xensource.com; +Cc: pageexec
[-- Attachment #1.1: Type: text/plain, Size: 941 bytes --]
Hi,
I'm attempting to boot the latest mainline kernel patched with PaX. The PaX patch marks some segments as read-only (R--) which is resulting in these segments not being loaded due to is_loadable_phdr returning zero for read-only segments:
int elf_phdr_is_loadable(struct elf_binary *elf, const elf_phdr * phdr)
{
uint64_t p_type = elf_uval(elf, phdr, p_type);
uint64_t p_flags = elf_uval(elf, phdr, p_flags);
return ((p_type == PT_LOAD) && (p_flags & (PF_W | PF_X)) != 0);
}
I'm trying to get an understanding of why a segment has to be writeable or executable for xen to load it. Does anyone know why this is so?
Also, is it likely that this behaviour could be changed? My understanding is that it's perfectly valid to have an ELF kernel with read-only segments in it. Attempting to use an image with a read-only segment leads to the kernel failing to boot with weird and hard to debug crashes.
Cheers,
Brad
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
[-- Attachment #2: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: is_loadable_phdr
2010-01-28 19:55 is_loadable_phdr Brad Plant
@ 2010-01-28 21:14 ` Keir Fraser
2010-01-28 22:02 ` is_loadable_phdr Brad Plant
0 siblings, 1 reply; 3+ messages in thread
From: Keir Fraser @ 2010-01-28 21:14 UTC (permalink / raw)
To: Brad Plant, xen-devel@lists.xensource.com; +Cc: pageexec@freemail.hu
On 28/01/2010 19:55, "Brad Plant" <bplant@iinet.net.au> wrote:
> I'm trying to get an understanding of why a segment has to be writeable or
> executable for xen to load it. Does anyone know why this is so?
>
> Also, is it likely that this behaviour could be changed? My understanding is
> that it's perfectly valid to have an ELF kernel with read-only segments in it.
> Attempting to use an image with a read-only segment leads to the kernel
> failing to boot with weird and hard to debug crashes.
Yes, we can change that. Send a patch for it.
-- Keir
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: is_loadable_phdr
2010-01-28 21:14 ` is_loadable_phdr Keir Fraser
@ 2010-01-28 22:02 ` Brad Plant
0 siblings, 0 replies; 3+ messages in thread
From: Brad Plant @ 2010-01-28 22:02 UTC (permalink / raw)
To: Keir Fraser; +Cc: pageexec@freemail.hu, xen-devel@lists.xensource.com
[-- Attachment #1.1.1: Type: text/plain, Size: 1023 bytes --]
On Thu, 28 Jan 2010 21:14:14 +0000
Keir Fraser <keir.fraser@eu.citrix.com> wrote:
> On 28/01/2010 19:55, "Brad Plant" <bplant@iinet.net.au> wrote:
>
> > I'm trying to get an understanding of why a segment has to be writeable or
> > executable for xen to load it. Does anyone know why this is so?
> >
> > Also, is it likely that this behaviour could be changed? My understanding is
> > that it's perfectly valid to have an ELF kernel with read-only segments in it.
> > Attempting to use an image with a read-only segment leads to the kernel
> > failing to boot with weird and hard to debug crashes.
>
> Yes, we can change that. Send a patch for it.
So there's no reason not loading read-only segments then?
I've attached a patch that'll change elf_phdr_is_loadable's behaviour. It just adds PF_R into the mix. I don't know if this will cause some unwanted side effects. Unfortunately there'll be some very unhappy people if I go rebooting an entire physical machine at the moment.
Cheers,
Brad
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1.2: libelf-tools.c.patch --]
[-- Type: text/x-patch, Size: 485 bytes --]
--- xen/common/libelf/libelf-tools.c.orig 2010-01-29 08:44:48.000000000 +1100
+++ xen/common/libelf/libelf-tools.c 2010-01-29 08:59:18.000000000 +1100
@@ -235,7 +235,7 @@ int elf_phdr_is_loadable(struct elf_bina
uint64_t p_type = elf_uval(elf, phdr, p_type);
uint64_t p_flags = elf_uval(elf, phdr, p_flags);
- return ((p_type == PT_LOAD) && (p_flags & (PF_W | PF_X)) != 0);
+ return ((p_type == PT_LOAD) && (p_flags & (PF_R | PF_W | PF_X)) != 0);
}
/*
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
[-- Attachment #2: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-01-28 22:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-28 19:55 is_loadable_phdr Brad Plant
2010-01-28 21:14 ` is_loadable_phdr Keir Fraser
2010-01-28 22:02 ` is_loadable_phdr Brad Plant
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).