Re: Going up the call stack on a system call

Andi Kleen (ak-uu@muc.de)
21 Nov 1999 12:44:07 +0100


karym@info.polymtl.ca (Karim Yaghmour) writes:
> {
> #if 1 /* This slows the system horibly and doesn't work */
> /* Do we have access to this region */
> if(!access_ok(VERIFY_READ, stack, sizeof(addr)))
> /* Don't go any further, otherwise we cause applications to crash since we
> generate page faults in the wrong places. */
> goto prepare_end;
>
> /* Get the current "address" of the stack */
> __get_user(addr, stack);

This should be if (get_user(addr, stack)) goto prepare_end;
Don't play with access_ok. The real access checking is done inside
the *_user function, access_ok only checks for kernel address
or not (it has very different semantics from the old verify_area !)

> #else /* This results in the death of klogd and others because of unresolved references */
> /* Get the current "address" off the stack */
> addr = *stack;

This will crash the machine when the page is swapped out.

A much simpler alternative: send some signal (e.g. SIGPWR) with send_sig(),
then return with -ERESTARTSYS if you want to be restarted, or some other
return value if you don't. Then the user can dump the backtrace with glibc's
backtrace() function or with gdb. They work with shared libraries too.

-Andi

-- 
This is like TV. I don't like TV.

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/