Solaris 9 kernel panic on SPARCstation 10 with "Memory address
alignment" exception during bootup. Anybody plays with sun4m...? :)
IPFilter 4.1.24 compiled with Sun Studio 11 C Compiler.
The trap occured in kernel's function atomic_add_64():
<------------------------------------------------------------------------->
> $c
atomic_add_64+0x4c(f6027e44, 0, 1, 160c8, 5620d4, 0)
fr_scanlist+0x3fc(fbe3eaa4, 8000002, 23, 0, 8, 600)
fr_firewall+0x180(fbe3eaa4, fbe3ea9c, f0260ad0, f61a7e5c, 8, 0)
fr_check+0x444(f5f02030, 14, f5f37f08, 0, fbe3ec3c, fbe3ed60)
pfil_precheck+0xbe4(0, fbe3ed60, 1, f5f37f08, 1, 600)
[...]
> atomic_add_64+0x4c/i
atomic_add_64+0x4c:             ldd       [%i0], %l0
<------------------------------------------------------------------------->

The patch attached below solved this problem for me.

-Mirek
PS: Sun's cc generates 32-bit code for the SPARC-V8+ architecture by
default, so we have to force V8.

<------------------------------------------------------------------------->
diff -ru ip_fil4.1.24-orig/buildsunos ip_fil4.1.24/buildsunos
--- ip_fil4.1.24-orig/buildsunos        Thu Mar 16 07:40:10 2006
+++ ip_fil4.1.24/buildsunos     Wed Aug  1 14:00:39 2007
@@ -89,8 +89,8 @@
                XARCH64_i386="-m64 -mcmodel=kernel -mno-red-zone -ffreestanding"
                ;;
        *)      # Sun C
-               XARCH32="-Xa -xildoff"
-               XARCH64_sparc="$XARCH32 -xarch=v9 -xchip=ultra -dalign 
-xcode=abs32"
+               XARCH32="-Xa -xildoff -xarch=v8 -xmemalign=8s"
+               XARCH64_sparc="-Xa -xildoff -xarch=v9 -xchip=ultra 
-xmemalign=8s -xcode=abs32"
                XARCH64_i386="$XARCH32 -xarch=amd64 -xcode=abs32"
                ;;
        esac
