use-private-xdr-in-kernel-to-avoid-conflicts-over-memory-ownership-20020608
authorDerrick Brashear <shadow@dementia.org>
Sat, 8 Jun 2002 08:44:09 +0000 (08:44 +0000)
committerDerrick Brashear <shadow@dementia.org>
Sat, 8 Jun 2002 08:44:09 +0000 (08:44 +0000)
allocating memory from a pool and then having it be freed out from under you is unwise

12 files changed:
src/afs/afs_callback.c
src/afs/sysincludes.h
src/fsint/afsaux.c
src/fsint/afsint.xg
src/libafs/Makefile.common.in
src/rx/rx_kcommon.h
src/rx/xdr.c
src/rx/xdr.h
src/rx/xdr_rx.c
src/rxgen/rpc_main.c
src/rxkad/rxkad_client.c
src/rxkad/rxkad_common.c

index f59ef40..01adda3 100644 (file)
@@ -1203,7 +1203,7 @@ int SRXAFSCB_GetCellServDB(
        afs_PutCell(tcell, READ_LOCK);
     }
 
-    t_name = (char *)rxi_Alloc(i+1);
+    t_name = (char *)afs_osi_Alloc(i+1);
     if (t_name == NULL) {
        ReleaseReadLock(&afs_xcell);
        RX_AFS_GUNLOCK();
@@ -1276,7 +1276,7 @@ int SRXAFSCB_GetLocalCell(
        plen = strlen(p_name);
     else
        plen = 0;
-    t_name = (char *)rxi_Alloc(plen+1);
+    t_name = (char *)afs_osi_Alloc(plen+1);
     if (t_name == NULL) {
        ReleaseReadLock(&afs_xcell);
        RX_AFS_GUNLOCK();
@@ -1376,7 +1376,7 @@ int SRXAFSCB_GetCacheConfig(
      * Currently only support version 1
      */
     allocsize = sizeof(cm_initparams_v1);
-    t_config = (afs_uint32 *)rxi_Alloc(allocsize);
+    t_config = (afs_uint32 *)afs_osi_Alloc(allocsize);
     if (t_config == NULL) {
        RX_AFS_GUNLOCK();
        return ENOMEM;
index 231c99e..5e27432 100644 (file)
@@ -271,7 +271,7 @@ MALLOC_DECLARE(M_AFS);
 #endif /* AFS_SUN5_ENV */
 
 #include "../rpc/types.h"
-#include "../rpc/xdr.h"
+#include "../rx/xdr.h"
 
 #ifdef AFS_AIX32_ENV
 #  include "net/spl.h"
@@ -366,7 +366,7 @@ MALLOC_DECLARE(M_AFS);
 #undef register
 #endif /* AFS_ALPHA_ENV */
 
-#include <rpc/xdr.h>
+#include <rx/xdr.h>
 #include <sys/proc.h>
 #include <sys/ioctl.h>
 
index 32edb08..aaf14a0 100644 (file)
@@ -28,7 +28,7 @@ RCSID("$Header$");
 #else
 #include "../h/types.h"
 #include "../rpc/types.h"
-#include "../rpc/xdr.h"
+#include "../rx/xdr.h"
 #endif
 #if !defined(AFS_ALPHA_ENV)
 #ifndef        XDR_GETINT32
@@ -38,9 +38,6 @@ RCSID("$Header$");
 #define        XDR_PUTINT32    XDR_PUTLONG
 #endif
 #endif
-#ifndef AFS_LINUX22_ENV
-#include "../rpc/auth.h"
-#endif
 #endif /* defined(UKERNEL) */
 #include "../afsint/afsint.h"
 #else /* KERNEL */
index 64a7444..bc95cac 100644 (file)
@@ -45,7 +45,7 @@ typedef afs_int32 ViceDataType;
 %#define SymbolicLink 3 
 
 %#ifdef       KERNEL
-%#define      xdr_array(a,b,c,d,e,f)  xdr_arrayN(a,b,c,d,e,f)
+%#define      afs_xdr_array(a,b,c,d,e,f)  afs_xdr_arrayN(a,b,c,d,e,f)
 %#endif
 
 struct BD {
index 3ee5551..4378945 100644 (file)
@@ -92,6 +92,8 @@ AFSAOBJS = \
        afsaux.o                \
        Kvice.xdr.o     \
        xdr_arrayn.o    \
+       xdr_array.o     \
+       xdr_int64.o     \
        Kvice.cs.o      \
        fcrypt.o                \
        rx.o            \
@@ -119,6 +121,7 @@ AFSAOBJS = \
        rxkad_client.o  \
        rxkad_common.o  \
        xdr_afsuuid.o   \
+       xdr.o           \
        afs_uuid.o $(AFS_OS_OBJS)
 
 # These next two allow nfs and nonfs builds to occur in the same directory.
@@ -308,6 +311,12 @@ afsaux.o: $(AFSINT)/afsaux.c
        $(CRULE1)
 xdr_arrayn.o: $(RX)/xdr_arrayn.c
        $(CRULE1)
+xdr_array.o: $(RX)/xdr_array.c
+       $(CRULE1)
+xdr_int64.o: $(RX)/xdr_int64.c
+       $(CRULE1)
+xdr.o: $(RX)/xdr.c
+       $(CRULE1)
 Kvldbint.cs.o: $(AFSINT)/Kvldbint.cs.c
        $(CRULE1)
 Kvldbint.xdr.o: $(AFSINT)/Kvldbint.xdr.c
index 3d3ed69..c83c88f 100644 (file)
@@ -93,9 +93,7 @@ struct coda_inode_info {};
 #include "../afs/afs_osi.h"
 #include "../rx/rx_kmutex.h"
 #include "../afs/lock.h"
-#ifndef AFS_LINUX22_ENV
-#include "../rpc/xdr.h"
-#endif
+#include "../rx/xdr.h"
 #include "../rx/rx.h"
 #include "../rx/rx_globals.h"
 #include "../afs/longc_procs.h"
index 2aa70b9..8ca8a4a 100644 (file)
@@ -129,22 +129,22 @@ xdr_u_int(xdrs, up)
        return (FALSE);
 }
 
-
+#else
 /*
  * XDR afs_int32 integers
  * same as xdr_u_long - open coded to save a proc call!
  */
 bool_t
-xdr_long(xdrs, lp)
+xdr_int(xdrs, lp)
        register XDR *xdrs;
-       long *lp;
+       int *lp;
 {
 
        if (xdrs->x_op == XDR_ENCODE)
-               return (XDR_PUTINT32(xdrs, lp));
+               return (XDR_PUTINT32(xdrs, (long *)lp));
 
        if (xdrs->x_op == XDR_DECODE)
-               return (XDR_GETINT32(xdrs, lp));
+               return (XDR_GETINT32(xdrs, (long *)lp));
 
        if (xdrs->x_op == XDR_FREE)
                return (TRUE);
@@ -157,38 +157,37 @@ xdr_long(xdrs, lp)
  * same as xdr_long - open coded to save a proc call!
  */
 bool_t
-xdr_u_long(xdrs, ulp)
+xdr_u_int(xdrs, ulp)
        register XDR *xdrs;
-       u_long *ulp;
+       int *ulp;
 {
 
        if (xdrs->x_op == XDR_DECODE)
                return (XDR_GETINT32(xdrs, (long *)ulp));
-
        if (xdrs->x_op == XDR_ENCODE)
                return (XDR_PUTINT32(xdrs, (long *)ulp));
-
        if (xdrs->x_op == XDR_FREE)
                return (TRUE);
-
        return (FALSE);
 }
-#else
+#endif
+
+
 /*
  * XDR afs_int32 integers
  * same as xdr_u_long - open coded to save a proc call!
  */
 bool_t
-xdr_int(xdrs, lp)
+xdr_long(xdrs, lp)
        register XDR *xdrs;
-       int *lp;
+       long *lp;
 {
 
        if (xdrs->x_op == XDR_ENCODE)
-               return (XDR_PUTINT32(xdrs, (long *)lp));
+               return (XDR_PUTINT32(xdrs, lp));
 
        if (xdrs->x_op == XDR_DECODE)
-               return (XDR_GETINT32(xdrs, (long *)lp));
+               return (XDR_GETINT32(xdrs, lp));
 
        if (xdrs->x_op == XDR_FREE)
                return (TRUE);
@@ -201,20 +200,23 @@ xdr_int(xdrs, lp)
  * same as xdr_long - open coded to save a proc call!
  */
 bool_t
-xdr_u_int(xdrs, ulp)
+xdr_u_long(xdrs, ulp)
        register XDR *xdrs;
-       int *ulp;
+       u_long *ulp;
 {
 
        if (xdrs->x_op == XDR_DECODE)
                return (XDR_GETINT32(xdrs, (long *)ulp));
+
        if (xdrs->x_op == XDR_ENCODE)
                return (XDR_PUTINT32(xdrs, (long *)ulp));
+
        if (xdrs->x_op == XDR_FREE)
                return (TRUE);
+
        return (FALSE);
 }
-#endif
+
 /*
  * XDR chars
  */
index c74a8f0..6869745 100644 (file)
 void *afs_osi_Alloc();
 #define        osi_alloc               afs_osi_Alloc
 #define        osi_free                afs_osi_Free
+
+#ifndef UKERNEL
+#define xdr_void afs_xdr_void
+#define xdr_int afs_xdr_int
+#define xdr_u_int afs_xdr_u_int
+#define xdr_short afs_xdr_short
+#define xdr_u_short afs_xdr_u_short
+#define xdr_long afs_xdr_long
+#define xdr_u_long afs_xdr_u_long
+#define xdr_char afs_xdr_char
+#define xdr_u_char afs_xdr_u_char
+#define xdr_bool afs_xdr_bool
+#define xdr_enum afs_xdr_enum
+#define xdr_array afs_xdr_array
+#define xdr_arrayN afs_xdr_arrayN
+#define xdr_bytes afs_xdr_bytes
+#define xdr_opaque afs_xdr_opaque
+#define xdr_string afs_xdr_string
+#define xdr_union afs_xdr_union
+#define xdr_float afs_xdr_float
+#define xdr_double afs_xdr_double
+#define xdr_reference afs_xdr_reference
+#define xdr_wrapstring afs_xdr_wrapstring
+#define xdr_vector afs_xdr_vector
+#define xdr_int64 afs_xdr_int64
+#define xdr_uint64 afs_xdr_uint64
+#endif
 #endif
 #ifndef major          /* ouch! */
 #include <sys/types.h>
index d4942f7..5ef8876 100644 (file)
@@ -45,7 +45,7 @@ RCSID("$Header$");
 #define u_quad_t __u_quad_t
 #endif
 #endif
-#include "../rpc/xdr.h"
+#include "../rx/xdr.h"
 #include "../netinet/in.h"
 #else /* !UKERNEL */
 #include "../afs/sysincludes.h"
index 0b003b8..d1f450c 100644 (file)
@@ -436,14 +436,7 @@ c_output(infile, define, extend, outfile, append)
            f_print(fout, "#include \"../h/stat.h\"\n");
            f_print(fout, "#include \"../netinet/in.h\"\n");
            f_print(fout, "#include \"../h/time.h\"\n");
-           f_print(fout, "#ifndef AFS_LINUX22_ENV\n");
-           f_print(fout, "#include \"../rpc/types.h\"\n");
-           f_print(fout, "#endif /* AFS_LINUX22_ENV */\n");
-           f_print(fout, "#ifdef AFS_LINUX22_ENV\n");
            f_print(fout, "#include \"../rx/xdr.h\"\n");
-           f_print(fout, "#else /* AFS_LINUX22_ENV */\n");
-           f_print(fout, "#include \"../rpc/xdr.h\"\n");
-           f_print(fout, "#endif /* AFS_LINUX22_ENV */\n");
            f_print(fout, "#include \"../afsint/rxgen_consts.h\"\n");
        } else {
            f_print(fout, "#include <rx/xdr.h>\n");
@@ -570,13 +563,7 @@ h_output(infile, define, extend, outfile, append)
        f_print(fout, "#define u_quad_t __u_quad_t\n");
        f_print(fout, "#endif\n");
        f_print(fout, "#endif\n");
-       f_print(fout, "#ifdef AFS_LINUX22_ENV\n");
        f_print(fout, "#include \"../rx/xdr.h\"\n");
-       f_print(fout, "#else /* AFS_LINUX22_ENV */\n");
-       f_print(fout, "extern bool_t xdr_int64();\n");
-       f_print(fout, "extern bool_t xdr_uint64();\n");
-       f_print(fout, "#include \"../rpc/xdr.h\"\n");
-       f_print(fout, "#endif /* AFS_LINUX22_ENV */\n");
        f_print(fout, "#endif /* XDR_GETLONG */\n");
        f_print(fout, "#endif   /* UKERNEL */\n");
        f_print(fout, "#include \"../afsint/rxgen_consts.h\"\n");
@@ -752,11 +739,7 @@ int append;
            f_print(fout, "#include \"../netinet/in.h\"\n");
            f_print(fout, "#include \"../h/time.h\"\n");
            f_print(fout, "#include \"../rpc/types.h\"\n");
-           f_print(fout, "#ifdef AFS_LINUX22_ENV\n");
            f_print(fout, "#include \"../rx/xdr.h\"\n");
-           f_print(fout, "#else /* AFS_LINUX22_ENV */\n");
-           f_print(fout, "#include \"../rpc/xdr.h\"\n");
-           f_print(fout, "#endif /* AFS_LINUX22_ENV */\n");
            f_print(fout, "#include \"../afsint/rxgen_consts.h\"\n");
            f_print(fout, "#include \"../afs/afs_osi.h\"\n");
            f_print(fout, "#include \"../rx/rx.h\"\n");
@@ -827,11 +810,7 @@ int append;
            f_print(fout, "#include \"../netinet/in.h\"\n");
            f_print(fout, "#include \"../h/time.h\"\n");
            f_print(fout, "#include \"../rpc/types.h\"\n");
-           f_print(fout, "#ifdef AFS_LINUX22_ENV\n");
            f_print(fout, "#include \"../rx/xdr.h\"\n");
-           f_print(fout, "#else /* AFS_LINUX22_ENV */\n");
-           f_print(fout, "#include \"../rpc/xdr.h\"\n");
-           f_print(fout, "#endif /* AFS_LINUX22_ENV */\n");
            f_print(fout, "#include \"../afsint/rxgen_consts.h\"\n");
            f_print(fout, "#include \"../afs/afs_osi.h\"\n");
            f_print(fout, "#include \"../rx/rx.h\"\n");
index f12d531..637ac76 100644 (file)
@@ -34,7 +34,7 @@ RCSID("$Header$");
 #endif /* !UKERNEL */
 #ifndef AFS_LINUX22_ENV
 #include "../rpc/types.h"
-#include "../rpc/xdr.h"
+#include "../rx/xdr.h"
 #endif
 #include "../rx/rx.h"
 #else /* ! KERNEL */
index 96f404a..7f7aab4 100644 (file)
@@ -29,7 +29,7 @@ RCSID("$Header$");
 #include "../h/time.h"
 #ifndef AFS_LINUX22_ENV
 #include "../rpc/types.h"
-#include "../rpc/xdr.h"
+#include "../rx/xdr.h"
 #endif /* AFS_LINUX22_ENV */
 #else /* !UKERNEL */
 #include "../afs/sysincludes.h"