From 1e0c6d22d7c44aad6aa0a0051e094a3558045dd2 Mon Sep 17 00:00:00 2001 From: Rainer Toebbicke Date: Wed, 2 Jun 2010 18:12:36 +0200 Subject: [PATCH] "fs checkservers" during cache creation can crash client Many pioctl calls pass as soon as the afs_resourceinit_flag is set, which happens relatively early, alas before the cell name is set. PCheckServers and others need the latter and dereference NULL. Easiest: set the cell name as soon as it is known and the dynroot initialisation piggy-backed to it can be done. Change-Id: I9985f2c4a0afddfed04b85338108b3d6e97b64e6 Reviewed-on: http://gerrit.openafs.org/2072 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/afs/afs_call.c | 9 +++++---- src/afs/afs_cell.c | 9 ++++++++- src/afsd/afsd.c | 10 +++++----- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/afs/afs_call.c b/src/afs/afs_call.c index 3b5093694..8c7f75a7b 100644 --- a/src/afs/afs_call.c +++ b/src/afs/afs_call.c @@ -817,13 +817,14 @@ afs_syscall_call(long parm, long parm2, long parm3, */ char *cell = osi_AllocSmallSpace(AFS_SMALLOCSIZ); - code = afs_InitDynroot(); - if (!code) { - AFS_COPYINSTR(AFSKPTR(parm2), cell, AFS_SMALLOCSIZ, &bufferSize, code); - } + afs_CellInit(); + AFS_COPYINSTR(AFSKPTR(parm2), cell, AFS_SMALLOCSIZ, &bufferSize, code); if (!code) afs_SetPrimaryCell(cell); osi_FreeSmallSpace(cell); + if (!code) { + code = afs_InitDynroot(); + } } else if (parm == AFSOP_CACHEINIT) { struct afs_cacheParams cparms; diff --git a/src/afs/afs_cell.c b/src/afs/afs_cell.c index 3fecdd59d..11c7f6ab7 100644 --- a/src/afs/afs_cell.c +++ b/src/afs/afs_cell.c @@ -549,7 +549,7 @@ afs_NewCellAlias(char *alias, char *cell) */ struct afs_q CellLRU; /* Export for kdump */ -static char *afs_thiscell; +static char *afs_thiscell = NULL; afs_int32 afs_cellindex; /* Export for kdump */ /*! @@ -1035,6 +1035,13 @@ afs_NewCell(char *acellName, afs_int32 * acellHosts, int aflags, void afs_CellInit(void) { + static char CellInit_done = 0; + + if (CellInit_done) + return; + + CellInit_done = 1; + AFS_RWLOCK_INIT(&afs_xcell, "afs_xcell"); AFS_RWLOCK_INIT(&afsdb_client_lock, "afsdb_client_lock"); AFS_RWLOCK_INIT(&afsdb_req_lock, "afsdb_req_lock"); diff --git a/src/afsd/afsd.c b/src/afsd/afsd.c index f794ad07c..450dab6a2 100644 --- a/src/afsd/afsd.c +++ b/src/afsd/afsd.c @@ -2143,6 +2143,11 @@ afsd_run(void) setpgrp(getpid(), 0); #endif /* mac2 */ + /* + * Set the primary cell name. + */ + afsd_call_syscall(AFSOP_SET_THISCELL, LclCellName); + /* Initialize RX daemons and services */ /* initialize the rx random number generator from user space */ @@ -2334,11 +2339,6 @@ afsd_run(void) afsconf_CellApply(cdir, ConfigCell, NULL); afsconf_CellAliasApply(cdir, ConfigCellAlias, NULL); - /* - * Set the primary cell name. - */ - afsd_call_syscall(AFSOP_SET_THISCELL, LclCellName); - /* Initialize AFS daemon threads. */ if (afsd_verbose) printf("%s: Forking AFS daemon.\n", rn); -- 2.39.5