Re: Strangest bug

Khimenko Victor (khim@sch57.msk.ru)
Sat, 24 Jul 1999 02:13:49 +0400 (MSD)


In <Pine.GSO.4.03.9907231529080.15129-100000@csa.bu.edu> Stanislav Krasilovskiy (prgrssor@cs.bu.edu) wrote:
> Hi,

> I am fairly new to kernel hacking, so forgive my stupidity. I have
> encountered a very strange bug and need help from someone who knows
> a lot about the kernel.

Not a lot. This particulat problem need fairly minimal knowledge about
*nix design...

> Description of the problem: A process passes a pointer allocated in the
> user space to the kernel through a custom system call. This pointer is
> then saved for future reference.

> Upon an interrupt, a kernel routine uses this saved pointer with
> copy_from_user() to obtain a copy of that structure. The problem is,
> every now and then the values in the structure are bogus!

Of course. It should be.

> This is not due to memory corruption (in the user process, I
> continuously print out the values, and they are fine). When I use
> mlock() on the structure, then the problem no longer occurs (the copy
> reflects accurate values). So the problem has something to do with
> virtual addressing and paging...

> If you can think of a reason why this might be happening, or how to fix
> this, please help me. If you need additional bits of information, I'll
> gladly supply it.

You just can not do it. You can not "save pointer to userspace for future use
in interrupt handler". That's all.

> I am using RH 6.0 w/kernel 2.2.5.

What you are doing is wrong in first place. Interrupt can be served in
completely different context. Where userspace belond to competely other
process. It can be even on disk ! How you will access data on disk from
interrupt handler ??? You do not need to know much about kernel internals
to understood stupidity of this...

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