public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Executing binaries on new filesystem
@ 2001-11-17 22:18 Rock Gordon
  2001-11-17 22:24 ` Mike Fedyk
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Rock Gordon @ 2001-11-17 22:18 UTC (permalink / raw)
  To: linux-kernel

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

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

* Re: Executing binaries on new filesystem
  2001-11-17 22:18 Executing binaries on new filesystem Rock Gordon
@ 2001-11-17 22:24 ` Mike Fedyk
  2001-11-18  0:08 ` Eric W. Biederman
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Mike Fedyk @ 2001-11-17 22:24 UTC (permalink / raw)
  To: Rock Gordon; +Cc: linux-kernel

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

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

* Re: Executing binaries on new filesystem
  2001-11-17 22:18 Executing binaries on new filesystem Rock Gordon
  2001-11-17 22:24 ` Mike Fedyk
@ 2001-11-18  0:08 ` Eric W. Biederman
  2001-11-18  0:54 ` Jeff Dike
  2001-11-18 15:13 ` Terje Eggestad
  3 siblings, 0 replies; 10+ messages in thread
From: Eric W. Biederman @ 2001-11-18  0:08 UTC (permalink / raw)
  To: Rock Gordon; +Cc: linux-kernel

Rock Gordon <rockgordon@yahoo.com> 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

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

* Re: Executing binaries on new filesystem
  2001-11-17 22:18 Executing binaries on new filesystem Rock Gordon
  2001-11-17 22:24 ` Mike Fedyk
  2001-11-18  0:08 ` Eric W. Biederman
@ 2001-11-18  0:54 ` Jeff Dike
  2001-11-18 15:13 ` Terje Eggestad
  3 siblings, 0 replies; 10+ messages in thread
From: Jeff Dike @ 2001-11-18  0:54 UTC (permalink / raw)
  To: Rock Gordon; +Cc: linux-kernel

rockgordon@yahoo.com 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


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

* Re: Executing binaries on new filesystem
  2001-11-17 22:18 Executing binaries on new filesystem Rock Gordon
                   ` (2 preceding siblings ...)
  2001-11-18  0:54 ` Jeff Dike
@ 2001-11-18 15:13 ` Terje Eggestad
  2001-11-19 16:34   ` Rock Gordon
  3 siblings, 1 reply; 10+ messages in thread
From: Terje Eggestad @ 2001-11-18 15:13 UTC (permalink / raw)
  To: Rock Gordon; +Cc: linux-kernel

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 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/
>

-- 
_________________________________________________________________________

Terje Eggestad                  terje.eggestad@scali.no
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
_________________________________________________________________________


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

* Re: Executing binaries on new filesystem
  2001-11-18 15:13 ` Terje Eggestad
@ 2001-11-19 16:34   ` Rock Gordon
  2001-11-19 23:45     ` Ryan Cumming
                       ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Rock Gordon @ 2001-11-19 16:34 UTC (permalink / raw)
  To: Terje Eggestad; +Cc: linux-kernel

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 <terje.eggestad@scali.no> 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 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/
> >
> 
> -- 
>
_________________________________________________________________________
> 
> Terje Eggestad                 
> terje.eggestad@scali.no
> 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

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

* Re: Executing binaries on new filesystem
  2001-11-19 16:34   ` Rock Gordon
@ 2001-11-19 23:45     ` Ryan Cumming
  2001-11-20  3:39     ` Eric W. Biederman
  2001-11-20  9:34     ` Terje Eggestad
  2 siblings, 0 replies; 10+ messages in thread
From: Ryan Cumming @ 2001-11-19 23:45 UTC (permalink / raw)
  To: Rock Gordon; +Cc: linux-kernel

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

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

* Re: Executing binaries on new filesystem
  2001-11-19 16:34   ` Rock Gordon
  2001-11-19 23:45     ` Ryan Cumming
@ 2001-11-20  3:39     ` Eric W. Biederman
  2001-11-20  9:34     ` Terje Eggestad
  2 siblings, 0 replies; 10+ messages in thread
From: Eric W. Biederman @ 2001-11-20  3:39 UTC (permalink / raw)
  To: Rock Gordon; +Cc: Terje Eggestad, linux-kernel

Rock Gordon <rockgordon@yahoo.com> 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



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

* Re: Executing binaries on new filesystem
  2001-11-19 16:34   ` Rock Gordon
  2001-11-19 23:45     ` Ryan Cumming
  2001-11-20  3:39     ` Eric W. Biederman
@ 2001-11-20  9:34     ` Terje Eggestad
  2001-11-28  1:43       ` Rock Gordon
  2 siblings, 1 reply; 10+ messages in thread
From: Terje Eggestad @ 2001-11-20  9:34 UTC (permalink / raw)
  To: Rock Gordon; +Cc: linux-kernel

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 <terje.eggestad@scali.no> 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 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/
> > >
> > 
> > -- 
> >
> _________________________________________________________________________
> > 
> > Terje Eggestad                 
> > terje.eggestad@scali.no
> > 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                  terje.eggestad@scali.no
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            
_________________________________________________________________________


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

* Re: Executing binaries on new filesystem
  2001-11-20  9:34     ` Terje Eggestad
@ 2001-11-28  1:43       ` Rock Gordon
  0 siblings, 0 replies; 10+ messages in thread
From: Rock Gordon @ 2001-11-28  1:43 UTC (permalink / raw)
  To: Terje Eggestad; +Cc: linux-kernel

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 <terje.eggestad@scali.no> 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 <terje.eggestad@scali.no>
> 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
> 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/
> > > >
> > > 
> > > -- 
> > >
> >
>
_________________________________________________________________________
> > > 
> > > Terje Eggestad                 
> > > terje.eggestad@scali.no
> > > 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                 
> terje.eggestad@scali.no
> 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

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

end of thread, other threads:[~2001-11-28  1:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-11-17 22:18 Executing binaries on new filesystem Rock Gordon
2001-11-17 22:24 ` Mike Fedyk
2001-11-18  0:08 ` Eric W. Biederman
2001-11-18  0:54 ` Jeff Dike
2001-11-18 15:13 ` Terje Eggestad
2001-11-19 16:34   ` Rock Gordon
2001-11-19 23:45     ` Ryan Cumming
2001-11-20  3:39     ` Eric W. Biederman
2001-11-20  9:34     ` Terje Eggestad
2001-11-28  1:43       ` Rock Gordon

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