Re: question about get_user

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




in your kernel module try to print current->pid
is it same as the user space process id ?
i think when in kernel module you are not in the same process context whihc you want to refer ...


Nidhi

On Wed, Apr 28, 2010 at 10:38 AM, Yang Fangkai <wolfgang.yang@xxxxxxxxx> wrote:
Hi, all,

I have a problem with get_user() macro. What I did is as follows:

I run the following program

int main()
{
      int a = 20;
      printf("address of a: %p", &a);
      sleep(200);
      return 0;
}

When the program runs, it outputs the address of a, say, 0xbff91914.

Then I pass this address to a module running in Kernel Mode that
retrieves the contents at this address (at the time when I did this, I
also made sure the process didn't terminate, because I put it to sleep
for 200 seconds... ):

The address is firstly sent as a string, and I cast them into pointer type.

int * ptr = (int*)simple_strtol(buffer, NULL,16);
printk("address: %p",ptr); // I use this line to make sure the cast is
correct. When running, it does output bff91914
int val = 0;
int res;
res= get_user(val, (int*) ptr);

However, res is always not 0, meaning that get_user returns error. I
am wondering what is the problem....

Thank you!!

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ




--
Thanks & Regards
Nidhi Mittal Hada
Scientific officer D
Computer Division
Bhabha Atomic Research Center
Mumbai



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux