use-private-xdr-in-kernel-to-avoid-conflicts-over-memory-ownership-20020608

allocating memory from a pool and then having it be freed out from under you is unwise
This commit is contained in:
Derrick Brashear 2002-06-08 08:44:09 +00:00
parent 3651150489
commit b80ae7d78c
12 changed files with 90 additions and 78 deletions

View 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;

View 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>

View 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 */

View 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 {

View 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

View 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"

View File

@ -129,6 +129,49 @@ 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_int(xdrs, lp)
register XDR *xdrs;
int *lp;
{
if (xdrs->x_op == XDR_ENCODE)
return (XDR_PUTINT32(xdrs, (long *)lp));
if (xdrs->x_op == XDR_DECODE)
return (XDR_GETINT32(xdrs, (long *)lp));
if (xdrs->x_op == XDR_FREE)
return (TRUE);
return (FALSE);
}
/*
* XDR unsigned afs_int32 integers
* same as xdr_long - open coded to save a proc call!
*/
bool_t
xdr_u_int(xdrs, ulp)
register XDR *xdrs;
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);
}
#endif
/*
* XDR afs_int32 integers
@ -173,48 +216,7 @@ xdr_u_long(xdrs, ulp)
return (FALSE);
}
#else
/*
* XDR afs_int32 integers
* same as xdr_u_long - open coded to save a proc call!
*/
bool_t
xdr_int(xdrs, lp)
register XDR *xdrs;
int *lp;
{
if (xdrs->x_op == XDR_ENCODE)
return (XDR_PUTINT32(xdrs, (long *)lp));
if (xdrs->x_op == XDR_DECODE)
return (XDR_GETINT32(xdrs, (long *)lp));
if (xdrs->x_op == XDR_FREE)
return (TRUE);
return (FALSE);
}
/*
* XDR unsigned afs_int32 integers
* same as xdr_long - open coded to save a proc call!
*/
bool_t
xdr_u_int(xdrs, ulp)
register XDR *xdrs;
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);
}
#endif
/*
* XDR chars
*/

View File

@ -65,6 +65,33 @@
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>

View 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"

View 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");

View 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 */

View 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"