Re: syscall from kernel thread?

From: Tigran Aivazian (tigran@veritas.com)
Date: Mon May 08 2000 - 11:24:01 EST


On Mon, 8 May 2000, Peter T. Breuer wrote:

> I didn't get any response when I asked about changes designed to help
> a module unload _itself_. I have the code working, but lets see if I
> can phrase a question that would enable me to avoid changing kernel
> interfaces ...
>
> 1) how can kernel code make use of a syscall? In particular I want to call
> sys_delete_module. But module.c only has a userspace interface and is
> linked with asmlinkage, so I've hacked out the code fragments I
> needed. Can I avoid doing this?

yes, using the standard trick

mm_segment_t old_fs = get_fs();
set_fs(KERNEL_DS);
pass kernel addresses pretending they are user addresses
set_fs(old_fs);

>
> Thanks for any pointers. Incidentally, a module that unloads itself,
> or part of itself, is kinda cute. It works nicely.
>

are you sure it is not insane? I mean delete_module will also free_module
which will module_unmap (i.e. vfree() really)- how are you successfully
unmapping the text which is currently being executed?

Regards,
Tigran

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



This archive was generated by hypermail 2b29 : Mon May 15 2000 - 21:00:11 EST