[parisc-linux] Re: Yet another '__canonicalize_funcptr_for_compare' pb
John David Anglin
dave@hiauly1.hia.nrc.ca
Sat, 10 May 2003 17:21:44 -0400 (EDT)
> dev = __dev_get_by_name(ifr->ifr_name);
> if (dev) {
> /* Device exist */
> tun = dev->priv;
>
> if (dev->init != tun_net_init || tun->attached)
> return -EBUSY;
>
> /* Check permissions */
> ...
>
> I suspect first if(dev) because dev is a pointer to a struct but finaly
> it is in "if (dev->init != tun_net_init..." which would become "if
> (dev->init != (void*)tun_net_init...".
__canonicalize_funcptr_for_compare is only used in comparisons involving
function pointers.
> Is it the right workaround? fixe?
Probably. There are some tricky issues with respect to loadable
kernel modules.
> I have another stupid question: as hppa seems to be the only platform
> requiring this stuff and I don't see how to check all src to track this
> pb (practicaly only try and chess?), how much would it be difficult to
> implement this __canonicalize_funcptr_for_compare into the hppa lib kernel?
You can tell if a kernel or module uses __canonicalize_funcptr_for_compare
with nm. If you find it's used somewhere, check each object module for
it. You can find the code location of it with "objdump -d". This will
give a pretty good idea where in the source the comparison occurs.
As to a kernel implementation, this is hard. If the function pointer
is in user space, canonicalization requires a bunch of tests and then
a call to code in the dynamic loader in the user program.
As far as function pointers in the kernel address space, this would
take some research. Direct comparison (i.e., using "void *" casts)
will work ok as long as the pointer either points directly to the
kernel function involved or unique plabels are used. If all
kernel function addresses get bound immediately when a module
is loaded, this would simplify the situation and the canonicalization
could be done simply by looking at the function address in the plabel.
The exact details depend on how the kernel and modules are linked.
The reason why function pointer canonicalization is needed on the
pa is that there can be several plabels pointing to the same function
a user program.
Dave
--
J. David Anglin dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6602)