[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

fix for kernel unaligned acc in 2.4.22 netfilter code



hi!

this fixed all kernel unaligned acc`s I had with 2.4.22

--
Juraj


the patch:

--- linux-2.4.22/net/core/filter.c      Mon Aug 25 13:44:44 2003
+++ linux-2.4.22-accfix/net/core/filter.c       Thu Oct 30 23:08:09 2003
@@ -202,7 +202,13 @@
                                k = fentry->k;
 load_w:
                                if(k >= 0 && (unsigned int)(k+sizeof(u32)) <= 
len) {
-                                       A = ntohl(*(u32*)&data[k]);
+                                       /*
+                                        *This is the kernel unalligned acc 
patch
+                                        * A = ntohl(*(u32*)&data[k]);
+                                        * */
+                                       u32 tmp;
+                                       memcpy(&tmp,&data[k],sizeof(u32));
+                                       A = ntohl(tmp);
                                        continue;
                                }
                                if (k<0) {
@@ -227,7 +233,13 @@
                                k = fentry->k;
 load_h:
                                if(k >= 0 && (unsigned int) (k + sizeof(u16)) 
<= len) {
-                                       A = ntohs(*(u16*)&data[k]);
+                                       /*
+                                        * kernel unaligned acc patch
+                                        * A = ntohs(*(u16*)&data[k]);
+                                        */
+                                       u16 tmp;
+                                       memcpy(&tmp,&data[k],sizeof(u16));
+                                       A = ntohs(tmp);
                                        continue;
                                }
                                if (k<0) {


diff -u -r linux-2.4.22/net/ipv4/netfilter/ip_tables.c 
linux-2.4.22-accfix/net/ipv4/netfilter/ip_tables.c
--- linux-2.4.22/net/ipv4/netfilter/ip_tables.c Mon Aug 25 13:44:44 2003
+++ linux-2.4.22-accfix/net/ipv4/netfilter/ip_tables.c  Fri Oct 31 00:52:40 
2003
@@ -259,7 +259,13 @@
             struct ipt_table *table,
             void *userdata)
 {
-       static const char nulldevname[IFNAMSIZ] = { 0 };
+       struct LALA
+       {
+               long lama;
+               char nulldevname[IFNAMSIZ];
+               long ofca;
+       };
+       struct LALA ofcolama = {0};
        u_int16_t offset;
        struct iphdr *ip;
        void *protohdr;
@@ -272,11 +278,13 @@
        struct ipt_entry *e, *back;
 
        /* Initialization */
+
+       
        ip = (*pskb)->nh.iph;
        protohdr = (u_int32_t *)ip + ip->ihl;
        datalen = (*pskb)->len - ip->ihl * 4;
-       indev = in ? in->name : nulldevname;
-       outdev = out ? out->name : nulldevname;
+       indev = in ? in->name :ofcolama.nulldevname;
+       outdev = out ? out->name :ofcolama.nulldevname;
        /* We handle fragments by dealing with the first fragment as
         * if it was a normal packet.  All other fragments are treated
         * normally, except that they will NEVER match rules that ask




Reply to: