mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Comprehensive list of kernel self-modifications?
@ 2008-05-01 19:46 Yan
  2008-05-02  0:38 ` Chris Wright
  2008-05-14 14:42 ` Pavel Machek
  0 siblings, 2 replies; 3+ messages in thread
From: Yan @ 2008-05-01 19:46 UTC (permalink / raw)
  To: linux-kernel

Hello,

I have been working on verifying kernel integrity and am trying to
differentiate
between vmlinux image on disk and the kernel loaded into memory. I understand
 that the kernel modifies itself (on x86 at least) during at least a few points:


1. It applies alternative instructions with apply_alternatives() from
check_bugs().
    The locations of all alternatives are found between __alt_instructions and
    __alt_instructions__end.
2. It also applies what looks to be relocation. I see the list of
reloc addresses at
    the end of vmlinux image and it appears that relocate_kernel in
relocate_kernel.S
    applies the relocations. I can't tell how it knows where the list
of addresses that
    need relocations is found. Nothing that I found points to that
area, and the on-
    disk data seems to live what gets mapped to as BSS when its running.
3. After manual inspection of all the relocs and alternatives, theres
still about 120
    bytes different. The data looks like groups of 3bytes+address tuples.

Most of this was found via trial and error, so I'm sure there are
other cases of
self-modification. Can anyone point me to a comprehensive list of everywhere
that a kernel can change its own text? Or if anyone knows off the top of their
head, that would be helpful too.

P.S. Please CC to me as I am not subscribed to the list.


Thank you in advance,
Yan

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

* Re: Comprehensive list of kernel self-modifications?
  2008-05-01 19:46 Comprehensive list of kernel self-modifications? Yan
@ 2008-05-02  0:38 ` Chris Wright
  2008-05-14 14:42 ` Pavel Machek
  1 sibling, 0 replies; 3+ messages in thread
From: Chris Wright @ 2008-05-02  0:38 UTC (permalink / raw)
  To: Yan; +Cc: linux-kernel

* Yan (rottled@gmail.com) wrote:
> I have been working on verifying kernel integrity and am trying to
> differentiate
> between vmlinux image on disk and the kernel loaded into memory. I understand
>  that the kernel modifies itself (on x86 at least) during at least a few points:
> 
> 
> 1. It applies alternative instructions with apply_alternatives() from
> check_bugs().
>     The locations of all alternatives are found between __alt_instructions and
>     __alt_instructions__end.

Similarly, there's apply_paravirt() for CONFIG_PARAVIRT kernels.
(Also kprobes, or anything that calls text_poke(), but I doubt it's what
you're looking for).

> 2. It also applies what looks to be relocation. I see the list of
> reloc addresses at
>     the end of vmlinux image and it appears that relocate_kernel in
> relocate_kernel.S
>     applies the relocations. I can't tell how it knows where the list
> of addresses that
>     need relocations is found. Nothing that I found points to that
> area, and the on-
>     disk data seems to live what gets mapped to as BSS when its running.

BSS?  It's not on disk outside of elf header and mapped and cleared at
startup (see clear_bss, for example).

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

* Re: Comprehensive list of kernel self-modifications?
  2008-05-01 19:46 Comprehensive list of kernel self-modifications? Yan
  2008-05-02  0:38 ` Chris Wright
@ 2008-05-14 14:42 ` Pavel Machek
  1 sibling, 0 replies; 3+ messages in thread
From: Pavel Machek @ 2008-05-14 14:42 UTC (permalink / raw)
  To: Yan; +Cc: linux-kernel


Hi!

> I have been working on verifying kernel integrity and am trying to
> differentiate
> between vmlinux image on disk and the kernel loaded into memory. I understand
>  that the kernel modifies itself (on x86 at least) during at least a few points:

This should go into Doc*/ somewhere. Self-modifying code just loves
provoking cpu bugs...
							Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

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

end of thread, other threads:[~2008-05-14 14:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-01 19:46 Comprehensive list of kernel self-modifications? Yan
2008-05-02  0:38 ` Chris Wright
2008-05-14 14:42 ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®