Patch for 2.6.12 and +
Nicolas DET <[email protected]>
| Newsgroups | gmane.linux.debian.ports.powerpc,gmane.linux.ports.ppc.mol.general |
|---|---|
| Message-ID | <[email protected]> |
Hello, You can find enclosed and here http://arrakin.homedns.org/~nicolas/mol-0.9.70_patch_2.6.14-rc1.diff a patch for MOL modules. Changes: * properly handles different sk_alloc() proto. Indeed, the API changed since 2.6.12 * Use access_ok() instead of verify_data() which is obsolete. The patch has been tested on 2.6.12, 2.6.13 and 2.6.14-rc1 Regards, -- Nicolas DET MorphOS & Linux developer
mol-0.9.70_patch_2.6.14-rc1.diff
(application/octet-stream, 4.5 KB)
diff -ur mol-0.9.70.orig/src/kmod/include/misc.h mol-0.9.70.nico/src/kmod/include/misc.h
--- mol-0.9.70.orig/src/kmod/include/misc.h 2005-09-14 09:58:21.138588750 +0200
+++ mol-0.9.70.nico/src/kmod/include/misc.h 2005-09-14 09:59:13.805880250 +0200
@@ -17,6 +17,21 @@
#ifndef _H_MOD
#define _H_MOD
+/*
+ * * Nico
+ * */
+
+#include <linux/version.h>
+#include <asm/uaccess.h>
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+#define compat_verify_area(a,b,c) ( ! access_ok(a,b,c) )
+#else
+#define compat_verify_area(a,b,c) verify_area(a,b,c)
+#endif
+
+
+
extern int g_num_sessions; /* number of active sessions */
struct kernel_vars;
diff -ur mol-0.9.70.orig/src/kmod/Linux/dev.c mol-0.9.70.nico/src/kmod/Linux/dev.c
--- mol-0.9.70.orig/src/kmod/Linux/dev.c 2005-09-14 09:58:21.090585750 +0200
+++ mol-0.9.70.nico/src/kmod/Linux/dev.c 2005-09-14 09:59:44.027769000 +0200
@@ -153,7 +153,7 @@
switch( cmd ) {
case MOL_IOCTL_GET_DIRTY_FBLINES: /* short *retbuf, int size -- npairs */
- if( verify_area(VERIFY_WRITE, (short*)p1, p2) )
+ if( compat_verify_area(VERIFY_WRITE, (short*)p1, p2) )
break;
ret = get_dirty_fb_lines( kv, (short*)p1, p2 );
break;
@@ -188,7 +188,7 @@
break;
case MOL_IOCTL_SET_RAM: /* void ( char *lvbase, size_t size ) */
- if( verify_area(VERIFY_WRITE, (char*)p1, p2) )
+ if( compat_verify_area(VERIFY_WRITE, (char*)p1, p2) )
break;
kv->mmu.linux_ram_base = (char*)p1;
kv->mmu.ram_size = p2;
diff -ur mol-0.9.70.orig/src/netdriver/sheep.c mol-0.9.70.nico/src/netdriver/sheep.c
--- mol-0.9.70.orig/src/netdriver/sheep.c 2005-09-14 09:58:22.602680250 +0200
+++ mol-0.9.70.nico/src/netdriver/sheep.c 2005-09-14 10:13:22.338910250 +0200
@@ -80,7 +80,13 @@
*/
#ifdef LINUX_26
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12))
+#define compat_sk_alloc(a,b,c) sk_alloc( (a), (b), &mol_proto, 1 )
+#else
#define compat_sk_alloc(a,b,c) sk_alloc( (a), (b), (c), NULL )
+#endif
+
#define skt_set_dead(skt) do {} while(0)
#define wmem_alloc sk_wmem_alloc
#else
@@ -156,8 +162,14 @@
* the IP address is wrong.)
*/
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14))
+static int
+sheep_net_receiver( struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev )
+#else
static int
sheep_net_receiver( struct sk_buff *skb, struct net_device *dev, struct packet_type *pt )
+#endif
{
int multicast = (ETH_HDR(skb)->h_dest[0] & ETH_ADDR_MULTICAST);
const char *laddr = dev->dev_addr;
@@ -242,6 +254,15 @@
/************************************************************************/
/* misc device ops */
/************************************************************************/
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12))
+static struct proto mol_proto =
+{
+ .name = "MOL",
+ .owner = THIS_MODULE,
+ .obj_size = sizeof(struct sock)
+};
+#endif
+
static int
sheep_net_open( struct inode *inode, struct file *f )
@@ -250,6 +271,13 @@
struct SheepVars *v;
D(bug("sheep_net: open\n"));
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12))
+ if (proto_register(&mol_proto,0) < 0)
+ {
+ printk(KERN_INFO "Unable to register protocol type\n");
+ return -1;
+ }
+#endif
// Must be opened with read permissions
if( (f->f_flags & O_ACCMODE) == O_WRONLY )
return -EPERM;
@@ -257,6 +285,7 @@
// Allocate private variables
if( !(v=(struct SheepVars *)f->private_data=kmalloc(sizeof(*v), GFP_USER)) )
return -ENOMEM;
+
memset( v, 0, sizeof(*v) );
memcpy( v->fake_addr, fake_addr_, 6 );
@@ -286,6 +315,10 @@
while( (skb=skb_dequeue(&v->queue)) )
kfree_skb(skb);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12))
+ proto_unregister(&mol_proto);
+#endif
+
// Free private variables
kfree(v);
return 0;
diff -ur mol-0.9.70.orig/src/netdriver/tun.c mol-0.9.70.nico/src/netdriver/tun.c
--- mol-0.9.70.orig/src/netdriver/tun.c 2005-09-14 09:58:22.594679750 +0200
+++ mol-0.9.70.nico/src/netdriver/tun.c 2005-09-14 09:59:30.534925750 +0200
@@ -240,7 +240,7 @@
DBG(KERN_INFO "%s: tun_chr_write %d\n", tun->name, count);
for (i = 0, len = 0; i < count; i++) {
- if (verify_area(VERIFY_READ, iv[i].iov_base, iv[i].iov_len))
+ if (compat_verify_area(VERIFY_READ, iv[i].iov_base, iv[i].iov_len))
return -EFAULT;
len += iv[i].iov_len;
}
@@ -304,7 +304,7 @@
DBG(KERN_INFO "%s: tun_chr_read\n", tun->name);
for (i = 0, len = 0; i < count; i++) {
- if (verify_area(VERIFY_WRITE, iv[i].iov_base, iv[i].iov_len))
+ if (compat_verify_area(VERIFY_WRITE, iv[i].iov_base, iv[i].iov_len))
return -EFAULT;
len += iv[i].iov_len;
}