Re: Fwd: Calling syscalls from x86-64 kernel results in a crash onOpteron machines

From: Richard B. Johnson
Date: Mon Sep 13 2004 - 10:02:37 EST


On Mon, 13 Sep 2004, Constantine Gavrilov wrote:

> >
> >
> >Subject: Calling syscalls from x86-64 kernel results in a crash on Opteron machines
> >Date: Mon, 13 Sep 2004 17:04:17 +0300
> >From: Constantine Gavrilov <constg@xxxxxxxxxxxx>
> >To: bugs@xxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx
> >
> >Hello:
> >
> >We have a piece of kernel code that calls some system calls in kernel
> >context (from a process with mm and a daemonized kernel thread that does
> >not have mm). This works fine on IA64 and i386 architectures.
> >
> ..............

Okay, It's a real process that has its own context.

>
> >Attached please find a test module that tries to call the umask() (JUST
> >TO DEMONSTRATE a problem) via the syscall machanism. Both methods (the
> >_syscall1() marco and GLIBC INLINE_SYCALL() were used.
> >
> >
>

You can't use the user-mode syscalls! You need to use the kernel
procedures to which they trap (like sys_open(), etc.). The reason
is that you are operating on the kernel stack, you then generate a
trap for the system call, which starts over again on the kernel
stack (overwriting your previous return addresses, etc.).

A kernel-mode daemon has a context of its own, but it shares
kernel data and stack.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.26 on an i686 machine (5570.56 BogoMips).
Note 96.31% of all statistics are fiction.

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