Skip to contentSkip to conversation

Initialize the sem->sem_pending list after restoring

PATCH In review Dan Smith 2 participants 2 messages Jun 16, 2010 1 message not in the archive

lore
Share & tools
lore

Dan Smith

author
#0 lore raw

PATCH 1/1 Initialize the sem->sem_pending list after restoring

Right now, we leave (effectively) garbage in it after restart. Not only must this be re-initialized (since we know it was empty on checkpoint), but it must be initialized after being copied into the final resting place.

Without this, you get lots of fun crashes in various places :)

---
 ipc/checkpoint_sem.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
ipc/checkpoint_sem.c +4 -1
index ab1830e..43e3cdf 100644
@@ -171,7 +171,7 @@ int restore_ipc_sem(struct ckpt_ctx *ctx, struct ipc_namespace *ns)
 	struct sem_array *sem;
 	struct sem *sma = NULL;
 	struct ipc_ids *sem_ids = &ns->ids[IPC_SEM_IDS];
-	int semflag, ret;
+	int semflag, ret, i;
 
 	h = ckpt_read_obj_type(ctx, sizeof(*h), CKPT_HDR_IPC_SEM);
 	if (IS_ERR(h))
@@ -222,6 +222,9 @@ int restore_ipc_sem(struct ckpt_ctx *ctx, struct ipc_namespace *ns)
 	sem = container_of(ipc, struct sem_array, sem_perm);
 	memcpy(sem->sem_base, sma, sem->sem_nsems * sizeof(*sma));
 
+	for (i = 0; i < sem->sem_nsems; i++)
+		INIT_LIST_HEAD(&sem->sem_base[i].sem_pending);
+
 	/* this is safe because no unauthorized access is possible */
 	ipc_unlock(ipc);
 
Signature · 1 line
1.7.0.4

A message that is not in the archive (sent off-list or not yet received): 1276707280-28974-1-git-send-email-danms-r/[email protected]

#2 lore raw

Good catch - applied.

Oren.

Quoted 34 lines · Dan Smith

Right now, we leave (effectively) garbage in it after restart. Not only must this be re-initialized (since we know it was empty on checkpoint), but it must be initialized after being copied into the final resting place.

Without this, you get lots of fun crashes in various places :)

---
 ipc/checkpoint_sem.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
ipc/checkpoint_sem.c +4 -1
index ab1830e..43e3cdf 100644
@@ -171,7 +171,7 @@ int restore_ipc_sem(struct ckpt_ctx *ctx, struct ipc_namespace *ns)
 	struct sem_array *sem;
 	struct sem *sma = NULL;
 	struct ipc_ids *sem_ids = &ns->ids[IPC_SEM_IDS];
-	int semflag, ret;
+	int semflag, ret, i;
 
 	h = ckpt_read_obj_type(ctx, sizeof(*h), CKPT_HDR_IPC_SEM);
 	if (IS_ERR(h))
@@ -222,6 +222,9 @@ int restore_ipc_sem(struct ckpt_ctx *ctx, struct ipc_namespace *ns)
 	sem = container_of(ipc, struct sem_array, sem_perm);
 	memcpy(sem->sem_base, sma, sem->sem_nsems * sizeof(*sma));
 
+	for (i = 0; i < sem->sem_nsems; i++)
+		INIT_LIST_HEAD(&sem->sem_base[i].sem_pending);
+
 	/* this is safe because no unauthorized access is possible */
 	ipc_unlock(ipc);