--- zzzz-none-000/linux-2.6.39.4/ipc/sem.c 2011-08-03 19:43:28.000000000 +0000 +++ puma6-arm-6490-729/linux-2.6.39.4/ipc/sem.c 2021-11-10 13:23:10.000000000 +0000 @@ -323,6 +323,7 @@ struct ipc_namespace *ns; struct ipc_ops sem_ops; struct ipc_params sem_params; + int id; ns = current->nsproxy->ipc_ns; @@ -337,7 +338,16 @@ sem_params.flg = semflg; sem_params.u.nsems = nsems; - return ipcget(ns, &sem_ids(ns), &sem_ops, &sem_params); + id = ipcget(ns, &sem_ids(ns), &sem_ops, &sem_params); + +#if 0 + if (id >= 0) + printk(KERN_NOTICE "%s(%d): semget(0x%lx,%d,0%o)=%d\n", + current->comm, current->pid, + key, nsems, semflg, id); +#endif + + return id; } /* @@ -1087,6 +1097,7 @@ if (semid < 0) return -EINVAL; + version = ipc_parse_version(&cmd); ns = current->nsproxy->ipc_ns; @@ -1104,6 +1115,9 @@ case GETZCNT: case SETVAL: case SETALL: + if (semid == 0) + printk(KERN_ERR "semctl(: %s(%d): using uninitialized semid (0).\n", + current->comm, current->pid); err = semctl_main(ns,semid,semnum,cmd,version,arg); return err; case IPC_RMID: @@ -1301,6 +1315,10 @@ struct ipc_namespace *ns; struct list_head tasks; + if (semid == 0) + printk(KERN_ERR "sem(timed)op: %s(%d): using uninitialized semid (0).\n", + current->comm, current->pid); + ns = current->nsproxy->ipc_ns; if (nsops < 1 || semid < 0) @@ -1586,6 +1604,9 @@ struct sem * semaphore = &sma->sem_base[i]; if (un->semadj[i]) { semaphore->semval += un->semadj[i]; + pr_notice("%s(%d): sem-undo(%d) += %d (semval %d)\n", + tsk->comm, tsk->pid, semid, + un->semadj[i], semaphore->semval); /* * Range checks of the new semaphore value, * not defined by sus: