pass function argument as Addr

Ask your beginner questions here.
Post Reply
nimaarek
Posts: 5
Joined: Tue Jun 23, 2015 3:51 am

pass function argument as Addr

Post by nimaarek » Sat Jul 28, 2018 9:46 pm

Hi,
I have a beginner problem, but I can not answer and can not find it :roll:

I want to use a kernel function, one of its values is the memory address As a result, I wrote an in the user-mode program to print a variable's address. Something like this:

Code: Select all

int main()
{
	while(1)
	{
        printf("%x", &a);
	}
	return 0;
}
And I used the kernel function this way:

Code: Select all

#include <linux/module.h>
#include <linux/kernel.h>

int hello_init (void)
{
    int result = access_ok( VERIFY_WRITE, [color=#FF0000]addr[/color], 10);
    printk ("Hello, result = %d\n", result );
    return 0;
}

void hello_exit (void)
{
    printk ("Goodbye");
}

module_init(hello_init);
module_exit(hello_exit);
Now how does the output of the user-mode application that contains the variable address is entered as a parameter(addr) to the access_ok function like this?

User avatar
EP_X0FF
Global Moderator
Posts: 4812
Joined: Sun Mar 07, 2010 5:35 am
Location: Russian Federation
Contact:

Re: pass function argument as Addr

Post by EP_X0FF » Thu Aug 09, 2018 4:42 pm

Your kernel module lacks most of code.

http://derekmolloy.ie/writing-a-linux-k ... er-device/
Ring0 - the source of inspiration

nimaarek
Posts: 5
Joined: Tue Jun 23, 2015 3:51 am

Re: pass function argument as Addr

Post by nimaarek » Fri Aug 10, 2018 8:40 am

Thank you, but I was wondering something else
The code I provided was an example
I wanted to know if the parameter of this function is an address
How does the kernel determine which address is for which processor?

User avatar
EP_X0FF
Global Moderator
Posts: 4812
Joined: Sun Mar 07, 2010 5:35 am
Location: Russian Federation
Contact:

Re: pass function argument as Addr

Post by EP_X0FF » Fri Aug 10, 2018 1:12 pm

Ring0 - the source of inspiration

Post Reply