Skip to contentSkip to conversation

khttpd and tmpfs don't get along?

DISCUSSION Dan Kegel 2 participants 4 messages May 22, 2002

lore
Share & tools
lore

Dan Kegel

author
#0 lore raw

I've found that khttpd tends to oops when used with tmpfs. The oops tracebacks are not especially informative. So far, I've only verified this with ppc, but I should be able to verify it with x86 soon.
- Dan

#1 lore raw
Quoted 4 lines · Dan Kegel

I've found that khttpd tends to oops when used with tmpfs. The oops tracebacks are not especially informative. So far, I've only verified this with ppc, but I should be able to verify it with x86 soon.

That's because it abuses do_generic_file_read. It' the same design mistake that also makes loop fail on tmpfs - do_generic_file_read should never have been exported from filemap.c..

author
#2 lore raw
In reply to Dan Kegel
Quoted 10 lines · Christoph Hellwig
Quoted 4 lines · Dan Kegel

I've found that khttpd tends to oops when used with tmpfs. The oops tracebacks are not especially informative. So far, I've only verified this with ppc, but I should be able to verify it with x86 soon.

That's because it abuses do_generic_file_read. It' the same design mistake that also makes loop fail on tmpfs - do_generic_file_read should never have been exported from filemap.c..

I see. Guess I should finally test that tmpfs/loop patch, eh? :-)

I just now crashed Red Hat 7.3 on x86 SMP by compiling in khttpd and serving files out of a tmpfs. It crashed with or without my earlier patch (http://www.kegel.com/linux/khttpd/khttpd-unbork.patch)
that fixes khttpd crashes with other filesystems.
Guess it wasn't a bug in linuxppc_2_4_devel after all.

I am now switching to ramfs instead of tmpfs to hold my documentroot, and that should be the end of my khttpd problems.
(There is no disk on the embedded ppc system I'm using, so I have to use one ram filesystem or another.)
- Dan

#3 lore raw
In reply to Dan Kegel
Quoted 5 lines · Dan Kegel

I just now crashed Red Hat 7.3 on x86 SMP by compiling in khttpd and serving files out of a tmpfs. It crashed with or without my earlier patch (http://www.kegel.com/linux/khttpd/khttpd-unbork.patch)
that fixes khttpd crashes with other filesystems.
Guess it wasn't a bug in linuxppc_2_4_devel after all.

I doubt it. the use of do_generic_file_read outside of code the filesystem has selected to use (i.e. generic methods) is FUNDAMENTALLY broken.

Some time ago I though I found a similar bug in XFS, but Steve Lord says it's not exploitable in real world (XFS uses the generic methods with additional locking around it).

The only sane soloution is to get rid of that abuse in khttpd, loop and sys_sendfile.