Re: Going up the call stack on a system call

Karim Yaghmour (karym@info.polymtl.ca)
Sun, 21 Nov 1999 16:03:25 -0500


Andi Kleen wrote:
>
> 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.
>

Actually this is for the Linux Trace Toolkit, therefore traces
have to be done in the kernel and that's why I'm implementing
backtracing in the kernel. The recording of the instruction
pointer of the caller has to, therefore, be done transparently
without affecting or modifying the system's behavior.

That said, I changed the code I posted to the following, this
is what's in the current LTT release and it doesn't crash
klogd and others now :

/* Are we in the kernel (This is a kernel thread)? */
if(!(regs->xcs & 3))
/* Don't go digining anywhere */
goto prepare_end;

....

/* Keep on going until we reach the end of the process' stack limit (wherever it may be) */
while( (((unsigned long)stack > current->mm->start_data)
&&((unsigned long)stack < current->mm->end_data))
||(((unsigned long)stack > current->mm->start_brk)
&&((unsigned long)stack < current->mm->brk))
||(((unsigned long)stack > current->mm->start_stack - current->rlim[RLIMIT_STACK].rlim_cur)
&&((unsigned long)stack < current->mm->start_stack)))
{
/* Get the current "address" off the stack, if it is addressable */
addr = *stack;

Will this still crash the machine if the page is swaped out?
Won't it simply generate a page fault which will result in
the page being brought back to memory? If it's the later,
it is still unacceptable since there's a modification to
the system's behavior, which is precisely what I want to
avoid.

Thanks for your help.

===================================================
Karim Yaghmour
karym@info.polymtl.ca
Operating System Consultant
(Linux kernel, real-time and distributed systems)
===================================================

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