Skip to contentSkip to conversation

2.6.0-mm1 - kernel panic (VFS bug?)

DISCUSSION Andi Kleen 4 participants 5 messages Jan 6, 2004 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Andi Kleen

author
#1 lore raw
Quoted 6 lines · Libor Vanek

...
asmlinkage long sys_open(const char __user * filename, int flags, int mode)

{
        char * tmp;
        int fd, error;
	char tmp_path[PATH_MAX],tmp2_path[PATH_MAX];

PATH_MAX is 4096. The i386 stack is only 6k. You already overflowed it. You're lucky if your machine only panics, much worse things can happen with kernel stack overflows.

-Andi

#2 lore raw
Quoted 11 lines · Andi Kleen
Quoted 8 lines · Libor Vanek

...
asmlinkage long sys_open(const char __user * filename, int flags, int mode)

{
       char * tmp;
       int fd, error;
	char tmp_path[PATH_MAX],tmp2_path[PATH_MAX];
Quoted 5 lines

PATH_MAX is 4096. The i386 stack is only 6k. You already overflowed it. You're lucky if your machine only panics, much worse things can happen with kernel stack overflows.

OK - what's correct implementation? Do a "char * tmp_path" and kmalloc it?

Signature · 1 line
Libor Vanek
#3 lore raw
Quoted 1 line

OK - what's correct implementation? Do a "char * tmp_path" and kmalloc it?

Use getname()/putname()

-Andi

#4 lore raw
Quoted 6 lines · Andi Kleen
Quoted 3 lines

OK - what's correct implementation? Do a "char * tmp_path" and kmalloc it?

Use getname()/putname()

I thought that these are used for copying data to/from userspace...

Signature · 1 line
Libor Vanek
#5 lore raw
In reply to Libor Vanek
Quoted 6 lines · Libor Vanek
Quoted 3 lines

PATH_MAX is 4096. The i386 stack is only 6k. You already overflowed it. You're lucky if your machine only panics, much worse things can happen with kernel stack overflows.

OK - what's correct implementation? Do a "char * tmp_path" and kmalloc it?

Generally speaking, yes. That way you get reentrancy for free and don't use up too much kernel stack. If speed is of the utmost importance, there are other possible solutions.

Cheers,
Muli

Signature · 4 lines
Muli Ben-Yehuda
http://www.mulix.org | http://mulix.livejournal.com/

"the nucleus of linux oscillates my world" - gccbot@#offtopic