All of lore.kernel.org
 help / color / mirror / Atom feed
* mkelf32 incorrectly filling out the program headers for NOTE
@ 2016-08-24 10:07 Sylvain Munaut
  2016-08-24 10:33 ` Jan Beulich
  0 siblings, 1 reply; 3+ messages in thread
From: Sylvain Munaut @ 2016-08-24 10:07 UTC (permalink / raw)
  To: xen-devel

Hi,

Here's the readelf output (snipped) on a xen-4.7 build :

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .text             PROGBITS        00100000 000080 1d0220 00 WAX  0   0 64
  [ 2] .shstrtab         STRTAB          00000000 1d0340 000018 00      0   0  1
  [ 3] .note             NOTE            00168e58 168ed8 000024 00      0   0  4

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x000080 0x00100000 0x00100000 0x1d0220 0x216000 RWE 0x40
  NOTE           0x168e58 0x00168e58 0x00168e58 0x00024 0x00024 R   0x4

If you look at the "offset" value for the .note section and the NOTE
program headers, they don't match ... but both should represent an
offset inside the file image and to the same thing, so they should
match.

The correct one is the one of the .note and the incorrect value of the
program header one causes kexec to parse the header wrongly and just
plain crash. (granted it should be more robust and not segfault, but
still)


Cheers,

    Sylvain Munaut,
    Whatever s.a.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: mkelf32 incorrectly filling out the program headers for NOTE
  2016-08-24 10:07 mkelf32 incorrectly filling out the program headers for NOTE Sylvain Munaut
@ 2016-08-24 10:33 ` Jan Beulich
  2016-08-24 12:42   ` Sylvain Munaut
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2016-08-24 10:33 UTC (permalink / raw)
  To: Sylvain Munaut; +Cc: xen-devel

>>> On 24.08.16 at 12:07, <s.munaut@whatever-company.com> wrote:
> Hi,
> 
> Here's the readelf output (snipped) on a xen-4.7 build :
> 
> Section Headers:
>   [Nr] Name              Type            Addr     Off    Size   ES Flg Lk 
> Inf Al
>   [ 0]                   NULL            00000000 000000 000000 00      0   
> 0  0
>   [ 1] .text             PROGBITS        00100000 000080 1d0220 00 WAX  0   
> 0 64
>   [ 2] .shstrtab         STRTAB          00000000 1d0340 000018 00      0   
> 0  1
>   [ 3] .note             NOTE            00168e58 168ed8 000024 00      0   
> 0  4
> 
> Program Headers:
>   Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
>   LOAD           0x000080 0x00100000 0x00100000 0x1d0220 0x216000 RWE 0x40
>   NOTE           0x168e58 0x00168e58 0x00168e58 0x00024 0x00024 R   0x4
> 
> If you look at the "offset" value for the .note section and the NOTE
> program headers, they don't match ... but both should represent an
> offset inside the file image and to the same thing, so they should
> match.
> 
> The correct one is the one of the .note and the incorrect value of the
> program header one causes kexec to parse the header wrongly and just
> plain crash. (granted it should be more robust and not segfault, but
> still)

Indeed, patch in the works. But why did you not provide a patch
yourself, considering that you've done all the diagnosis?

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: mkelf32 incorrectly filling out the program headers for NOTE
  2016-08-24 10:33 ` Jan Beulich
@ 2016-08-24 12:42   ` Sylvain Munaut
  0 siblings, 0 replies; 3+ messages in thread
From: Sylvain Munaut @ 2016-08-24 12:42 UTC (permalink / raw)
  To: Jan Beulich; +Cc: xen-devel

Hi Jan,


> Indeed, patch in the works. But why did you not provide a patch
> yourself, considering that you've done all the diagnosis?

I read the code of that tool this morning and couldn't really
understand how "offset" was computed.

I was seeing :

offset = in64_phdr.p_offset;

then a bit later

offset = in64_phdr.p_offset - offset;

which made no sense to me and so decided I'd better not meddle with
things I didn't understand.


Re-reading it now a bit more awake, I see I completely overlooked that
in64_phdr is changed in the mean time (duh ! not sure how I missed it)
...
I could also have looked at how out_shdr_note.sh_offset is assigned
since that one seems correct and notice the missing RAW_OFFSET.


Next time, I'll give it a fresh second look a day later before
posting, sorry about that.


Cheers,

    Sylvain

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-08-24 12:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-24 10:07 mkelf32 incorrectly filling out the program headers for NOTE Sylvain Munaut
2016-08-24 10:33 ` Jan Beulich
2016-08-24 12:42   ` Sylvain Munaut

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.