lkml.org 
[lkml]   [2004]   [Jan]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] First patch to improve ELF sanity checks


On Sat, 10 Jan 2004, Davide Libenzi wrote:

> On Sat, 10 Jan 2004, Jesper Juhl wrote:
>
> >
> > Hi,
> >
> > Andrew, please consider including the patch below in -mm for testing.
> > The patch works nicely here, but broader testing and review would be good.
> > An explanation of the patch can be found below.
> >
> > This is only a first version, and it does not yet check all I want it to,
> > but the checks it does add should be valid. As far as I've been able to
> > tell, the checks it makes are valid according to the ELF spec, and it does
> > not seem to break anything. I'm currently using it on my own box and I
> > have not yet seen a single binary fail to load - I've also been testing by
> > modifying a valid ELF binary to contain invalid info in the fields that
> > are checked, and all my test-cases fail as expected.
> >
> > This patch /should/ work on all archs. It adds a check to asm-i386/elf.h
> > that I've not added to any other archs for the simple reason that I don't
> > know what a valid check would be on anything but x86 32 bit atm, but I'll
> > be looking into that, and the additional check for i386 should not harm
> > other archs - their checking will just be a little weaker than i386.
> >
> > So far I've only added these checks to load_elf_binary , but Jakub pointed
> > out to me that they would need to go into load_elf_interp as well. I will
> > add the checks there as well as soon as I convince myself that they really
> > are needed there. So far I only see load_elf_binary calling
> > load_elf_interp, and since load_elf_binary does the checks and abort if
> > they fail before calling load_elf_interp I don't (yet) see why they would
> > be needed there as well. I'm sure Jakub is probably right, and I'm looking
>
> You do not have to convince yourself, trust Jakub ;)

I do trust that Jakub is correct, but I still want to convice myself
before changing the code. I don't want to make some silly mistake.


>The checks are needed
> even inside load_elf_interp since they refer to two different images.

Ok. I'm still reading the code and tracing code paths. This is slow work
for me since I'm not intimately familliar with these functions (nor with
kernel code in general). I'll get there, but I'll be getting there in
small incremental steps..


>You
> might also want to create a separate function that does the checks and
> call it from both load_elf_interp and load_elf_binary.
>
Creating a sepperate function is certainly preferable to having duplicate
code in two functions. But I did not want to do that just yet - I wanted
to get confirmation that the checks where correct and ensure that they
really were needed in load_elf_interp before doing that.


-- Jesper Juhl

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:59    [W:0.158 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site