diff -ru ip_fil4.1.24-orig/ip_auth.h ip_fil4.1.24/ip_auth.h
--- ip_fil4.1.24-orig/ip_auth.h Fri Jul 14 08:12:05 2006
+++ ip_fil4.1.24/ip_auth.h      Tue Jul 31 13:52:56 2007
@@ -33,8 +33,8 @@
 } frauthent_t;

 typedef struct  fr_authstat {
-       U_QUAD_T        fas_hits;
-       U_QUAD_T        fas_miss;
+       uint64_t        fas_hits;
+       uint64_t        fas_miss;
        u_long          fas_nospace;
        u_long          fas_added;
        u_long          fas_sendfail;
diff -ru ip_fil4.1.24-orig/ip_fil.h ip_fil4.1.24/ip_fil.h
--- ip_fil4.1.24-orig/ip_fil.h  Wed Jul  4 23:48:23 2007
+++ ip_fil4.1.24/ip_fil.h       Tue Jul 31 13:51:59 2007
@@ -304,6 +304,7 @@


 typedef        struct  fr_info {
+       struct  frentry *fin_fr;        /* last matching rule */
        void    *fin_ifp;               /* interface packet is `on' */
        fr_ip_t fin_fi;         /* IP Packet summary */
        union   {
@@ -317,7 +318,6 @@
        u_char  fin_icode;              /* ICMP error to return */
        u_32_t  fin_rule;               /* rule # last matched */
        char    fin_group[FR_GROUPLEN]; /* group number, -1 for none */
-       struct  frentry *fin_fr;        /* last matching rule */
        void    *fin_dp;                /* start of data past IP header */
        int     fin_dlen;               /* length of data portion of packet */
        int     fin_plen;
@@ -494,6 +494,12 @@
 typedef        struct  frentry * (* frentfunc_t) __P((fr_info_t *));

 typedef        struct  frentry {
+       /*
+        * These are only incremented when a packet  matches this rule and
+        * it is the last match
+        */
+       uint64_t        fr_hits;
+       uint64_t        fr_bytes;
        ipfmutex_t      fr_lock;
        struct  frentry *fr_next;
        struct  frentry **fr_grp;
@@ -510,12 +516,6 @@
         * on the other side of fr_func.
         */
        int     fr_flineno;     /* line number from conf file */
-       /*
-        * These are only incremented when a packet  matches this rule and
-        * it is the last match
-        */
-       U_QUAD_T        fr_hits;
-       U_QUAD_T        fr_bytes;

        /*
         * For PPS rate limiting
diff -ru ip_fil4.1.24-orig/tools/ipfstat.c ip_fil4.1.24/tools/ipfstat.c
--- ip_fil4.1.24-orig/tools/ipfstat.c   Sat Jun 30 11:48:50 2007
+++ ip_fil4.1.24/tools/ipfstat.c        Wed Aug  1 14:06:15 2007
@@ -839,13 +839,13 @@
 #ifdef USE_QUAD_T
                        PRINTF("%qu ", (unsigned long long) fp->fr_hits);
 #else
-                       PRINTF("%lu ", fp->fr_hits);
+                       PRINTF("%llu ", fp->fr_hits);
 #endif
                if (opts & (OPT_ACCNT|OPT_VERBOSE))
 #ifdef USE_QUAD_T
                        PRINTF("%qu ", (unsigned long long) fp->fr_bytes);
 #else
-                       PRINTF("%lu ", fp->fr_bytes);
+                       PRINTF("%llu ", fp->fr_bytes);
 #endif
                if (opts & OPT_SHOWLINENO)
                        PRINTF("@%d ", n);
@@ -943,13 +943,13 @@
 #ifdef USE_QUAD_T
                        PRINTF("%qu ", (unsigned long long) fb.fr_hits);
 #else
-                       PRINTF("%lu ", fb.fr_hits);
+                       PRINTF("%llu ", fb.fr_hits);
 #endif
                if (opts & (OPT_ACCNT|OPT_VERBOSE))
 #ifdef USE_QUAD_T
                        PRINTF("%qu ", (unsigned long long) fb.fr_bytes);
 #else
-                       PRINTF("%lu ", fb.fr_bytes);
+                       PRINTF("%llu ", fb.fr_bytes);
 #endif
                if (opts & OPT_SHOWLINENO)
                        PRINTF("@%d ", n);
@@ -1729,7 +1729,7 @@
                (unsigned long long) asp->fas_hits,
                (unsigned long long) asp->fas_miss);
 #else
-       printf("Authorisation hits: %ld\tmisses %ld\n", asp->fas_hits,
+       printf("Authorisation hits: %llu\tmisses %llu\n", asp->fas_hits,
                asp->fas_miss);
 #endif
        printf("nospace %ld\nadded %ld\nsendfail %ld\nsendok %ld\n",
diff -ru ip_fil4.1.24-orig/tools/ipftest.c ip_fil4.1.24/tools/ipftest.c
--- ip_fil4.1.24-orig/tools/ipftest.c   Tue Dec 12 17:13:01 2006
+++ ip_fil4.1.24/tools/ipftest.c        Wed Aug  1 14:12:24 2007
@@ -701,7 +701,7 @@
 #ifdef USE_QUAD_T
                                printf("%qu ",(unsigned long long)fr->fr_hits);
 #else
-                               printf("%ld ", fr->fr_hits);
+                               printf("%llu ", fr->fr_hits);
 #endif
                                printfr(fr, ipftestioctl);
                        }
@@ -716,7 +716,7 @@
 #ifdef USE_QUAD_T
                                printf("%qu ",(unsigned long long)fr->fr_hits);
 #else
-                               printf("%ld ", fr->fr_hits);
+                               printf("%llu ", fr->fr_hits);
 #endif
                                printfr(fr, ipftestioctl);
                        }
<------------------------------------------------------------------------->

Reply via email to