EXPORT_SYMBOL and rebinding functions

AYAN KUMAR HALDER ayankumarh at gmail.com
Tue Jun 3 04:57:06 EDT 2014


Hi Peter,

I can think of two simple ways of achieving the same without messing
up with exported symbols.

1.  If your intention is to use a common api to call
function_1/my_print_function and function_2, then use a common
placeholder.
Assign it to function_1/my_print_function.
Use the placeholder to call function_1/my_print_function.
Reassign placeholder to function_2.
Use placeholder to call function_2.

2. A neater way would be to directly call
function_1/my_print_function and function_2. This would reduce
complexities.

About your code, I am not sure if you were able to compile the code
successfully because "my_print_fuction = function_2" is a potential
compilation error.

Even if compilation succeeds, the risk is any thread executing
simultaneously and using my_print_function (exported symbol) might
experience a weird behavior when it's definition is dynamically
changed by a different thread.

Hope this helps, lest I confused you.

Regards,
Ayan Kumar Halder

On Tue, Jun 3, 2014 at 10:51 AM, Greg KH <greg at kroah.com> wrote:
>
> A: No.
> Q: Should I include quotations after my reply?
>
> http://daringfireball.net/2007/07/on_top
>
> On Mon, Jun 02, 2014 at 10:10:16PM -0700, Peter Tosh wrote:
>> It's currently being done in a user space application which I am porting
>> to a kernel module. Is there some other way of accomplishing the same
>> thing safely?
>
> Again, what is such a thing being done _for_?
>
> Why are they doing this?
>
> And why would a userspace program need to be ported to the kernel?  What
> type of application is this?  What does it do?  Any pointers to the
> source to take a look at it?
>
> thanks,
>
> greg k-h
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



More information about the Kernelnewbies mailing list