Find the answer to your Linux question:
Results 1 to 6 of 6
Hi, Can someone kindly let me know if it is possible to access the user process' address space from a kernel thread. I tried changing the mm pointer from NULL ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2007
    Posts
    1

    Access user address from the kernel


    Hi,
    Can someone kindly let me know if it is possible to access the user process' address space from a kernel thread.
    I tried changing the mm pointer from NULL to a user space mm but it OOPSed giving page fault error.(Or is there anything else i need to apart from resetting the mm pointer and active_mm pointer to user thread's mm and active_mm?)

    I also tried to tried to reset the cr3 register of the processor executing the kernel thread to the user thread's cr3(My machine has 2 processors) but it didnt help either.
    I am stuck with this for a loong time now.Kindly let me know if this is possible.
    Thanks a lot,
    KA

  2. #2
    Just Joined! stevexyz's Avatar
    Join Date
    Jan 2007
    Posts
    3
    Although I have no idea why you might be trying to do this, is there a very good reason why you can't use one of the established mechanisms for user <-> kernel communication?

  3. #3
    Linux Newbie burntfuse's Avatar
    Join Date
    Nov 2006
    Location
    Laurel, MD
    Posts
    158
    I'm not a kernel hacker, but I think there's a function called copy_to_user that's for copying from kernelspace memory to userspace memory.
    I have sold my soul to the penguin

  4. #4
    Just Joined!
    Join Date
    Mar 2007
    Posts
    2

    trouble over copy_to_user

    Hi,

    I used copy_to_user in kernel 2.6.18.1.2798-fc6. I made update to 2.6.20.1 and reboot, my program start to fail on this particular call. Anyone has idea?

    Thanks!

  5. #5
    Linux Newbie dilbert's Avatar
    Join Date
    Sep 2006
    Location
    Yorkshire, GB
    Posts
    237
    For copy_to_user() I queried always access_ok() before. Not for copy_from_usser. I don't remember anymore why. I only remember that I spent some time with this.
    (BTW, the example is from a 2.4.x driver.)


    if (copy_from_user (&hxx_afe_if, rq->ifr_data, sizeof(hxx_afe_if)))
    {
    return -EFAULT;
    }

    if (0 != access_ok(VERIFY_WRITE, &rq->ifr_data, sizeof(data)))
    {
    return -EFAULT;
    }
    else
    {
    if ((result = copy_to_user (rq->ifr_data, &hxx_afe_if, sizeof(hxx_afe_if))))
    {
    return -EFAULT;
    }
    }
    Bus Error: Passengers dumped. Hech gap yo'q.

  6. #6
    Just Joined!
    Join Date
    Mar 2007
    Posts
    2

    Invalid module format response from modprobe

    Thanks Dilbert for your response!

    I made mistake. It may not be copy_to_user problem. I think I copied my driver into wrong place (for older version of kernel) that caused the ioctl function not work which used copy_to_user in the ioctl. However, I am having trouble to insmod or modprobe my driver. I got "Invalid module format" after my mobprobe.

    Anyone has idea?

    Allen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •