Hi,
I've written a modest filesystem for fun, it works
pretty ok, but when I try to execute binaries from it,
bash says "cannot execute binary file" ... If I copy
the same binary elsewhere, it executes perfectly.
Does anybody have any clue ?
Regards,
Rock
__________________________________________________
Do You Yahoo!?
Find the one for you at Yahoo! Personals
http://personals.yahoo.com
On Sat, Nov 17, 2001 at 02:18:21PM -0800, Rock Gordon wrote:
> Hi,
>
> I've written a modest filesystem for fun, it works
> pretty ok, but when I try to execute binaries from it,
> bash says "cannot execute binary file" ... If I copy
> the same binary elsewhere, it executes perfectly.
>
There's probably a way for the FS to tell the rest of the kernel that the
file is executable.... You'll probably need to set that for all files.
That is, unless you have a chmod interface for your "FS for fun"...
Mike
[email protected] said:
> I've written a modest filesystem for fun, it works pretty ok, but when
> I try to execute binaries from it, bash says "cannot execute binary
> file" ... If I copy the same binary elsewhere, it executes perfectly.
> Does anybody have any clue ?
Dump it into UML, and stare it with gdb until you see where the error is
coming from.
Jeff
Rock Gordon <[email protected]> writes:
> Hi,
>
> I've written a modest filesystem for fun, it works
> pretty ok, but when I try to execute binaries from it,
> bash says "cannot execute binary file" ... If I copy
> the same binary elsewhere, it executes perfectly.
>
> Does anybody have any clue ?
A classic problem is that the filesystem doesn't support
mmap. But with more recent kernels I think it would but
hard not too...
Eric
On Sat, 17 Nov 2001, Rock Gordon wrote:
> Hi,
>
> I've written a modest filesystem for fun, it works
> pretty ok, but when I try to execute binaries from it,
> bash says "cannot execute binary file" ... If I copy
> the same binary elsewhere, it executes perfectly.
>
> Does anybody have any clue ?
Yes
keep in mind taht the kernel do demand paging of the text (code) in our
executable, meaning that a page of code is not loaded into the procs
memory spce (and thus phys mem) until the proc actually tries to exec the
code page. This is one manifestation of the funny term "page fault"!
I do belive that the current kernel uses mmap to map in the exec file text
segment. (Even if I can hear the ice cracking under my feet, never
actually looked at the code handling execs) but if you strace anexec that
uses shared libs you'll note that the sh.libs are mmaped into the process
space. (also note the MMAP_EXEC flag in the mmap(2) man page).
TJ
>
> Regards,
> Rock
>
> __________________________________________________
> Do You Yahoo!?
> Find the one for you at Yahoo! Personals
> http://personals.yahoo.com
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
--
_________________________________________________________________________
Terje Eggestad [email protected]
Scali Scalable Linux Systems http://www.scali.com
Olaf Helsets Vei 6 tel: +47 22 62 89 61 (OFFICE)
P.O.Box 70 Bogerud +47 975 31 574 (MOBILE)
N-0621 Oslo fax: +47 22 62 89 51
NORWAY
_________________________________________________________________________
All said and done, the file is with correct
permissions (for that matter any binary that I execute
on my filesystem has correct permissions). The only
thing strace tells me is "bad file format". The same
binary works perfectly elsewhere.
I don't think mmap is the problem; you don't need it
in order to run binaries ...
--- Terje Eggestad <[email protected]> wrote:
> On Sat, 17 Nov 2001, Rock Gordon wrote:
>
> > Hi,
> >
> > I've written a modest filesystem for fun, it works
> > pretty ok, but when I try to execute binaries from
> it,
> > bash says "cannot execute binary file" ... If I
> copy
> > the same binary elsewhere, it executes perfectly.
> >
> > Does anybody have any clue ?
>
> Yes
>
> keep in mind taht the kernel do demand paging of the
> text (code) in our
> executable, meaning that a page of code is not
> loaded into the procs
> memory spce (and thus phys mem) until the proc
> actually tries to exec the
> code page. This is one manifestation of the funny
> term "page fault"!
>
> I do belive that the current kernel uses mmap to map
> in the exec file text
> segment. (Even if I can hear the ice cracking under
> my feet, never
> actually looked at the code handling execs) but if
> you strace anexec that
> uses shared libs you'll note that the sh.libs are
> mmaped into the process
> space. (also note the MMAP_EXEC flag in the mmap(2)
> man page).
>
>
> TJ
>
> >
> > Regards,
> > Rock
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Find the one for you at Yahoo! Personals
> > http://personals.yahoo.com
> > -
> > To unsubscribe from this list: send the line
> "unsubscribe linux-kernel" in
> > the body of a message to [email protected]
> > More majordomo info at
> http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at http://www.tux.org/lkml/
> >
>
> --
>
_________________________________________________________________________
>
> Terje Eggestad
> [email protected]
> Scali Scalable Linux Systems http://www.scali.com
>
> Olaf Helsets Vei 6 tel: +47 22 62 89
> 61 (OFFICE)
> P.O.Box 70 Bogerud +47 975 31
> 574 (MOBILE)
> N-0621 Oslo fax: +47 22 62 89
> 51
> NORWAY
>
_________________________________________________________________________
>
__________________________________________________
Do You Yahoo!?
Find the one for you at Yahoo! Personals
http://personals.yahoo.com
On November 19, 2001 08:34, Rock Gordon wrote:
> I don't think mmap is the problem; you don't need it
> in order to run binaries ...
Er... and what brings you to that assertion? Try cat'ing /proc/<pid>/maps on
any program, and you'll see the program's binary in the maps list multiple
times, including one executable map of the .code section. To use my current
mail client as an example:
bodnar42:~$ pidof kmail
3905
bodnar42:~$ cat /proc/3905/maps
08048000-081b0000 r-xp 00000000 03:05 1209118 /usr/bin/kmail
081b0000-081bb000 rw-p 00167000 03:05 1209118 /usr/bin/kmail
081bb000-0863a000 rwxp 00000000 00:00 0
40000000-40014000 r-xp 00000000 03:05 1154 /lib/ld-2.2.4.so
40014000-40015000 rw-p 00013000 03:05 1154 /lib/ld-2.2.4.so
40015000-40016000 rwxp 00000000 00:00 0
40016000-4001c000 rw-p 00000000 00:00 0
4001d000-4001e000 rw-p 00007000 00:00 0
40022000-40203000 r-xp 00000000 03:05 442168 /usr/lib/libkhtml.so.3.0.0
40203000-40235000 rw-p 001e0000 03:05 442168 /usr/lib/libkhtml.so.3.0.0
...
Any sane ELF loader will use mmap() to both execute binaries and load shared
libraries, and Linux's ELF loader is certainly no exception. I remember users
not being able to run binaries (both Win32 and Linux/ELF) off of NTFS
partitions, because the Linux NTFS driver did not implement mmap(). You'll
probably have much better luck once you implement it on yours.
-Ryan
Rock Gordon <[email protected]> writes:
> All said and done, the file is with correct
> permissions (for that matter any binary that I execute
> on my filesystem has correct permissions). The only
> thing strace tells me is "bad file format". The same
> binary works perfectly elsewhere.
>
> I don't think mmap is the problem; you don't need it
> in order to run binaries ...
Yes you do. Look at all of the calls to do_mmap in binfmt_elf,
binfmt_aout and others. The only case that doesn't use mmap
is old a.out binaries that are not properly aligned so cannot be
mmaped.
Linux implements demand paging in the loading of binaries and
for that you need mmap.
Eric
man, 2001-11-19 kl. 17:34 skrev Rock Gordon:
> All said and done, the file is with correct
> permissions (for that matter any binary that I execute
> on my filesystem has correct permissions). The only
> thing strace tells me is "bad file format". The same
> binary works perfectly elsewhere.
>
> I don't think mmap is the problem; you don't need it
> in order to run binaries ...
>
Yes you do. See load_elf_binary in fs/binfmt_elf.c, or
load_aout_binary in fs/binfmt_aout.c.....
> --- Terje Eggestad <[email protected]> wrote:
> > On Sat, 17 Nov 2001, Rock Gordon wrote:
> >
> > > Hi,
> > >
> > > I've written a modest filesystem for fun, it works
> > > pretty ok, but when I try to execute binaries from
> > it,
> > > bash says "cannot execute binary file" ... If I
> > copy
> > > the same binary elsewhere, it executes perfectly.
> > >
> > > Does anybody have any clue ?
> >
> > Yes
> >
> > keep in mind taht the kernel do demand paging of the
> > text (code) in our
> > executable, meaning that a page of code is not
> > loaded into the procs
> > memory spce (and thus phys mem) until the proc
> > actually tries to exec the
> > code page. This is one manifestation of the funny
> > term "page fault"!
> >
> > I do belive that the current kernel uses mmap to map
> > in the exec file text
> > segment. (Even if I can hear the ice cracking under
> > my feet, never
> > actually looked at the code handling execs) but if
> > you strace anexec that
> > uses shared libs you'll note that the sh.libs are
> > mmaped into the process
> > space. (also note the MMAP_EXEC flag in the mmap(2)
> > man page).
> >
> >
> > TJ
> >
> > >
> > > Regards,
> > > Rock
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Find the one for you at Yahoo! Personals
> > > http://personals.yahoo.com
> > > -
> > > To unsubscribe from this list: send the line
> > "unsubscribe linux-kernel" in
> > > the body of a message to [email protected]
> > > More majordomo info at
> > http://vger.kernel.org/majordomo-info.html
> > > Please read the FAQ at http://www.tux.org/lkml/
> > >
> >
> > --
> >
> _________________________________________________________________________
> >
> > Terje Eggestad
> > [email protected]
> > Scali Scalable Linux Systems http://www.scali.com
> >
> > Olaf Helsets Vei 6 tel: +47 22 62 89
> > 61 (OFFICE)
> > P.O.Box 70 Bogerud +47 975 31
> > 574 (MOBILE)
> > N-0621 Oslo fax: +47 22 62 89
> > 51
> > NORWAY
> >
> _________________________________________________________________________
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Find the one for you at Yahoo! Personals
> http://personals.yahoo.com
--
_________________________________________________________________________
Terje Eggestad [email protected]
Scali Scalable Linux Systems http://www.scali.com
Olaf Helsets Vei 6 tel: +47 22 62 89 61 (OFFICE)
P.O.Box 70 Bogerud +47 975 31 574 (MOBILE)
N-0621 Oslo fax: +47 22 62 89 51
NORWAY
_________________________________________________________________________
Oh yes, I've implemented a feeble mmap, but it never
get's to the point where it calls f_op->mmap:
It actually issues a read, starts the program with
start_thread, and it gets a segfault !
All this without calling a single line of code that
I've written that could be the cause of the segfault.
If it had page faulted, it would have been ok, since
readpage would have taken care of it ...
--- Terje Eggestad <[email protected]> wrote:
> man, 2001-11-19 kl. 17:34 skrev Rock Gordon:
> > All said and done, the file is with correct
> > permissions (for that matter any binary that I
> execute
> > on my filesystem has correct permissions). The
> only
> > thing strace tells me is "bad file format". The
> same
> > binary works perfectly elsewhere.
> >
> > I don't think mmap is the problem; you don't need
> it
> > in order to run binaries ...
> >
>
> Yes you do. See load_elf_binary in fs/binfmt_elf.c,
> or
> load_aout_binary in fs/binfmt_aout.c.....
>
>
> > --- Terje Eggestad <[email protected]>
> wrote:
> > > On Sat, 17 Nov 2001, Rock Gordon wrote:
> > >
> > > > Hi,
> > > >
> > > > I've written a modest filesystem for fun, it
> works
> > > > pretty ok, but when I try to execute binaries
> from
> > > it,
> > > > bash says "cannot execute binary file" ... If
> I
> > > copy
> > > > the same binary elsewhere, it executes
> perfectly.
> > > >
> > > > Does anybody have any clue ?
> > >
> > > Yes
> > >
> > > keep in mind taht the kernel do demand paging of
> the
> > > text (code) in our
> > > executable, meaning that a page of code is not
> > > loaded into the procs
> > > memory spce (and thus phys mem) until the proc
> > > actually tries to exec the
> > > code page. This is one manifestation of the
> funny
> > > term "page fault"!
> > >
> > > I do belive that the current kernel uses mmap to
> map
> > > in the exec file text
> > > segment. (Even if I can hear the ice cracking
> under
> > > my feet, never
> > > actually looked at the code handling execs) but
> if
> > > you strace anexec that
> > > uses shared libs you'll note that the sh.libs
> are
> > > mmaped into the process
> > > space. (also note the MMAP_EXEC flag in the
> mmap(2)
> > > man page).
> > >
> > >
> > > TJ
> > >
> > > >
> > > > Regards,
> > > > Rock
> > > >
> > > >
> __________________________________________________
> > > > Do You Yahoo!?
> > > > Find the one for you at Yahoo! Personals
> > > > http://personals.yahoo.com
> > > > -
> > > > To unsubscribe from this list: send the line
> > > "unsubscribe linux-kernel" in
> > > > the body of a message to
> [email protected]
> > > > More majordomo info at
> > > http://vger.kernel.org/majordomo-info.html
> > > > Please read the FAQ at
> http://www.tux.org/lkml/
> > > >
> > >
> > > --
> > >
> >
>
_________________________________________________________________________
> > >
> > > Terje Eggestad
> > > [email protected]
> > > Scali Scalable Linux Systems
> http://www.scali.com
> > >
> > > Olaf Helsets Vei 6 tel: +47 22
> 62 89
> > > 61 (OFFICE)
> > > P.O.Box 70 Bogerud +47 975
> 31
> > > 574 (MOBILE)
> > > N-0621 Oslo fax: +47 22
> 62 89
> > > 51
> > > NORWAY
> > >
> >
>
_________________________________________________________________________
> > >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Find the one for you at Yahoo! Personals
> > http://personals.yahoo.com
> --
>
_________________________________________________________________________
>
> Terje Eggestad
> [email protected]
> Scali Scalable Linux Systems http://www.scali.com
>
> Olaf Helsets Vei 6 tel: +47 22 62 89
> 61 (OFFICE)
> P.O.Box 70 Bogerud +47 975 31
> 574 (MOBILE)
> N-0621 Oslo fax: +47 22 62 89
> 51
> NORWAY
>
_________________________________________________________________________
>
__________________________________________________
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1