lkml.org 
[lkml]   [2000]   [Oct]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
Subjectexecuting a user space function in kernel module
Hi,


struct t{
int (*x)(int);
}fstruct;

main()
{
.
.
fstruct.x = f;
./*write fstruct to a device file*/
.
}

int f(int i)
{
printf("got %d\n",i);
return i;
}


i pass this structure to kernel module by writting to device file.
the write function of module is like

..
..
char *kbuf;
struct t *fstruct;
kbuf = kmalloc(count*sizeof(char), GFP_KERNEL);
copy_from_user((void*)kbuf,(void*)buf,count);
if( (filp->f_flags & O_ACCMODE) == O_WRONLY)
fstruct = (struct t*)kbuf;
printk("calling from kernel:%d\n",(fstruct->x)(8));
...

Now, is there any problem in executing a user space function in a kernel
module
by just passing a function pointer to the module????

In Linux, is it possible to execute a function in kernel which is a part of
user application
and hence a part of user address space??

Thanks,
daljeet



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:39    [W:0.066 / U:0.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site