Hi all,
I have changed the sys_call_table[__NR_socketcall] & implemented my own sys_setsockopt(). The code is exactly the same as the original sys_setsockopt().
Now after loading the module, I start getting this message randomly :
socki_lookup: socket file changed!
This comes from sockfd_lookup() if the struct file* from the process file table and sock do not match.
I have included my module code.
Regards, Swapnil.
PS: Sorry for cluttering the devel list but kernelnewbies list seems to be non functional.
#include <linux/module.h> #include <linux/kernel.h> #include <linux/errno.h> #include <asm/uaccess.h> #include <linux/unistd.h> #include <linux/net.h>
asmlinkage long (*save_sys_socketcall)(int call, unsigned long *args) = NULL;
extern void *sys_call_table[];
asmlinkage long my_setsockopt(int fd, int level, int optname, char *optval, int optlen) {
int err; struct socket *sock;
if (optlen < 0) return -EINVAL;
if ((sock = sockfd_lookup(fd, &err))!=NULL) {
if (level == SOL_SOCKET) err=sock_setsockopt(sock,level,optname,optval,optlen); else err=sock->ops->setsockopt(sock, level, optname, optval, optlen); fput(sock->file); /* since sockfd_put() is not exported */ }
return err; }
asmlinkage long my_socketcall(int call, unsigned long *args) {
int err; if (call == SYS_SETSOCKOPT) { unsigned long a[6];
if (copy_from_user(a, args, 5*sizeof(unsigned long))) { return -EFAULT; } return my_setsockopt(a[0], a[1], a[2], (char*)a[3], a[4]); }
return save_sys_socketcall(call, args); }
int init_mod() {
save_sys_socketcall = sys_call_table[__NR_socketcall]; sys_call_table[__NR_socketcall] = my_socketcall;
return 0; }
void exit_mod() { sys_call_table[__NR_socketcall] = save_sys_socketcall; }
module_init(init_mod); module_exit(exit_mod);
- : send the line "unsubscribe linux-net" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html