[opencryptoki-users] pkcsslotd crashes on Linux 2.6.10 uclibc
Brought to you by:
ebarretto
From: King G.G. <kin...@gm...> - 2005-11-15 09:00:14
|
Hi all here is the description of problems I have: System configuration: Linux 2.6.10 uclibc, BusyBox v1.00-rc3, openCryptoki 2.1.5-6 built with i386 uclibc gcc 3.3.4 Any application which calls C_Initialize and stays in the memory for a few seconds causes pkcsslotd to 'disappear' from memory without freeing shared memory. Most likely pkcsslotd crashes and shared memory stays until next reboot since despite pkcsslotd i= s no longer running any call to C_XXX functions succeed and applications work fine. After spending days I found that even there is no need to call C_XXX functions from PKCS11_API.so. To make pkcsslotd crash it's enough to attach to shared memory and write into 2 fields: Slot_Mgr_Proc_t::inuse and Slot_Mgr_Proc_t::proc_id, and stay in memory for a few seconds: key_t tok; int shmid =3D 0; void* shmp =3D NULL; Slot_Mgr_Shr_t *shm; Slot_Mgr_Proc_t *procp; tok =3D ftok("/usr/sbin/pkcsslotd",'b'); shmid =3D shmget(tok, sizeof(Slot_Mgr_Shr_t),S_IWUSR|S_IWGRP|S_IRGRP|S_IRUS= R); printf("shmid =3D %d\n",shmid); shmp =3D shmat(shmid,NULL,0); shm =3D shmp; procp =3D shm->proc_table; procp->inuse =3D TRUE; procp->proc_id =3D getpid(); while(1); Couple of days later I found the following code in garbage_linux.c, line 846: memset(&p->cmd, 0, sizeof(p->cmd)); sscanf(buf, "%d (%15c", &p->pid, p->cmd); // comm[16] in kernel where cmd is an unallocated char*. After changing definition of cmd in proc_t structure from char* to char[16] this issue was solved. To me it seems this is the only place where cmd is used. But since pkcsslot= d is very important part I'm afraid of breaking something in it's functionality by this change. Could you please tell me is this a bug or this is how it supposed to be? What is the meaning of that memset? Is it supposed to zeroise string pointed by cmd or make cmd NULL-pointer? I= f zeroise, how many bytes? Are my changes correct or not? May they affect some other parts of openCryptoki or somehow cause malfunctioning? Or if that cmd is not used at all then may be it's better to skip it? Gev |