Executing binaries on new filesystem
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
Quoted 7 lines · Rock Gordon
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
Quoted 5 lines · [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
Quoted 8 lines · Rock Gordon
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
Quoted 8 lines · Rock Gordon
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
Quoted 14 lines
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/
Signature · 10 lines
_________________________________________________________________________ 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 ...
Quoted 48 lines · --- Terje Eggestad
Quoted 4 lines · Rock Gordon
Hi,
I've written a modest filesystem for fun, it works pretty ok, but when I try to execute binaries from
it,
Quoted 1 line
bash says "cannot execute binary file" ... If I
copy
Quoted 3 lines
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 theMMAP_EXECflag in the mmap(2) man page).TJ
Quoted 10 lines
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
Quoted 9 lines
"unsubscribe linux-kernel" in
Quoted 2 lines
the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html
Quoted 2 lines
Please read the FAQ at http://www.tux.org/lkml/
_________________________________________________________________________
Quoted 5 lines
Terje Eggestad
[email protected]
Scali Scalable Linux Systems http://www.scali.com
Quoted 8 lines
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
_________________________________________________________________________
Quoted 1 line
__________________________________________________
Do You Yahoo!?
Find the one for you at Yahoo! Personals
http://personals.yahoo.com
Quoted 2 lines · Rock Gordon
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
Quoted 8 lines · 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. 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:
Quoted 9 lines
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.....
Quoted 80 lines
Quoted 48 lines · --- Terje Eggestad
Quoted 4 lines · Rock Gordon
Hi,
I've written a modest filesystem for fun, it works pretty ok, but when I try to execute binaries from
it,
Quoted 1 line
bash says "cannot execute binary file" ... If I
copy
Quoted 3 lines
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 theMMAP_EXECflag in the mmap(2) man page).TJ
Quoted 10 lines
Regards,
Rock__________________________________________________
Do You Yahoo!?
Find the one for you at Yahoo! Personals
http://personals.yahoo.com
-
To unsubscribe from this list: send the lineQuoted 9 lines
"unsubscribe linux-kernel" in
Quoted 2 lines
the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html
Quoted 2 lines
Please read the FAQ at http://www.tux.org/lkml/
_________________________________________________________________________
Quoted 5 lines
Terje Eggestad
[email protected]
Scali Scalable Linux Systems http://www.scali.comQuoted 8 lines
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_________________________________________________________________________
Quoted 1 line
__________________________________________________
Do You Yahoo!?
Find the one for you at Yahoo! Personals
http://personals.yahoo.com
Signature · 10 lines
_________________________________________________________________________ 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 ...
Quoted 82 lines · --- Terje Eggestad
man, 2001-11-19 kl. 17:34 skrev Rock Gordon:
Quoted 2 lines
All said and done, the file is with correct
permissions (for that matter any binary that Iexecute
Quoted 1 line
on my filesystem has correct permissions). The
only
Quoted 1 line
thing strace tells me is "bad file format". The
same
Quoted 3 lines
binary works perfectly elsewhere.
I don't think mmap is the problem; you don't need
it
Quoted 2 lines
in order to run binaries ...
Yes you do. See
load_elf_binaryinfs/binfmt_elf.c, orload_aout_binaryinfs/binfmt_aout.c.....Quoted 1 line
--- Terje Eggestad <[email protected]>
Quoted 5 lines · wrote:
Quoted 5 lines · Rock Gordon
Quoted 4 lines
Hi,
I've written a modest filesystem for fun, it
works
Quoted 1 line
Quoted 1 line
Quoted 1 line
pretty ok, but when I try to execute binaries
from
Quoted 2 lines
Quoted 2 lines
it,
Quoted 1 line
bash says "cannot execute binary file" ... If
I
Quoted 2 lines
Quoted 2 lines
copy
Quoted 1 line
the same binary elsewhere, it executes
perfectly.
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Does anybody have any clue ?
Yes
keep in mind taht the kernel do demand paging of
the
Quoted 6 lines
Quoted 6 lines
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 thefunny
Quoted 3 lines
Quoted 3 lines
term "page fault"!
I do belive that the current kernel uses mmap to
map
Quoted 2 lines
Quoted 2 lines
in the exec file text
segment. (Even if I can hear the ice crackingunder
Quoted 2 lines
Quoted 2 lines
my feet, never
actually looked at the code handling execs) butif
Quoted 2 lines
Quoted 2 lines
you strace anexec that
uses shared libs you'll note that the sh.libsare
Quoted 2 lines
Quoted 2 lines
mmaped into the process
space. (also note theMMAP_EXECflag in themmap(2)
Quoted 10 lines
Quoted 10 lines
man page).
TJ
Quoted 5 lines
Regards,
Rock__________________________________________________
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Do You Yahoo!?
Find the one for you at Yahoo! Personals
http://personals.yahoo.com
-
To unsubscribe from this list: send the line
Quoted 13 lines
Quoted 2 lines
Quoted 2 lines
"unsubscribe linux-kernel" in
Quoted 1 line
the body of a message to
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Quoted 1 line
Please read the FAQ at
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
_________________________________________________________________________
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Terje Eggestad
[email protected]
Scali Scalable Linux SystemsQuoted 1 line
Quoted 1 line
Quoted 13 lines
Quoted 1 line
Quoted 1 line
Olaf Helsets Vei 6 tel: +47 22
62 89
Quoted 2 lines
Quoted 2 lines
61 (OFFICE)
P.O.Box 70 Bogerud +47 97531
Quoted 2 lines
Quoted 2 lines
574 (MOBILE)
N-0621 Oslo fax: +47 2262 89
Quoted 4 lines
Quoted 3 lines
51
NORWAY
_________________________________________________________________________
Quoted 9 lines
Quoted 7 lines
Quoted 1 line
__________________________________________________
Do You Yahoo!?
Find the one for you at Yahoo! Personals
http://personals.yahoo.com
_________________________________________________________________________
Quoted 5 lines
Terje Eggestad
[email protected]
Scali Scalable Linux Systems http://www.scali.com
Quoted 8 lines
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
_________________________________________________________________________
Quoted 1 line
__________________________________________________
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1