From: Chas Williams Date: Mon, 2 Jun 2003 19:11:40 +0000 (+0000) Subject: kernel-reduce-stack-use-20030529 X-Git-Tag: openafs-devel-1_3_50~194 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=07f9b84fd75eaf7d1ea7129044d01da6532a8de6;p=packages%2Fo%2Fopenafs.git kernel-reduce-stack-use-20030529 FIXES 1485 so we allocate instead of using memory off the stack in the kernel paths --- diff --git a/src/afs/afs_analyze.c b/src/afs/afs_analyze.c index 14d006855..bddea3254 100644 --- a/src/afs/afs_analyze.c +++ b/src/afs/afs_analyze.c @@ -294,7 +294,7 @@ static int VLDB_Same (struct VenusFid *afid, struct vrequest *areq) struct vldbentry tve; struct nvldbentry ntve; struct uvldbentry utve; - } v; + } *v; struct volume *tvp; struct cell *tcell; char *bp, tbuf[CVBS]; /* biggest volume id is 2^32, ~ 4*10^9 */ @@ -305,6 +305,7 @@ static int VLDB_Same (struct VenusFid *afid, struct vrequest *areq) afs_FinalizeReq(areq); if ((i = afs_InitReq(&treq, &afs_osi_cred))) return DUNNO; + v = afs_osi_Alloc(sizeof(*v)); tcell = afs_GetCell(afid->Cell, READ_LOCK); bp = afs_cv2string(&tbuf[CVBS], afid->Fid.Volume); do { @@ -315,29 +316,29 @@ static int VLDB_Same (struct VenusFid *afid, struct vrequest *areq) if (tconn->srvr->server->flags & SNO_LHOSTS) { type = 0; RX_AFS_GUNLOCK(); - i = VL_GetEntryByNameO(tconn->id, bp, &v.tve); + i = VL_GetEntryByNameO(tconn->id, bp, &v->tve); RX_AFS_GLOCK(); } else if (tconn->srvr->server->flags & SYES_LHOSTS) { type = 1; RX_AFS_GUNLOCK(); - i = VL_GetEntryByNameN(tconn->id, bp, &v.ntve); + i = VL_GetEntryByNameN(tconn->id, bp, &v->ntve); RX_AFS_GLOCK(); } else { type = 2; RX_AFS_GUNLOCK(); - i = VL_GetEntryByNameU(tconn->id, bp, &v.utve); + i = VL_GetEntryByNameU(tconn->id, bp, &v->utve); RX_AFS_GLOCK(); if (!(tconn->srvr->server->flags & SVLSRV_UUID)) { if (i == RXGEN_OPCODE) { type = 1; RX_AFS_GUNLOCK(); - i = VL_GetEntryByNameN(tconn->id, bp, &v.ntve); + i = VL_GetEntryByNameN(tconn->id, bp, &v->ntve); RX_AFS_GLOCK(); if (i == RXGEN_OPCODE) { type = 0; tconn->srvr->server->flags |= SNO_LHOSTS; RX_AFS_GUNLOCK(); - i = VL_GetEntryByNameO(tconn->id, bp, &v.tve); + i = VL_GetEntryByNameO(tconn->id, bp, &v->tve); RX_AFS_GLOCK(); } else if (!i) tconn->srvr->server->flags |= SYES_LHOSTS; @@ -357,6 +358,7 @@ static int VLDB_Same (struct VenusFid *afid, struct vrequest *areq) ICL_TYPE_INT32, i); if (i) { + afs_osi_Free(v, sizeof(*v)); return DUNNO; } /* have info, copy into serverHost array */ @@ -369,13 +371,13 @@ static int VLDB_Same (struct VenusFid *afid, struct vrequest *areq) } if (type == 2) { - InstallUVolumeEntry(tvp, &v.utve, afid->Cell, tcell, &treq); + InstallUVolumeEntry(tvp, &v->utve, afid->Cell, tcell, &treq); } else if (type == 1) { - InstallNVolumeEntry(tvp, &v.ntve, afid->Cell); + InstallNVolumeEntry(tvp, &v->ntve, afid->Cell); } else { - InstallVolumeEntry(tvp, &v.tve, afid->Cell); + InstallVolumeEntry(tvp, &v->tve, afid->Cell); } if (i < NMAXNSERVERS && tvp->serverHost[i]) { @@ -394,11 +396,16 @@ static int VLDB_Same (struct VenusFid *afid, struct vrequest *areq) tvp = afs_GetVolume(afid, &treq, WRITE_LOCK); if (tvp) { afs_PutVolume(tvp, WRITE_LOCK); + afs_osi_Free(v, sizeof(*v)); return DIFFERENT; } - else return DUNNO; + else { + afs_osi_Free(v, sizeof(*v)); + return DUNNO; + } } + afs_osi_Free(v, sizeof(*v)); return (changed ? DIFFERENT : SAME); } /*VLDB_Same */ diff --git a/src/afs/afs_call.c b/src/afs/afs_call.c index a323a13be..660374086 100644 --- a/src/afs/afs_call.c +++ b/src/afs/afs_call.c @@ -492,21 +492,22 @@ long parm, parm2, parm3, parm4, parm5, parm6; /* add a cell. Parameter 2 is 8 hosts (in net order), parm 3 is the null-terminated name. Parameter 4 is the length of the name, including the null. Parm 5 is the home cell flag (0x1 bit) and the nosuid flag (0x2 bit) */ - struct afsop_cell tcell; + struct afsop_cell *tcell = afs_osi_Alloc(sizeof(struct afsop_cell)); - AFS_COPYIN((char *)parm2, (char *)tcell.hosts, sizeof(tcell.hosts), code); + AFS_COPYIN((char *)parm2, (char *)tcell->hosts, sizeof(tcell->hosts), code); if (!code) { - if (parm4 > sizeof(tcell.cellName)) + if (parm4 > sizeof(tcell->cellName)) code = EFAULT; else { - AFS_COPYIN((char *)parm3, tcell.cellName, parm4, code); + AFS_COPYIN((char *)parm3, tcell->cellName, parm4, code); if (!code) - afs_NewCell(tcell.cellName, tcell.hosts, parm5, + afs_NewCell(tcell->cellName, tcell->hosts, parm5, NULL, 0, 0, 0); } } + afs_osi_Free(tcell, sizeof(struct afsop_cell)); } else if (parm == AFSOP_ADDCELL2) { - struct afsop_cell tcell; + struct afsop_cell *tcell = afs_osi_Alloc(sizeof(struct afsop_cell)); char *tbuffer = osi_AllocSmallSpace(AFS_SMALLOCSIZ), *lcnamep = 0; char *tbuffer1 = osi_AllocSmallSpace(AFS_SMALLOCSIZ); int cflags = parm4; @@ -516,7 +517,7 @@ long parm, parm2, parm3, parm4, parm5, parm6; while (afs_initState < AFSOP_START_BKG) afs_osi_Sleep(&afs_initState); #endif - AFS_COPYIN((char *)parm2, (char *)tcell.hosts, sizeof(tcell.hosts), code); + AFS_COPYIN((char *)parm2, (char *)tcell->hosts, sizeof(tcell->hosts), code); if (!code) { AFS_COPYINSTR((char *)parm3, tbuffer1, AFS_SMALLOCSIZ, &bufferSize, code); if (!code) { @@ -528,10 +529,11 @@ long parm, parm2, parm3, parm4, parm5, parm6; } } if (!code) - code = afs_NewCell(tbuffer1, tcell.hosts, cflags, + code = afs_NewCell(tbuffer1, tcell->hosts, cflags, lcnamep, 0, 0, 0); } } + afs_osi_Free(tcell, sizeof(struct afsop_cell)); osi_FreeSmallSpace(tbuffer); osi_FreeSmallSpace(tbuffer1); } @@ -668,9 +670,9 @@ long parm, parm2, parm3, parm4, parm5, parm6; else if (parm == AFSOP_ADVISEADDR) { /* pass in the host address to the rx package */ afs_int32 count = parm2; - afs_int32 buffer[AFS_MAX_INTERFACE_ADDR]; - afs_int32 maskbuffer[AFS_MAX_INTERFACE_ADDR]; - afs_int32 mtubuffer[AFS_MAX_INTERFACE_ADDR]; + afs_int32 *buffer = afs_osi_Alloc(sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR); + afs_int32 *maskbuffer = afs_osi_Alloc(sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR); + afs_int32 *mtubuffer = afs_osi_Alloc(sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR); int i; int code; @@ -704,6 +706,9 @@ long parm, parm2, parm3, parm4, parm5, parm6; } afs_uuid_create(&afs_cb_interface.uuid); rxi_setaddr(buffer[0]); + afs_osi_Free(buffer, sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR); + afs_osi_Free(maskbuffer, sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR); + afs_osi_Free(mtubuffer, sizeof(afs_int32) * AFS_MAX_INTERFACE_ADDR); } #ifdef AFS_SGI53_ENV diff --git a/src/afs/afs_pioctl.c b/src/afs/afs_pioctl.c index f9120cafc..4e7140901 100644 --- a/src/afs/afs_pioctl.c +++ b/src/afs/afs_pioctl.c @@ -1434,17 +1434,20 @@ DECL_PIOCTL(PSetTokens) DECL_PIOCTL(PGetVolumeStatus) { char volName[32]; - char offLineMsg[256]; - char motd[256]; + char *offLineMsg = afs_osi_Alloc(256); + char *motd = afs_osi_Alloc(256); register struct conn *tc; - register afs_int32 code; + register afs_int32 code = 0; struct VolumeStatus volstat; register char *cp; char *Name, *OfflineMsg, *MOTD; XSTATS_DECLS; AFS_STATCNT(PGetVolumeStatus); - if (!avc) return EINVAL; + if (!avc) { + code = EINVAL; + goto out; + } Name = volName; OfflineMsg = offLineMsg; MOTD = motd; @@ -1464,7 +1467,7 @@ DECL_PIOCTL(PGetVolumeStatus) AFS_STATS_FS_RPCIDX_GETVOLUMESTATUS, SHARED_LOCK, NULL)); - if (code) return code; + if (code) goto out; /* Copy all this junk into msg->im_data, keeping track of the lengths. */ cp = aout; memcpy(cp, (char *)&volstat, sizeof(VolumeStatus)); @@ -1476,16 +1479,19 @@ DECL_PIOCTL(PGetVolumeStatus) strcpy(cp, motd); cp += strlen(motd)+1; *aoutSize = (cp - aout); - return 0; +out: + afs_osi_Free(offLineMsg, 256); + afs_osi_Free(motd, 256); + return code; } DECL_PIOCTL(PSetVolumeStatus) { char volName[32]; - char offLineMsg[256]; - char motd[256]; + char *offLineMsg = afs_osi_Alloc(256); + char *motd = afs_osi_Alloc(256); register struct conn *tc; - register afs_int32 code; + register afs_int32 code = 0; struct AFSFetchVolumeStatus volstat; struct AFSStoreVolumeStatus storeStat; register struct volume *tvp; @@ -1544,7 +1550,7 @@ DECL_PIOCTL(PSetVolumeStatus) AFS_STATS_FS_RPCIDX_SETVOLUMESTATUS, SHARED_LOCK, NULL)); - if (code) return code; + if (code) goto out; /* we are sending parms back to make compat. with prev system. should change interface later to not ask for current status, just set new status */ cp = aout; @@ -1557,7 +1563,10 @@ DECL_PIOCTL(PSetVolumeStatus) strcpy(cp, motd); cp += strlen(motd)+1; *aoutSize = cp - aout; - return 0; +out: + afs_osi_Free(offLineMsg, 256); + afs_osi_Free(motd, 256); + return code; } DECL_PIOCTL(PFlush) diff --git a/src/afs/afs_vcache.c b/src/afs/afs_vcache.c index df9f5d1ee..27a795354 100644 --- a/src/afs/afs_vcache.c +++ b/src/afs/afs_vcache.c @@ -312,7 +312,7 @@ int afs_FreeCBR(register struct afs_cbr *asp) */ afs_int32 afs_FlushVCBs (afs_int32 lockit) { - struct AFSFid tfids[AFS_MAXCBRSCALL]; + struct AFSFid *tfids; struct AFSCallBack callBacks[1]; struct AFSCBFids fidArray; struct AFSCBs cbArray; @@ -328,6 +328,7 @@ afs_int32 afs_FlushVCBs (afs_int32 lockit) if ((code = afs_InitReq(&treq, &afs_osi_cred))) return code; treq.flags |= O_NONBLOCK; + tfids = afs_osi_Alloc(sizeof(struct AFSFid) * AFS_MAXCBRSCALL); if (lockit) MObtainWriteLock(&afs_xvcb,273); ObtainReadLock(&afs_xserver); @@ -402,6 +403,7 @@ afs_int32 afs_FlushVCBs (afs_int32 lockit) ReleaseReadLock(&afs_xserver); if (lockit) MReleaseWriteLock(&afs_xvcb); + afs_osi_Free(tfids, sizeof(struct AFSFid) * AFS_MAXCBRSCALL); return 0; } diff --git a/src/afs/afs_volume.c b/src/afs/afs_volume.c index 938949eae..c50e0d81a 100644 --- a/src/afs/afs_volume.c +++ b/src/afs/afs_volume.c @@ -533,23 +533,25 @@ static struct volume *afs_NewDynrootVolume(struct VenusFid *fid) { struct cell *tcell; struct volume *tv; - struct vldbentry tve; + struct vldbentry *tve; char *bp, tbuf[CVBS]; tcell = afs_GetCell(fid->Cell, READ_LOCK); if (!tcell) return NULL; + tve = afs_osi_Alloc(sizeof(*tve)); if (!(tcell->states & CHasVolRef)) tcell->states |= CHasVolRef; bp = afs_cv2string(&tbuf[CVBS], fid->Fid.Volume); - memset(&tve, 0, sizeof(tve)); - strcpy(tve.name, "local-dynroot"); - tve.volumeId[ROVOL] = fid->Fid.Volume; - tve.flags = VLF_ROEXISTS; + memset(tve, 0, sizeof(*tve)); + strcpy(tve->name, "local-dynroot"); + tve->volumeId[ROVOL] = fid->Fid.Volume; + tve->flags = VLF_ROEXISTS; - tv = afs_SetupVolume(0, bp, (char *) &tve, tcell, 0, 0, 0); + tv = afs_SetupVolume(0, bp, tve, tcell, 0, 0, 0); afs_PutCell(tcell, READ_LOCK); + afs_osi_Free(tve, sizeof(*tve)); return tv; }