Linux Kernel - Modifying a module_param variable from other drivers
Valdis.Kletnieks at vt.edu
Valdis.Kletnieks at vt.edu
Thu Nov 14 16:03:43 EST 2013
On Thu, 14 Nov 2013 18:32:05 +0900, manty kuma said:
> I see that when we declare a variable as module_param from a driver, i can
> see it listed in "/sys/module/xxx/parameters/...".
>
> Ex : /sys/module/usbcore/parameters/autosuspend
>
> we can modify and read it with echo and cat commands from terminal.
>
> But is there a way i can read this value from other drivers? Common sense
> says it should be there because if we are able to access them from user
> space, from kernel space we should definitely be able to do. Is it so? If
> yes, what are the API's?
It's just a variable. Read the source and find out what it's name is.
You may need an EXPORT_SYMBOL() to make it available if it isn't already.
And depending on the variable and its use, you may need locking and/or
atomic operations to read it.
And *modifying* another module's variables is just asking for trouble,
mostly because very little code is written assuming that its variables may
be maliciously modified out from under it. So consider code like:
int foo_size, i;
struct bar *stuff;
stuff = malloc(foo_size* sizeof(struct bar));
/* somebody raises the value of foo_size from outside */
for (i=0; i < foo_size; i++) do_something(stuff[i]);
You can see where that sort of stuff is heading....
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 865 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20131114/82278b96/attachment.bin
More information about the Kernelnewbies
mailing list