Initialize the sem->sem_pending list after restoring
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
@@ -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]
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 :)
Signed-off-by Dan Smith <danms-r/[email protected]>--- ipc/checkpoint_sem.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)ipc/checkpoint_sem.c +4
-1@@ -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);